Skip to content
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
2 changes: 1 addition & 1 deletion generator/ServiceClientGeneratorLib/ServiceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public List<Operation> S3AllowListOperations
//new Operation(this, "SelectObjectContent", DocumentRoot[OperationsKey]["SelectObjectContent"]),
new Operation(this, "PutBucketAnalyticsConfiguration" , DocumentRoot[OperationsKey]["PutBucketAnalyticsConfiguration"]),
new Operation(this, "PutBucketIntelligentTieringConfiguration", DocumentRoot[OperationsKey]["PutBucketIntelligentTieringConfiguration"]),
//new Operation(this, "PutBucketInventoryConfiguration", DocumentRoot[OperationsKey]["PutBucketInventoryConfiguration"]),
new Operation(this, "PutBucketInventoryConfiguration", DocumentRoot[OperationsKey]["PutBucketInventoryConfiguration"]),
new Operation(this, "PutBucketMetricsConfiguration", DocumentRoot[OperationsKey]["PutBucketMetricsConfiguration"]),
new Operation(this, "DeleteBucketMetricsConfiguration", DocumentRoot[OperationsKey]["DeleteBucketMetricsConfiguration"]),
new Operation(this, "DeleteBucketAnalyticsConfiguration", DocumentRoot[OperationsKey]["DeleteBucketAnalyticsConfiguration"]),
Expand Down
58 changes: 56 additions & 2 deletions generator/ServiceModels/s3/s3.customizations.json
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,59 @@
"Id":{"emitPropertyName": "IntelligentTieringId"}
}
]
},
"PutBucketInventoryConfigurationRequest":{
"modify":[
{
"Id" :{"emitPropertyName":"InventoryId"}
},
{
"ExpectedBucketOwner":{"injectXmlIsSet":["return !String.IsNullOrEmpty(this._expectedBucketOwner);"]}
}
]
},
"InventoryConfiguration":{
"modify":[
{
"Filter":{"emitPropertyName":"InventoryFilter"}
},
{
"Id":{"emitPropertyName":"InventoryId"}
},
{
"InventoryId":{"injectXmlIsSet":["return !String.IsNullOrEmpty(this._inventoryId);"]}
},
{
"OptionalFields":{"emitPropertyName": "InventoryOptionalFields"}
},
{
"InventoryFilter":{"injectXmlMarshallCode":["InventoryFilterCustomMarshall(publicRequest, xmlWriter);"]}
},
{
"IsEnabled":{"injectXmlMarshallCode":["CustomIsEnabledMarshall(publicRequest, xmlWriter);"]}
}
]
},
"InventoryS3BucketDestination":{
"modify":[
{
"AccountId":{"injectXmlIsSet":["return !String.IsNullOrEmpty(this._accountId);"]}
},
{
"BucketName":{"injectXmlIsSet":["return !String.IsNullOrEmpty(this._bucketName);"]}
},
{
"Encryption":{"emitPropertyName": "InventoryEncryption"}
},
{
"Prefix":{"injectXmlIsSet":["return !String.IsNullOrEmpty(this._prefix);"]}
},
{
"Format":{"emitPropertyName":"InventoryFormat"}
}
]
}

},
"operationModifiers": {
"CreateBucket": {
Expand Down Expand Up @@ -1221,7 +1273,8 @@
}
},
"overrideTreatEnumsAsString":{
"ObjectAttributesList": false
"ObjectAttributesList": false,
"InventoryOptionalFields": false
},
"dataTypeSwap":{
"ListPartsRequest":{
Expand Down Expand Up @@ -1452,6 +1505,7 @@
"AnalyticsFilter",
"AnalyticsAndOperator",
"IntelligentTieringFilter",
"IntelligentTieringAndOperator"
"IntelligentTieringAndOperator",
"InventoryFilter"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,167 +32,27 @@ namespace Amazon.S3.Model.Internal.MarshallTransformations
/// <summary>
/// Request Marshaller for PutInventoryConfiguration operation
/// </summary>
public class PutBucketInventoryConfigurationRequestMarshaller : IMarshaller<IRequest, PutBucketInventoryConfigurationRequest>, IMarshaller<IRequest, Amazon.Runtime.AmazonWebServiceRequest>
public partial class PutBucketInventoryConfigurationRequestMarshaller : IMarshaller<IRequest, PutBucketInventoryConfigurationRequest>, IMarshaller<IRequest, Amazon.Runtime.AmazonWebServiceRequest>
{
public IRequest Marshall(Amazon.Runtime.AmazonWebServiceRequest input)
partial void PostMarshallCustomization(DefaultRequest defaultRequest, PutBucketInventoryConfigurationRequest publicRequest)
{
return this.Marshall((PutBucketInventoryConfigurationRequest)input);
ChecksumUtils.SetChecksumData(defaultRequest);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noticed this after looking at the other PRs, but why did the checksum call ended up here for this operation but in the generated file in https://github.com/aws/aws-sdk-net/pull/4160/files#diff-823c389908e565fb1a97dda8255656e5f47bb05e34f44bdcbf5a8d31b9b4886dR135?

Copy link
Contributor

Choose a reason for hiding this comment

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

The link didn't work as I wanted, but here's the direct file:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is because PutBucketInventoryRequest doesn't have the httpChecksum modeled but the custom code was still doing checksum validation for some reason so I had to preserve that behavior and put it in the custom partial.

Whereas CreateBucketMetadataConfiguration does model httpChecksum so it is just generated as-is and no custom partial is needed

}
public IRequest Marshall(PutBucketInventoryConfigurationRequest putBucketInventoryConfigurationRequest)
{
IRequest request = new DefaultRequest(putBucketInventoryConfigurationRequest, "Amazon.S3");

request.HttpMethod = "PUT";

if (putBucketInventoryConfigurationRequest.IsSetExpectedBucketOwner())
request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putBucketInventoryConfigurationRequest.ExpectedBucketOwner));

if (string.IsNullOrEmpty(putBucketInventoryConfigurationRequest.BucketName))
throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketInventoryConfigurationRequest.BucketName");

request.ResourcePath = "/";

request.AddSubResource("inventory");

if (putBucketInventoryConfigurationRequest.IsSetInventoryId())
{
request.AddSubResource("id", S3Transforms.ToStringValue(putBucketInventoryConfigurationRequest.InventoryId));
}

var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture);
using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize }))
{
if (putBucketInventoryConfigurationRequest.IsSetInventoryConfiguration())
{
var inventoryConfiguration = putBucketInventoryConfigurationRequest.InventoryConfiguration;
xmlWriter.WriteStartElement("InventoryConfiguration", S3Constants.S3RequestXmlNamespace);
if (inventoryConfiguration != null)
{
if (inventoryConfiguration.IsSetDestination())
{
InventoryDestination inventoryDestination = inventoryConfiguration.Destination;
xmlWriter.WriteStartElement("Destination");
if (inventoryDestination.isSetS3BucketDestination())
{
InventoryS3BucketDestination inventoryS3BucketDestination = inventoryDestination.S3BucketDestination;
xmlWriter.WriteStartElement("S3BucketDestination");
if (inventoryS3BucketDestination.IsSetAccountId())
{
xmlWriter.WriteElementString("AccountId", S3Transforms.ToXmlStringValue(inventoryS3BucketDestination.AccountId));
}
if (inventoryS3BucketDestination.IsSetBucketName())
{
xmlWriter.WriteElementString("Bucket", S3Transforms.ToXmlStringValue(inventoryS3BucketDestination.BucketName));
}
if (inventoryS3BucketDestination.IsSetInventoryFormat())
{
xmlWriter.WriteElementString("Format", S3Transforms.ToXmlStringValue(inventoryS3BucketDestination.InventoryFormat));
}
if (inventoryS3BucketDestination.IsSetPrefix())
{
xmlWriter.WriteElementString("Prefix", S3Transforms.ToXmlStringValue(inventoryS3BucketDestination.Prefix));
}
if (inventoryS3BucketDestination.IsSetInventoryEncryption())
{
xmlWriter.WriteStartElement("Encryption");
var inventoryEncryption = inventoryS3BucketDestination.InventoryEncryption;
if (inventoryEncryption.IsSetSSEKMS())
{
xmlWriter.WriteStartElement("SSE-KMS");
if (inventoryEncryption.SSEKMS.IsSetKeyId())
{
xmlWriter.WriteElementString("KeyId", S3Transforms.ToXmlStringValue(inventoryEncryption.SSEKMS.KeyId));
}
xmlWriter.WriteEndElement();
}
if (inventoryEncryption.IsSetSSES3())
{
xmlWriter.WriteStartElement("SSE-S3");
xmlWriter.WriteEndElement();
}
xmlWriter.WriteEndElement();
}
xmlWriter.WriteEndElement();
}
xmlWriter.WriteEndElement();
}

xmlWriter.WriteElementString("IsEnabled", S3Transforms.ToXmlStringValue(inventoryConfiguration.IsEnabled.GetValueOrDefault()));

if (inventoryConfiguration.IsSetInventoryFilter())
{
xmlWriter.WriteStartElement("Filter");
var predicate = inventoryConfiguration.InventoryFilter.InventoryFilterPredicate;
predicate.Accept(new InventoryPredicateVisitor(xmlWriter));
xmlWriter.WriteEndElement();
}

if(inventoryConfiguration.IsSetInventoryId())
{
xmlWriter.WriteElementString("Id", S3Transforms.ToXmlStringValue(inventoryConfiguration.InventoryId));
}

if(inventoryConfiguration.IsSetIncludedObjectVersions())
{
xmlWriter.WriteElementString("IncludedObjectVersions", S3Transforms.ToXmlStringValue(inventoryConfiguration.IncludedObjectVersions));
}

if (inventoryConfiguration.IsSetInventoryOptionalFields())
{
xmlWriter.WriteStartElement("OptionalFields");
foreach (var inventoryOptionalField in inventoryConfiguration.InventoryOptionalFields)
{
xmlWriter.WriteElementString("Field", S3Transforms.ToXmlStringValue(inventoryOptionalField));
}
xmlWriter.WriteEndElement();
}

if(inventoryConfiguration.IsSetSchedule())
{
xmlWriter.WriteStartElement("Schedule");
var inventorySchedule = inventoryConfiguration.Schedule;
if (inventorySchedule.IsFrequency())
{
xmlWriter.WriteElementString("Frequency", S3Transforms.ToXmlStringValue(inventorySchedule.Frequency));
}
xmlWriter.WriteEndElement();
}
}
xmlWriter.WriteEndElement();
}
}

try
{
var content = stringWriter.ToString();
request.Content = Encoding.UTF8.GetBytes(content);
request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml";

ChecksumUtils.SetChecksumData(request);
}
catch (EncoderFallbackException e)
void InventoryFilterCustomMarshall(PutBucketInventoryConfigurationRequest publicRequest, XmlWriter xmlWriter)
{
var inventoryConfiguration = publicRequest.InventoryConfiguration;
if (inventoryConfiguration.IsSetInventoryFilter())
{
throw new AmazonServiceException("Unable to marshall request to XML", e);
xmlWriter.WriteStartElement("Filter");
var predicate = inventoryConfiguration.InventoryFilter.InventoryFilterPredicate;
predicate.Accept(new InventoryPredicateVisitor(xmlWriter));
xmlWriter.WriteEndElement();
}

return request;
}

private static PutBucketInventoryConfigurationRequestMarshaller _instance;

/// <summary>
/// Singleton for marshaller
/// </summary>
public static PutBucketInventoryConfigurationRequestMarshaller Instance
void CustomIsEnabledMarshall(PutBucketInventoryConfigurationRequest publicRequest, XmlWriter xmlWriter)
{
get
{
if (_instance == null)
{
_instance = new PutBucketInventoryConfigurationRequestMarshaller();
}
return _instance;
}
xmlWriter.WriteElementString("IsEnabled", StringUtils.FromBool(publicRequest.InventoryConfiguration.IsEnabled.GetValueOrDefault()));
}
}
}

This file was deleted.

Loading