|
1 |
| -from typing import Any, Dict, Iterator, Optional |
| 1 | +from typing import Dict, Iterator, Optional |
2 | 2 | from urllib.parse import unquote_plus
|
3 | 3 |
|
4 |
| -from aws_lambda_powertools.utilities.data_classes.common import DictWrapper, get_header_value |
| 4 | +from aws_lambda_powertools.utilities.data_classes.common import DictWrapper |
5 | 5 |
|
6 | 6 |
|
7 | 7 | class S3Identity(DictWrapper):
|
@@ -187,208 +187,3 @@ def bucket_name(self) -> str:
|
187 | 187 | def object_key(self) -> str:
|
188 | 188 | """Get the object key for the first s3 event record and unquote plus"""
|
189 | 189 | return unquote_plus(self["Records"][0]["s3"]["object"]["key"])
|
190 |
| - |
191 |
| - |
192 |
| -class S3ObjectContext(DictWrapper): |
193 |
| - """The input and output details for connections to Amazon S3 and S3 Object Lambda.""" |
194 |
| - |
195 |
| - @property |
196 |
| - def input_s3_url(self) -> str: |
197 |
| - """A presigned URL that can be used to fetch the original object from Amazon S3. |
198 |
| - The URL is signed using the original caller’s identity, and their permissions |
199 |
| - will apply when the URL is used. If there are signed headers in the URL, the |
200 |
| - Lambda function must include these in the call to Amazon S3, except for the Host.""" |
201 |
| - return self["inputS3Url"] |
202 |
| - |
203 |
| - @property |
204 |
| - def output_route(self) -> str: |
205 |
| - """A routing token that is added to the S3 Object Lambda URL when the Lambda function |
206 |
| - calls `WriteGetObjectResponse`.""" |
207 |
| - return self["outputRoute"] |
208 |
| - |
209 |
| - @property |
210 |
| - def output_token(self) -> str: |
211 |
| - """An opaque token used by S3 Object Lambda to match the WriteGetObjectResponse call |
212 |
| - with the original caller.""" |
213 |
| - return self["outputToken"] |
214 |
| - |
215 |
| - |
216 |
| -class S3ObjectConfiguration(DictWrapper): |
217 |
| - """Configuration information about the S3 Object Lambda access point.""" |
218 |
| - |
219 |
| - @property |
220 |
| - def access_point_arn(self) -> str: |
221 |
| - """The Amazon Resource Name (ARN) of the S3 Object Lambda access point that received |
222 |
| - this request.""" |
223 |
| - return self["accessPointArn"] |
224 |
| - |
225 |
| - @property |
226 |
| - def supporting_access_point_arn(self) -> str: |
227 |
| - """The ARN of the supporting access point that is specified in the S3 Object Lambda |
228 |
| - access point configuration.""" |
229 |
| - return self["supportingAccessPointArn"] |
230 |
| - |
231 |
| - @property |
232 |
| - def payload(self) -> str: |
233 |
| - """Custom data that is applied to the S3 Object Lambda access point configuration. |
234 |
| - S3 Object Lambda treats this as an opaque string, so it might need to be decoded |
235 |
| - before use.""" |
236 |
| - return self["payload"] |
237 |
| - |
238 |
| - |
239 |
| -class S3ObjectUserRequest(DictWrapper): |
240 |
| - """ Information about the original call to S3 Object Lambda.""" |
241 |
| - |
242 |
| - @property |
243 |
| - def url(self) -> str: |
244 |
| - """The decoded URL of the request as received by S3 Object Lambda, excluding any |
245 |
| - authorization-related query parameters.""" |
246 |
| - return self["url"] |
247 |
| - |
248 |
| - @property |
249 |
| - def headers(self) -> Dict[str, str]: |
250 |
| - """A map of string to strings containing the HTTP headers and their values from the |
251 |
| - original call, excluding any authorization-related headers. If the same header appears |
252 |
| - multiple times, their values are combined into a comma-delimited list. The case of the |
253 |
| - original headers is retained in this map.""" |
254 |
| - return self["headers"] |
255 |
| - |
256 |
| - def get_header_value( |
257 |
| - self, name: str, default_value: Optional[str] = None, case_sensitive: Optional[bool] = False |
258 |
| - ) -> Optional[str]: |
259 |
| - """Get header value by name |
260 |
| -
|
261 |
| - Parameters |
262 |
| - ---------- |
263 |
| - name: str |
264 |
| - Header name |
265 |
| - default_value: str, optional |
266 |
| - Default value if no value was found by name |
267 |
| - case_sensitive: bool |
268 |
| - Whether to use a case sensitive look up |
269 |
| - Returns |
270 |
| - ------- |
271 |
| - str, optional |
272 |
| - Header value |
273 |
| - """ |
274 |
| - return get_header_value(self.headers, name, default_value, case_sensitive) |
275 |
| - |
276 |
| - |
277 |
| -class S3ObjectUserIdentity(DictWrapper): |
278 |
| - """Details about the identity that made the call to S3 Object Lambda. |
279 |
| -
|
280 |
| - Documentation: |
281 |
| - ------------- |
282 |
| - - https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-user-identity.html |
283 |
| - """ |
284 |
| - |
285 |
| - @property |
286 |
| - def get_type(self) -> str: |
287 |
| - """The type of identity. |
288 |
| -
|
289 |
| - The following values are possible: |
290 |
| -
|
291 |
| - - Root – The request was made with your AWS account credentials. If the userIdentity |
292 |
| - type is Root and you set an alias for your account, the userName field contains your account alias. |
293 |
| - For more information, see Your AWS Account ID and Its Alias. |
294 |
| - - IAMUser – The request was made with the credentials of an IAM user. |
295 |
| - - AssumedRole – The request was made with temporary security credentials that were obtained |
296 |
| - with a role via a call to the AWS Security Token Service (AWS STS) AssumeRole API. This can include |
297 |
| - roles for Amazon EC2 and cross-account API access. |
298 |
| - - FederatedUser – The request was made with temporary security credentials that were obtained via a |
299 |
| - call to the AWS STS GetFederationToken API. The sessionIssuer element indicates if the API was |
300 |
| - called with root or IAM user credentials. |
301 |
| - - AWSAccount – The request was made by another AWS account. |
302 |
| - - AWSService – The request was made by an AWS account that belongs to an AWS service. |
303 |
| - For example, AWS Elastic Beanstalk assumes an IAM role in your account to call other AWS services |
304 |
| - on your behalf. |
305 |
| - """ |
306 |
| - return self["type"] |
307 |
| - |
308 |
| - @property |
309 |
| - def account_id(self) -> str: |
310 |
| - """The account that owns the entity that granted permissions for the request. |
311 |
| - If the request was made with temporary security credentials, this is the account that owns the IAM |
312 |
| - user or role that was used to obtain credentials.""" |
313 |
| - return self["accountId"] |
314 |
| - |
315 |
| - @property |
316 |
| - def access_key_id(self) -> str: |
317 |
| - """The access key ID that was used to sign the request. |
318 |
| -
|
319 |
| - If the request was made with temporary security credentials, this is the access key ID of |
320 |
| - the temporary credentials. For security reasons, accessKeyId might not be present, or might |
321 |
| - be displayed as an empty string.""" |
322 |
| - return self["accessKeyId"] |
323 |
| - |
324 |
| - @property |
325 |
| - def user_name(self) -> str: |
326 |
| - """The friendly name of the identity that made the call.""" |
327 |
| - return self["userName"] |
328 |
| - |
329 |
| - @property |
330 |
| - def principal_id(self) -> str: |
331 |
| - """The unique identifier for the identity that made the call. |
332 |
| -
|
333 |
| - For requests made with temporary security credentials, this value includes |
334 |
| - the session name that is passed to the AssumeRole, AssumeRoleWithWebIdentity, |
335 |
| - or GetFederationToken API call.""" |
336 |
| - return self["principalId"] |
337 |
| - |
338 |
| - @property |
339 |
| - def arn(self) -> str: |
340 |
| - """The ARN of the principal that made the call. |
341 |
| - The last section of the ARN contains the user or role that made the call.""" |
342 |
| - return self["arn"] |
343 |
| - |
344 |
| - @property |
345 |
| - def session_context(self) -> Optional[Dict[str, Any]]: |
346 |
| - """ If the request was made with temporary security credentials, |
347 |
| - this element provides information about the session that was created for those credentials.""" |
348 |
| - return self.get("sessionContext") |
349 |
| - |
350 |
| - |
351 |
| -class S3ObjectLambdaEvent(DictWrapper): |
352 |
| - """S3 object event notification |
353 |
| -
|
354 |
| - Documentation: |
355 |
| - ------------- |
356 |
| - - https://docs.aws.amazon.com/AmazonS3/latest/userguide/olap-writing-lambda.html |
357 |
| - """ |
358 |
| - |
359 |
| - @property |
360 |
| - def request_id(self) -> str: |
361 |
| - """The Amazon S3 request ID for this request. We recommend that you log this value to help with debugging.""" |
362 |
| - return self["xAmzRequestId"] |
363 |
| - |
364 |
| - @property |
365 |
| - def object_context(self) -> S3ObjectContext: |
366 |
| - """The input and output details for connections to Amazon S3 and S3 Object Lambda.""" |
367 |
| - return S3ObjectContext(self["getObjectContext"]) |
368 |
| - |
369 |
| - @property |
370 |
| - def configuration(self) -> S3ObjectConfiguration: |
371 |
| - """Configuration information about the S3 Object Lambda access point.""" |
372 |
| - return S3ObjectConfiguration(self["configuration"]) |
373 |
| - |
374 |
| - @property |
375 |
| - def user_request(self) -> S3ObjectUserRequest: |
376 |
| - """Information about the original call to S3 Object Lambda.""" |
377 |
| - return S3ObjectUserRequest(self["userRequest"]) |
378 |
| - |
379 |
| - @property |
380 |
| - def user_identity(self) -> S3ObjectUserIdentity: |
381 |
| - """Details about the identity that made the call to S3 Object Lambda.""" |
382 |
| - return S3ObjectUserIdentity(self["userIdentity"]) |
383 |
| - |
384 |
| - @property |
385 |
| - def protocol_version(self) -> str: |
386 |
| - """The version ID of the context provided. |
387 |
| -
|
388 |
| - The format of this field is `{Major Version}`.`{Minor Version}`. |
389 |
| - The minor version numbers are always two-digit numbers. Any removal or change to the semantics of a |
390 |
| - field will necessitate a major version bump and will require active opt-in. Amazon S3 can add new |
391 |
| - fields at any time, at which point you might experience a minor version bump. Due to the nature of |
392 |
| - software rollouts, it is possible that you might see multiple minor versions in use at once. |
393 |
| - """ |
394 |
| - return self["protocolVersion"] |
0 commit comments