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