Skip to content

Commit 4cfb75b

Browse files
committed
Generate AbortMultipartUpload and CreateBucketMetadataTableConfiguration. Generate DeleteBucket and DeleteBucket related operations. Remove custom files.
1 parent 82909d5 commit 4cfb75b

File tree

79 files changed

+4225
-2937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+4225
-2937
lines changed

generator/.DevConfigs/7064092c-4180-4624-a402-c6d354a1dfeb.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"serviceName": "S3",
55
"type": "patch",
66
"changeLogMessages": [
7-
"Generate ListBuckets and ListDirectoryBuckets. Delete custom files."
7+
"Generate DeleteBucket, DeleteBucketEncryption and related DeleteBucket operations. Delete relevant custom files."
88
]
99
}
1010
]

generator/ServiceClientGeneratorLib/Customizations.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ public OperationModifiers GetOperationModifiers(string operationName)
12201220
var data = _documentRoot[OperationModifiers.OperationModifiersKey];
12211221
if (data == null)
12221222
return null;
1223-
1223+
12241224
var operation = data[operationName] as JsonData;
12251225
if (operation == null)
12261226
return null;
@@ -1248,7 +1248,8 @@ public OperationModifiers GetOperationModifiers(string operationName)
12481248
modifiers.DeprecatedMessage = (string)operation[OperationModifiers.DeprecatedMessageKey];
12491249
if (operation[OperationModifiers.StopPaginationOnSameTokenKey] != null && operation[OperationModifiers.StopPaginationOnSameTokenKey].IsBoolean)
12501250
modifiers.StopPaginationOnSameToken = (bool)operation[OperationModifiers.StopPaginationOnSameTokenKey];
1251-
1251+
if (operation[OperationModifiers.CustomizeMarshallerKey] != null && operation[OperationModifiers.CustomizeMarshallerKey].IsBoolean)
1252+
modifiers.CustomizeMarshaller = (bool)operation[OperationModifiers.CustomizeMarshallerKey];
12521253
if (operation[OperationModifiers.MarshallNameOverrides] != null &&
12531254
operation[OperationModifiers.MarshallNameOverrides].IsArray)
12541255
{
@@ -1315,13 +1316,30 @@ public class OperationModifiers
13151316
public const string DeprecatedMessageKey = "deprecatedMessage";
13161317
public const string DocumentationKey = "documentation";
13171318
public const string StopPaginationOnSameTokenKey = "stopPaginationOnSameToken";
1319+
public const string CustomizeMarshallerKey = "customizeMarshaller";
13181320

13191321
// within a marshal override for a shape; one or both may be present
13201322
public const string MarshallLocationName = "marshallLocationName";
13211323
public const string MarshallName = "marshallName";
13221324

13231325
private Dictionary<string, JsonData> _marshallNameOverrides = null;
13241326

1327+
/// <summary>
1328+
/// Indicates if the operation's marshaller should be customized.
1329+
/// If set to true, the operation's marshaller will call CustomizeMarshaller();
1330+
/// which will be custom code for that specific marshaller.
1331+
///usage:
1332+
/// customizeMarshaller
1333+
/// "DeleteBucket":{
1334+
/// "customizeMarshaller": true
1335+
/// },
1336+
/// </summary>
1337+
public bool CustomizeMarshaller
1338+
{
1339+
get;
1340+
set;
1341+
}
1342+
13251343
/// <summary>
13261344
/// The name of the operation modified
13271345
/// </summary>

generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlRequestMarshaller.cs

Lines changed: 670 additions & 624 deletions
Large diffs are not rendered by default.

generator/ServiceClientGeneratorLib/Generators/Marshallers/RestXmlRequestMarshaller.tt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
AddCommonUsingStatements();
1111
#>
1212
using System.Xml;
13+
<#
14+
var operationModifiers = this.Config.ServiceModel.Customizations.GetOperationModifiers(this.Operation.Name);
15+
if(this.Config.ServiceId == "S3" && operationModifiers != null && operationModifiers.CustomizeMarshaller)
16+
{
17+
#>
18+
using Amazon.S3.Internal;
19+
<#
20+
}
21+
#>
1322

1423
#pragma warning disable CS0612,CS0618
1524
namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
@@ -38,6 +47,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
3847
{
3948
var request = new DefaultRequest(publicRequest, "<#=this.Config.Namespace#>");
4049
<#
50+
4151
if ((this.Config.ServiceModel.H2Support == H2SupportDegree.Optional && this.Operation.IsEventStreamBidi) || (this.Config.ServiceModel.H2Support == H2SupportDegree.EventStream && this.Operation.IsEventStreamOutput) || this.Config.ServiceModel.H2Support == H2SupportDegree.Required)
4252
{
4353
#>
@@ -116,7 +126,14 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
116126
ProcessEndpointHostPrefixMembers(3, "publicRequest", this.Operation);
117127
}
118128
#>
119-
129+
<#
130+
if (operationModifiers != null && operationModifiers.CustomizeMarshaller)
131+
{
132+
#>
133+
request = CustomMarshallTransformations.Customize<#=this.Operation.Name#>Marshaller(request, publicRequest);
134+
<#
135+
}
136+
#>
120137
return request;
121138
}
122139
<#

generator/ServiceClientGeneratorLib/ServiceModel.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -469,17 +469,17 @@ public List<Operation> S3AllowListOperations
469469
{
470470
_s3AllowListOperations = new List<Operation>()
471471
{
472-
//new Operation(this,"AbortMultipartUpload", DocumentRoot[OperationsKey]["AbortMultipartUpload"]),
473-
//new Operation(this,"CreateBucketMetadataTableConfiguration", DocumentRoot[OperationsKey]["CreateBucketMetadataTableConfiguration"]),
472+
new Operation(this,"AbortMultipartUpload", DocumentRoot[OperationsKey]["AbortMultipartUpload"]),
473+
new Operation(this,"CreateBucketMetadataTableConfiguration", DocumentRoot[OperationsKey]["CreateBucketMetadataTableConfiguration"]),
474474
//new Operation(this, "CreateSession", DocumentRoot[OperationsKey]["CreateSession"]),
475-
//new Operation(this, "DeleteBucket", DocumentRoot[OperationsKey]["DeleteBucket"]),
476-
//new Operation(this, "DeleteBucketEncryption", DocumentRoot[OperationsKey]["DeleteBucketEncryption"]),
477-
//new Operation(this, "DeleteBucketMetadataTableConfiguration", DocumentRoot[OperationsKey]["DeleteBucketMetadataTableConfiguration"]),
478-
//new Operation(this, "DeleteBucketOwnershipControls", DocumentRoot[OperationsKey]["DeleteBucketOwnershipControls"]),
479-
//new Operation(this, "DeleteBucketPolicy", DocumentRoot[OperationsKey]["DeleteBucketPolicy"]),
480-
//new Operation(this, "DeleteBucketReplication", DocumentRoot[OperationsKey]["DeleteBucketReplication"]),
481-
//new Operation(this, "DeleteBucketTagging", DocumentRoot[OperationsKey]["DeleteBucketTagging"]),
482-
//new Operation(this, "DeletePublicAccessBlock", DocumentRoot[OperationsKey]["DeletePublicAccessBlock"]),
475+
new Operation(this, "DeleteBucket", DocumentRoot[OperationsKey]["DeleteBucket"]),
476+
new Operation(this, "DeleteBucketEncryption", DocumentRoot[OperationsKey]["DeleteBucketEncryption"]),
477+
new Operation(this, "DeleteBucketMetadataTableConfiguration", DocumentRoot[OperationsKey]["DeleteBucketMetadataTableConfiguration"]),
478+
new Operation(this, "DeleteBucketOwnershipControls", DocumentRoot[OperationsKey]["DeleteBucketOwnershipControls"]),
479+
new Operation(this, "DeleteBucketPolicy", DocumentRoot[OperationsKey]["DeleteBucketPolicy"]),
480+
new Operation(this, "DeleteBucketReplication", DocumentRoot[OperationsKey]["DeleteBucketReplication"]),
481+
new Operation(this, "DeleteBucketTagging", DocumentRoot[OperationsKey]["DeleteBucketTagging"]),
482+
new Operation(this, "DeletePublicAccessBlock", DocumentRoot[OperationsKey]["DeletePublicAccessBlock"]),
483483
//new Operation(this, "GetBucketAccelerateConfiguration", DocumentRoot[OperationsKey]["GetBucketAccelerateConfiguration"]),
484484
//new Operation(this, "GetBucketAnalyticsConfiguration", DocumentRoot[OperationsKey]["GetBucketAnalyticsConfiguration"]),
485485
//new Operation(this, "GetBucketEncryption", DocumentRoot[OperationsKey]["GetBucketEncryption"]),

generator/ServiceModels/s3/s3.customizations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@
245245
"CreateMultipartUpload": {
246246
"name": "InitiateMultipartUpload"
247247
},
248+
"DeleteBucket":{
249+
"customizeMarshaller": true
250+
},
248251
"DeleteBucketCors": {
249252
"name": "DeleteCORSConfiguration"
250253
},
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Amazon.Runtime.Internal;
2+
using Amazon.S3.Model;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace Amazon.S3.Internal
10+
{
11+
/// <summary>
12+
/// Class containing custom marshall transformations for S3.
13+
/// Only meant for internal use.
14+
/// </summary>
15+
public static class CustomMarshallTransformations
16+
{
17+
/// <summary>
18+
/// Custom Marshall transformation for default bucket request. Meant for internal usage only.
19+
/// </summary>
20+
/// <param name="defaultRequest"></param>
21+
/// <param name="request"></param>
22+
/// <returns></returns>
23+
public static DefaultRequest CustomizeDeleteBucketMarshaller(DefaultRequest defaultRequest, DeleteBucketRequest request)
24+
{
25+
if (request.BucketRegion != null)
26+
{
27+
RegionEndpoint regionEndpoint;
28+
#pragma warning disable CR1004
29+
if (request.BucketRegion == S3Region.USEast1)
30+
{
31+
regionEndpoint = RegionEndpoint.USEast1;
32+
}
33+
else if (request.BucketRegion == S3Region.EUWest1)
34+
{
35+
regionEndpoint = RegionEndpoint.EUWest1;
36+
}
37+
else
38+
{
39+
regionEndpoint = RegionEndpoint.GetBySystemName(request.BucketRegion.Value);
40+
}
41+
#pragma warning restore CR1004
42+
defaultRequest.AlternateEndpoint = regionEndpoint;
43+
}
44+
return defaultRequest;
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)