1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package redshiftdata 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/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Lists the schemas in a database. A token is returned to page through the schema 15// list. Depending on the authorization method, use one of the following 16// combinations of request parameters: 17// 18// * AWS Secrets Manager - specify the Amazon 19// Resource Name (ARN) of the secret and the cluster identifier that matches the 20// cluster in the secret. 21// 22// * Temporary credentials - specify the cluster 23// identifier, the database name, and the database user name. Permission to call 24// the redshift:GetClusterCredentials operation is required to use this method. 25func (c *Client) ListSchemas(ctx context.Context, params *ListSchemasInput, optFns ...func(*Options)) (*ListSchemasOutput, error) { 26 if params == nil { 27 params = &ListSchemasInput{} 28 } 29 30 result, metadata, err := c.invokeOperation(ctx, "ListSchemas", params, optFns, addOperationListSchemasMiddlewares) 31 if err != nil { 32 return nil, err 33 } 34 35 out := result.(*ListSchemasOutput) 36 out.ResultMetadata = metadata 37 return out, nil 38} 39 40type ListSchemasInput struct { 41 42 // The cluster identifier. This parameter is required when authenticating using 43 // either AWS Secrets Manager or temporary credentials. 44 // 45 // This member is required. 46 ClusterIdentifier *string 47 48 // The name of the database. This parameter is required when authenticating using 49 // temporary credentials. 50 // 51 // This member is required. 52 Database *string 53 54 // The database user name. This parameter is required when authenticating using 55 // temporary credentials. 56 DbUser *string 57 58 // The maximum number of schemas to return in the response. If more schemas exist 59 // than fit in one response, then NextToken is returned to page through the 60 // results. 61 MaxResults int32 62 63 // A value that indicates the starting point for the next set of response records 64 // in a subsequent request. If a value is returned in a response, you can retrieve 65 // the next set of records by providing this returned NextToken value in the next 66 // NextToken parameter and retrying the command. If the NextToken field is empty, 67 // all response records have been retrieved for the request. 68 NextToken *string 69 70 // A pattern to filter results by schema name. Within a schema pattern, "%" means 71 // match any substring of 0 or more characters and "_" means match any one 72 // character. Only schema name entries matching the search pattern are returned. 73 SchemaPattern *string 74 75 // The name or ARN of the secret that enables access to the database. This 76 // parameter is required when authenticating using AWS Secrets Manager. 77 SecretArn *string 78} 79 80type ListSchemasOutput struct { 81 82 // A value that indicates the starting point for the next set of response records 83 // in a subsequent request. If a value is returned in a response, you can retrieve 84 // the next set of records by providing this returned NextToken value in the next 85 // NextToken parameter and retrying the command. If the NextToken field is empty, 86 // all response records have been retrieved for the request. 87 NextToken *string 88 89 // The schemas that match the request pattern. 90 Schemas []string 91 92 // Metadata pertaining to the operation's result. 93 ResultMetadata middleware.Metadata 94} 95 96func addOperationListSchemasMiddlewares(stack *middleware.Stack, options Options) (err error) { 97 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListSchemas{}, middleware.After) 98 if err != nil { 99 return err 100 } 101 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListSchemas{}, middleware.After) 102 if err != nil { 103 return err 104 } 105 if err = addSetLoggerMiddleware(stack, options); err != nil { 106 return err 107 } 108 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 109 return err 110 } 111 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 112 return err 113 } 114 if err = addResolveEndpointMiddleware(stack, options); err != nil { 115 return err 116 } 117 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 118 return err 119 } 120 if err = addRetryMiddlewares(stack, options); err != nil { 121 return err 122 } 123 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 124 return err 125 } 126 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 127 return err 128 } 129 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 130 return err 131 } 132 if err = addClientUserAgent(stack); err != nil { 133 return err 134 } 135 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 136 return err 137 } 138 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 139 return err 140 } 141 if err = addOpListSchemasValidationMiddleware(stack); err != nil { 142 return err 143 } 144 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListSchemas(options.Region), middleware.Before); err != nil { 145 return err 146 } 147 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 148 return err 149 } 150 if err = addResponseErrorMiddleware(stack); err != nil { 151 return err 152 } 153 if err = addRequestResponseLogging(stack, options); err != nil { 154 return err 155 } 156 return nil 157} 158 159// ListSchemasAPIClient is a client that implements the ListSchemas operation. 160type ListSchemasAPIClient interface { 161 ListSchemas(context.Context, *ListSchemasInput, ...func(*Options)) (*ListSchemasOutput, error) 162} 163 164var _ ListSchemasAPIClient = (*Client)(nil) 165 166// ListSchemasPaginatorOptions is the paginator options for ListSchemas 167type ListSchemasPaginatorOptions struct { 168 // The maximum number of schemas to return in the response. If more schemas exist 169 // than fit in one response, then NextToken is returned to page through the 170 // results. 171 Limit int32 172 173 // Set to true if pagination should stop if the service returns a pagination token 174 // that matches the most recent token provided to the service. 175 StopOnDuplicateToken bool 176} 177 178// ListSchemasPaginator is a paginator for ListSchemas 179type ListSchemasPaginator struct { 180 options ListSchemasPaginatorOptions 181 client ListSchemasAPIClient 182 params *ListSchemasInput 183 nextToken *string 184 firstPage bool 185} 186 187// NewListSchemasPaginator returns a new ListSchemasPaginator 188func NewListSchemasPaginator(client ListSchemasAPIClient, params *ListSchemasInput, optFns ...func(*ListSchemasPaginatorOptions)) *ListSchemasPaginator { 189 options := ListSchemasPaginatorOptions{} 190 if params.MaxResults != 0 { 191 options.Limit = params.MaxResults 192 } 193 194 for _, fn := range optFns { 195 fn(&options) 196 } 197 198 if params == nil { 199 params = &ListSchemasInput{} 200 } 201 202 return &ListSchemasPaginator{ 203 options: options, 204 client: client, 205 params: params, 206 firstPage: true, 207 } 208} 209 210// HasMorePages returns a boolean indicating whether more pages are available 211func (p *ListSchemasPaginator) HasMorePages() bool { 212 return p.firstPage || p.nextToken != nil 213} 214 215// NextPage retrieves the next ListSchemas page. 216func (p *ListSchemasPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListSchemasOutput, error) { 217 if !p.HasMorePages() { 218 return nil, fmt.Errorf("no more pages available") 219 } 220 221 params := *p.params 222 params.NextToken = p.nextToken 223 224 params.MaxResults = p.options.Limit 225 226 result, err := p.client.ListSchemas(ctx, ¶ms, optFns...) 227 if err != nil { 228 return nil, err 229 } 230 p.firstPage = false 231 232 prevToken := p.nextToken 233 p.nextToken = result.NextToken 234 235 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 236 p.nextToken = nil 237 } 238 239 return result, nil 240} 241 242func newServiceMetadataMiddleware_opListSchemas(region string) *awsmiddleware.RegisterServiceMetadata { 243 return &awsmiddleware.RegisterServiceMetadata{ 244 Region: region, 245 ServiceID: ServiceID, 246 SigningName: "redshift-data", 247 OperationName: "ListSchemas", 248 } 249} 250