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