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