1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package redshift 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/redshift/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Lists the status of one or more table restore requests made using the 16// RestoreTableFromClusterSnapshot API action. If you don't specify a value for the 17// TableRestoreRequestId parameter, then DescribeTableRestoreStatus returns the 18// status of all table restore requests ordered by the date and time of the request 19// in ascending order. Otherwise DescribeTableRestoreStatus returns the status of 20// the table specified by TableRestoreRequestId. 21func (c *Client) DescribeTableRestoreStatus(ctx context.Context, params *DescribeTableRestoreStatusInput, optFns ...func(*Options)) (*DescribeTableRestoreStatusOutput, error) { 22 if params == nil { 23 params = &DescribeTableRestoreStatusInput{} 24 } 25 26 result, metadata, err := c.invokeOperation(ctx, "DescribeTableRestoreStatus", params, optFns, addOperationDescribeTableRestoreStatusMiddlewares) 27 if err != nil { 28 return nil, err 29 } 30 31 out := result.(*DescribeTableRestoreStatusOutput) 32 out.ResultMetadata = metadata 33 return out, nil 34} 35 36// 37type DescribeTableRestoreStatusInput struct { 38 39 // The Amazon Redshift cluster that the table is being restored to. 40 ClusterIdentifier *string 41 42 // An optional pagination token provided by a previous DescribeTableRestoreStatus 43 // request. If this parameter is specified, the response includes only records 44 // beyond the marker, up to the value specified by the MaxRecords parameter. 45 Marker *string 46 47 // The maximum number of records to include in the response. If more records exist 48 // than the specified MaxRecords value, a pagination token called a marker is 49 // included in the response so that the remaining results can be retrieved. 50 MaxRecords *int32 51 52 // The identifier of the table restore request to return status for. If you don't 53 // specify a TableRestoreRequestId value, then DescribeTableRestoreStatus returns 54 // the status of all in-progress table restore requests. 55 TableRestoreRequestId *string 56} 57 58// 59type DescribeTableRestoreStatusOutput struct { 60 61 // A pagination token that can be used in a subsequent DescribeTableRestoreStatus 62 // request. 63 Marker *string 64 65 // A list of status details for one or more table restore requests. 66 TableRestoreStatusDetails []types.TableRestoreStatus 67 68 // Metadata pertaining to the operation's result. 69 ResultMetadata middleware.Metadata 70} 71 72func addOperationDescribeTableRestoreStatusMiddlewares(stack *middleware.Stack, options Options) (err error) { 73 err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeTableRestoreStatus{}, middleware.After) 74 if err != nil { 75 return err 76 } 77 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeTableRestoreStatus{}, middleware.After) 78 if err != nil { 79 return err 80 } 81 if err = addSetLoggerMiddleware(stack, options); err != nil { 82 return err 83 } 84 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 85 return err 86 } 87 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 88 return err 89 } 90 if err = addResolveEndpointMiddleware(stack, options); err != nil { 91 return err 92 } 93 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 94 return err 95 } 96 if err = addRetryMiddlewares(stack, options); err != nil { 97 return err 98 } 99 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 100 return err 101 } 102 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 103 return err 104 } 105 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 106 return err 107 } 108 if err = addClientUserAgent(stack); err != nil { 109 return err 110 } 111 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 112 return err 113 } 114 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 115 return err 116 } 117 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeTableRestoreStatus(options.Region), middleware.Before); err != nil { 118 return err 119 } 120 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 121 return err 122 } 123 if err = addResponseErrorMiddleware(stack); err != nil { 124 return err 125 } 126 if err = addRequestResponseLogging(stack, options); err != nil { 127 return err 128 } 129 return nil 130} 131 132// DescribeTableRestoreStatusAPIClient is a client that implements the 133// DescribeTableRestoreStatus operation. 134type DescribeTableRestoreStatusAPIClient interface { 135 DescribeTableRestoreStatus(context.Context, *DescribeTableRestoreStatusInput, ...func(*Options)) (*DescribeTableRestoreStatusOutput, error) 136} 137 138var _ DescribeTableRestoreStatusAPIClient = (*Client)(nil) 139 140// DescribeTableRestoreStatusPaginatorOptions is the paginator options for 141// DescribeTableRestoreStatus 142type DescribeTableRestoreStatusPaginatorOptions struct { 143 // The maximum number of records to include in the response. If more records exist 144 // than the specified MaxRecords value, a pagination token called a marker is 145 // included in the response so that the remaining results can be retrieved. 146 Limit int32 147 148 // Set to true if pagination should stop if the service returns a pagination token 149 // that matches the most recent token provided to the service. 150 StopOnDuplicateToken bool 151} 152 153// DescribeTableRestoreStatusPaginator is a paginator for 154// DescribeTableRestoreStatus 155type DescribeTableRestoreStatusPaginator struct { 156 options DescribeTableRestoreStatusPaginatorOptions 157 client DescribeTableRestoreStatusAPIClient 158 params *DescribeTableRestoreStatusInput 159 nextToken *string 160 firstPage bool 161} 162 163// NewDescribeTableRestoreStatusPaginator returns a new 164// DescribeTableRestoreStatusPaginator 165func NewDescribeTableRestoreStatusPaginator(client DescribeTableRestoreStatusAPIClient, params *DescribeTableRestoreStatusInput, optFns ...func(*DescribeTableRestoreStatusPaginatorOptions)) *DescribeTableRestoreStatusPaginator { 166 if params == nil { 167 params = &DescribeTableRestoreStatusInput{} 168 } 169 170 options := DescribeTableRestoreStatusPaginatorOptions{} 171 if params.MaxRecords != nil { 172 options.Limit = *params.MaxRecords 173 } 174 175 for _, fn := range optFns { 176 fn(&options) 177 } 178 179 return &DescribeTableRestoreStatusPaginator{ 180 options: options, 181 client: client, 182 params: params, 183 firstPage: true, 184 } 185} 186 187// HasMorePages returns a boolean indicating whether more pages are available 188func (p *DescribeTableRestoreStatusPaginator) HasMorePages() bool { 189 return p.firstPage || p.nextToken != nil 190} 191 192// NextPage retrieves the next DescribeTableRestoreStatus page. 193func (p *DescribeTableRestoreStatusPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeTableRestoreStatusOutput, error) { 194 if !p.HasMorePages() { 195 return nil, fmt.Errorf("no more pages available") 196 } 197 198 params := *p.params 199 params.Marker = p.nextToken 200 201 var limit *int32 202 if p.options.Limit > 0 { 203 limit = &p.options.Limit 204 } 205 params.MaxRecords = limit 206 207 result, err := p.client.DescribeTableRestoreStatus(ctx, ¶ms, optFns...) 208 if err != nil { 209 return nil, err 210 } 211 p.firstPage = false 212 213 prevToken := p.nextToken 214 p.nextToken = result.Marker 215 216 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 217 p.nextToken = nil 218 } 219 220 return result, nil 221} 222 223func newServiceMetadataMiddleware_opDescribeTableRestoreStatus(region string) *awsmiddleware.RegisterServiceMetadata { 224 return &awsmiddleware.RegisterServiceMetadata{ 225 Region: region, 226 ServiceID: ServiceID, 227 SigningName: "redshift", 228 OperationName: "DescribeTableRestoreStatus", 229 } 230} 231