Skip to content

Commit d8bcbb3

Browse files
authored
.NET v3: S3 Conditional Requests Feature Scenario Follow (#7174)
1 parent 7fc628c commit d8bcbb3

File tree

14 files changed

+1017
-1
lines changed

14 files changed

+1017
-1
lines changed

.doc_gen/metadata/s3_metadata.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ s3_CopyObject:
236236
- description:
237237
snippet_tags:
238238
- S3.dotnet35.CopyObject
239+
- description: Copy an object using a conditional request.
240+
genai: some
241+
snippet_tags:
242+
- S3ConditionalRequests.dotnetv3.CopyObjectConditional
239243
C++:
240244
versions:
241245
- sdk_version: 1
@@ -854,6 +858,10 @@ s3_GetObject:
854858
- description:
855859
snippet_tags:
856860
- S3.dotnetv3.S3_Basics-DownloadObject
861+
- description: Get an object using a conditional request.
862+
genai: some
863+
snippet_tags:
864+
- S3ConditionalRequests.dotnetv3.GetObjectConditional
857865
C++:
858866
versions:
859867
- sdk_version: 1
@@ -1491,6 +1499,10 @@ s3_PutObject:
14911499
- description: Upload an object with server-side encryption.
14921500
snippet_tags:
14931501
- S3.dotnetv3.ServerSideEncryptionExample
1502+
- description: Put an object using a conditional request.
1503+
genai: some
1504+
snippet_tags:
1505+
- S3ConditionalRequests.dotnetv3.PutObjectConditional
14941506
C++:
14951507
versions:
14961508
- sdk_version: 1
@@ -3593,6 +3605,18 @@ s3_Scenario_ConditionalRequests:
35933605
genai: some
35943606
snippet_tags:
35953607
- python.example_code.s3.S3ConditionalRequests.wrapper
3608+
.NET:
3609+
versions:
3610+
- sdk_version: 3
3611+
github: dotnetv3/S3/scenarios/S3ConditionalRequestsScenario
3612+
sdkguide:
3613+
excerpts:
3614+
- description: Run an interactive scenario demonstrating &S3; conditional request features.
3615+
snippet_tags:
3616+
- S3ConditionalRequests.dotnetv3.Scenario
3617+
- description: A wrapper class for S3 functions.
3618+
snippet_tags:
3619+
- S3ConditionalRequests.dotnetv3.S3ActionsWrapper
35963620
services:
35973621
s3: {GetObject, PutObject, CopyObject}
35983622
s3_Scenario_DownloadS3Directory:

dotnetv3/S3/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ functions within the same service.
8484
- [Get started with encryption](SSEClientEncryptionExample/SSEClientEncryption.cs)
8585
- [Get started with tags](ObjectTagExample/ObjectTag.cs)
8686
- [Lock Amazon S3 objects](scenarios/S3ObjectLockScenario/S3ObjectLockWorkflow/S3ObjectLockWorkflow.cs)
87+
- [Make conditional requests](scenarios/S3ConditionalRequestsScenario/S3ConditionalRequests/S3ConditionalRequestsScenario.cs)
8788
- [Manage access control lists (ACLs)](ManageACLsExample/ManageACLs.cs)
8889
- [Perform a multipart copy](MPUapiCopyObjExample/MPUapiCopyObj.cs)
8990
- [Transform data with S3 Object Lambda](../cross-service/S3ObjectLambdaFunction)
@@ -209,6 +210,18 @@ This example shows you how to work with S3 object lock features.
209210
<!--custom.scenarios.s3_Scenario_ObjectLock.start-->
210211
<!--custom.scenarios.s3_Scenario_ObjectLock.end-->
211212

213+
#### Make conditional requests
214+
215+
This example shows you how to add preconditions to Amazon S3 requests.
216+
217+
218+
<!--custom.scenario_prereqs.s3_Scenario_ConditionalRequests.start-->
219+
<!--custom.scenario_prereqs.s3_Scenario_ConditionalRequests.end-->
220+
221+
222+
<!--custom.scenarios.s3_Scenario_ConditionalRequests.start-->
223+
<!--custom.scenarios.s3_Scenario_ConditionalRequests.end-->
224+
212225
#### Manage access control lists (ACLs)
213226

214227
This example shows you how to manage access control lists (ACLs) for Amazon S3 buckets.
@@ -283,4 +296,4 @@ in the `dotnetv3` folder.
283296

284297
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
285298

286-
SPDX-License-Identifier: Apache-2.0
299+
SPDX-License-Identifier: Apache-2.0
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Amazon S3 Conditional Requests Feature Scenario for the SDK for .NET
2+
3+
## Overview
4+
5+
This example demonstrates how to use the AWS SDK for Python (boto3) to work with Amazon Simple Storage Service (Amazon S3) conditional request features. The scenario demonstrates how to add preconditions to S3 operations, and how those operations will succeed or fail based on the conditional requests.
6+
7+
[Amazon S3 Conditional Requests](https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-requests.html) are used to add preconditions to S3 read, copy, or write requests.
8+
9+
## ⚠ Important
10+
11+
* Running this code might result in charges to your AWS account.
12+
* Running the tests might result in charges to your AWS account.
13+
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
14+
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
15+
16+
## Scenario
17+
18+
This example uses a feature scenario to demonstrate various aspects of S3 conditional requests. The scenario is divided into three stages:
19+
20+
1. **Setup**: Create test buckets and objects.
21+
2. **Conditional Reads and Writes**: Explore S3 conditional requests by listing objects, attempting to read or write with conditional requests, and viewing request results.
22+
3. **Clean**: Delete all objects and buckets.
23+
24+
### Prerequisites
25+
26+
For general prerequisites, see the [README](../../../README.md) in the `dotnetv3` folder.
27+
28+
### Resources
29+
30+
The scenario steps create the buckets and objects needed for the example. No additional resources are required.
31+
32+
### Instructions
33+
34+
After the example compiles, you can run it from the command line. To do so, navigate to
35+
the folder that contains the .sln file and run the following command:
36+
37+
```
38+
dotnet run
39+
```
40+
41+
Alternatively, you can run the example from within your IDE.
42+
43+
This starts an interactive scenario that walks you through exploring conditional requests for read, write, and copy operations.
44+
45+
## Additional resources
46+
47+
- [Amazon S3 Developer Guide](https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-requests.html)
48+
49+
---
50+
51+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
namespace S3ConditionalRequestsScenario;
5+
6+
public enum S3ConditionType
7+
{
8+
IfMatch,
9+
IfNoneMatch,
10+
IfModifiedSince,
11+
IfUnmodifiedSince
12+
}

0 commit comments

Comments
 (0)