1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package elasticache 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/elasticache/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Returns a list of cache parameter group descriptions. If a cache parameter group 16// name is specified, the list contains only the descriptions for that group. 17func (c *Client) DescribeCacheParameterGroups(ctx context.Context, params *DescribeCacheParameterGroupsInput, optFns ...func(*Options)) (*DescribeCacheParameterGroupsOutput, error) { 18 if params == nil { 19 params = &DescribeCacheParameterGroupsInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "DescribeCacheParameterGroups", params, optFns, addOperationDescribeCacheParameterGroupsMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*DescribeCacheParameterGroupsOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32// Represents the input of a DescribeCacheParameterGroups operation. 33type DescribeCacheParameterGroupsInput struct { 34 35 // The name of a specific cache parameter group to return details for. 36 CacheParameterGroupName *string 37 38 // An optional marker returned from a prior request. Use this marker for pagination 39 // of results from this operation. If this parameter is specified, the response 40 // includes only records beyond the marker, up to the value specified by 41 // MaxRecords. 42 Marker *string 43 44 // The maximum number of records to include in the response. If more records exist 45 // than the specified MaxRecords value, a marker is included in the response so 46 // that the remaining results can be retrieved. Default: 100 Constraints: minimum 47 // 20; maximum 100. 48 MaxRecords *int32 49} 50 51// Represents the output of a DescribeCacheParameterGroups operation. 52type DescribeCacheParameterGroupsOutput struct { 53 54 // A list of cache parameter groups. Each element in the list contains detailed 55 // information about one cache parameter group. 56 CacheParameterGroups []types.CacheParameterGroup 57 58 // Provides an identifier to allow retrieval of paginated results. 59 Marker *string 60 61 // Metadata pertaining to the operation's result. 62 ResultMetadata middleware.Metadata 63} 64 65func addOperationDescribeCacheParameterGroupsMiddlewares(stack *middleware.Stack, options Options) (err error) { 66 err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeCacheParameterGroups{}, middleware.After) 67 if err != nil { 68 return err 69 } 70 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeCacheParameterGroups{}, middleware.After) 71 if err != nil { 72 return err 73 } 74 if err = addSetLoggerMiddleware(stack, options); err != nil { 75 return err 76 } 77 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 78 return err 79 } 80 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 81 return err 82 } 83 if err = addResolveEndpointMiddleware(stack, options); err != nil { 84 return err 85 } 86 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 87 return err 88 } 89 if err = addRetryMiddlewares(stack, options); err != nil { 90 return err 91 } 92 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 93 return err 94 } 95 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 96 return err 97 } 98 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 99 return err 100 } 101 if err = addClientUserAgent(stack); err != nil { 102 return err 103 } 104 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 105 return err 106 } 107 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 108 return err 109 } 110 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeCacheParameterGroups(options.Region), middleware.Before); err != nil { 111 return err 112 } 113 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 114 return err 115 } 116 if err = addResponseErrorMiddleware(stack); err != nil { 117 return err 118 } 119 if err = addRequestResponseLogging(stack, options); err != nil { 120 return err 121 } 122 return nil 123} 124 125// DescribeCacheParameterGroupsAPIClient is a client that implements the 126// DescribeCacheParameterGroups operation. 127type DescribeCacheParameterGroupsAPIClient interface { 128 DescribeCacheParameterGroups(context.Context, *DescribeCacheParameterGroupsInput, ...func(*Options)) (*DescribeCacheParameterGroupsOutput, error) 129} 130 131var _ DescribeCacheParameterGroupsAPIClient = (*Client)(nil) 132 133// DescribeCacheParameterGroupsPaginatorOptions is the paginator options for 134// DescribeCacheParameterGroups 135type DescribeCacheParameterGroupsPaginatorOptions struct { 136 // The maximum number of records to include in the response. If more records exist 137 // than the specified MaxRecords value, a marker is included in the response so 138 // that the remaining results can be retrieved. Default: 100 Constraints: minimum 139 // 20; maximum 100. 140 Limit int32 141 142 // Set to true if pagination should stop if the service returns a pagination token 143 // that matches the most recent token provided to the service. 144 StopOnDuplicateToken bool 145} 146 147// DescribeCacheParameterGroupsPaginator is a paginator for 148// DescribeCacheParameterGroups 149type DescribeCacheParameterGroupsPaginator struct { 150 options DescribeCacheParameterGroupsPaginatorOptions 151 client DescribeCacheParameterGroupsAPIClient 152 params *DescribeCacheParameterGroupsInput 153 nextToken *string 154 firstPage bool 155} 156 157// NewDescribeCacheParameterGroupsPaginator returns a new 158// DescribeCacheParameterGroupsPaginator 159func NewDescribeCacheParameterGroupsPaginator(client DescribeCacheParameterGroupsAPIClient, params *DescribeCacheParameterGroupsInput, optFns ...func(*DescribeCacheParameterGroupsPaginatorOptions)) *DescribeCacheParameterGroupsPaginator { 160 if params == nil { 161 params = &DescribeCacheParameterGroupsInput{} 162 } 163 164 options := DescribeCacheParameterGroupsPaginatorOptions{} 165 if params.MaxRecords != nil { 166 options.Limit = *params.MaxRecords 167 } 168 169 for _, fn := range optFns { 170 fn(&options) 171 } 172 173 return &DescribeCacheParameterGroupsPaginator{ 174 options: options, 175 client: client, 176 params: params, 177 firstPage: true, 178 } 179} 180 181// HasMorePages returns a boolean indicating whether more pages are available 182func (p *DescribeCacheParameterGroupsPaginator) HasMorePages() bool { 183 return p.firstPage || p.nextToken != nil 184} 185 186// NextPage retrieves the next DescribeCacheParameterGroups page. 187func (p *DescribeCacheParameterGroupsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeCacheParameterGroupsOutput, error) { 188 if !p.HasMorePages() { 189 return nil, fmt.Errorf("no more pages available") 190 } 191 192 params := *p.params 193 params.Marker = p.nextToken 194 195 var limit *int32 196 if p.options.Limit > 0 { 197 limit = &p.options.Limit 198 } 199 params.MaxRecords = limit 200 201 result, err := p.client.DescribeCacheParameterGroups(ctx, ¶ms, optFns...) 202 if err != nil { 203 return nil, err 204 } 205 p.firstPage = false 206 207 prevToken := p.nextToken 208 p.nextToken = result.Marker 209 210 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 211 p.nextToken = nil 212 } 213 214 return result, nil 215} 216 217func newServiceMetadataMiddleware_opDescribeCacheParameterGroups(region string) *awsmiddleware.RegisterServiceMetadata { 218 return &awsmiddleware.RegisterServiceMetadata{ 219 Region: region, 220 ServiceID: ServiceID, 221 SigningName: "elasticache", 222 OperationName: "DescribeCacheParameterGroups", 223 } 224} 225