1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package xray 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/xray/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13 "time" 14) 15 16// Retrieves the summaries of all insights in the specified group matching the 17// provided filter values. 18func (c *Client) GetInsightSummaries(ctx context.Context, params *GetInsightSummariesInput, optFns ...func(*Options)) (*GetInsightSummariesOutput, error) { 19 if params == nil { 20 params = &GetInsightSummariesInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "GetInsightSummaries", params, optFns, addOperationGetInsightSummariesMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*GetInsightSummariesOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33type GetInsightSummariesInput struct { 34 35 // The end of the time frame in which the insights ended. The end time can't be 36 // more than 30 days old. 37 // 38 // This member is required. 39 EndTime *time.Time 40 41 // The beginning of the time frame in which the insights started. The start time 42 // can't be more than 30 days old. 43 // 44 // This member is required. 45 StartTime *time.Time 46 47 // The Amazon Resource Name (ARN) of the group. Required if the GroupName isn't 48 // provided. 49 GroupARN *string 50 51 // The name of the group. Required if the GroupARN isn't provided. 52 GroupName *string 53 54 // The maximum number of results to display. 55 MaxResults *int32 56 57 // Pagination token. 58 NextToken *string 59 60 // The list of insight states. 61 States []types.InsightState 62} 63 64type GetInsightSummariesOutput struct { 65 66 // The summary of each insight within the group matching the provided filters. The 67 // summary contains the InsightID, start and end time, the root cause service, the 68 // root cause and client impact statistics, the top anomalous services, and the 69 // status of the insight. 70 InsightSummaries []types.InsightSummary 71 72 // Pagination token. 73 NextToken *string 74 75 // Metadata pertaining to the operation's result. 76 ResultMetadata middleware.Metadata 77} 78 79func addOperationGetInsightSummariesMiddlewares(stack *middleware.Stack, options Options) (err error) { 80 err = stack.Serialize.Add(&awsRestjson1_serializeOpGetInsightSummaries{}, middleware.After) 81 if err != nil { 82 return err 83 } 84 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpGetInsightSummaries{}, middleware.After) 85 if err != nil { 86 return err 87 } 88 if err = addSetLoggerMiddleware(stack, options); err != nil { 89 return err 90 } 91 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 92 return err 93 } 94 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 95 return err 96 } 97 if err = addResolveEndpointMiddleware(stack, options); err != nil { 98 return err 99 } 100 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 101 return err 102 } 103 if err = addRetryMiddlewares(stack, options); err != nil { 104 return err 105 } 106 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 107 return err 108 } 109 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 110 return err 111 } 112 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 113 return err 114 } 115 if err = addClientUserAgent(stack); err != nil { 116 return err 117 } 118 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 119 return err 120 } 121 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 122 return err 123 } 124 if err = addOpGetInsightSummariesValidationMiddleware(stack); err != nil { 125 return err 126 } 127 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetInsightSummaries(options.Region), middleware.Before); err != nil { 128 return err 129 } 130 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 131 return err 132 } 133 if err = addResponseErrorMiddleware(stack); err != nil { 134 return err 135 } 136 if err = addRequestResponseLogging(stack, options); err != nil { 137 return err 138 } 139 return nil 140} 141 142// GetInsightSummariesAPIClient is a client that implements the GetInsightSummaries 143// operation. 144type GetInsightSummariesAPIClient interface { 145 GetInsightSummaries(context.Context, *GetInsightSummariesInput, ...func(*Options)) (*GetInsightSummariesOutput, error) 146} 147 148var _ GetInsightSummariesAPIClient = (*Client)(nil) 149 150// GetInsightSummariesPaginatorOptions is the paginator options for 151// GetInsightSummaries 152type GetInsightSummariesPaginatorOptions struct { 153 // The maximum number of results to display. 154 Limit int32 155 156 // Set to true if pagination should stop if the service returns a pagination token 157 // that matches the most recent token provided to the service. 158 StopOnDuplicateToken bool 159} 160 161// GetInsightSummariesPaginator is a paginator for GetInsightSummaries 162type GetInsightSummariesPaginator struct { 163 options GetInsightSummariesPaginatorOptions 164 client GetInsightSummariesAPIClient 165 params *GetInsightSummariesInput 166 nextToken *string 167 firstPage bool 168} 169 170// NewGetInsightSummariesPaginator returns a new GetInsightSummariesPaginator 171func NewGetInsightSummariesPaginator(client GetInsightSummariesAPIClient, params *GetInsightSummariesInput, optFns ...func(*GetInsightSummariesPaginatorOptions)) *GetInsightSummariesPaginator { 172 if params == nil { 173 params = &GetInsightSummariesInput{} 174 } 175 176 options := GetInsightSummariesPaginatorOptions{} 177 if params.MaxResults != nil { 178 options.Limit = *params.MaxResults 179 } 180 181 for _, fn := range optFns { 182 fn(&options) 183 } 184 185 return &GetInsightSummariesPaginator{ 186 options: options, 187 client: client, 188 params: params, 189 firstPage: true, 190 } 191} 192 193// HasMorePages returns a boolean indicating whether more pages are available 194func (p *GetInsightSummariesPaginator) HasMorePages() bool { 195 return p.firstPage || p.nextToken != nil 196} 197 198// NextPage retrieves the next GetInsightSummaries page. 199func (p *GetInsightSummariesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetInsightSummariesOutput, error) { 200 if !p.HasMorePages() { 201 return nil, fmt.Errorf("no more pages available") 202 } 203 204 params := *p.params 205 params.NextToken = p.nextToken 206 207 var limit *int32 208 if p.options.Limit > 0 { 209 limit = &p.options.Limit 210 } 211 params.MaxResults = limit 212 213 result, err := p.client.GetInsightSummaries(ctx, ¶ms, optFns...) 214 if err != nil { 215 return nil, err 216 } 217 p.firstPage = false 218 219 prevToken := p.nextToken 220 p.nextToken = result.NextToken 221 222 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 223 p.nextToken = nil 224 } 225 226 return result, nil 227} 228 229func newServiceMetadataMiddleware_opGetInsightSummaries(region string) *awsmiddleware.RegisterServiceMetadata { 230 return &awsmiddleware.RegisterServiceMetadata{ 231 Region: region, 232 ServiceID: ServiceID, 233 SigningName: "xray", 234 OperationName: "GetInsightSummaries", 235 } 236} 237