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// Lists available reserved DB instance offerings.
16func (c *Client) DescribeReservedDBInstancesOfferings(ctx context.Context, params *DescribeReservedDBInstancesOfferingsInput, optFns ...func(*Options)) (*DescribeReservedDBInstancesOfferingsOutput, error) {
17	if params == nil {
18		params = &DescribeReservedDBInstancesOfferingsInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "DescribeReservedDBInstancesOfferings", params, optFns, c.addOperationDescribeReservedDBInstancesOfferingsMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*DescribeReservedDBInstancesOfferingsOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31//
32type DescribeReservedDBInstancesOfferingsInput struct {
33
34	// The DB instance class filter value. Specify this parameter to show only the
35	// available offerings matching the specified DB instance class.
36	DBInstanceClass *string
37
38	// Duration filter value, specified in years or seconds. Specify this parameter to
39	// show only reservations for this duration. Valid Values: 1 | 3 | 31536000 |
40	// 94608000
41	Duration *string
42
43	// This parameter isn't currently supported.
44	Filters []types.Filter
45
46	// An optional pagination token provided by a previous request. If this parameter
47	// is specified, the response includes only records beyond the marker, up to the
48	// value specified by MaxRecords.
49	Marker *string
50
51	// The maximum number of records to include in the response. If more than the
52	// MaxRecords value is available, a pagination token called a marker is included in
53	// the response so you can retrieve the remaining results. Default: 100
54	// Constraints: Minimum 20, maximum 100.
55	MaxRecords *int32
56
57	// A value that indicates whether to show only those reservations that support
58	// Multi-AZ.
59	MultiAZ *bool
60
61	// The offering type filter value. Specify this parameter to show only the
62	// available offerings matching the specified offering type. Valid Values: "Partial
63	// Upfront" | "All Upfront" | "No Upfront"
64	OfferingType *string
65
66	// Product description filter value. Specify this parameter to show only the
67	// available offerings that contain the specified product description. The results
68	// show offerings that partially match the filter value.
69	ProductDescription *string
70
71	// The offering identifier filter value. Specify this parameter to show only the
72	// available offering that matches the specified reservation identifier. Example:
73	// 438012d3-4052-4cc7-b2e3-8d3372e0e706
74	ReservedDBInstancesOfferingId *string
75
76	noSmithyDocumentSerde
77}
78
79// Contains the result of a successful invocation of the
80// DescribeReservedDBInstancesOfferings action.
81type DescribeReservedDBInstancesOfferingsOutput struct {
82
83	// An optional pagination token provided by a previous request. If this parameter
84	// is specified, the response includes only records beyond the marker, up to the
85	// value specified by MaxRecords.
86	Marker *string
87
88	// A list of reserved DB instance offerings.
89	ReservedDBInstancesOfferings []types.ReservedDBInstancesOffering
90
91	// Metadata pertaining to the operation's result.
92	ResultMetadata middleware.Metadata
93
94	noSmithyDocumentSerde
95}
96
97func (c *Client) addOperationDescribeReservedDBInstancesOfferingsMiddlewares(stack *middleware.Stack, options Options) (err error) {
98	err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeReservedDBInstancesOfferings{}, middleware.After)
99	if err != nil {
100		return err
101	}
102	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeReservedDBInstancesOfferings{}, middleware.After)
103	if err != nil {
104		return err
105	}
106	if err = addSetLoggerMiddleware(stack, options); err != nil {
107		return err
108	}
109	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
110		return err
111	}
112	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
113		return err
114	}
115	if err = addResolveEndpointMiddleware(stack, options); err != nil {
116		return err
117	}
118	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
119		return err
120	}
121	if err = addRetryMiddlewares(stack, options); err != nil {
122		return err
123	}
124	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
125		return err
126	}
127	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
128		return err
129	}
130	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
131		return err
132	}
133	if err = addClientUserAgent(stack); err != nil {
134		return err
135	}
136	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
137		return err
138	}
139	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
140		return err
141	}
142	if err = addOpDescribeReservedDBInstancesOfferingsValidationMiddleware(stack); err != nil {
143		return err
144	}
145	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeReservedDBInstancesOfferings(options.Region), middleware.Before); err != nil {
146		return err
147	}
148	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
149		return err
150	}
151	if err = addResponseErrorMiddleware(stack); err != nil {
152		return err
153	}
154	if err = addRequestResponseLogging(stack, options); err != nil {
155		return err
156	}
157	return nil
158}
159
160// DescribeReservedDBInstancesOfferingsAPIClient is a client that implements the
161// DescribeReservedDBInstancesOfferings operation.
162type DescribeReservedDBInstancesOfferingsAPIClient interface {
163	DescribeReservedDBInstancesOfferings(context.Context, *DescribeReservedDBInstancesOfferingsInput, ...func(*Options)) (*DescribeReservedDBInstancesOfferingsOutput, error)
164}
165
166var _ DescribeReservedDBInstancesOfferingsAPIClient = (*Client)(nil)
167
168// DescribeReservedDBInstancesOfferingsPaginatorOptions is the paginator options
169// for DescribeReservedDBInstancesOfferings
170type DescribeReservedDBInstancesOfferingsPaginatorOptions struct {
171	// The maximum number of records to include in the response. If more than the
172	// MaxRecords value is available, a pagination token called a marker is included in
173	// the response so you can retrieve the remaining results. Default: 100
174	// Constraints: Minimum 20, maximum 100.
175	Limit int32
176
177	// Set to true if pagination should stop if the service returns a pagination token
178	// that matches the most recent token provided to the service.
179	StopOnDuplicateToken bool
180}
181
182// DescribeReservedDBInstancesOfferingsPaginator is a paginator for
183// DescribeReservedDBInstancesOfferings
184type DescribeReservedDBInstancesOfferingsPaginator struct {
185	options   DescribeReservedDBInstancesOfferingsPaginatorOptions
186	client    DescribeReservedDBInstancesOfferingsAPIClient
187	params    *DescribeReservedDBInstancesOfferingsInput
188	nextToken *string
189	firstPage bool
190}
191
192// NewDescribeReservedDBInstancesOfferingsPaginator returns a new
193// DescribeReservedDBInstancesOfferingsPaginator
194func NewDescribeReservedDBInstancesOfferingsPaginator(client DescribeReservedDBInstancesOfferingsAPIClient, params *DescribeReservedDBInstancesOfferingsInput, optFns ...func(*DescribeReservedDBInstancesOfferingsPaginatorOptions)) *DescribeReservedDBInstancesOfferingsPaginator {
195	if params == nil {
196		params = &DescribeReservedDBInstancesOfferingsInput{}
197	}
198
199	options := DescribeReservedDBInstancesOfferingsPaginatorOptions{}
200	if params.MaxRecords != nil {
201		options.Limit = *params.MaxRecords
202	}
203
204	for _, fn := range optFns {
205		fn(&options)
206	}
207
208	return &DescribeReservedDBInstancesOfferingsPaginator{
209		options:   options,
210		client:    client,
211		params:    params,
212		firstPage: true,
213	}
214}
215
216// HasMorePages returns a boolean indicating whether more pages are available
217func (p *DescribeReservedDBInstancesOfferingsPaginator) HasMorePages() bool {
218	return p.firstPage || p.nextToken != nil
219}
220
221// NextPage retrieves the next DescribeReservedDBInstancesOfferings page.
222func (p *DescribeReservedDBInstancesOfferingsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeReservedDBInstancesOfferingsOutput, error) {
223	if !p.HasMorePages() {
224		return nil, fmt.Errorf("no more pages available")
225	}
226
227	params := *p.params
228	params.Marker = p.nextToken
229
230	var limit *int32
231	if p.options.Limit > 0 {
232		limit = &p.options.Limit
233	}
234	params.MaxRecords = limit
235
236	result, err := p.client.DescribeReservedDBInstancesOfferings(ctx, &params, optFns...)
237	if err != nil {
238		return nil, err
239	}
240	p.firstPage = false
241
242	prevToken := p.nextToken
243	p.nextToken = result.Marker
244
245	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
246		p.nextToken = nil
247	}
248
249	return result, nil
250}
251
252func newServiceMetadataMiddleware_opDescribeReservedDBInstancesOfferings(region string) *awsmiddleware.RegisterServiceMetadata {
253	return &awsmiddleware.RegisterServiceMetadata{
254		Region:        region,
255		ServiceID:     ServiceID,
256		SigningName:   "rds",
257		OperationName: "DescribeReservedDBInstancesOfferings",
258	}
259}
260