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