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