Skip to content

Generate PutBucket #3928

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

Merged
merged 7 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions generator/.DevConfigs/02d8bc0f-1757-4948-9c6c-ac1833b2b0dc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"core": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Core if only S3 files are being changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is b/c PostMarshallCustomization is generated for every RestXml service and I moved the location of it so that it runs before we set the request.Content

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Up to you if you'd like to change it now, but you could have that message for Core and have a separate entry for S3 (if someone wanted to check when PutBucket was generated I think it'd make more sense to have that in the specific S3 version).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"updateMinimum": true,
"type": "patch",
"changeLogMessages": [
"Move PostMarshallCustomization for restXml services to right before setting request.Content"
]
},
"services":[
{
"serviceName": "S3",
"type": "patch",
"changeLogMessages": [
"Generate PutBucket operation."
]
}
]
}
22 changes: 22 additions & 0 deletions generator/ServiceClientGeneratorLib/Customizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ public class CustomizationsModel
public const string OverrideTreatEnumsAsStringKey = "overrideTreatEnumsAsString";
public const string ExcludeMembersKey = "excludeMembers";
public const string UnwrapXmlOutputKey = "unwrapXmlOutput";
public const string InheritAlternateBaseClassKey = "inheritAlternateBaseClass";

JsonData _documentRoot;

Expand Down Expand Up @@ -704,6 +705,27 @@ public HashSet<string> ResultGenerationSuppressions
}
}

/// <summary>
/// Overrides the base class that structures inherit from.
/// Here is an example of the usage
/// "inheritAlternateBaseClass":{
/// "CreateBucketRequest": {
/// "alternateBaseClass" : "PutWithAclRequest"
/// }
/// }
/// </summary>
/// <param name="shapeName"></param>
/// <returns></returns>
public string InheritAlternateBaseClass(string shapeName)
{
var data = _documentRoot[InheritAlternateBaseClassKey];
if (data == null || data[shapeName] == null) return null;

if (data[shapeName]["alternateBaseClass"] == null)
throw new InvalidDataException("You must specify \"alternateBaseClass\" as the key for this customization");
return data[shapeName]["alternateBaseClass"].ToString();
}

public bool GenerateCustomUnmarshaller
{
get
Expand Down
6 changes: 4 additions & 2 deletions generator/ServiceClientGeneratorLib/GeneratorDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,11 @@ public void Execute()
/// <param name="operation">The operation object which contains info about what the request needs to contain for the operation</param>
void GenerateRequest(Operation operation)
{
var baseClassString = this.Configuration.ServiceModel.Customizations.InheritAlternateBaseClass(operation.Name + "Request");
var requestGenerator = new StructureGenerator
{
ClassName = operation.Name + "Request",
BaseClass = this.Configuration.ServiceId != "S3" ? string.Format("Amazon{0}Request", Configuration.ClassName) : "AmazonWebServiceRequest",
BaseClass = baseClassString ?? (this.Configuration.ServiceId != "S3" ? string.Format("Amazon{0}Request", Configuration.ClassName) : "AmazonWebServiceRequest"),
StructureType = StructureType.Request,
Operation = operation
};
Expand Down Expand Up @@ -459,10 +460,11 @@ var propertyModifier
}
else
{
var baseClassString = this.Configuration.ServiceModel.Customizations.InheritAlternateBaseClass(operation.Name + "Response");
var resultGenerator = new StructureGenerator
{
ClassName = operation.Name + "Response",
BaseClass = "AmazonWebServiceResponse",
BaseClass = baseClassString ?? "AmazonWebServiceResponse",
IsWrapped = operation.IsResponseWrapped,
Operation = operation,
StructureType = StructureType.Response
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,23 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
// Process any members which are marshalled as part of the request body
if(this.Operation.RequestHasBodyMembers || shouldMarshallPayload)
{
ProcessRequestBodyMembers("publicRequest", this.Operation);
ProcessRequestBodyMembers("publicRequest", this.Operation);
}
else if(payload != null && !payload.Shape.IsStructure)
{
ProcessNonStructurePayload(payload, 3);
#>
PostMarshallCustomization(request, publicRequest);
<#
GenerateRequestChecksumHandling(this.Operation, "content");
}
else
{
#>

PostMarshallCustomization(request, publicRequest);
<#
}
if (this.Operation.UnsignedPayload)
{
#>
Expand All @@ -118,7 +125,6 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
ProcessEndpointHostPrefixMembers(3, "publicRequest", this.Operation);
}
#>
PostMarshallCustomization(request, publicRequest);
return request;
}
<#
Expand Down Expand Up @@ -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
if (this.Config.ServiceId != "S3")
{
#>
xmlWriter.WriteStartElement("<#=operation.RequestPayloadMember.LocationName != operation.RequestStructure.PayloadMemberName ? operation.RequestPayloadMember.LocationName : operation.RequestPayloadMember.Shape.MarshallName#>", "<#=operation.XmlNamespace#>");
<#+
}
else
{
#>
xmlWriter.WriteStartElement("<#=operation.RequestPayloadMember.LocationName#>", "<#=operation.XmlNamespace#>");
<#+
}
}
else
{
#>
if (<#=variableName + ".IsSet" + operation.RequestPayloadMember.PropertyName#>())
{
<#+
if (this.Config.ServiceId != "S3")
{
#>
xmlWriter.WriteStartElement("<#=operation.RequestPayloadMember.LocationName != operation.RequestStructure.PayloadMemberName ? operation.RequestPayloadMember.LocationName : operation.RequestPayloadMember.Shape.MarshallName#>");
xmlWriter.WriteAttributeString("xmlns","<#=operation.XmlNamespacePrefix#>",null,"<#=operation.XmlNamespace#>");
<#+
}
else
{
#>
xmlWriter.WriteStartElement("<#=operation.RequestPayloadMember.LocationName#>");
xmlWriter.WriteAttributeString("xmlns","<#=operation.XmlNamespacePrefix#>",null,"<#=operation.XmlNamespace#>");
<#+
}
}
#>
<#+
Expand Down Expand Up @@ -282,6 +312,7 @@ WriteXmlAttributeString(level + 1, member, variableName, isPayload: true, operat
}
#>
}
PostMarshallCustomization(request, publicRequest);
try
{
string content = stringWriter.ToString();
Expand Down
25 changes: 24 additions & 1 deletion generator/ServiceClientGeneratorLib/ServiceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,30 @@ public List<Operation> S3AllowListOperations
new Operation(this, "PutObjectTagging", DocumentRoot[OperationsKey]["PutObjectTagging"]),
new Operation(this, "PutPublicAccessBlock", DocumentRoot[OperationsKey]["PutPublicAccessBlock"]),
//new Operation(this, "RestoreObject", DocumentRoot[OperationsKey]["RestoreObject"]),
//new Operation(this, "SelectObjectContent", DocumentRoot[OperationsKey]["SelectObjectContent"])
//new Operation(this, "SelectObjectContent", DocumentRoot[OperationsKey]["SelectObjectContent"]),

// PHASE 2
new Operation(this, "CreateBucket", DocumentRoot[OperationsKey]["CreateBucket"]),
//new Operation(this, "CreateBucketMetadataTableConfiguration", DocumentRoot[OperationsKey]["CreateBucketMetadataTableConfiguration"]),
//new Operation(this, "CreateMultipartUpload", DocumentRoot[OperationsKey]["CreateMultipartUpload"]),
//new Operation(this, "DeleteBucketCors", DocumentRoot[OperationsKey]["DeleteBucketCors"]),
//new Operation(this, "DeleteBucketLifecycle", DocumentRoot[OperationsKey]["DeleteBucketLifecycle"]),
//new Operation(this, "GetBucketAcl", DocumentRoot[OperationsKey]["GetBucketAcl"]),
//new Operation(this, "GetBucketCors", DocumentRoot[OperationsKey]["GetBucketCors"]),
//new Operation(this, "GetBucketLifecycle", DocumentRoot[OperationsKey]["GetBucketLifecycle"]),
//new Operation(this, "GetBucketLifecycleConfiguration", DocumentRoot[OperationsKey]["GetBucketLifecycleConfiguration"]),
//new Operation(this, "GetBucketNotificationConfiguration", DocumentRoot[OperationsKey]["GetBucketNotificationConfiguration"]),
//new Operation(this, "GetObjectAcl", DocumentRoot[OperationsKey]["GetObjectAcl"]),
//new Operation(this, "HeadObject", DocumentRoot[OperationsKey]["HeadObject"]),
//new Operation(this, "ListObjectVersions", DocumentRoot[OperationsKey]["ListObjectVersions"]),
//new Operation(this, "PutBucketAcl", DocumentRoot[OperationsKey]["PutBucketAcl"]),
//new Operation(this, "PutBucketCors", DocumentRoot[OperationsKey]["PutBucketCors"]),
//new Operation(this, "PutBucketLifecycle", DocumentRoot[OperationsKey]["PutBucketLifecycle"]),
//new Operation(this, "PutBucketLifecycleConfiguration", DocumentRoot[OperationsKey]["PutBucketLifecycleConfiguration"]),
//new Operation(this, "PutBucketNotificationConfiguration", DocumentRoot[OperationsKey]["PutBucketNotificationConfiguration"]),
//new Operation(this, "PutObjectAcl", DocumentRoot[OperationsKey]["PutObjectAcl"]),
//new Operation(this, "UploadPartCopy", DocumentRoot[OperationsKey]["UploadPartCopy"]),

};
}
return _s3AllowListOperations;
Expand Down
43 changes: 42 additions & 1 deletion generator/ServiceModels/s3/s3.customizations.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,30 @@
}
]
},
"CreateBucketRequest":{
"exclude":[
"GrantFullControl",
"GrantRead",
"GrantReadACP",
"GrantWrite",
"GrantWriteACP"
],
"modify":[
{
"ACL": {"emitPropertyName": "CannedACL"}
},
{
"CreateBucketConfiguration" : {"emitPropertyName" : "PutBucketConfiguration"}
}
]
},
"PutBucketConfiguration":{
"modify":[
{
"BucketName" : {"emitPropertyName" : "BucketInfo"}
}
]
},
"QueueConfigurationDeprecated": {
"modify": [
{
Expand Down Expand Up @@ -401,8 +425,13 @@
},
"Part":{
"renameShape": "PartDetail"
},
"CreateBucketConfiguration":{
"renameShape":"PutBucketConfiguration"
},
"BucketCannedACL":{
"renameShape":"S3CannedACL"
}

},
"overrideTreatEnumsAsString":{
"ObjectAttributesList": false
Expand All @@ -421,6 +450,13 @@
"Marshaller" : "StringUtils.FromString",
"Unmarshaller" : "StringUnmarshaller"
}
},
"PutBucketConfiguration":{
"LocationConstraint":{
"Type": "BucketLocationConstraint",
"Marshaller": "StringUtils.FromString",
"Unmarshaller": "StringUnmarshaller"
}
}
},
"excludeMembers":{
Expand All @@ -436,5 +472,10 @@
},
"unwrapXmlOutput":{
"GetBucketLocationOutput": true
},
"inheritAlternateBaseClass":{
"PutBucketRequest": {
"alternateBaseClass" : "PutWithACLRequest"
}
}
}
Loading