Skip to content

Commit 34f5b98

Browse files
committed
Metadata updates.
1 parent 2bd60c7 commit 34f5b98

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

.doc_gen/metadata/s3_metadata.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ s3_CopyObject:
294294
snippet_tags:
295295
- python.example_code.s3.helper.ObjectWrapper
296296
- python.example_code.s3.CopyObject
297+
- description: Copy an object using a conditional request.
298+
genai: some
299+
snippet_tags:
300+
- python.example_code.s3.helper.S3ConditionalRequests
301+
- python.example_code.s3.CopyObjectConditional
297302
Ruby:
298303
versions:
299304
- sdk_version: 3
@@ -872,6 +877,11 @@ s3_GetObject:
872877
snippet_tags:
873878
- python.example_code.s3.helper.ObjectWrapper
874879
- python.example_code.s3.GetObject
880+
- description: Get an object using a conditional request.
881+
genai: some
882+
snippet_tags:
883+
- python.example_code.s3.helper.S3ConditionalRequests
884+
- python.example_code.s3.GetObjectConditional
875885
JavaScript:
876886
versions:
877887
- sdk_version: 3
@@ -1510,6 +1520,11 @@ s3_PutObject:
15101520
snippet_tags:
15111521
- python.example_code.s3.helper.ObjectWrapper
15121522
- python.example_code.s3.PutObject
1523+
- description: Upload an object using a conditional request.
1524+
genai: some
1525+
snippet_tags:
1526+
- python.example_code.s3.helper.S3ConditionalRequests
1527+
- python.example_code.s3.PutObjectConditional
15131528
Rust:
15141529
versions:
15151530
- sdk_version: 1
@@ -3454,6 +3469,28 @@ s3_Scenario_DeleteAllObjects:
34543469
- javascriptv3/example_code/s3/scenarios/delete-all-objects.js
34553470
services:
34563471
s3: {DeleteObjects, ListObjectsV2}
3472+
s3_Scenario_ConditionalRequests:
3473+
title: Make &S3; conditional requests using an &AWS; SDK.
3474+
title_abbrev: Make conditional requests
3475+
synopsis: add preconditions to &S3; requests.
3476+
category: Scenarios
3477+
languages:
3478+
Python:
3479+
versions:
3480+
- sdk_version: 3
3481+
github: python/example_code/s3/scenarios/conditional_requests
3482+
sdkguide:
3483+
excerpts:
3484+
- description: Run an interactive scenario demonstrating &S3; conditional requests.
3485+
genai: some
3486+
snippet_tags:
3487+
- python.example_code.s3.S3ConditionalRequests.scenario
3488+
- description: A wrapper class that defines the conditional request operations.
3489+
genai: some
3490+
snippet_tags:
3491+
- python.example_code.s3.S3ConditionalRequests.wrapper
3492+
services:
3493+
s3: {GetObject, PutObject, CopyObject}
34573494
s3_Scenario_ExpressBasics:
34583495
title: Learn the basics of Amazon S3 Express One Zone with an &AWS; SDK
34593496
title_abbrev: Learn the basics of S3 Express One Zone

python/example_code/s3/scenarios/conditional_requests/s3_conditional_requests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
# snippet-start:[python.example_code.s3.S3ConditionalRequests.wrapper]
5+
46
import boto3
57
import logging
68

@@ -10,6 +12,7 @@
1012
logger = logging.getLogger(__name__)
1113

1214

15+
# snippet-start:[python.example_code.s3.helper.S3ConditionalRequests]
1316
class S3ConditionalRequests:
1417
"""Encapsulates S3 conditional request operations."""
1518

@@ -24,6 +27,8 @@ def from_client(cls):
2427
s3_client = boto3.client("s3")
2528
return cls(s3_client)
2629

30+
# snippet-end:[python.example_code.s3.helper.S3ConditionalRequests]
31+
2732
# snippet-start:[python.example_code.s3.GetObjectConditional]
2833

2934
def get_object_conditional(
@@ -134,3 +139,4 @@ def copy_object_conditional(
134139
raise
135140

136141
# snippet-end:[python.example_code.s3.CopyObjectConditional]
142+
# snippet-end:[python.example_code.s3.S3ConditionalRequests.wrapper]

python/example_code/s3/scenarios/conditional_requests/scenario.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
# snippet-start:[python.example_code.s3.S3ConditionalRequests.scenario]
45
"""
56
Purpose
67
@@ -283,3 +284,4 @@ def run_scenario(self):
283284
S3ConditionalRequests.from_client(), boto3.client("s3")
284285
)
285286
scenario.run_scenario()
287+
# snippet-end:[python.example_code.s3.S3ConditionalRequests.scenario]

workflows/s3_conditional_requests/SPECIFICATION.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ todo
3333
3434
```
3535
- Amazon S3 objects created in the scenario:
36-
- Three test files in the source bucket, using a name prefix provided by the user.
36+
- One test file in the source bucket.
3737

3838
Example:
3939

@@ -74,12 +74,16 @@ todo
7474
---
7575

7676
## Errors
77-
78-
| action | Error | Handling |
79-
|-----------------------|-------|----------|
80-
| `GetObject` | todo | todo |
81-
| `CopyObject` | todo | todo |
82-
| `PutObject` | todo | todo |
77+
The PreconditionFailed exceptions are part of the flow of this scenario. After a success or failure,
78+
the user can print the contents of the buckets to see the result.
79+
80+
| action | Error | Handling |
81+
|--------------|-----------------------|--------------------------------------------|
82+
| `GetObject` | PreconditionFailed | Notify the user and do not print contents. |
83+
| `GetObject` | ObjectNotModified 304 | Notify the user and do not print contents. |
84+
| `CopyObject` | PreconditionFailed | Notify the user of the failure. |
85+
| `CopyObject` | ObjectNotModified 304 | Notify the user of the failure. |
86+
| `PutObject` | PreconditionFailed | Notify the user of the failure. |
8387

8488

8589
---

0 commit comments

Comments
 (0)