1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package glacier
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	glaciercust "github.com/aws/aws-sdk-go-v2/service/glacier/internal/customizations"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// This operation initiates a multipart upload. Amazon S3 Glacier creates a
15// multipart upload resource and returns its ID in the response. The multipart
16// upload ID is used in subsequent requests to upload parts of an archive (see
17// UploadMultipartPart). When you initiate a multipart upload, you specify the part
18// size in number of bytes. The part size must be a megabyte (1024 KB) multiplied
19// by a power of 2-for example, 1048576 (1 MB), 2097152 (2 MB), 4194304 (4 MB),
20// 8388608 (8 MB), and so on. The minimum allowable part size is 1 MB, and the
21// maximum is 4 GB. Every part you upload to this resource (see
22// UploadMultipartPart), except the last one, must have the same size. The last one
23// can be the same size or smaller. For example, suppose you want to upload a 16.2
24// MB file. If you initiate the multipart upload with a part size of 4 MB, you will
25// upload four parts of 4 MB each and one part of 0.2 MB. You don't need to know
26// the size of the archive when you start a multipart upload because Amazon S3
27// Glacier does not require you to specify the overall archive size. After you
28// complete the multipart upload, Amazon S3 Glacier (Glacier) removes the multipart
29// upload resource referenced by the ID. Glacier also removes the multipart upload
30// resource if you cancel the multipart upload or it may be removed if there is no
31// activity for a period of 24 hours. An AWS account has full permission to perform
32// all operations (actions). However, AWS Identity and Access Management (IAM)
33// users don't have any permissions by default. You must grant them explicit
34// permission to perform specific actions. For more information, see Access Control
35// Using AWS Identity and Access Management (IAM)
36// (https://docs.aws.amazon.com/amazonglacier/latest/dev/using-iam-with-amazon-glacier.html).
37// For conceptual information and underlying REST API, see Uploading Large Archives
38// in Parts (Multipart Upload)
39// (https://docs.aws.amazon.com/amazonglacier/latest/dev/uploading-archive-mpu.html)
40// and Initiate Multipart Upload
41// (https://docs.aws.amazon.com/amazonglacier/latest/dev/api-multipart-initiate-upload.html)
42// in the Amazon Glacier Developer Guide.
43func (c *Client) InitiateMultipartUpload(ctx context.Context, params *InitiateMultipartUploadInput, optFns ...func(*Options)) (*InitiateMultipartUploadOutput, error) {
44	if params == nil {
45		params = &InitiateMultipartUploadInput{}
46	}
47
48	result, metadata, err := c.invokeOperation(ctx, "InitiateMultipartUpload", params, optFns, addOperationInitiateMultipartUploadMiddlewares)
49	if err != nil {
50		return nil, err
51	}
52
53	out := result.(*InitiateMultipartUploadOutput)
54	out.ResultMetadata = metadata
55	return out, nil
56}
57
58// Provides options for initiating a multipart upload to an Amazon S3 Glacier
59// vault.
60type InitiateMultipartUploadInput struct {
61
62	// The AccountId value is the AWS account ID of the account that owns the vault.
63	// You can either specify an AWS account ID or optionally a single '-' (hyphen), in
64	// which case Amazon S3 Glacier uses the AWS account ID associated with the
65	// credentials used to sign the request. If you use an account ID, do not include
66	// any hyphens ('-') in the ID.
67	//
68	// This member is required.
69	AccountId *string
70
71	// The name of the vault.
72	//
73	// This member is required.
74	VaultName *string
75
76	// The archive description that you are uploading in parts. The part size must be a
77	// megabyte (1024 KB) multiplied by a power of 2, for example 1048576 (1 MB),
78	// 2097152 (2 MB), 4194304 (4 MB), 8388608 (8 MB), and so on. The minimum allowable
79	// part size is 1 MB, and the maximum is 4 GB (4096 MB).
80	ArchiveDescription *string
81
82	// The size of each part except the last, in bytes. The last part can be smaller
83	// than this part size.
84	PartSize *string
85}
86
87// The Amazon S3 Glacier response to your request.
88type InitiateMultipartUploadOutput struct {
89
90	// The relative URI path of the multipart upload ID Amazon S3 Glacier created.
91	Location *string
92
93	// The ID of the multipart upload. This value is also included as part of the
94	// location.
95	UploadId *string
96
97	// Metadata pertaining to the operation's result.
98	ResultMetadata middleware.Metadata
99}
100
101func addOperationInitiateMultipartUploadMiddlewares(stack *middleware.Stack, options Options) (err error) {
102	err = stack.Serialize.Add(&awsRestjson1_serializeOpInitiateMultipartUpload{}, middleware.After)
103	if err != nil {
104		return err
105	}
106	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpInitiateMultipartUpload{}, middleware.After)
107	if err != nil {
108		return err
109	}
110	if err = addSetLoggerMiddleware(stack, options); err != nil {
111		return err
112	}
113	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
114		return err
115	}
116	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
117		return err
118	}
119	if err = addResolveEndpointMiddleware(stack, options); err != nil {
120		return err
121	}
122	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
123		return err
124	}
125	if err = addRetryMiddlewares(stack, options); err != nil {
126		return err
127	}
128	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
129		return err
130	}
131	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
132		return err
133	}
134	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
135		return err
136	}
137	if err = addClientUserAgent(stack); err != nil {
138		return err
139	}
140	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
141		return err
142	}
143	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
144		return err
145	}
146	if err = addOpInitiateMultipartUploadValidationMiddleware(stack); err != nil {
147		return err
148	}
149	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opInitiateMultipartUpload(options.Region), middleware.Before); err != nil {
150		return err
151	}
152	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
153		return err
154	}
155	if err = addResponseErrorMiddleware(stack); err != nil {
156		return err
157	}
158	if err = glaciercust.AddTreeHashMiddleware(stack); err != nil {
159		return err
160	}
161	if err = glaciercust.AddGlacierAPIVersionMiddleware(stack, ServiceAPIVersion); err != nil {
162		return err
163	}
164	if err = glaciercust.AddDefaultAccountIDMiddleware(stack, setDefaultAccountID); err != nil {
165		return err
166	}
167	if err = addRequestResponseLogging(stack, options); err != nil {
168		return err
169	}
170	return nil
171}
172
173func newServiceMetadataMiddleware_opInitiateMultipartUpload(region string) *awsmiddleware.RegisterServiceMetadata {
174	return &awsmiddleware.RegisterServiceMetadata{
175		Region:        region,
176		ServiceID:     ServiceID,
177		SigningName:   "glacier",
178		OperationName: "InitiateMultipartUpload",
179	}
180}
181