/
GetObjectAttributesCommand.ts
260 lines (250 loc) · 11.5 KB
/
GetObjectAttributesCommand.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
// smithy-typescript generated code
import { getBucketEndpointPlugin } from "@aws-sdk/middleware-bucket-endpoint";
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { getSsecPlugin } from "@aws-sdk/middleware-ssec";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import {
GetObjectAttributesOutput,
GetObjectAttributesOutputFilterSensitiveLog,
GetObjectAttributesRequest,
GetObjectAttributesRequestFilterSensitiveLog,
} from "../models/models_0";
import {
deserializeAws_restXmlGetObjectAttributesCommand,
serializeAws_restXmlGetObjectAttributesCommand,
} from "../protocols/Aws_restXml";
import { S3ClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../S3Client";
export interface GetObjectAttributesCommandInput extends GetObjectAttributesRequest {}
export interface GetObjectAttributesCommandOutput extends GetObjectAttributesOutput, __MetadataBearer {}
/**
* <p>Retrieves all the metadata from an object without returning the object itself. This
* action is useful if you're interested only in an object's metadata. To use
* <code>GetObjectAttributes</code>, you must have READ access to the object.</p>
*
* <p>
* <code>GetObjectAttributes</code> combines the functionality of
* <code>GetObjectAcl</code>, <code>GetObjectLegalHold</code>,
* <code>GetObjectLockConfiguration</code>, <code>GetObjectRetention</code>,
* <code>GetObjectTagging</code>, <code>HeadObject</code>, and <code>ListParts</code>. All
* of the data returned with each of those individual calls can be returned with a single call
* to <code>GetObjectAttributes</code>.</p>
*
* <p>If you encrypt an object by using server-side encryption with customer-provided
* encryption keys (SSE-C) when you store the object in Amazon S3, then when you retrieve the
* metadata from the object, you must use the following headers:</p>
* <ul>
* <li>
* <p>
* <code>x-amz-server-side-encryption-customer-algorithm</code>
* </p>
* </li>
* <li>
* <p>
* <code>x-amz-server-side-encryption-customer-key</code>
* </p>
* </li>
* <li>
* <p>
* <code>x-amz-server-side-encryption-customer-key-MD5</code>
* </p>
* </li>
* </ul>
* <p>For more information about SSE-C, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/ServerSideEncryptionCustomerKeys.html">Server-Side Encryption
* (Using Customer-Provided Encryption Keys)</a> in the
* <i>Amazon S3 User Guide</i>.</p>
* <note>
* <ul>
* <li>
* <p>Encryption request headers, such as
* <code>x-amz-server-side-encryption</code>, should not be sent for GET requests
* if your object uses server-side encryption with Amazon Web Services KMS keys stored in Amazon Web Services Key
* Management Service (SSE-KMS) or server-side encryption with Amazon S3 managed
* encryption keys (SSE-S3). If your object does use these types of keys, you'll get
* an HTTP <code>400 Bad Request</code> error.</p>
* </li>
* <li>
* <p>
* The last modified property in this case is the creation date of the object.</p>
* </li>
* </ul>
* </note>
*
* <p>Consider the following when using request headers:</p>
* <ul>
* <li>
* <p> If both of the <code>If-Match</code> and <code>If-Unmodified-Since</code>
* headers are present in the request as follows, then Amazon S3 returns the HTTP
* status code <code>200 OK</code> and the data requested:</p>
* <ul>
* <li>
* <p>
* <code>If-Match</code> condition evaluates to <code>true</code>.</p>
* </li>
* <li>
* <p>
* <code>If-Unmodified-Since</code> condition evaluates to
* <code>false</code>.</p>
* </li>
* </ul>
* </li>
* <li>
* <p>If both of the <code>If-None-Match</code> and <code>If-Modified-Since</code>
* headers are present in the request as follows, then Amazon S3 returns the HTTP status code
* <code>304 Not Modified</code>:</p>
* <ul>
* <li>
* <p>
* <code>If-None-Match</code> condition evaluates to
* <code>false</code>.</p>
* </li>
* <li>
* <p>
* <code>If-Modified-Since</code> condition evaluates to
* <code>true</code>.</p>
* </li>
* </ul>
* </li>
* </ul>
*
* <p>For more information about conditional requests, see <a href="https://tools.ietf.org/html/rfc7232">RFC 7232</a>.</p>
*
* <p>
* <b>Permissions</b>
* </p>
* <p>The permissions that you need to use this operation depend on whether the bucket is
* versioned. If the bucket is versioned, you need both the <code>s3:GetObjectVersion</code>
* and <code>s3:GetObjectVersionAttributes</code> permissions for this operation. If the
* bucket is not versioned, you need the <code>s3:GetObject</code> and
* <code>s3:GetObjectAttributes</code> permissions. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html">Specifying
* Permissions in a Policy</a> in the <i>Amazon S3 User Guide</i>. If the
* object that you request does not exist, the error Amazon S3 returns depends on whether you also
* have the <code>s3:ListBucket</code> permission.</p>
* <ul>
* <li>
* <p>If you have the <code>s3:ListBucket</code> permission on the bucket, Amazon S3
* returns an HTTP status code <code>404 Not Found</code> ("no such key") error.</p>
* </li>
* <li>
* <p>If you don't have the <code>s3:ListBucket</code> permission, Amazon S3 returns an
* HTTP status code <code>403 Forbidden</code> ("access denied") error.</p>
* </li>
* </ul>
*
* <p>The following actions are related to <code>GetObjectAttributes</code>:</p>
* <ul>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html">GetObject</a>
* </p>
* </li>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAcl.html">GetObjectAcl</a>
* </p>
* </li>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectLegalHold.html">GetObjectLegalHold</a>
* </p>
* </li>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectLockConfiguration.html">GetObjectLockConfiguration</a>
* </p>
* </li>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectRetention.html">GetObjectRetention</a>
* </p>
* </li>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html">GetObjectTagging</a>
* </p>
* </li>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html">HeadObject</a>
* </p>
* </li>
* <li>
* <p>
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html">ListParts</a>
* </p>
* </li>
* </ul>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { S3Client, GetObjectAttributesCommand } from "@aws-sdk/client-s3"; // ES Modules import
* // const { S3Client, GetObjectAttributesCommand } = require("@aws-sdk/client-s3"); // CommonJS import
* const client = new S3Client(config);
* const command = new GetObjectAttributesCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link GetObjectAttributesCommandInput} for command's `input` shape.
* @see {@link GetObjectAttributesCommandOutput} for command's `response` shape.
* @see {@link S3ClientResolvedConfig | config} for S3Client's `config` shape.
*
*/
export class GetObjectAttributesCommand extends $Command<
GetObjectAttributesCommandInput,
GetObjectAttributesCommandOutput,
S3ClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties
constructor(readonly input: GetObjectAttributesCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}
/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: S3ClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<GetObjectAttributesCommandInput, GetObjectAttributesCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
this.middlewareStack.use(getSsecPlugin(configuration));
this.middlewareStack.use(getBucketEndpointPlugin(configuration));
const stack = clientStack.concat(this.middlewareStack);
const { logger } = configuration;
const clientName = "S3Client";
const commandName = "GetObjectAttributesCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: GetObjectAttributesRequestFilterSensitiveLog,
outputFilterSensitiveLog: GetObjectAttributesOutputFilterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}
private serialize(input: GetObjectAttributesCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_restXmlGetObjectAttributesCommand(input, context);
}
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetObjectAttributesCommandOutput> {
return deserializeAws_restXmlGetObjectAttributesCommand(output, context);
}
// Start section: command_body_extra
// End section: command_body_extra
}