api_op_GetAutoSnapshots.go raw
1 // Code generated by smithy-go-codegen DO NOT EDIT.
2
3 package lightsail
4
5 import (
6 "context"
7 "fmt"
8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
9 "github.com/aws/aws-sdk-go-v2/service/lightsail/types"
10 "github.com/aws/smithy-go/middleware"
11 smithyhttp "github.com/aws/smithy-go/transport/http"
12 )
13
14 // Returns the available automatic snapshots for an instance or disk. For more
15 // information, see the [Amazon Lightsail Developer Guide].
16 //
17 // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-configuring-automatic-snapshots
18 func (c *Client) GetAutoSnapshots(ctx context.Context, params *GetAutoSnapshotsInput, optFns ...func(*Options)) (*GetAutoSnapshotsOutput, error) {
19 if params == nil {
20 params = &GetAutoSnapshotsInput{}
21 }
22
23 result, metadata, err := c.invokeOperation(ctx, "GetAutoSnapshots", params, optFns, c.addOperationGetAutoSnapshotsMiddlewares)
24 if err != nil {
25 return nil, err
26 }
27
28 out := result.(*GetAutoSnapshotsOutput)
29 out.ResultMetadata = metadata
30 return out, nil
31 }
32
33 type GetAutoSnapshotsInput struct {
34
35 // The name of the source instance or disk from which to get automatic snapshot
36 // information.
37 //
38 // This member is required.
39 ResourceName *string
40
41 noSmithyDocumentSerde
42 }
43
44 type GetAutoSnapshotsOutput struct {
45
46 // An array of objects that describe the automatic snapshots that are available
47 // for the specified source instance or disk.
48 AutoSnapshots []types.AutoSnapshotDetails
49
50 // The name of the source instance or disk for the automatic snapshots.
51 ResourceName *string
52
53 // The resource type of the automatic snapshot. The possible values are Instance ,
54 // and Disk .
55 ResourceType types.ResourceType
56
57 // Metadata pertaining to the operation's result.
58 ResultMetadata middleware.Metadata
59
60 noSmithyDocumentSerde
61 }
62
63 func (c *Client) addOperationGetAutoSnapshotsMiddlewares(stack *middleware.Stack, options Options) (err error) {
64 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
65 return err
66 }
67 err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetAutoSnapshots{}, middleware.After)
68 if err != nil {
69 return err
70 }
71 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetAutoSnapshots{}, middleware.After)
72 if err != nil {
73 return err
74 }
75 if err := addProtocolFinalizerMiddlewares(stack, options, "GetAutoSnapshots"); err != nil {
76 return fmt.Errorf("add protocol finalizers: %v", err)
77 }
78
79 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
80 return err
81 }
82 if err = addSetLoggerMiddleware(stack, options); err != nil {
83 return err
84 }
85 if err = addClientRequestID(stack); err != nil {
86 return err
87 }
88 if err = addComputeContentLength(stack); err != nil {
89 return err
90 }
91 if err = addResolveEndpointMiddleware(stack, options); err != nil {
92 return err
93 }
94 if err = addComputePayloadSHA256(stack); err != nil {
95 return err
96 }
97 if err = addRetry(stack, options); err != nil {
98 return err
99 }
100 if err = addRawResponseToMetadata(stack); err != nil {
101 return err
102 }
103 if err = addRecordResponseTiming(stack); err != nil {
104 return err
105 }
106 if err = addSpanRetryLoop(stack, options); err != nil {
107 return err
108 }
109 if err = addClientUserAgent(stack, options); err != nil {
110 return err
111 }
112 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
113 return err
114 }
115 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
116 return err
117 }
118 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
119 return err
120 }
121 if err = addTimeOffsetBuild(stack, c); err != nil {
122 return err
123 }
124 if err = addUserAgentRetryMode(stack, options); err != nil {
125 return err
126 }
127 if err = addCredentialSource(stack, options); err != nil {
128 return err
129 }
130 if err = addOpGetAutoSnapshotsValidationMiddleware(stack); err != nil {
131 return err
132 }
133 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetAutoSnapshots(options.Region), middleware.Before); err != nil {
134 return err
135 }
136 if err = addRecursionDetection(stack); err != nil {
137 return err
138 }
139 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
140 return err
141 }
142 if err = addResponseErrorMiddleware(stack); err != nil {
143 return err
144 }
145 if err = addRequestResponseLogging(stack, options); err != nil {
146 return err
147 }
148 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
149 return err
150 }
151 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
152 return err
153 }
154 if err = addInterceptAttempt(stack, options); err != nil {
155 return err
156 }
157 if err = addInterceptors(stack, options); err != nil {
158 return err
159 }
160 return nil
161 }
162
163 func newServiceMetadataMiddleware_opGetAutoSnapshots(region string) *awsmiddleware.RegisterServiceMetadata {
164 return &awsmiddleware.RegisterServiceMetadata{
165 Region: region,
166 ServiceID: ServiceID,
167 OperationName: "GetAutoSnapshots",
168 }
169 }
170