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 // Copies a manual snapshot of an instance or disk as another manual snapshot, or
15 // copies an automatic snapshot of an instance or disk as a manual snapshot. This
16 // operation can also be used to copy a manual or automatic snapshot of an instance
17 // or a disk from one Amazon Web Services Region to another in Amazon Lightsail.
18 //
19 // When copying a manual snapshot, be sure to define the source region , source
20 // snapshot name , and target snapshot name parameters.
21 //
22 // When copying an automatic snapshot, be sure to define the source region ,
23 // source resource name , target snapshot name , and either the restore date or
24 // the use latest restorable auto snapshot parameters.
25 func (c *Client) CopySnapshot(ctx context.Context, params *CopySnapshotInput, optFns ...func(*Options)) (*CopySnapshotOutput, error) {
26 if params == nil {
27 params = &CopySnapshotInput{}
28 }
29 30 result, metadata, err := c.invokeOperation(ctx, "CopySnapshot", params, optFns, c.addOperationCopySnapshotMiddlewares)
31 if err != nil {
32 return nil, err
33 }
34 35 out := result.(*CopySnapshotOutput)
36 out.ResultMetadata = metadata
37 return out, nil
38 }
39 40 type CopySnapshotInput struct {
41 42 // The Amazon Web Services Region where the source manual or automatic snapshot is
43 // located.
44 //
45 // This member is required.
46 SourceRegion types.RegionName
47 48 // The name of the new manual snapshot to be created as a copy.
49 //
50 // This member is required.
51 TargetSnapshotName *string
52 53 // The date of the source automatic snapshot to copy. Use the get auto snapshots
54 // operation to identify the dates of the available automatic snapshots.
55 //
56 // Constraints:
57 //
58 // - Must be specified in YYYY-MM-DD format.
59 //
60 // - This parameter cannot be defined together with the use latest restorable
61 // auto snapshot parameter. The restore date and use latest restorable auto
62 // snapshot parameters are mutually exclusive.
63 //
64 // - Define this parameter only when copying an automatic snapshot as a manual
65 // snapshot. For more information, see the [Amazon Lightsail Developer Guide].
66 //
67 // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-keeping-automatic-snapshots
68 RestoreDate *string
69 70 // The name of the source instance or disk from which the source automatic
71 // snapshot was created.
72 //
73 // Constraint:
74 //
75 // - Define this parameter only when copying an automatic snapshot as a manual
76 // snapshot. For more information, see the [Amazon Lightsail Developer Guide].
77 //
78 // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-keeping-automatic-snapshots
79 SourceResourceName *string
80 81 // The name of the source manual snapshot to copy.
82 //
83 // Constraint:
84 //
85 // - Define this parameter only when copying a manual snapshot as another manual
86 // snapshot.
87 SourceSnapshotName *string
88 89 // A Boolean value to indicate whether to use the latest available automatic
90 // snapshot of the specified source instance or disk.
91 //
92 // Constraints:
93 //
94 // - This parameter cannot be defined together with the restore date parameter.
95 // The use latest restorable auto snapshot and restore date parameters are
96 // mutually exclusive.
97 //
98 // - Define this parameter only when copying an automatic snapshot as a manual
99 // snapshot. For more information, see the [Amazon Lightsail Developer Guide].
100 //
101 // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-keeping-automatic-snapshots
102 UseLatestRestorableAutoSnapshot *bool
103 104 noSmithyDocumentSerde
105 }
106 107 type CopySnapshotOutput struct {
108 109 // An array of objects that describe the result of the action, such as the status
110 // of the request, the timestamp of the request, and the resources affected by the
111 // request.
112 Operations []types.Operation
113 114 // Metadata pertaining to the operation's result.
115 ResultMetadata middleware.Metadata
116 117 noSmithyDocumentSerde
118 }
119 120 func (c *Client) addOperationCopySnapshotMiddlewares(stack *middleware.Stack, options Options) (err error) {
121 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
122 return err
123 }
124 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCopySnapshot{}, middleware.After)
125 if err != nil {
126 return err
127 }
128 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCopySnapshot{}, middleware.After)
129 if err != nil {
130 return err
131 }
132 if err := addProtocolFinalizerMiddlewares(stack, options, "CopySnapshot"); err != nil {
133 return fmt.Errorf("add protocol finalizers: %v", err)
134 }
135 136 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
137 return err
138 }
139 if err = addSetLoggerMiddleware(stack, options); err != nil {
140 return err
141 }
142 if err = addClientRequestID(stack); err != nil {
143 return err
144 }
145 if err = addComputeContentLength(stack); err != nil {
146 return err
147 }
148 if err = addResolveEndpointMiddleware(stack, options); err != nil {
149 return err
150 }
151 if err = addComputePayloadSHA256(stack); err != nil {
152 return err
153 }
154 if err = addRetry(stack, options); err != nil {
155 return err
156 }
157 if err = addRawResponseToMetadata(stack); err != nil {
158 return err
159 }
160 if err = addRecordResponseTiming(stack); err != nil {
161 return err
162 }
163 if err = addSpanRetryLoop(stack, options); err != nil {
164 return err
165 }
166 if err = addClientUserAgent(stack, options); err != nil {
167 return err
168 }
169 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
170 return err
171 }
172 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
173 return err
174 }
175 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
176 return err
177 }
178 if err = addTimeOffsetBuild(stack, c); err != nil {
179 return err
180 }
181 if err = addUserAgentRetryMode(stack, options); err != nil {
182 return err
183 }
184 if err = addCredentialSource(stack, options); err != nil {
185 return err
186 }
187 if err = addOpCopySnapshotValidationMiddleware(stack); err != nil {
188 return err
189 }
190 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCopySnapshot(options.Region), middleware.Before); err != nil {
191 return err
192 }
193 if err = addRecursionDetection(stack); err != nil {
194 return err
195 }
196 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
197 return err
198 }
199 if err = addResponseErrorMiddleware(stack); err != nil {
200 return err
201 }
202 if err = addRequestResponseLogging(stack, options); err != nil {
203 return err
204 }
205 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
206 return err
207 }
208 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
209 return err
210 }
211 if err = addInterceptAttempt(stack, options); err != nil {
212 return err
213 }
214 if err = addInterceptors(stack, options); err != nil {
215 return err
216 }
217 return nil
218 }
219 220 func newServiceMetadataMiddleware_opCopySnapshot(region string) *awsmiddleware.RegisterServiceMetadata {
221 return &awsmiddleware.RegisterServiceMetadata{
222 Region: region,
223 ServiceID: ServiceID,
224 OperationName: "CopySnapshot",
225 }
226 }
227