1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ec2 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/ec2/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Describes the state of fast snapshot restores for your snapshots. 16func (c *Client) DescribeFastSnapshotRestores(ctx context.Context, params *DescribeFastSnapshotRestoresInput, optFns ...func(*Options)) (*DescribeFastSnapshotRestoresOutput, error) { 17 if params == nil { 18 params = &DescribeFastSnapshotRestoresInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "DescribeFastSnapshotRestores", params, optFns, addOperationDescribeFastSnapshotRestoresMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*DescribeFastSnapshotRestoresOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type DescribeFastSnapshotRestoresInput struct { 32 33 // Checks whether you have the required permissions for the action, without 34 // actually making the request, and provides an error response. If you have the 35 // required permissions, the error response is DryRunOperation. Otherwise, it is 36 // UnauthorizedOperation. 37 DryRun bool 38 39 // The filters. The possible values are: 40 // 41 // * availability-zone: The Availability 42 // Zone of the snapshot. 43 // 44 // * owner-id: The ID of the AWS account that enabled fast 45 // snapshot restore on the snapshot. 46 // 47 // * snapshot-id: The ID of the snapshot. 48 // 49 // * 50 // state: The state of fast snapshot restores for the snapshot (enabling | 51 // optimizing | enabled | disabling | disabled). 52 Filters []types.Filter 53 54 // The maximum number of results to return with a single call. To retrieve the 55 // remaining results, make another call with the returned nextToken value. 56 MaxResults *int32 57 58 // The token for the next page of results. 59 NextToken *string 60} 61 62type DescribeFastSnapshotRestoresOutput struct { 63 64 // Information about the state of fast snapshot restores. 65 FastSnapshotRestores []types.DescribeFastSnapshotRestoreSuccessItem 66 67 // The token to use to retrieve the next page of results. This value is null when 68 // there are no more results to return. 69 NextToken *string 70 71 // Metadata pertaining to the operation's result. 72 ResultMetadata middleware.Metadata 73} 74 75func addOperationDescribeFastSnapshotRestoresMiddlewares(stack *middleware.Stack, options Options) (err error) { 76 err = stack.Serialize.Add(&awsEc2query_serializeOpDescribeFastSnapshotRestores{}, middleware.After) 77 if err != nil { 78 return err 79 } 80 err = stack.Deserialize.Add(&awsEc2query_deserializeOpDescribeFastSnapshotRestores{}, middleware.After) 81 if err != nil { 82 return err 83 } 84 if err = addSetLoggerMiddleware(stack, options); err != nil { 85 return err 86 } 87 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 88 return err 89 } 90 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 91 return err 92 } 93 if err = addResolveEndpointMiddleware(stack, options); err != nil { 94 return err 95 } 96 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 97 return err 98 } 99 if err = addRetryMiddlewares(stack, options); err != nil { 100 return err 101 } 102 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 103 return err 104 } 105 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 106 return err 107 } 108 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 109 return err 110 } 111 if err = addClientUserAgent(stack); err != nil { 112 return err 113 } 114 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 115 return err 116 } 117 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 118 return err 119 } 120 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeFastSnapshotRestores(options.Region), middleware.Before); err != nil { 121 return err 122 } 123 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 124 return err 125 } 126 if err = addResponseErrorMiddleware(stack); err != nil { 127 return err 128 } 129 if err = addRequestResponseLogging(stack, options); err != nil { 130 return err 131 } 132 return nil 133} 134 135// DescribeFastSnapshotRestoresAPIClient is a client that implements the 136// DescribeFastSnapshotRestores operation. 137type DescribeFastSnapshotRestoresAPIClient interface { 138 DescribeFastSnapshotRestores(context.Context, *DescribeFastSnapshotRestoresInput, ...func(*Options)) (*DescribeFastSnapshotRestoresOutput, error) 139} 140 141var _ DescribeFastSnapshotRestoresAPIClient = (*Client)(nil) 142 143// DescribeFastSnapshotRestoresPaginatorOptions is the paginator options for 144// DescribeFastSnapshotRestores 145type DescribeFastSnapshotRestoresPaginatorOptions struct { 146 // The maximum number of results to return with a single call. To retrieve the 147 // remaining results, make another call with the returned nextToken value. 148 Limit int32 149 150 // Set to true if pagination should stop if the service returns a pagination token 151 // that matches the most recent token provided to the service. 152 StopOnDuplicateToken bool 153} 154 155// DescribeFastSnapshotRestoresPaginator is a paginator for 156// DescribeFastSnapshotRestores 157type DescribeFastSnapshotRestoresPaginator struct { 158 options DescribeFastSnapshotRestoresPaginatorOptions 159 client DescribeFastSnapshotRestoresAPIClient 160 params *DescribeFastSnapshotRestoresInput 161 nextToken *string 162 firstPage bool 163} 164 165// NewDescribeFastSnapshotRestoresPaginator returns a new 166// DescribeFastSnapshotRestoresPaginator 167func NewDescribeFastSnapshotRestoresPaginator(client DescribeFastSnapshotRestoresAPIClient, params *DescribeFastSnapshotRestoresInput, optFns ...func(*DescribeFastSnapshotRestoresPaginatorOptions)) *DescribeFastSnapshotRestoresPaginator { 168 options := DescribeFastSnapshotRestoresPaginatorOptions{} 169 if params.MaxResults != nil { 170 options.Limit = *params.MaxResults 171 } 172 173 for _, fn := range optFns { 174 fn(&options) 175 } 176 177 if params == nil { 178 params = &DescribeFastSnapshotRestoresInput{} 179 } 180 181 return &DescribeFastSnapshotRestoresPaginator{ 182 options: options, 183 client: client, 184 params: params, 185 firstPage: true, 186 } 187} 188 189// HasMorePages returns a boolean indicating whether more pages are available 190func (p *DescribeFastSnapshotRestoresPaginator) HasMorePages() bool { 191 return p.firstPage || p.nextToken != nil 192} 193 194// NextPage retrieves the next DescribeFastSnapshotRestores page. 195func (p *DescribeFastSnapshotRestoresPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeFastSnapshotRestoresOutput, error) { 196 if !p.HasMorePages() { 197 return nil, fmt.Errorf("no more pages available") 198 } 199 200 params := *p.params 201 params.NextToken = p.nextToken 202 203 var limit *int32 204 if p.options.Limit > 0 { 205 limit = &p.options.Limit 206 } 207 params.MaxResults = limit 208 209 result, err := p.client.DescribeFastSnapshotRestores(ctx, ¶ms, optFns...) 210 if err != nil { 211 return nil, err 212 } 213 p.firstPage = false 214 215 prevToken := p.nextToken 216 p.nextToken = result.NextToken 217 218 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 219 p.nextToken = nil 220 } 221 222 return result, nil 223} 224 225func newServiceMetadataMiddleware_opDescribeFastSnapshotRestores(region string) *awsmiddleware.RegisterServiceMetadata { 226 return &awsmiddleware.RegisterServiceMetadata{ 227 Region: region, 228 ServiceID: ServiceID, 229 SigningName: "ec2", 230 OperationName: "DescribeFastSnapshotRestores", 231 } 232} 233