/*******************************************************************************
* Copyright 2012-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file.
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
* *****************************************************************************
*
* AWS Tools for Windows (TM) PowerShell (TM)
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using Amazon.PowerShell.Common;
using Amazon.Runtime;
using Amazon.Connect;
using Amazon.Connect.Model;
namespace Amazon.PowerShell.Cmdlets.CONN
{
///
/// Gets metric data from the specified Amazon Connect instance.
///
///
/// GetMetricDataV2
offers more features than GetMetricData,
/// the previous version of this API. It has new metrics, offers filtering at a metric
/// level, and offers the ability to filter and group data by channels, queues, routing
/// profiles, agents, and agent hierarchy levels. It can retrieve historical data for
/// the last 35 days, in 24-hour intervals.
///
/// For a description of the historical metrics that are supported by GetMetricDataV2
/// and GetMetricData
, see Historical
/// metrics definitions in the Amazon Connect Administrator's Guide.
///
This cmdlet automatically pages all available results to the pipeline - parameters related to iteration are only needed if you want to manually control the paginated output. To disable autopagination, use -NoAutoIteration.
///
[Cmdlet("Get", "CONNMetricDataV2")]
[OutputType("Amazon.Connect.Model.MetricResultV2")]
[AWSCmdlet("Calls the Amazon Connect Service GetMetricDataV2 API operation.", Operation = new[] {"GetMetricDataV2"}, SelectReturnType = typeof(Amazon.Connect.Model.GetMetricDataV2Response))]
[AWSCmdletOutput("Amazon.Connect.Model.MetricResultV2 or Amazon.Connect.Model.GetMetricDataV2Response",
"This cmdlet returns a collection of Amazon.Connect.Model.MetricResultV2 objects.",
"The service call response (type Amazon.Connect.Model.GetMetricDataV2Response) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class GetCONNMetricDataV2Cmdlet : AmazonConnectClientCmdlet, IExecutor
{
#region Parameter EndTime
///
///
/// The timestamp, in UNIX Epoch time format, at which to end the reporting interval for
/// the retrieval of historical metrics data. The time must be later than the start time
/// timestamp. It cannot be later than the current timestamp.The time range between the start and end time must be less than 24 hours.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.DateTime? EndTime { get; set; }
#endregion
#region Parameter Filter
///
///
/// The filters to apply to returned metrics. You can filter on the following resources:- Queues
- Routing profiles
- Agents
- Channels
- User hierarchy groups
- Feature
At least one filter must be passed from queues, routing profiles, agents, or user
/// hierarchy groups.To filter by phone number, see Create
/// a historical metrics report in the Amazon Connect Administrator's Guide.Note the following limits:- Filter keys: A maximum of 5 filter keys are supported in a single request.
/// Valid filter keys:
QUEUE
| ROUTING_PROFILE
| AGENT
/// | CHANNEL
| AGENT_HIERARCHY_LEVEL_ONE
| AGENT_HIERARCHY_LEVEL_TWO
/// | AGENT_HIERARCHY_LEVEL_THREE
| AGENT_HIERARCHY_LEVEL_FOUR
/// | AGENT_HIERARCHY_LEVEL_FIVE
| FEATURE
- Filter values: A maximum of 100 filter values are supported in a single request.
/// VOICE, CHAT, and TASK are valid
filterValue
for the CHANNEL filter key.
/// They do not count towards limitation of 100 filter values. For example, a GetMetricDataV2
/// request can filter by 50 queues, 35 agents, and 15 routing profiles for a total of
/// 100 filter values, along with 3 channel filters. contact_lens_conversational_analytics
is a valid filterValue for the
/// FEATURE
filter key. It is available only to contacts analyzed by Contact
/// Lens conversational analytics.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyCollection]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
[Alias("Filters")]
public Amazon.Connect.Model.FilterV2[] Filter { get; set; }
#endregion
#region Parameter Grouping
///
///
/// The grouping applied to the metrics that are returned. For example, when results are
/// grouped by queue, the metrics returned are grouped by queue. The values that are returned
/// apply to the metrics for each queue. They are not aggregated for all queues.If no grouping is specified, a summary of all metrics is returned.Valid grouping keys: QUEUE
| ROUTING_PROFILE
| AGENT
/// | CHANNEL
| AGENT_HIERARCHY_LEVEL_ONE
| AGENT_HIERARCHY_LEVEL_TWO
/// | AGENT_HIERARCHY_LEVEL_THREE
| AGENT_HIERARCHY_LEVEL_FOUR
/// | AGENT_HIERARCHY_LEVEL_FIVE
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Groupings")]
public System.String[] Grouping { get; set; }
#endregion
#region Parameter Metric
///
///
/// The metrics to retrieve. Specify the name, groupings, and filters for each metric.
/// The following historical metrics are available. For a description of each metric,
/// see Historical
/// metrics definitions in the Amazon Connect Administrator's Guide.- AGENT_ADHERENT_TIME
- This metric is available only in Amazon Web Services Regions where Forecasting,
/// capacity planning, and scheduling is available.Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
///
- AGENT_NON_RESPONSE
- Unit: CountValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
///
- AGENT_OCCUPANCY
- Unit: PercentageValid groupings and filters: Routing Profile, Agent, Agent Hierarchy
- AGENT_SCHEDULE_ADHERENCE
- This metric is available only in Amazon Web Services Regions where Forecasting,
/// capacity planning, and scheduling is available.Unit: PercentValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AGENT_SCHEDULED_TIME
- This metric is available only in Amazon Web Services Regions where Forecasting,
/// capacity planning, and scheduling is available.Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AVG_ABANDON_TIME
- Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AVG_AFTER_CONTACT_WORK_TIME
- Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy,
/// FeatureFeature is a valid filter but not a valid grouping.
- AVG_AGENT_CONNECTING_TIME
- Unit: SecondsValid metric filter key:
INITIATION_METHOD
. For now, this metric only
/// supports the following as INITIATION_METHOD
: INBOUND
| OUTBOUND
/// | CALLBACK
| API
Valid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy - AVG_AGENT_CONNECTING_TIME
- Unit: SecondsValid metric filter key:
INITIATION_METHOD
. For now, this metric only
/// supports the following as INITIATION_METHOD
: INBOUND
| OUTBOUND
/// | CALLBACK
| API
Valid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy - AVG_CONTACT_DURATION
- Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy,
/// FeatureFeature is a valid filter but not a valid grouping.
- AVG_CONVERSATION_DURATION
- Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AVG_GREETING_TIME_AGENT
- This metric is available only for contacts analyzed by Contact Lens conversational
/// analytics.Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AVG_HANDLE_TIME
- Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy,
/// FeatureFeature is a valid filter but not a valid grouping.
- AVG_HOLD_TIME
- Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy,
/// FeatureFeature is a valid filter but not a valid grouping.
- AVG_HOLDS
- Unit: CountValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy,
/// FeatureFeature is a valid filter but not a valid grouping.
- AVG_INTERACTION_AND_HOLD_TIME
- Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AVG_INTERACTION_TIME
- Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, FeatureFeature is a valid filter but not a valid grouping.
- AVG_INTERRUPTIONS_AGENT
- This metric is available only for contacts analyzed by Contact Lens conversational
/// analytics.Unit: CountValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AVG_INTERRUPTION_TIME_AGENT
- This metric is available only for contacts analyzed by Contact Lens conversational
/// analytics.Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AVG_NON_TALK_TIME
- This metric is available only for contacts analyzed by Contact Lens conversational
/// analytics.Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AVG_QUEUE_ANSWER_TIME
- Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, FeatureFeature is a valid filter but not a valid grouping.
- AVG_TALK_TIME
- This metric is available only for contacts analyzed by Contact Lens conversational
/// analytics.Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AVG_TALK_TIME_AGENT
- This metric is available only for contacts analyzed by Contact Lens conversational
/// analytics.Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- AVG_TALK_TIME_CUSTOMER
- This metric is available only for contacts analyzed by Contact Lens conversational
/// analytics.Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- CONTACTS_ABANDONED
- Unit: CountValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- CONTACTS_CREATED
- Unit: CountValid metric filter key:
INITIATION_METHOD
Valid groupings and filters: Queue, Channel, Routing Profile, FeatureFeature is a valid filter but not a valid grouping. - CONTACTS_HANDLED
- Unit: CountValid metric filter key:
INITIATION_METHOD
, DISCONNECT_REASON
Valid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy,
/// FeatureFeature is a valid filter but not a valid grouping. - CONTACTS_HOLD_ABANDONS
- Unit: CountValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- CONTACTS_QUEUED
- Unit: CountValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- CONTACTS_TRANSFERRED_OUT
- Unit: CountValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy,
/// FeatureFeature is a valid filter but not a valid grouping.
- CONTACTS_TRANSFERRED_OUT_BY_AGENT
- Unit: CountValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- CONTACTS_TRANSFERRED_OUT_FROM_QUEUE
- Unit: CountValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- MAX_QUEUED_TIME
- Unit: SecondsValid groupings and filters: Queue, Channel, Routing Profile, Agent, Agent Hierarchy
- SERVICE_LEVEL
- You can include up to 20 SERVICE_LEVEL metrics in a request.Unit: PercentValid groupings and filters: Queue, Channel, Routing ProfileThreshold: For
ThresholdValue
, enter any whole number from 1 to 604800
/// (inclusive), in seconds. For Comparison
, you must enter LT
/// (for "Less than"). - SUM_CONTACTS_ANSWERED_IN_X
- Unit: CountValid groupings and filters: Queue, Channel, Routing ProfileThreshold: For
ThresholdValue
, enter any whole number from 1 to 604800
/// (inclusive), in seconds. For Comparison
, you must enter LT
/// (for "Less than"). - SUM_CONTACTS_ABANDONED_IN_X
- Unit: CountValid groupings and filters: Queue, Channel, Routing ProfileThreshold: For
ThresholdValue
, enter any whole number from 1 to 604800
/// (inclusive), in seconds. For Comparison
, you must enter LT
/// (for "Less than"). - SUM_CONTACTS_DISCONNECTED
- Valid metric filter key:
DISCONNECT_REASON
Unit: CountValid groupings and filters: Queue, Channel, Routing Profile - SUM_RETRY_CALLBACK_ATTEMPTS
- Unit: CountValid groupings and filters: Queue, Channel, Routing Profile
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyCollection]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
[Alias("Metrics")]
public Amazon.Connect.Model.MetricV2[] Metric { get; set; }
#endregion
#region Parameter ResourceArn
///
///
/// The Amazon Resource Name (ARN) of the resource. This includes the instanceId
/// an Amazon Connect instance.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.String ResourceArn { get; set; }
#endregion
#region Parameter StartTime
///
///
/// The timestamp, in UNIX Epoch time format, at which to start the reporting interval
/// for the retrieval of historical metrics data. The time must be before the end time
/// timestamp. The time range between the start and end time must be less than 24 hours.
/// The start time cannot be earlier than 35 days before the time of the request. Historical
/// metrics are available for 35 days.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.DateTime? StartTime { get; set; }
#endregion
#region Parameter MaxResult
///
///
/// The maximum number of results to return per page.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("MaxResults")]
public System.Int32? MaxResult { get; set; }
#endregion
#region Parameter NextToken
///
///
/// The token for the next set of results. Use the value returned in the previous response
/// in the next request to retrieve the next set of results.
///
///
///
Note: This parameter is only used if you are manually controlling output pagination of the service API call.
///
In order to manually control output pagination, use '-NextToken $null' for the first call and '-NextToken $AWSHistory.LastServiceResponse.NextToken' for subsequent calls.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String NextToken { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The default value is 'MetricResults'.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.Connect.Model.GetMetricDataV2Response).
/// Specifying the name of a property of type Amazon.Connect.Model.GetMetricDataV2Response will result in that property being returned.
/// Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public string Select { get; set; } = "MetricResults";
#endregion
#region Parameter NoAutoIteration
///
/// By default the cmdlet will auto-iterate and retrieve all results to the pipeline by performing multiple
/// service calls. If set, the cmdlet will retrieve only the next 'page' of results using the value of NextToken
/// as the start point.
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter NoAutoIteration { get; set; }
#endregion
protected override void ProcessRecord()
{
this._AWSSignerType = "v4";
base.ProcessRecord();
var context = new CmdletContext();
// allow for manipulation of parameters prior to loading into context
PreExecutionContextLoad(context);
if (ParameterWasBound(nameof(this.Select)))
{
context.Select = CreateSelectDelegate(Select) ??
throw new System.ArgumentException("Invalid value for -Select parameter.", nameof(this.Select));
}
context.EndTime = this.EndTime;
#if MODULAR
if (this.EndTime == null && ParameterWasBound(nameof(this.EndTime)))
{
WriteWarning("You are passing $null as a value for parameter EndTime which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
if (this.Filter != null)
{
context.Filter = new List(this.Filter);
}
#if MODULAR
if (this.Filter == null && ParameterWasBound(nameof(this.Filter)))
{
WriteWarning("You are passing $null as a value for parameter Filter which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
if (this.Grouping != null)
{
context.Grouping = new List(this.Grouping);
}
context.MaxResult = this.MaxResult;
if (this.Metric != null)
{
context.Metric = new List(this.Metric);
}
#if MODULAR
if (this.Metric == null && ParameterWasBound(nameof(this.Metric)))
{
WriteWarning("You are passing $null as a value for parameter Metric which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
context.NextToken = this.NextToken;
context.ResourceArn = this.ResourceArn;
#if MODULAR
if (this.ResourceArn == null && ParameterWasBound(nameof(this.ResourceArn)))
{
WriteWarning("You are passing $null as a value for parameter ResourceArn which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
context.StartTime = this.StartTime;
#if MODULAR
if (this.StartTime == null && ParameterWasBound(nameof(this.StartTime)))
{
WriteWarning("You are passing $null as a value for parameter StartTime which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
// allow further manipulation of loaded context prior to processing
PostExecutionContextLoad(context);
var output = Execute(context) as CmdletOutput;
ProcessOutput(output);
}
#region IExecutor Members
public object Execute(ExecutorContext context)
{
var cmdletContext = context as CmdletContext;
var useParameterSelect = this.Select.StartsWith("^");
// create request and set iteration invariants
var request = new Amazon.Connect.Model.GetMetricDataV2Request();
if (cmdletContext.EndTime != null)
{
request.EndTime = cmdletContext.EndTime.Value;
}
if (cmdletContext.Filter != null)
{
request.Filters = cmdletContext.Filter;
}
if (cmdletContext.Grouping != null)
{
request.Groupings = cmdletContext.Grouping;
}
if (cmdletContext.MaxResult != null)
{
request.MaxResults = cmdletContext.MaxResult.Value;
}
if (cmdletContext.Metric != null)
{
request.Metrics = cmdletContext.Metric;
}
if (cmdletContext.ResourceArn != null)
{
request.ResourceArn = cmdletContext.ResourceArn;
}
if (cmdletContext.StartTime != null)
{
request.StartTime = cmdletContext.StartTime.Value;
}
// Initialize loop variant and commence piping
var _nextToken = cmdletContext.NextToken;
var _userControllingPaging = this.NoAutoIteration.IsPresent || ParameterWasBound(nameof(this.NextToken));
var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);
do
{
request.NextToken = _nextToken;
CmdletOutput output;
try
{
var response = CallAWSServiceOperation(client, request);
object pipelineOutput = null;
if (!useParameterSelect)
{
pipelineOutput = cmdletContext.Select(response, this);
}
output = new CmdletOutput
{
PipelineOutput = pipelineOutput,
ServiceResponse = response
};
_nextToken = response.NextToken;
}
catch (Exception e)
{
output = new CmdletOutput { ErrorResponse = e };
}
ProcessOutput(output);
} while (!_userControllingPaging && AutoIterationHelpers.HasValue(_nextToken));
if (useParameterSelect)
{
WriteObject(cmdletContext.Select(null, this));
}
return null;
}
public ExecutorContext CreateContext()
{
return new CmdletContext();
}
#endregion
#region AWS Service Operation Call
private Amazon.Connect.Model.GetMetricDataV2Response CallAWSServiceOperation(IAmazonConnect client, Amazon.Connect.Model.GetMetricDataV2Request request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Connect Service", "GetMetricDataV2");
try
{
#if DESKTOP
return client.GetMetricDataV2(request);
#elif CORECLR
return client.GetMetricDataV2Async(request).GetAwaiter().GetResult();
#else
#error "Unknown build edition"
#endif
}
catch (AmazonServiceException exc)
{
var webException = exc.InnerException as System.Net.WebException;
if (webException != null)
{
throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
}
throw;
}
}
#endregion
internal partial class CmdletContext : ExecutorContext
{
public System.DateTime? EndTime { get; set; }
public List Filter { get; set; }
public List Grouping { get; set; }
public System.Int32? MaxResult { get; set; }
public List Metric { get; set; }
public System.String NextToken { get; set; }
public System.String ResourceArn { get; set; }
public System.DateTime? StartTime { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response.MetricResults;
}
}
}