1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package storagegateway
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/storagegateway/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Initiates a snapshot of a volume. AWS Storage Gateway provides the ability to
15// back up point-in-time snapshots of your data to Amazon Simple Storage (Amazon
16// S3) for durable off-site recovery, and also import the data to an Amazon Elastic
17// Block Store (EBS) volume in Amazon Elastic Compute Cloud (EC2). You can take
18// snapshots of your gateway volume on a scheduled or ad hoc basis. This API
19// enables you to take an ad hoc snapshot. For more information, see Editing a
20// snapshot schedule
21// (https://docs.aws.amazon.com/storagegateway/latest/userguide/managing-volumes.html#SchedulingSnapshot).
22// In the CreateSnapshot request, you identify the volume by providing its Amazon
23// Resource Name (ARN). You must also provide description for the snapshot. When
24// AWS Storage Gateway takes the snapshot of specified volume, the snapshot and
25// description appears in the AWS Storage Gateway console. In response, AWS Storage
26// Gateway returns you a snapshot ID. You can use this snapshot ID to check the
27// snapshot progress or later use it when you want to create a volume from a
28// snapshot. This operation is only supported in stored and cached volume gateway
29// type. To list or delete a snapshot, you must use the Amazon EC2 API. For more
30// information, see DescribeSnapshots
31// (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSnapshots.html)
32// or DeleteSnapshot
33// (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DeleteSnapshot.html)
34// in the Amazon Elastic Compute Cloud API Reference. Volume and snapshot IDs are
35// changing to a longer length ID format. For more information, see the important
36// note on the Welcome
37// (https://docs.aws.amazon.com/storagegateway/latest/APIReference/Welcome.html)
38// page.
39func (c *Client) CreateSnapshot(ctx context.Context, params *CreateSnapshotInput, optFns ...func(*Options)) (*CreateSnapshotOutput, error) {
40	if params == nil {
41		params = &CreateSnapshotInput{}
42	}
43
44	result, metadata, err := c.invokeOperation(ctx, "CreateSnapshot", params, optFns, addOperationCreateSnapshotMiddlewares)
45	if err != nil {
46		return nil, err
47	}
48
49	out := result.(*CreateSnapshotOutput)
50	out.ResultMetadata = metadata
51	return out, nil
52}
53
54// A JSON object containing one or more of the following fields:
55//
56// *
57// CreateSnapshotInput$SnapshotDescription
58//
59// * CreateSnapshotInput$VolumeARN
60type CreateSnapshotInput struct {
61
62	// Textual description of the snapshot that appears in the Amazon EC2 console,
63	// Elastic Block Store snapshots panel in the Description field, and in the AWS
64	// Storage Gateway snapshot Details pane, Description field.
65	//
66	// This member is required.
67	SnapshotDescription *string
68
69	// The Amazon Resource Name (ARN) of the volume. Use the ListVolumes operation to
70	// return a list of gateway volumes.
71	//
72	// This member is required.
73	VolumeARN *string
74
75	// A list of up to 50 tags that can be assigned to a snapshot. Each tag is a
76	// key-value pair. Valid characters for key and value are letters, spaces, and
77	// numbers representable in UTF-8 format, and the following special characters: + -
78	// = . _ : / @. The maximum length of a tag's key is 128 characters, and the
79	// maximum length for a tag's value is 256.
80	Tags []types.Tag
81}
82
83// A JSON object containing the following fields:
84type CreateSnapshotOutput struct {
85
86	// The snapshot ID that is used to refer to the snapshot in future operations such
87	// as describing snapshots (Amazon Elastic Compute Cloud API DescribeSnapshots) or
88	// creating a volume from a snapshot (CreateStorediSCSIVolume).
89	SnapshotId *string
90
91	// The Amazon Resource Name (ARN) of the volume of which the snapshot was taken.
92	VolumeARN *string
93
94	// Metadata pertaining to the operation's result.
95	ResultMetadata middleware.Metadata
96}
97
98func addOperationCreateSnapshotMiddlewares(stack *middleware.Stack, options Options) (err error) {
99	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateSnapshot{}, middleware.After)
100	if err != nil {
101		return err
102	}
103	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateSnapshot{}, middleware.After)
104	if err != nil {
105		return err
106	}
107	if err = addSetLoggerMiddleware(stack, options); err != nil {
108		return err
109	}
110	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
111		return err
112	}
113	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
114		return err
115	}
116	if err = addResolveEndpointMiddleware(stack, options); err != nil {
117		return err
118	}
119	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
120		return err
121	}
122	if err = addRetryMiddlewares(stack, options); err != nil {
123		return err
124	}
125	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
126		return err
127	}
128	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
129		return err
130	}
131	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
132		return err
133	}
134	if err = addClientUserAgent(stack); err != nil {
135		return err
136	}
137	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
138		return err
139	}
140	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
141		return err
142	}
143	if err = addOpCreateSnapshotValidationMiddleware(stack); err != nil {
144		return err
145	}
146	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateSnapshot(options.Region), middleware.Before); err != nil {
147		return err
148	}
149	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
150		return err
151	}
152	if err = addResponseErrorMiddleware(stack); err != nil {
153		return err
154	}
155	if err = addRequestResponseLogging(stack, options); err != nil {
156		return err
157	}
158	return nil
159}
160
161func newServiceMetadataMiddleware_opCreateSnapshot(region string) *awsmiddleware.RegisterServiceMetadata {
162	return &awsmiddleware.RegisterServiceMetadata{
163		Region:        region,
164		ServiceID:     ServiceID,
165		SigningName:   "storagegateway",
166		OperationName: "CreateSnapshot",
167	}
168}
169