-
Notifications
You must be signed in to change notification settings - Fork 870
S3 Gen Phase 2: Generate PutBucket #3909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -181,17 +187,41 @@ WriteXmlAttributeString(level, member, variableName, isPayload: false); | |||
#> | |||
if (<#=variableName + ".IsSet" + operation.RequestPayloadMember.PropertyName#>()) | |||
{ | |||
<#+ | |||
// S3 doesn't follow the rule where if the request payload member's location name is the same as the payload member name, we marshall with the payload member's shape's marshall name instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this, we would incorrectly write PutBucketConfiguration
as the xml element name when it should be CreateBucketConfiguration
. S3 doesn't follow this rule.
@@ -97,7 +97,7 @@ public IRequest Marshall(PutObjectRetentionRequest publicRequest) | |||
{ | |||
if (publicRequest.IsSetRetention()) | |||
{ | |||
xmlWriter.WriteStartElement("ObjectLockRetention", "http://s3.amazonaws.com/doc/2006-03-01/"); | |||
xmlWriter.WriteStartElement("Retention", "http://s3.amazonaws.com/doc/2006-03-01/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this was a benign bug that we were using the wrong root element name. I see in the docs Retention
is the correct value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, i also tested the operation when i did a sweep of all released operations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the S3 PutBucket operation support by:
- Customizing the base class of
PutBucketRequest
to inherit fromPutWithACLRequest
- Moving
PostMarshallCustomization
calls into the generated marshaller template for more precise timing - Implementing logic in the
BucketRegion
andBucketRegionName
setters to auto-create aPutBucketConfiguration
and removing unused members
Reviewed Changes
Copilot reviewed 9 out of 38 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
sdk/src/Services/S3/Custom/Model/PutBucketRequest.cs | Updated inheritance, moved ACL logic to base class, added region-based configuration in property setters, removed unused properties |
sdk/src/Services/S3/Custom/Model/PutBucketConfiguration.cs | Deleted manual copy of PutBucketConfiguration (now generated) |
sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/PutBucketRequestMarshaller.cs | Converted to partial class, preserved ACL header logic in PostMarshallCustomization |
generator/ServiceClientGeneratorLib/* | Added support for inheritAlternateBaseClass in generator and patched the T4 marshaller template to invoke PostMarshallCustomization |
_putBucketConfiguration.LocationConstraint = bucketRegion.Value; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BucketRegion
setter only initializes the configuration once, so updating the region a second time won’t update LocationConstraint
. Consider always assigning or updating _putBucketConfiguration.LocationConstraint
to reflect the latest BucketRegion
.
_putBucketConfiguration.LocationConstraint = bucketRegion.Value; | |
} | |
} | |
_putBucketConfiguration.LocationConstraint = bucketRegion.Value; |
Copilot uses AI. Check for mistakes.
set | ||
{ | ||
this.bucketRegionName = value; | ||
if (bucketRegionName != "us-east-1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When BucketRegionName
is reset to "us-east-1", the existing _putBucketConfiguration
isn’t cleared, potentially leaving a stale LocationConstraint
. Consider clearing or resetting the configuration when returning to the default region.
Copilot uses AI. Check for mistakes.
{ | ||
_putBucketConfiguration = new PutBucketConfiguration(); | ||
if (bucketRegionName == "eu-west-1") | ||
_putBucketConfiguration.LocationConstraint = "EU"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Hard-coded region strings (e.g., "eu-west-1", "EU") can lead to typos or drift. Prefer using defined constants or the S3Region
enum to ensure consistency.
_putBucketConfiguration.LocationConstraint = "EU"; | |
_putBucketConfiguration.LocationConstraint = S3Region.EU.Value; |
Copilot uses AI. Check for mistakes.
// the NoAcl logic exists because it was originally a part of the IsSetCannedACL() | ||
// method https://github.com/aws/aws-sdk-net/blob/623dc261499331cb38bfec47789ddc4ef456222c/sdk/src/Services/S3/Custom/Model/PutBucketRequest.cs#L195-L198 | ||
if (publicRequest.IsSetCannedACL() && publicRequest.CannedACL == S3CannedACL.NoACL) | ||
defaultRequest.Headers.Remove("x-amz-acl"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the HeaderKeys.XAmzAclHeader
constant instead of a literal string to remove the ACL header, improving consistency and reducing the risk of typos.
defaultRequest.Headers.Remove("x-amz-acl"); | |
defaultRequest.Headers.Remove(HeaderKeys.XAmzAclHeader); |
Copilot uses AI. Check for mistakes.
This reverts commit 6501007.
Description
This generates PutBucket. The major changes are
PostMarshallCustomization
to before thetry
catch
block where we set the content because we could be altering the content in that methodPutBucketRequestMarshaller
where the user could setBucketRegion
orBucketRegionName
and not have to create aPutBucketConfiguration
object and we would create the appropriate xml for the user. I moved that logic to the setters of bothBucketRegion
andBucketRegionName
PutBucketRequest
has logic with setting ACLsMotivation and Context
S3 Generation Phase 2.
Testing
I did some manual checks to make sure that a user could still only specify the bucket region and name and create a bucket without having to create the
PutBucketConfiguration
object themselves.Assembly comparer output (empty)
Dry_Run passes caeb33aa-9f50-4418-af23-d054dcd47197
Screenshots (if appropriate)
Types of changes
Checklist
License