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	"io"
13)
14
15// This operation uploads a part of an archive. You can upload archive parts in any
16// order. You can also upload them in parallel. You can upload up to 10,000 parts
17// for a multipart upload. Amazon Glacier rejects your upload part request if any
18// of the following conditions is true:
19//
20// * SHA256 tree hash does not matchTo ensure
21// that part data is not corrupted in transmission, you compute a SHA256 tree hash
22// of the part and include it in your request. Upon receiving the part data, Amazon
23// S3 Glacier also computes a SHA256 tree hash. If these hash values don't match,
24// the operation fails. For information about computing a SHA256 tree hash, see
25// Computing Checksums
26// (https://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html).
27//
28// *
29// Part size does not matchThe size of each part except the last must match the
30// size specified in the corresponding InitiateMultipartUpload request. The size of
31// the last part must be the same size as, or smaller than, the specified size. If
32// you upload a part whose size is smaller than the part size you specified in your
33// initiate multipart upload request and that part is not the last part, then the
34// upload part request will succeed. However, the subsequent Complete Multipart
35// Upload request will fail.
36//
37// * Range does not alignThe byte range value in the
38// request does not align with the part size specified in the corresponding
39// initiate request. For example, if you specify a part size of 4194304 bytes (4
40// MB), then 0 to 4194303 bytes (4 MB - 1) and 4194304 (4 MB) to 8388607 (8 MB - 1)
41// are valid part ranges. However, if you set a range value of 2 MB to 6 MB, the
42// range does not align with the part size and the upload will fail.
43//
44// This
45// operation is idempotent. If you upload the same part multiple times, the data
46// included in the most recent request overwrites the previously uploaded data. An
47// AWS account has full permission to perform all operations (actions). However,
48// AWS Identity and Access Management (IAM) users don't have any permissions by
49// default. You must grant them explicit permission to perform specific actions.
50// For more information, see Access Control Using AWS Identity and Access
51// Management (IAM)
52// (https://docs.aws.amazon.com/amazonglacier/latest/dev/using-iam-with-amazon-glacier.html).
53// For conceptual information and underlying REST API, see Uploading Large Archives
54// in Parts (Multipart Upload)
55// (https://docs.aws.amazon.com/amazonglacier/latest/dev/uploading-archive-mpu.html)
56// and Upload Part
57// (https://docs.aws.amazon.com/amazonglacier/latest/dev/api-upload-part.html) in
58// the Amazon Glacier Developer Guide.
59func (c *Client) UploadMultipartPart(ctx context.Context, params *UploadMultipartPartInput, optFns ...func(*Options)) (*UploadMultipartPartOutput, error) {
60	if params == nil {
61		params = &UploadMultipartPartInput{}
62	}
63
64	result, metadata, err := c.invokeOperation(ctx, "UploadMultipartPart", params, optFns, addOperationUploadMultipartPartMiddlewares)
65	if err != nil {
66		return nil, err
67	}
68
69	out := result.(*UploadMultipartPartOutput)
70	out.ResultMetadata = metadata
71	return out, nil
72}
73
74// Provides options to upload a part of an archive in a multipart upload operation.
75type UploadMultipartPartInput struct {
76
77	// The AccountId value is the AWS account ID of the account that owns the vault.
78	// You can either specify an AWS account ID or optionally a single '-' (hyphen), in
79	// which case Amazon S3 Glacier uses the AWS account ID associated with the
80	// credentials used to sign the request. If you use an account ID, do not include
81	// any hyphens ('-') in the ID.
82	//
83	// This member is required.
84	AccountId *string
85
86	// The upload ID of the multipart upload.
87	//
88	// This member is required.
89	UploadId *string
90
91	// The name of the vault.
92	//
93	// This member is required.
94	VaultName *string
95
96	// The data to upload.
97	Body io.Reader
98
99	// The SHA256 tree hash of the data being uploaded.
100	Checksum *string
101
102	// Identifies the range of bytes in the assembled archive that will be uploaded in
103	// this part. Amazon S3 Glacier uses this information to assemble the archive in
104	// the proper sequence. The format of this header follows RFC 2616. An example
105	// header is Content-Range:bytes 0-4194303/*.
106	Range *string
107}
108
109// Contains the Amazon S3 Glacier response to your request.
110type UploadMultipartPartOutput struct {
111
112	// The SHA256 tree hash that Amazon S3 Glacier computed for the uploaded part.
113	Checksum *string
114
115	// Metadata pertaining to the operation's result.
116	ResultMetadata middleware.Metadata
117}
118
119func addOperationUploadMultipartPartMiddlewares(stack *middleware.Stack, options Options) (err error) {
120	err = stack.Serialize.Add(&awsRestjson1_serializeOpUploadMultipartPart{}, middleware.After)
121	if err != nil {
122		return err
123	}
124	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpUploadMultipartPart{}, middleware.After)
125	if err != nil {
126		return err
127	}
128	if err = addSetLoggerMiddleware(stack, options); err != nil {
129		return err
130	}
131	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
132		return err
133	}
134	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
135		return err
136	}
137	if err = addResolveEndpointMiddleware(stack, options); err != nil {
138		return err
139	}
140	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
141		return err
142	}
143	if err = addRetryMiddlewares(stack, options); err != nil {
144		return err
145	}
146	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
147		return err
148	}
149	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
150		return err
151	}
152	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
153		return err
154	}
155	if err = addClientUserAgent(stack); err != nil {
156		return err
157	}
158	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
159		return err
160	}
161	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
162		return err
163	}
164	if err = addOpUploadMultipartPartValidationMiddleware(stack); err != nil {
165		return err
166	}
167	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUploadMultipartPart(options.Region), middleware.Before); err != nil {
168		return err
169	}
170	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
171		return err
172	}
173	if err = addResponseErrorMiddleware(stack); err != nil {
174		return err
175	}
176	if err = glaciercust.AddTreeHashMiddleware(stack); err != nil {
177		return err
178	}
179	if err = glaciercust.AddGlacierAPIVersionMiddleware(stack, ServiceAPIVersion); err != nil {
180		return err
181	}
182	if err = glaciercust.AddDefaultAccountIDMiddleware(stack, setDefaultAccountID); err != nil {
183		return err
184	}
185	if err = addRequestResponseLogging(stack, options); err != nil {
186		return err
187	}
188	return nil
189}
190
191func newServiceMetadataMiddleware_opUploadMultipartPart(region string) *awsmiddleware.RegisterServiceMetadata {
192	return &awsmiddleware.RegisterServiceMetadata{
193		Region:        region,
194		ServiceID:     ServiceID,
195		SigningName:   "glacier",
196		OperationName: "UploadMultipartPart",
197	}
198}
199