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