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) 14 15// Retrieves all active group details. 16func (c *Client) GetGroups(ctx context.Context, params *GetGroupsInput, optFns ...func(*Options)) (*GetGroupsOutput, error) { 17 if params == nil { 18 params = &GetGroupsInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "GetGroups", params, optFns, addOperationGetGroupsMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*GetGroupsOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type GetGroupsInput struct { 32 33 // Pagination token. 34 NextToken *string 35} 36 37type GetGroupsOutput struct { 38 39 // The collection of all active groups. 40 Groups []types.GroupSummary 41 42 // Pagination token. 43 NextToken *string 44 45 // Metadata pertaining to the operation's result. 46 ResultMetadata middleware.Metadata 47} 48 49func addOperationGetGroupsMiddlewares(stack *middleware.Stack, options Options) (err error) { 50 err = stack.Serialize.Add(&awsRestjson1_serializeOpGetGroups{}, middleware.After) 51 if err != nil { 52 return err 53 } 54 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpGetGroups{}, middleware.After) 55 if err != nil { 56 return err 57 } 58 if err = addSetLoggerMiddleware(stack, options); err != nil { 59 return err 60 } 61 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 62 return err 63 } 64 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 65 return err 66 } 67 if err = addResolveEndpointMiddleware(stack, options); err != nil { 68 return err 69 } 70 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 71 return err 72 } 73 if err = addRetryMiddlewares(stack, options); err != nil { 74 return err 75 } 76 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 77 return err 78 } 79 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 80 return err 81 } 82 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 83 return err 84 } 85 if err = addClientUserAgent(stack); err != nil { 86 return err 87 } 88 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 89 return err 90 } 91 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 92 return err 93 } 94 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetGroups(options.Region), middleware.Before); err != nil { 95 return err 96 } 97 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 98 return err 99 } 100 if err = addResponseErrorMiddleware(stack); err != nil { 101 return err 102 } 103 if err = addRequestResponseLogging(stack, options); err != nil { 104 return err 105 } 106 return nil 107} 108 109// GetGroupsAPIClient is a client that implements the GetGroups operation. 110type GetGroupsAPIClient interface { 111 GetGroups(context.Context, *GetGroupsInput, ...func(*Options)) (*GetGroupsOutput, error) 112} 113 114var _ GetGroupsAPIClient = (*Client)(nil) 115 116// GetGroupsPaginatorOptions is the paginator options for GetGroups 117type GetGroupsPaginatorOptions struct { 118 // Set to true if pagination should stop if the service returns a pagination token 119 // that matches the most recent token provided to the service. 120 StopOnDuplicateToken bool 121} 122 123// GetGroupsPaginator is a paginator for GetGroups 124type GetGroupsPaginator struct { 125 options GetGroupsPaginatorOptions 126 client GetGroupsAPIClient 127 params *GetGroupsInput 128 nextToken *string 129 firstPage bool 130} 131 132// NewGetGroupsPaginator returns a new GetGroupsPaginator 133func NewGetGroupsPaginator(client GetGroupsAPIClient, params *GetGroupsInput, optFns ...func(*GetGroupsPaginatorOptions)) *GetGroupsPaginator { 134 if params == nil { 135 params = &GetGroupsInput{} 136 } 137 138 options := GetGroupsPaginatorOptions{} 139 140 for _, fn := range optFns { 141 fn(&options) 142 } 143 144 return &GetGroupsPaginator{ 145 options: options, 146 client: client, 147 params: params, 148 firstPage: true, 149 } 150} 151 152// HasMorePages returns a boolean indicating whether more pages are available 153func (p *GetGroupsPaginator) HasMorePages() bool { 154 return p.firstPage || p.nextToken != nil 155} 156 157// NextPage retrieves the next GetGroups page. 158func (p *GetGroupsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetGroupsOutput, error) { 159 if !p.HasMorePages() { 160 return nil, fmt.Errorf("no more pages available") 161 } 162 163 params := *p.params 164 params.NextToken = p.nextToken 165 166 result, err := p.client.GetGroups(ctx, ¶ms, optFns...) 167 if err != nil { 168 return nil, err 169 } 170 p.firstPage = false 171 172 prevToken := p.nextToken 173 p.nextToken = result.NextToken 174 175 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 176 p.nextToken = nil 177 } 178 179 return result, nil 180} 181 182func newServiceMetadataMiddleware_opGetGroups(region string) *awsmiddleware.RegisterServiceMetadata { 183 return &awsmiddleware.RegisterServiceMetadata{ 184 Region: region, 185 ServiceID: ServiceID, 186 SigningName: "xray", 187 OperationName: "GetGroups", 188 } 189} 190