1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package appconfig 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/appconfig/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Lists the configuration profiles for an application. 16func (c *Client) ListConfigurationProfiles(ctx context.Context, params *ListConfigurationProfilesInput, optFns ...func(*Options)) (*ListConfigurationProfilesOutput, error) { 17 if params == nil { 18 params = &ListConfigurationProfilesInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "ListConfigurationProfiles", params, optFns, addOperationListConfigurationProfilesMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*ListConfigurationProfilesOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type ListConfigurationProfilesInput struct { 32 33 // The application ID. 34 // 35 // This member is required. 36 ApplicationId *string 37 38 // The maximum number of items to return for this call. The call also returns a 39 // token that you can specify in a subsequent call to get the next set of results. 40 MaxResults int32 41 42 // A token to start the list. Use this token to get the next set of results. 43 NextToken *string 44} 45 46type ListConfigurationProfilesOutput struct { 47 48 // The elements from this collection. 49 Items []types.ConfigurationProfileSummary 50 51 // The token for the next set of items to return. Use this token to get the next 52 // set of results. 53 NextToken *string 54 55 // Metadata pertaining to the operation's result. 56 ResultMetadata middleware.Metadata 57} 58 59func addOperationListConfigurationProfilesMiddlewares(stack *middleware.Stack, options Options) (err error) { 60 err = stack.Serialize.Add(&awsRestjson1_serializeOpListConfigurationProfiles{}, middleware.After) 61 if err != nil { 62 return err 63 } 64 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListConfigurationProfiles{}, middleware.After) 65 if err != nil { 66 return err 67 } 68 if err = addSetLoggerMiddleware(stack, options); err != nil { 69 return err 70 } 71 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 72 return err 73 } 74 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 75 return err 76 } 77 if err = addResolveEndpointMiddleware(stack, options); err != nil { 78 return err 79 } 80 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 81 return err 82 } 83 if err = addRetryMiddlewares(stack, options); err != nil { 84 return err 85 } 86 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 87 return err 88 } 89 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 90 return err 91 } 92 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 93 return err 94 } 95 if err = addClientUserAgent(stack); err != nil { 96 return err 97 } 98 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 99 return err 100 } 101 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 102 return err 103 } 104 if err = addOpListConfigurationProfilesValidationMiddleware(stack); err != nil { 105 return err 106 } 107 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListConfigurationProfiles(options.Region), middleware.Before); err != nil { 108 return err 109 } 110 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 111 return err 112 } 113 if err = addResponseErrorMiddleware(stack); err != nil { 114 return err 115 } 116 if err = addRequestResponseLogging(stack, options); err != nil { 117 return err 118 } 119 return nil 120} 121 122// ListConfigurationProfilesAPIClient is a client that implements the 123// ListConfigurationProfiles operation. 124type ListConfigurationProfilesAPIClient interface { 125 ListConfigurationProfiles(context.Context, *ListConfigurationProfilesInput, ...func(*Options)) (*ListConfigurationProfilesOutput, error) 126} 127 128var _ ListConfigurationProfilesAPIClient = (*Client)(nil) 129 130// ListConfigurationProfilesPaginatorOptions is the paginator options for 131// ListConfigurationProfiles 132type ListConfigurationProfilesPaginatorOptions struct { 133 // The maximum number of items to return for this call. The call also returns a 134 // token that you can specify in a subsequent call to get the next set of results. 135 Limit int32 136 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// ListConfigurationProfilesPaginator is a paginator for ListConfigurationProfiles 143type ListConfigurationProfilesPaginator struct { 144 options ListConfigurationProfilesPaginatorOptions 145 client ListConfigurationProfilesAPIClient 146 params *ListConfigurationProfilesInput 147 nextToken *string 148 firstPage bool 149} 150 151// NewListConfigurationProfilesPaginator returns a new 152// ListConfigurationProfilesPaginator 153func NewListConfigurationProfilesPaginator(client ListConfigurationProfilesAPIClient, params *ListConfigurationProfilesInput, optFns ...func(*ListConfigurationProfilesPaginatorOptions)) *ListConfigurationProfilesPaginator { 154 options := ListConfigurationProfilesPaginatorOptions{} 155 if params.MaxResults != 0 { 156 options.Limit = params.MaxResults 157 } 158 159 for _, fn := range optFns { 160 fn(&options) 161 } 162 163 if params == nil { 164 params = &ListConfigurationProfilesInput{} 165 } 166 167 return &ListConfigurationProfilesPaginator{ 168 options: options, 169 client: client, 170 params: params, 171 firstPage: true, 172 } 173} 174 175// HasMorePages returns a boolean indicating whether more pages are available 176func (p *ListConfigurationProfilesPaginator) HasMorePages() bool { 177 return p.firstPage || p.nextToken != nil 178} 179 180// NextPage retrieves the next ListConfigurationProfiles page. 181func (p *ListConfigurationProfilesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListConfigurationProfilesOutput, error) { 182 if !p.HasMorePages() { 183 return nil, fmt.Errorf("no more pages available") 184 } 185 186 params := *p.params 187 params.NextToken = p.nextToken 188 189 params.MaxResults = p.options.Limit 190 191 result, err := p.client.ListConfigurationProfiles(ctx, ¶ms, optFns...) 192 if err != nil { 193 return nil, err 194 } 195 p.firstPage = false 196 197 prevToken := p.nextToken 198 p.nextToken = result.NextToken 199 200 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 201 p.nextToken = nil 202 } 203 204 return result, nil 205} 206 207func newServiceMetadataMiddleware_opListConfigurationProfiles(region string) *awsmiddleware.RegisterServiceMetadata { 208 return &awsmiddleware.RegisterServiceMetadata{ 209 Region: region, 210 ServiceID: ServiceID, 211 SigningName: "appconfig", 212 OperationName: "ListConfigurationProfiles", 213 } 214} 215