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