Skip to content
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
1 change: 1 addition & 0 deletions generator/ServiceClientGeneratorLib/ServiceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ public List<Operation> S3AllowListOperations
new Operation(this, "GetBucketMetadataConfiguration", DocumentRoot[OperationsKey]["GetBucketMetadataConfiguration"]),
new Operation(this, "RenameObject", DocumentRoot[OperationsKey]["RenameObject"]),
new Operation(this, "PutBucketOwnershipControls", DocumentRoot[OperationsKey]["PutBucketOwnershipControls"]),
new Operation(this, "PutBucketTagging", DocumentRoot[OperationsKey]["PutBucketTagging"]),
};
}
return _s3AllowListOperations.Where(operation => operation.data != null).ToList();
Expand Down
12 changes: 5 additions & 7 deletions generator/ServiceModels/s3/s3.customizations.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,9 @@
]
},
"PutBucketTaggingRequest": {
"exclude": [ "Tagging" ],
"inject": [
"modify":[
{
"TagSet": {
"shape": "TagSet",
"originalMember": "Tagging"
}
"ExpectedBucketOwner" :{"injectXmlIsSet":["return !string.IsNullOrEmpty(this._expectedBucketOwner);"]}
}
]
},
Expand Down Expand Up @@ -1253,7 +1249,6 @@
}
]
}

},
"operationModifiers": {
"CreateBucket": {
Expand Down Expand Up @@ -1620,6 +1615,9 @@
],
"UploadPartCopyOutput" : [
"CopyPartResult"
],
"PutBucketTaggingRequest":[
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't realize this was in flattenShapes (the diff makes it seem like it's under operationModifiers...), is that why the entry in shapeModifiers was changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, because we don't need to modify it anymore, flatten it is better to reach the same behavior that existed in the custom code.

"Tagging"
]
},
"excludeShapes":[
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

/*
* Do not modify this file. This file is generated from the s3-2006-03-01.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml.Serialization;

using Amazon.S3.Model;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Transform;
using Amazon.Runtime.Internal.Util;
using System.Xml;

#pragma warning disable CS0612,CS0618
namespace Amazon.S3.Model.Internal.MarshallTransformations
{
/// <summary>
/// PutBucketTagging Request Marshaller
/// </summary>
public partial class PutBucketTaggingRequestMarshaller : IMarshaller<IRequest, PutBucketTaggingRequest> , IMarshaller<IRequest,AmazonWebServiceRequest>
{
/// <summary>
/// Marshaller the request object to the HTTP request.
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public IRequest Marshall(AmazonWebServiceRequest input)
{
return this.Marshall((PutBucketTaggingRequest)input);
}

/// <summary>
/// Marshaller the request object to the HTTP request.
/// </summary>
/// <param name="publicRequest"></param>
/// <returns></returns>
public IRequest Marshall(PutBucketTaggingRequest publicRequest)
{
var request = new DefaultRequest(publicRequest, "Amazon.S3");
PreMarshallCustomization(request, publicRequest);
request.HttpMethod = "PUT";
request.AddSubResource("tagging");

if (publicRequest.IsSetChecksumAlgorithm())
{
request.Headers["x-amz-sdk-checksum-algorithm"] = publicRequest.ChecksumAlgorithm;
}

if (publicRequest.IsSetContentMD5())
{
request.Headers["Content-MD5"] = publicRequest.ContentMD5;
}

if (publicRequest.IsSetExpectedBucketOwner())
{
request.Headers["x-amz-expected-bucket-owner"] = publicRequest.ExpectedBucketOwner;
}
if (string.IsNullOrEmpty(publicRequest.BucketName))
throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketTaggingRequest.BucketName");
request.ResourcePath = "/";
var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture);
using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize }))
{
xmlWriter.WriteStartElement("Tagging", "http://s3.amazonaws.com/doc/2006-03-01/");
var publicRequestTagSet = publicRequest.TagSet;
if (publicRequestTagSet != null && (publicRequestTagSet.Count > 0 || !AWSConfigs.InitializeCollections))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is not using IsSetTagSet here intentional? The generated file has the same this._tagSet != null && (this._tagSet.Count > 0 || !AWSConfigs.InitializeCollections) logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really intentional since it is doing the same thing and I wouldn't prefer to duplicate it, probably a side effect of adding it to flattenShapes, I didn't want to add any extra customizations as long as the generated code behaves similar to the custom code that we removed.

{
xmlWriter.WriteStartElement("TagSet");
foreach (var publicRequestTagSetValue in publicRequestTagSet)
{
if (publicRequestTagSetValue != null)
{
xmlWriter.WriteStartElement("Tag");
if(publicRequestTagSetValue.IsSetKey())
xmlWriter.WriteElementString("Key", StringUtils.FromString(publicRequestTagSetValue.Key));
if(publicRequestTagSetValue.IsSetValue())
xmlWriter.WriteElementString("Value", StringUtils.FromString(publicRequestTagSetValue.Value));
xmlWriter.WriteEndElement();
}
}
xmlWriter.WriteEndElement();
}

xmlWriter.WriteEndElement();
}
PostMarshallCustomization(request, publicRequest);
try
{
string content = stringWriter.ToString();
request.Content = System.Text.Encoding.UTF8.GetBytes(content);
request.Headers["Content-Type"] = "application/xml";
ChecksumUtils.SetChecksumData(
request,
publicRequest.ChecksumAlgorithm,
fallbackToMD5: false,
isRequestChecksumRequired: true,
headerName: "x-amz-sdk-checksum-algorithm"
);
request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2006-03-01";
}
catch (EncoderFallbackException e)
{
throw new AmazonServiceException("Unable to marshall request to XML", e);
}
return request;
}
private static PutBucketTaggingRequestMarshaller _instance = new PutBucketTaggingRequestMarshaller();

internal static PutBucketTaggingRequestMarshaller GetInstance()
{
return _instance;
}

/// <summary>
/// Gets the singleton.
/// </summary>
public static PutBucketTaggingRequestMarshaller Instance
{
get
{
return _instance;
}
}

partial void PostMarshallCustomization(DefaultRequest defaultRequest, PutBucketTaggingRequest publicRequest);
partial void PreMarshallCustomization(DefaultRequest defaultRequest, PutBucketTaggingRequest publicRequest);
}
}
Loading