1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package codedeploy 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/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Lists the deployment groups for an application registered with the IAM user or 15// AWS account. 16func (c *Client) ListDeploymentGroups(ctx context.Context, params *ListDeploymentGroupsInput, optFns ...func(*Options)) (*ListDeploymentGroupsOutput, error) { 17 if params == nil { 18 params = &ListDeploymentGroupsInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "ListDeploymentGroups", params, optFns, addOperationListDeploymentGroupsMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*ListDeploymentGroupsOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31// Represents the input of a ListDeploymentGroups operation. 32type ListDeploymentGroupsInput struct { 33 34 // The name of an AWS CodeDeploy application associated with the IAM user or AWS 35 // account. 36 // 37 // This member is required. 38 ApplicationName *string 39 40 // An identifier returned from the previous list deployment groups call. It can be 41 // used to return the next set of deployment groups in the list. 42 NextToken *string 43} 44 45// Represents the output of a ListDeploymentGroups operation. 46type ListDeploymentGroupsOutput struct { 47 48 // The application name. 49 ApplicationName *string 50 51 // A list of deployment group names. 52 DeploymentGroups []string 53 54 // If a large amount of information is returned, an identifier is also returned. It 55 // can be used in a subsequent list deployment groups call to return the next set 56 // of deployment groups in the list. 57 NextToken *string 58 59 // Metadata pertaining to the operation's result. 60 ResultMetadata middleware.Metadata 61} 62 63func addOperationListDeploymentGroupsMiddlewares(stack *middleware.Stack, options Options) (err error) { 64 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListDeploymentGroups{}, middleware.After) 65 if err != nil { 66 return err 67 } 68 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListDeploymentGroups{}, middleware.After) 69 if err != nil { 70 return err 71 } 72 if err = addSetLoggerMiddleware(stack, options); err != nil { 73 return err 74 } 75 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 76 return err 77 } 78 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 79 return err 80 } 81 if err = addResolveEndpointMiddleware(stack, options); err != nil { 82 return err 83 } 84 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 85 return err 86 } 87 if err = addRetryMiddlewares(stack, options); err != nil { 88 return err 89 } 90 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 91 return err 92 } 93 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 94 return err 95 } 96 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 97 return err 98 } 99 if err = addClientUserAgent(stack); err != nil { 100 return err 101 } 102 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 103 return err 104 } 105 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 106 return err 107 } 108 if err = addOpListDeploymentGroupsValidationMiddleware(stack); err != nil { 109 return err 110 } 111 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListDeploymentGroups(options.Region), middleware.Before); err != nil { 112 return err 113 } 114 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 115 return err 116 } 117 if err = addResponseErrorMiddleware(stack); err != nil { 118 return err 119 } 120 if err = addRequestResponseLogging(stack, options); err != nil { 121 return err 122 } 123 return nil 124} 125 126// ListDeploymentGroupsAPIClient is a client that implements the 127// ListDeploymentGroups operation. 128type ListDeploymentGroupsAPIClient interface { 129 ListDeploymentGroups(context.Context, *ListDeploymentGroupsInput, ...func(*Options)) (*ListDeploymentGroupsOutput, error) 130} 131 132var _ ListDeploymentGroupsAPIClient = (*Client)(nil) 133 134// ListDeploymentGroupsPaginatorOptions is the paginator options for 135// ListDeploymentGroups 136type ListDeploymentGroupsPaginatorOptions struct { 137 // Set to true if pagination should stop if the service returns a pagination token 138 // that matches the most recent token provided to the service. 139 StopOnDuplicateToken bool 140} 141 142// ListDeploymentGroupsPaginator is a paginator for ListDeploymentGroups 143type ListDeploymentGroupsPaginator struct { 144 options ListDeploymentGroupsPaginatorOptions 145 client ListDeploymentGroupsAPIClient 146 params *ListDeploymentGroupsInput 147 nextToken *string 148 firstPage bool 149} 150 151// NewListDeploymentGroupsPaginator returns a new ListDeploymentGroupsPaginator 152func NewListDeploymentGroupsPaginator(client ListDeploymentGroupsAPIClient, params *ListDeploymentGroupsInput, optFns ...func(*ListDeploymentGroupsPaginatorOptions)) *ListDeploymentGroupsPaginator { 153 options := ListDeploymentGroupsPaginatorOptions{} 154 155 for _, fn := range optFns { 156 fn(&options) 157 } 158 159 if params == nil { 160 params = &ListDeploymentGroupsInput{} 161 } 162 163 return &ListDeploymentGroupsPaginator{ 164 options: options, 165 client: client, 166 params: params, 167 firstPage: true, 168 } 169} 170 171// HasMorePages returns a boolean indicating whether more pages are available 172func (p *ListDeploymentGroupsPaginator) HasMorePages() bool { 173 return p.firstPage || p.nextToken != nil 174} 175 176// NextPage retrieves the next ListDeploymentGroups page. 177func (p *ListDeploymentGroupsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListDeploymentGroupsOutput, error) { 178 if !p.HasMorePages() { 179 return nil, fmt.Errorf("no more pages available") 180 } 181 182 params := *p.params 183 params.NextToken = p.nextToken 184 185 result, err := p.client.ListDeploymentGroups(ctx, ¶ms, optFns...) 186 if err != nil { 187 return nil, err 188 } 189 p.firstPage = false 190 191 prevToken := p.nextToken 192 p.nextToken = result.NextToken 193 194 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 195 p.nextToken = nil 196 } 197 198 return result, nil 199} 200 201func newServiceMetadataMiddleware_opListDeploymentGroups(region string) *awsmiddleware.RegisterServiceMetadata { 202 return &awsmiddleware.RegisterServiceMetadata{ 203 Region: region, 204 ServiceID: ServiceID, 205 SigningName: "codedeploy", 206 OperationName: "ListDeploymentGroups", 207 } 208} 209