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 information about Aurora global database clusters. This API supports
16// pagination. For more information on Amazon Aurora, see  What Is Amazon Aurora?
17// (https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/CHAP_AuroraOverview.html)
18// in the Amazon Aurora User Guide. This action only applies to Aurora DB clusters.
19func (c *Client) DescribeGlobalClusters(ctx context.Context, params *DescribeGlobalClustersInput, optFns ...func(*Options)) (*DescribeGlobalClustersOutput, error) {
20	if params == nil {
21		params = &DescribeGlobalClustersInput{}
22	}
23
24	result, metadata, err := c.invokeOperation(ctx, "DescribeGlobalClusters", params, optFns, addOperationDescribeGlobalClustersMiddlewares)
25	if err != nil {
26		return nil, err
27	}
28
29	out := result.(*DescribeGlobalClustersOutput)
30	out.ResultMetadata = metadata
31	return out, nil
32}
33
34type DescribeGlobalClustersInput struct {
35
36	// A filter that specifies one or more global DB clusters to describe. Supported
37	// filters:
38	//
39	// * db-cluster-id - Accepts DB cluster identifiers and DB cluster Amazon
40	// Resource Names (ARNs). The results list will only include information about the
41	// DB clusters identified by these ARNs.
42	Filters []types.Filter
43
44	// The user-supplied DB cluster identifier. If this parameter is specified,
45	// information from only the specific DB cluster is returned. This parameter isn't
46	// case-sensitive. Constraints:
47	//
48	// * If supplied, must match an existing
49	// DBClusterIdentifier.
50	GlobalClusterIdentifier *string
51
52	// An optional pagination token provided by a previous DescribeGlobalClusters
53	// request. If this parameter is specified, the response includes only records
54	// beyond the marker, up to the value specified by MaxRecords.
55	Marker *string
56
57	// The maximum number of records to include in the response. If more records exist
58	// than the specified MaxRecords value, a pagination token called a marker is
59	// included in the response so that you can retrieve the remaining results.
60	// Default: 100 Constraints: Minimum 20, maximum 100.
61	MaxRecords *int32
62}
63
64type DescribeGlobalClustersOutput struct {
65
66	// The list of global clusters returned by this request.
67	GlobalClusters []types.GlobalCluster
68
69	// An optional pagination token provided by a previous DescribeGlobalClusters
70	// request. If this parameter is specified, the response includes only records
71	// beyond the marker, up to the value specified by MaxRecords.
72	Marker *string
73
74	// Metadata pertaining to the operation's result.
75	ResultMetadata middleware.Metadata
76}
77
78func addOperationDescribeGlobalClustersMiddlewares(stack *middleware.Stack, options Options) (err error) {
79	err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeGlobalClusters{}, middleware.After)
80	if err != nil {
81		return err
82	}
83	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeGlobalClusters{}, middleware.After)
84	if err != nil {
85		return err
86	}
87	if err = addSetLoggerMiddleware(stack, options); err != nil {
88		return err
89	}
90	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
91		return err
92	}
93	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
94		return err
95	}
96	if err = addResolveEndpointMiddleware(stack, options); err != nil {
97		return err
98	}
99	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
100		return err
101	}
102	if err = addRetryMiddlewares(stack, options); err != nil {
103		return err
104	}
105	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
106		return err
107	}
108	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
109		return err
110	}
111	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
112		return err
113	}
114	if err = addClientUserAgent(stack); err != nil {
115		return err
116	}
117	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
118		return err
119	}
120	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
121		return err
122	}
123	if err = addOpDescribeGlobalClustersValidationMiddleware(stack); err != nil {
124		return err
125	}
126	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeGlobalClusters(options.Region), middleware.Before); err != nil {
127		return err
128	}
129	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
130		return err
131	}
132	if err = addResponseErrorMiddleware(stack); err != nil {
133		return err
134	}
135	if err = addRequestResponseLogging(stack, options); err != nil {
136		return err
137	}
138	return nil
139}
140
141// DescribeGlobalClustersAPIClient is a client that implements the
142// DescribeGlobalClusters operation.
143type DescribeGlobalClustersAPIClient interface {
144	DescribeGlobalClusters(context.Context, *DescribeGlobalClustersInput, ...func(*Options)) (*DescribeGlobalClustersOutput, error)
145}
146
147var _ DescribeGlobalClustersAPIClient = (*Client)(nil)
148
149// DescribeGlobalClustersPaginatorOptions is the paginator options for
150// DescribeGlobalClusters
151type DescribeGlobalClustersPaginatorOptions struct {
152	// The maximum number of records to include in the response. If more records exist
153	// than the specified MaxRecords value, a pagination token called a marker is
154	// included in the response so that you can retrieve the remaining results.
155	// Default: 100 Constraints: Minimum 20, maximum 100.
156	Limit int32
157
158	// Set to true if pagination should stop if the service returns a pagination token
159	// that matches the most recent token provided to the service.
160	StopOnDuplicateToken bool
161}
162
163// DescribeGlobalClustersPaginator is a paginator for DescribeGlobalClusters
164type DescribeGlobalClustersPaginator struct {
165	options   DescribeGlobalClustersPaginatorOptions
166	client    DescribeGlobalClustersAPIClient
167	params    *DescribeGlobalClustersInput
168	nextToken *string
169	firstPage bool
170}
171
172// NewDescribeGlobalClustersPaginator returns a new DescribeGlobalClustersPaginator
173func NewDescribeGlobalClustersPaginator(client DescribeGlobalClustersAPIClient, params *DescribeGlobalClustersInput, optFns ...func(*DescribeGlobalClustersPaginatorOptions)) *DescribeGlobalClustersPaginator {
174	if params == nil {
175		params = &DescribeGlobalClustersInput{}
176	}
177
178	options := DescribeGlobalClustersPaginatorOptions{}
179	if params.MaxRecords != nil {
180		options.Limit = *params.MaxRecords
181	}
182
183	for _, fn := range optFns {
184		fn(&options)
185	}
186
187	return &DescribeGlobalClustersPaginator{
188		options:   options,
189		client:    client,
190		params:    params,
191		firstPage: true,
192	}
193}
194
195// HasMorePages returns a boolean indicating whether more pages are available
196func (p *DescribeGlobalClustersPaginator) HasMorePages() bool {
197	return p.firstPage || p.nextToken != nil
198}
199
200// NextPage retrieves the next DescribeGlobalClusters page.
201func (p *DescribeGlobalClustersPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeGlobalClustersOutput, error) {
202	if !p.HasMorePages() {
203		return nil, fmt.Errorf("no more pages available")
204	}
205
206	params := *p.params
207	params.Marker = p.nextToken
208
209	var limit *int32
210	if p.options.Limit > 0 {
211		limit = &p.options.Limit
212	}
213	params.MaxRecords = limit
214
215	result, err := p.client.DescribeGlobalClusters(ctx, &params, optFns...)
216	if err != nil {
217		return nil, err
218	}
219	p.firstPage = false
220
221	prevToken := p.nextToken
222	p.nextToken = result.Marker
223
224	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
225		p.nextToken = nil
226	}
227
228	return result, nil
229}
230
231func newServiceMetadataMiddleware_opDescribeGlobalClusters(region string) *awsmiddleware.RegisterServiceMetadata {
232	return &awsmiddleware.RegisterServiceMetadata{
233		Region:        region,
234		ServiceID:     ServiceID,
235		SigningName:   "rds",
236		OperationName: "DescribeGlobalClusters",
237	}
238}
239