Skip to content

Generate 8 more S3 Operations #3895

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

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions generator/.DevConfigs/c881e931-b1ff-45ff-9521-9653e179466e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"services": [
{
"serviceName": "S3",
"type": "patch",
"changeLogMessages": [
"Update ExceptionUnmarshallers and add S3 Exception t4 file. Generate PutBucketPolicy, PutObjectLegalHold, PutObjectLockConfiguration, PutObjectRetention, PutPublicAccessBlock, HeadBucket, ListParts, PutObjectTagging",
"[Breaking Change] `LastModified` in `Amazon.S3.Model.PartDetail` is `DateTime?` instead of `DateTime` to follow v4 pattern of nullable types",
"[Breaking Change] `Tagging` in `PutBucketPolicyRequest` is no longer automatically initialized if null. You must initialize the object."
]
}
]
}
36 changes: 36 additions & 0 deletions generator/ServiceClientGeneratorLib/Customizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ public class CustomizationsModel
public const string StopPaginationOnSameTokenKey = "stopPaginationOnSameToken";
public const string OriginalMemberKey = "originalMember";
public const string OverrideTreatEnumsAsStringKey = "overrideTreatEnumsAsString";
public const string ExcludeMembersKey = "excludeMembers";

JsonData _documentRoot;

SimpleMethodFormsModel _simpleMethodsModel;
Expand Down Expand Up @@ -560,6 +562,40 @@ public bool RetainOriginalMemberOrdering
}
}

/// <summary>
/// Used to exclude property generation, but not at the marshaller level and only at the shape level.
/// To use this customization add an entry like below, where the top-level key is the name of the shape and
/// the array is filled with members to exclude. To exclude members from marshalling, use ShapeModifiers.Exclude key.
/// "excludeMembers":{
/// "PartDetail":[
/// "ChecksumCRC32",
/// "ChecksumCRC32C",
/// "ChecksumCRC64NVME",
/// "ChecksumSHA1",
/// "ChecksumSHA256",
/// "ETag",
/// "LastModified",
/// "PartNumber"
/// ]
/// }
/// </summary>
public List<string> ExcludeMembers(string shapeName)
{
var data = _documentRoot[ExcludeMembersKey];
if (data == null || data[shapeName] == null) return null;
if (!data[shapeName].IsArray)
throw new InvalidDataException("The members to exclude must be within an array.");


var excludedMembers = new List<string>();
foreach (var member in data[shapeName])
{
excludedMembers.Add(member.ToString());
}
return excludedMembers;

}

/// <summary>
/// A list of uri properties for the service where we should not do validation for presence.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,79 @@ public override string TransformText()
#line default
#line hidden
this.Write(" Unmarshall(XmlUnmarshallerContext context, Amazon.Runtime.Internal.ErrorResponse" +
" errorResponse)\r\n {\r\n ");
" errorResponse)\r\n {\r\n");

#line 38 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"

if (this.Config.ServiceId == "S3")
{


#line default
#line hidden
this.Write(@" string id2 = null, amzCfId = null;
var s3ErrorResponse = errorResponse as S3ErrorResponse;
if (s3ErrorResponse != null)
{
id2 = s3ErrorResponse.Id2;
amzCfId = s3ErrorResponse.AmzCfId;
}
");

#line 49 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(" response = new ");

#line 38 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 49 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(@"(errorResponse.Message, errorResponse.InnerException,
errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode);
this.Write("(errorResponse.Message, errorResponse.InnerException,\r\n errorRespo" +
"nse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode," +
" id2, amzCfId);\r\n\r\n");

#line 52 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"

while (context.Read())
{
if (context.IsStartElement || context.IsAttribute)
{
");
}
else
{


#line default
#line hidden
this.Write(" ");

#line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(" response = new ");

#line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write("(errorResponse.Message, errorResponse.InnerException, \r\n errorResp" +
"onse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode" +
");\r\n");

#line 59 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"

}


#line default
#line hidden
this.Write("\r\n while (context.Read())\r\n {\r\n if (context." +
"IsStartElement || context.IsAttribute)\r\n {\r\n");

#line 45 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 67 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"

foreach (var member in this.Structure.Members)
{
Expand All @@ -132,56 +181,56 @@ public override string TransformText()
#line hidden
this.Write(" if (context.TestExpression(\"");

#line 52 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 74 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));

#line default
#line hidden
this.Write("/");

#line 52 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 74 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(listMarshallName));

#line default
#line hidden
this.Write("\"))\r\n {\r\n var unmarshaller = ");

#line 54 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 76 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));

#line default
#line hidden
this.Write(";\r\n if (response.");

#line 55 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 77 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));

#line default
#line hidden
this.Write(" == null)\r\n {\r\n response.");

#line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 79 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));

#line default
#line hidden
this.Write(" = new ");

#line 57 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 79 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineType()));

#line default
#line hidden
this.Write("();\r\n }\r\n response.");

#line 59 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 81 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));

#line default
#line hidden
this.Write(".Add(unmarshaller.Unmarshall(context));\r\n }\r\n");

#line 61 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 83 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"

}
else
Expand All @@ -192,28 +241,28 @@ public override string TransformText()
#line hidden
this.Write(" if (context.TestExpression(\"");

#line 66 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 88 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));

#line default
#line hidden
this.Write("\"))\r\n {\r\n var unmarshaller = ");

#line 68 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 90 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));

#line default
#line hidden
this.Write(";\r\n response.");

#line 69 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 91 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));

#line default
#line hidden
this.Write(" = unmarshaller.Unmarshall(context);\r\n }\r\n");

#line 71 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 93 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"

}
}
Expand All @@ -223,7 +272,7 @@ public override string TransformText()
#line hidden
this.Write(" }\r\n }\r\n return response;\r\n }\r\n\r\n");

#line 80 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"
#line 102 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlExceptionUnmarshaller.tt"

this.AddStructureSingletonMethod();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,30 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
/// <returns></returns>
public <#=this.UnmarshallerBaseName #> Unmarshall(XmlUnmarshallerContext context, Amazon.Runtime.Internal.ErrorResponse errorResponse)
{
<#
if (this.Config.ServiceId == "S3")
{
#>
string id2 = null, amzCfId = null;
var s3ErrorResponse = errorResponse as S3ErrorResponse;
if (s3ErrorResponse != null)
{
id2 = s3ErrorResponse.Id2;
amzCfId = s3ErrorResponse.AmzCfId;
}
<#=this.UnmarshallerBaseName #> response = new <#=this.UnmarshallerBaseName #>(errorResponse.Message, errorResponse.InnerException,
errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode, id2, amzCfId);

<#
}
else
{
#>
<#=this.UnmarshallerBaseName #> response = new <#=this.UnmarshallerBaseName #>(errorResponse.Message, errorResponse.InnerException,
errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode);
<#
}
#>

while (context.Read())
{
Expand Down
Loading