1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package connect 4 5import ( 6 "context" 7 "fmt" 8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 9 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 10 "github.com/aws/aws-sdk-go-v2/service/connect/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13 "time" 14) 15 16// Gets historical metric data from the specified Amazon Connect instance. For a 17// description of each historical metric, see Historical Metrics Definitions 18// (https://docs.aws.amazon.com/connect/latest/adminguide/historical-metrics-definitions.html) 19// in the Amazon Connect Administrator Guide. 20func (c *Client) GetMetricData(ctx context.Context, params *GetMetricDataInput, optFns ...func(*Options)) (*GetMetricDataOutput, error) { 21 if params == nil { 22 params = &GetMetricDataInput{} 23 } 24 25 result, metadata, err := c.invokeOperation(ctx, "GetMetricData", params, optFns, addOperationGetMetricDataMiddlewares) 26 if err != nil { 27 return nil, err 28 } 29 30 out := result.(*GetMetricDataOutput) 31 out.ResultMetadata = metadata 32 return out, nil 33} 34 35type GetMetricDataInput struct { 36 37 // The timestamp, in UNIX Epoch time format, at which to end the reporting interval 38 // for the retrieval of historical metrics data. The time must be specified using 39 // an interval of 5 minutes, such as 11:00, 11:05, 11:10, and must be later than 40 // the start time timestamp. The time range between the start and end time must be 41 // less than 24 hours. 42 // 43 // This member is required. 44 EndTime *time.Time 45 46 // The queues, up to 100, or channels, to use to filter the metrics returned. 47 // Metric data is retrieved only for the resources associated with the queues or 48 // channels included in the filter. You can include both queue IDs and queue ARNs 49 // in the same request. VOICE, CHAT, and TASK channels are supported. 50 // 51 // This member is required. 52 Filters *types.Filters 53 54 // The metrics to retrieve. Specify the name, unit, and statistic for each metric. 55 // The following historical metrics are available. For a description of each 56 // metric, see Historical Metrics Definitions 57 // (https://docs.aws.amazon.com/connect/latest/adminguide/historical-metrics-definitions.html) 58 // in the Amazon Connect Administrator Guide. ABANDON_TIME Unit: SECONDS Statistic: 59 // AVG AFTER_CONTACT_WORK_TIME Unit: SECONDS Statistic: AVG API_CONTACTS_HANDLED 60 // Unit: COUNT Statistic: SUM CALLBACK_CONTACTS_HANDLED Unit: COUNT Statistic: SUM 61 // CONTACTS_ABANDONED Unit: COUNT Statistic: SUM CONTACTS_AGENT_HUNG_UP_FIRST Unit: 62 // COUNT Statistic: SUM CONTACTS_CONSULTED Unit: COUNT Statistic: SUM 63 // CONTACTS_HANDLED Unit: COUNT Statistic: SUM CONTACTS_HANDLED_INCOMING Unit: 64 // COUNT Statistic: SUM CONTACTS_HANDLED_OUTBOUND Unit: COUNT Statistic: SUM 65 // CONTACTS_HOLD_ABANDONS Unit: COUNT Statistic: SUM CONTACTS_MISSED Unit: COUNT 66 // Statistic: SUM CONTACTS_QUEUED Unit: COUNT Statistic: SUM 67 // CONTACTS_TRANSFERRED_IN Unit: COUNT Statistic: SUM 68 // CONTACTS_TRANSFERRED_IN_FROM_QUEUE Unit: COUNT Statistic: SUM 69 // CONTACTS_TRANSFERRED_OUT Unit: COUNT Statistic: SUM 70 // CONTACTS_TRANSFERRED_OUT_FROM_QUEUE Unit: COUNT Statistic: SUM HANDLE_TIME Unit: 71 // SECONDS Statistic: AVG HOLD_TIME Unit: SECONDS Statistic: AVG 72 // INTERACTION_AND_HOLD_TIME Unit: SECONDS Statistic: AVG INTERACTION_TIME Unit: 73 // SECONDS Statistic: AVG OCCUPANCY Unit: PERCENT Statistic: AVG QUEUE_ANSWER_TIME 74 // Unit: SECONDS Statistic: AVG QUEUED_TIME Unit: SECONDS Statistic: MAX 75 // SERVICE_LEVEL Unit: PERCENT Statistic: AVG Threshold: Only "Less than" 76 // comparisons are supported, with the following service level thresholds: 15, 20, 77 // 25, 30, 45, 60, 90, 120, 180, 240, 300, 600 78 // 79 // This member is required. 80 HistoricalMetrics []types.HistoricalMetric 81 82 // The identifier of the Amazon Connect instance. 83 // 84 // This member is required. 85 InstanceId *string 86 87 // The timestamp, in UNIX Epoch time format, at which to start the reporting 88 // interval for the retrieval of historical metrics data. The time must be 89 // specified using a multiple of 5 minutes, such as 10:05, 10:10, 10:15. The start 90 // time cannot be earlier than 24 hours before the time of the request. Historical 91 // metrics are available only for 24 hours. 92 // 93 // This member is required. 94 StartTime *time.Time 95 96 // The grouping applied to the metrics returned. For example, when results are 97 // grouped by queue, the metrics returned are grouped by queue. The values returned 98 // apply to the metrics for each queue rather than aggregated for all queues. The 99 // only supported grouping is QUEUE. If no grouping is specified, a summary of 100 // metrics for all queues is returned. 101 Groupings []types.Grouping 102 103 // The maximum number of results to return per page. 104 MaxResults int32 105 106 // The token for the next set of results. Use the value returned in the previous 107 // response in the next request to retrieve the next set of results. 108 NextToken *string 109} 110 111type GetMetricDataOutput struct { 112 113 // Information about the historical metrics. If no grouping is specified, a summary 114 // of metric data is returned. 115 MetricResults []types.HistoricalMetricResult 116 117 // If there are additional results, this is the token for the next set of results. 118 // The token expires after 5 minutes from the time it is created. Subsequent 119 // requests that use the token must use the same request parameters as the request 120 // that generated the token. 121 NextToken *string 122 123 // Metadata pertaining to the operation's result. 124 ResultMetadata middleware.Metadata 125} 126 127func addOperationGetMetricDataMiddlewares(stack *middleware.Stack, options Options) (err error) { 128 err = stack.Serialize.Add(&awsRestjson1_serializeOpGetMetricData{}, middleware.After) 129 if err != nil { 130 return err 131 } 132 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpGetMetricData{}, middleware.After) 133 if err != nil { 134 return err 135 } 136 if err = addSetLoggerMiddleware(stack, options); err != nil { 137 return err 138 } 139 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 140 return err 141 } 142 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 143 return err 144 } 145 if err = addResolveEndpointMiddleware(stack, options); err != nil { 146 return err 147 } 148 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 149 return err 150 } 151 if err = addRetryMiddlewares(stack, options); err != nil { 152 return err 153 } 154 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 155 return err 156 } 157 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 158 return err 159 } 160 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 161 return err 162 } 163 if err = addClientUserAgent(stack); err != nil { 164 return err 165 } 166 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 167 return err 168 } 169 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 170 return err 171 } 172 if err = addOpGetMetricDataValidationMiddleware(stack); err != nil { 173 return err 174 } 175 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetMetricData(options.Region), middleware.Before); err != nil { 176 return err 177 } 178 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 179 return err 180 } 181 if err = addResponseErrorMiddleware(stack); err != nil { 182 return err 183 } 184 if err = addRequestResponseLogging(stack, options); err != nil { 185 return err 186 } 187 return nil 188} 189 190// GetMetricDataAPIClient is a client that implements the GetMetricData operation. 191type GetMetricDataAPIClient interface { 192 GetMetricData(context.Context, *GetMetricDataInput, ...func(*Options)) (*GetMetricDataOutput, error) 193} 194 195var _ GetMetricDataAPIClient = (*Client)(nil) 196 197// GetMetricDataPaginatorOptions is the paginator options for GetMetricData 198type GetMetricDataPaginatorOptions struct { 199 // The maximum number of results to return per page. 200 Limit int32 201 202 // Set to true if pagination should stop if the service returns a pagination token 203 // that matches the most recent token provided to the service. 204 StopOnDuplicateToken bool 205} 206 207// GetMetricDataPaginator is a paginator for GetMetricData 208type GetMetricDataPaginator struct { 209 options GetMetricDataPaginatorOptions 210 client GetMetricDataAPIClient 211 params *GetMetricDataInput 212 nextToken *string 213 firstPage bool 214} 215 216// NewGetMetricDataPaginator returns a new GetMetricDataPaginator 217func NewGetMetricDataPaginator(client GetMetricDataAPIClient, params *GetMetricDataInput, optFns ...func(*GetMetricDataPaginatorOptions)) *GetMetricDataPaginator { 218 if params == nil { 219 params = &GetMetricDataInput{} 220 } 221 222 options := GetMetricDataPaginatorOptions{} 223 if params.MaxResults != 0 { 224 options.Limit = params.MaxResults 225 } 226 227 for _, fn := range optFns { 228 fn(&options) 229 } 230 231 return &GetMetricDataPaginator{ 232 options: options, 233 client: client, 234 params: params, 235 firstPage: true, 236 } 237} 238 239// HasMorePages returns a boolean indicating whether more pages are available 240func (p *GetMetricDataPaginator) HasMorePages() bool { 241 return p.firstPage || p.nextToken != nil 242} 243 244// NextPage retrieves the next GetMetricData page. 245func (p *GetMetricDataPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetMetricDataOutput, error) { 246 if !p.HasMorePages() { 247 return nil, fmt.Errorf("no more pages available") 248 } 249 250 params := *p.params 251 params.NextToken = p.nextToken 252 253 params.MaxResults = p.options.Limit 254 255 result, err := p.client.GetMetricData(ctx, ¶ms, optFns...) 256 if err != nil { 257 return nil, err 258 } 259 p.firstPage = false 260 261 prevToken := p.nextToken 262 p.nextToken = result.NextToken 263 264 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 265 p.nextToken = nil 266 } 267 268 return result, nil 269} 270 271func newServiceMetadataMiddleware_opGetMetricData(region string) *awsmiddleware.RegisterServiceMetadata { 272 return &awsmiddleware.RegisterServiceMetadata{ 273 Region: region, 274 ServiceID: ServiceID, 275 SigningName: "connect", 276 OperationName: "GetMetricData", 277 } 278} 279