1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package redshift 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/redshift/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Returns one or more cluster subnet group objects, which contain metadata about 16// your cluster subnet groups. By default, this operation returns information about 17// all cluster subnet groups that are defined in you AWS account. If you specify 18// both tag keys and tag values in the same request, Amazon Redshift returns all 19// subnet groups that match any combination of the specified keys and values. For 20// example, if you have owner and environment for tag keys, and admin and test for 21// tag values, all subnet groups that have any combination of those values are 22// returned. If both tag keys and values are omitted from the request, subnet 23// groups are returned regardless of whether they have tag keys or values 24// associated with them. 25func (c *Client) DescribeClusterSubnetGroups(ctx context.Context, params *DescribeClusterSubnetGroupsInput, optFns ...func(*Options)) (*DescribeClusterSubnetGroupsOutput, error) { 26 if params == nil { 27 params = &DescribeClusterSubnetGroupsInput{} 28 } 29 30 result, metadata, err := c.invokeOperation(ctx, "DescribeClusterSubnetGroups", params, optFns, addOperationDescribeClusterSubnetGroupsMiddlewares) 31 if err != nil { 32 return nil, err 33 } 34 35 out := result.(*DescribeClusterSubnetGroupsOutput) 36 out.ResultMetadata = metadata 37 return out, nil 38} 39 40// 41type DescribeClusterSubnetGroupsInput struct { 42 43 // The name of the cluster subnet group for which information is requested. 44 ClusterSubnetGroupName *string 45 46 // An optional parameter that specifies the starting point to return a set of 47 // response records. When the results of a DescribeClusterSubnetGroups request 48 // exceed the value specified in MaxRecords, AWS returns a value in the Marker 49 // field of the response. You can retrieve the next set of response records by 50 // providing the returned marker value in the Marker parameter and retrying the 51 // request. 52 Marker *string 53 54 // The maximum number of response records to return in each call. If the number of 55 // remaining response records exceeds the specified MaxRecords value, a value is 56 // returned in a marker field of the response. You can retrieve the next set of 57 // records by retrying the command with the returned marker value. Default: 100 58 // Constraints: minimum 20, maximum 100. 59 MaxRecords *int32 60 61 // A tag key or keys for which you want to return all matching cluster subnet 62 // groups that are associated with the specified key or keys. For example, suppose 63 // that you have subnet groups that are tagged with keys called owner and 64 // environment. If you specify both of these tag keys in the request, Amazon 65 // Redshift returns a response with the subnet groups that have either or both of 66 // these tag keys associated with them. 67 TagKeys []string 68 69 // A tag value or values for which you want to return all matching cluster subnet 70 // groups that are associated with the specified tag value or values. For example, 71 // suppose that you have subnet groups that are tagged with values called admin and 72 // test. If you specify both of these tag values in the request, Amazon Redshift 73 // returns a response with the subnet groups that have either or both of these tag 74 // values associated with them. 75 TagValues []string 76} 77 78// Contains the output from the DescribeClusterSubnetGroups action. 79type DescribeClusterSubnetGroupsOutput struct { 80 81 // A list of ClusterSubnetGroup instances. 82 ClusterSubnetGroups []types.ClusterSubnetGroup 83 84 // A value that indicates the starting point for the next set of response records 85 // in a subsequent request. If a value is returned in a response, you can retrieve 86 // the next set of records by providing this returned marker value in the Marker 87 // parameter and retrying the command. If the Marker field is empty, all response 88 // records have been retrieved for the request. 89 Marker *string 90 91 // Metadata pertaining to the operation's result. 92 ResultMetadata middleware.Metadata 93} 94 95func addOperationDescribeClusterSubnetGroupsMiddlewares(stack *middleware.Stack, options Options) (err error) { 96 err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeClusterSubnetGroups{}, middleware.After) 97 if err != nil { 98 return err 99 } 100 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeClusterSubnetGroups{}, middleware.After) 101 if err != nil { 102 return err 103 } 104 if err = addSetLoggerMiddleware(stack, options); err != nil { 105 return err 106 } 107 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 108 return err 109 } 110 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 111 return err 112 } 113 if err = addResolveEndpointMiddleware(stack, options); err != nil { 114 return err 115 } 116 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 117 return err 118 } 119 if err = addRetryMiddlewares(stack, options); err != nil { 120 return err 121 } 122 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 123 return err 124 } 125 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 126 return err 127 } 128 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 129 return err 130 } 131 if err = addClientUserAgent(stack); err != nil { 132 return err 133 } 134 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 135 return err 136 } 137 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 138 return err 139 } 140 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeClusterSubnetGroups(options.Region), middleware.Before); err != nil { 141 return err 142 } 143 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 144 return err 145 } 146 if err = addResponseErrorMiddleware(stack); err != nil { 147 return err 148 } 149 if err = addRequestResponseLogging(stack, options); err != nil { 150 return err 151 } 152 return nil 153} 154 155// DescribeClusterSubnetGroupsAPIClient is a client that implements the 156// DescribeClusterSubnetGroups operation. 157type DescribeClusterSubnetGroupsAPIClient interface { 158 DescribeClusterSubnetGroups(context.Context, *DescribeClusterSubnetGroupsInput, ...func(*Options)) (*DescribeClusterSubnetGroupsOutput, error) 159} 160 161var _ DescribeClusterSubnetGroupsAPIClient = (*Client)(nil) 162 163// DescribeClusterSubnetGroupsPaginatorOptions is the paginator options for 164// DescribeClusterSubnetGroups 165type DescribeClusterSubnetGroupsPaginatorOptions struct { 166 // The maximum number of response records to return in each call. If the number of 167 // remaining response records exceeds the specified MaxRecords value, a value is 168 // returned in a marker field of the response. You can retrieve the next set of 169 // records by retrying the command with the returned marker value. Default: 100 170 // Constraints: minimum 20, maximum 100. 171 Limit int32 172 173 // Set to true if pagination should stop if the service returns a pagination token 174 // that matches the most recent token provided to the service. 175 StopOnDuplicateToken bool 176} 177 178// DescribeClusterSubnetGroupsPaginator is a paginator for 179// DescribeClusterSubnetGroups 180type DescribeClusterSubnetGroupsPaginator struct { 181 options DescribeClusterSubnetGroupsPaginatorOptions 182 client DescribeClusterSubnetGroupsAPIClient 183 params *DescribeClusterSubnetGroupsInput 184 nextToken *string 185 firstPage bool 186} 187 188// NewDescribeClusterSubnetGroupsPaginator returns a new 189// DescribeClusterSubnetGroupsPaginator 190func NewDescribeClusterSubnetGroupsPaginator(client DescribeClusterSubnetGroupsAPIClient, params *DescribeClusterSubnetGroupsInput, optFns ...func(*DescribeClusterSubnetGroupsPaginatorOptions)) *DescribeClusterSubnetGroupsPaginator { 191 if params == nil { 192 params = &DescribeClusterSubnetGroupsInput{} 193 } 194 195 options := DescribeClusterSubnetGroupsPaginatorOptions{} 196 if params.MaxRecords != nil { 197 options.Limit = *params.MaxRecords 198 } 199 200 for _, fn := range optFns { 201 fn(&options) 202 } 203 204 return &DescribeClusterSubnetGroupsPaginator{ 205 options: options, 206 client: client, 207 params: params, 208 firstPage: true, 209 } 210} 211 212// HasMorePages returns a boolean indicating whether more pages are available 213func (p *DescribeClusterSubnetGroupsPaginator) HasMorePages() bool { 214 return p.firstPage || p.nextToken != nil 215} 216 217// NextPage retrieves the next DescribeClusterSubnetGroups page. 218func (p *DescribeClusterSubnetGroupsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeClusterSubnetGroupsOutput, error) { 219 if !p.HasMorePages() { 220 return nil, fmt.Errorf("no more pages available") 221 } 222 223 params := *p.params 224 params.Marker = p.nextToken 225 226 var limit *int32 227 if p.options.Limit > 0 { 228 limit = &p.options.Limit 229 } 230 params.MaxRecords = limit 231 232 result, err := p.client.DescribeClusterSubnetGroups(ctx, ¶ms, optFns...) 233 if err != nil { 234 return nil, err 235 } 236 p.firstPage = false 237 238 prevToken := p.nextToken 239 p.nextToken = result.Marker 240 241 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 242 p.nextToken = nil 243 } 244 245 return result, nil 246} 247 248func newServiceMetadataMiddleware_opDescribeClusterSubnetGroups(region string) *awsmiddleware.RegisterServiceMetadata { 249 return &awsmiddleware.RegisterServiceMetadata{ 250 Region: region, 251 ServiceID: ServiceID, 252 SigningName: "redshift", 253 OperationName: "DescribeClusterSubnetGroups", 254 } 255} 256