Skip to content

Commit 6ea1dfe

Browse files
authored
Generate PutBucket (#3928)
* Generate PutBucket * Other generated changes from moving PostMarshallCustomization * Add Devconfig * Remove CreateBucketConfiguration * Fix merge conflicts * update devconfig * Run custom tool for RestXmlRequestMarshaller
1 parent c8107bd commit 6ea1dfe

38 files changed

+1819
-1279
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"core": {
3+
"updateMinimum": true,
4+
"type": "patch",
5+
"changeLogMessages": [
6+
"Move PostMarshallCustomization for restXml services to right before setting request.Content"
7+
]
8+
},
9+
"services":[
10+
{
11+
"serviceName": "S3",
12+
"type": "patch",
13+
"changeLogMessages": [
14+
"Generate PutBucket operation."
15+
]
16+
}
17+
]
18+
}

generator/ServiceClientGeneratorLib/Customizations.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ public class CustomizationsModel
427427
public const string OverrideTreatEnumsAsStringKey = "overrideTreatEnumsAsString";
428428
public const string ExcludeMembersKey = "excludeMembers";
429429
public const string UnwrapXmlOutputKey = "unwrapXmlOutput";
430+
public const string InheritAlternateBaseClassKey = "inheritAlternateBaseClass";
430431

431432
JsonData _documentRoot;
432433

@@ -704,6 +705,27 @@ public HashSet<string> ResultGenerationSuppressions
704705
}
705706
}
706707

708+
/// <summary>
709+
/// Overrides the base class that structures inherit from.
710+
/// Here is an example of the usage
711+
/// "inheritAlternateBaseClass":{
712+
/// "CreateBucketRequest": {
713+
/// "alternateBaseClass" : "PutWithAclRequest"
714+
/// }
715+
/// }
716+
/// </summary>
717+
/// <param name="shapeName"></param>
718+
/// <returns></returns>
719+
public string InheritAlternateBaseClass(string shapeName)
720+
{
721+
var data = _documentRoot[InheritAlternateBaseClassKey];
722+
if (data == null || data[shapeName] == null) return null;
723+
724+
if (data[shapeName]["alternateBaseClass"] == null)
725+
throw new InvalidDataException("You must specify \"alternateBaseClass\" as the key for this customization");
726+
return data[shapeName]["alternateBaseClass"].ToString();
727+
}
728+
707729
public bool GenerateCustomUnmarshaller
708730
{
709731
get

generator/ServiceClientGeneratorLib/GeneratorDriver.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,11 @@ public void Execute()
286286
/// <param name="operation">The operation object which contains info about what the request needs to contain for the operation</param>
287287
void GenerateRequest(Operation operation)
288288
{
289+
var baseClassString = this.Configuration.ServiceModel.Customizations.InheritAlternateBaseClass(operation.Name + "Request");
289290
var requestGenerator = new StructureGenerator
290291
{
291292
ClassName = operation.Name + "Request",
292-
BaseClass = this.Configuration.ServiceId != "S3" ? string.Format("Amazon{0}Request", Configuration.ClassName) : "AmazonWebServiceRequest",
293+
BaseClass = baseClassString ?? (this.Configuration.ServiceId != "S3" ? string.Format("Amazon{0}Request", Configuration.ClassName) : "AmazonWebServiceRequest"),
293294
StructureType = StructureType.Request,
294295
Operation = operation
295296
};
@@ -459,10 +460,11 @@ var propertyModifier
459460
}
460461
else
461462
{
463+
var baseClassString = this.Configuration.ServiceModel.Customizations.InheritAlternateBaseClass(operation.Name + "Response");
462464
var resultGenerator = new StructureGenerator
463465
{
464466
ClassName = operation.Name + "Response",
465-
BaseClass = "AmazonWebServiceResponse",
467+
BaseClass = baseClassString ?? "AmazonWebServiceResponse",
466468
IsWrapped = operation.IsResponseWrapped,
467469
Operation = operation,
468470
StructureType = StructureType.Response

generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlRequestMarshaller.cs

Lines changed: 767 additions & 616 deletions
Large diffs are not rendered by default.

generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlRequestMarshaller.tt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,23 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
8989
// Process any members which are marshalled as part of the request body
9090
if(this.Operation.RequestHasBodyMembers || shouldMarshallPayload)
9191
{
92-
ProcessRequestBodyMembers("publicRequest", this.Operation);
92+
ProcessRequestBodyMembers("publicRequest", this.Operation);
9393
}
9494
else if(payload != null && !payload.Shape.IsStructure)
9595
{
9696
ProcessNonStructurePayload(payload, 3);
97+
#>
98+
PostMarshallCustomization(request, publicRequest);
99+
<#
97100
GenerateRequestChecksumHandling(this.Operation, "content");
98101
}
102+
else
103+
{
99104
#>
100105

106+
PostMarshallCustomization(request, publicRequest);
101107
<#
108+
}
102109
if (this.Operation.UnsignedPayload)
103110
{
104111
#>
@@ -118,7 +125,6 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
118125
ProcessEndpointHostPrefixMembers(3, "publicRequest", this.Operation);
119126
}
120127
#>
121-
PostMarshallCustomization(request, publicRequest);
122128
return request;
123129
}
124130
<#
@@ -181,17 +187,41 @@ WriteXmlAttributeString(level, member, variableName, isPayload: false);
181187
#>
182188
if (<#=variableName + ".IsSet" + operation.RequestPayloadMember.PropertyName#>())
183189
{
190+
<#+
191+
// 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
192+
if (this.Config.ServiceId != "S3")
193+
{
194+
#>
184195
xmlWriter.WriteStartElement("<#=operation.RequestPayloadMember.LocationName != operation.RequestStructure.PayloadMemberName ? operation.RequestPayloadMember.LocationName : operation.RequestPayloadMember.Shape.MarshallName#>", "<#=operation.XmlNamespace#>");
185196
<#+
197+
}
198+
else
199+
{
200+
#>
201+
xmlWriter.WriteStartElement("<#=operation.RequestPayloadMember.LocationName#>", "<#=operation.XmlNamespace#>");
202+
<#+
203+
}
186204
}
187205
else
188206
{
189207
#>
190208
if (<#=variableName + ".IsSet" + operation.RequestPayloadMember.PropertyName#>())
191209
{
210+
<#+
211+
if (this.Config.ServiceId != "S3")
212+
{
213+
#>
192214
xmlWriter.WriteStartElement("<#=operation.RequestPayloadMember.LocationName != operation.RequestStructure.PayloadMemberName ? operation.RequestPayloadMember.LocationName : operation.RequestPayloadMember.Shape.MarshallName#>");
193215
xmlWriter.WriteAttributeString("xmlns","<#=operation.XmlNamespacePrefix#>",null,"<#=operation.XmlNamespace#>");
194216
<#+
217+
}
218+
else
219+
{
220+
#>
221+
xmlWriter.WriteStartElement("<#=operation.RequestPayloadMember.LocationName#>");
222+
xmlWriter.WriteAttributeString("xmlns","<#=operation.XmlNamespacePrefix#>",null,"<#=operation.XmlNamespace#>");
223+
<#+
224+
}
195225
}
196226
#>
197227
<#+
@@ -282,6 +312,7 @@ WriteXmlAttributeString(level + 1, member, variableName, isPayload: true, operat
282312
}
283313
#>
284314
}
315+
PostMarshallCustomization(request, publicRequest);
285316
try
286317
{
287318
string content = stringWriter.ToString();

generator/ServiceClientGeneratorLib/ServiceModel.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,30 @@ public List<Operation> S3AllowListOperations
521521
new Operation(this, "PutObjectTagging", DocumentRoot[OperationsKey]["PutObjectTagging"]),
522522
new Operation(this, "PutPublicAccessBlock", DocumentRoot[OperationsKey]["PutPublicAccessBlock"]),
523523
//new Operation(this, "RestoreObject", DocumentRoot[OperationsKey]["RestoreObject"]),
524-
//new Operation(this, "SelectObjectContent", DocumentRoot[OperationsKey]["SelectObjectContent"])
524+
//new Operation(this, "SelectObjectContent", DocumentRoot[OperationsKey]["SelectObjectContent"]),
525+
526+
// PHASE 2
527+
new Operation(this, "CreateBucket", DocumentRoot[OperationsKey]["CreateBucket"]),
528+
//new Operation(this, "CreateBucketMetadataTableConfiguration", DocumentRoot[OperationsKey]["CreateBucketMetadataTableConfiguration"]),
529+
//new Operation(this, "CreateMultipartUpload", DocumentRoot[OperationsKey]["CreateMultipartUpload"]),
530+
//new Operation(this, "DeleteBucketCors", DocumentRoot[OperationsKey]["DeleteBucketCors"]),
531+
//new Operation(this, "DeleteBucketLifecycle", DocumentRoot[OperationsKey]["DeleteBucketLifecycle"]),
532+
//new Operation(this, "GetBucketAcl", DocumentRoot[OperationsKey]["GetBucketAcl"]),
533+
//new Operation(this, "GetBucketCors", DocumentRoot[OperationsKey]["GetBucketCors"]),
534+
//new Operation(this, "GetBucketLifecycle", DocumentRoot[OperationsKey]["GetBucketLifecycle"]),
535+
//new Operation(this, "GetBucketLifecycleConfiguration", DocumentRoot[OperationsKey]["GetBucketLifecycleConfiguration"]),
536+
//new Operation(this, "GetBucketNotificationConfiguration", DocumentRoot[OperationsKey]["GetBucketNotificationConfiguration"]),
537+
//new Operation(this, "GetObjectAcl", DocumentRoot[OperationsKey]["GetObjectAcl"]),
538+
//new Operation(this, "HeadObject", DocumentRoot[OperationsKey]["HeadObject"]),
539+
//new Operation(this, "ListObjectVersions", DocumentRoot[OperationsKey]["ListObjectVersions"]),
540+
//new Operation(this, "PutBucketAcl", DocumentRoot[OperationsKey]["PutBucketAcl"]),
541+
//new Operation(this, "PutBucketCors", DocumentRoot[OperationsKey]["PutBucketCors"]),
542+
//new Operation(this, "PutBucketLifecycle", DocumentRoot[OperationsKey]["PutBucketLifecycle"]),
543+
//new Operation(this, "PutBucketLifecycleConfiguration", DocumentRoot[OperationsKey]["PutBucketLifecycleConfiguration"]),
544+
//new Operation(this, "PutBucketNotificationConfiguration", DocumentRoot[OperationsKey]["PutBucketNotificationConfiguration"]),
545+
//new Operation(this, "PutObjectAcl", DocumentRoot[OperationsKey]["PutObjectAcl"]),
546+
//new Operation(this, "UploadPartCopy", DocumentRoot[OperationsKey]["UploadPartCopy"]),
547+
525548
};
526549
}
527550
return _s3AllowListOperations;

generator/ServiceModels/s3/s3.customizations.json

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,30 @@
210210
}
211211
]
212212
},
213+
"CreateBucketRequest":{
214+
"exclude":[
215+
"GrantFullControl",
216+
"GrantRead",
217+
"GrantReadACP",
218+
"GrantWrite",
219+
"GrantWriteACP"
220+
],
221+
"modify":[
222+
{
223+
"ACL": {"emitPropertyName": "CannedACL"}
224+
},
225+
{
226+
"CreateBucketConfiguration" : {"emitPropertyName" : "PutBucketConfiguration"}
227+
}
228+
]
229+
},
230+
"PutBucketConfiguration":{
231+
"modify":[
232+
{
233+
"BucketName" : {"emitPropertyName" : "BucketInfo"}
234+
}
235+
]
236+
},
213237
"QueueConfigurationDeprecated": {
214238
"modify": [
215239
{
@@ -401,8 +425,13 @@
401425
},
402426
"Part":{
403427
"renameShape": "PartDetail"
428+
},
429+
"CreateBucketConfiguration":{
430+
"renameShape":"PutBucketConfiguration"
431+
},
432+
"BucketCannedACL":{
433+
"renameShape":"S3CannedACL"
404434
}
405-
406435
},
407436
"overrideTreatEnumsAsString":{
408437
"ObjectAttributesList": false
@@ -421,6 +450,13 @@
421450
"Marshaller" : "StringUtils.FromString",
422451
"Unmarshaller" : "StringUnmarshaller"
423452
}
453+
},
454+
"PutBucketConfiguration":{
455+
"LocationConstraint":{
456+
"Type": "BucketLocationConstraint",
457+
"Marshaller": "StringUtils.FromString",
458+
"Unmarshaller": "StringUnmarshaller"
459+
}
424460
}
425461
},
426462
"excludeMembers":{
@@ -436,5 +472,10 @@
436472
},
437473
"unwrapXmlOutput":{
438474
"GetBucketLocationOutput": true
475+
},
476+
"inheritAlternateBaseClass":{
477+
"PutBucketRequest": {
478+
"alternateBaseClass" : "PutWithACLRequest"
479+
}
439480
}
440481
}

0 commit comments

Comments
 (0)