Skip to content

Commit 9a887f5

Browse files
Generate PutBucketTagging S3 operation
1 parent 92e8bd1 commit 9a887f5

File tree

12 files changed

+362
-240
lines changed

12 files changed

+362
-240
lines changed

generator/ServiceClientGeneratorLib/ServiceModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ public List<Operation> S3AllowListOperations
577577
new Operation(this, "GetBucketMetadataConfiguration", DocumentRoot[OperationsKey]["GetBucketMetadataConfiguration"]),
578578
new Operation(this, "RenameObject", DocumentRoot[OperationsKey]["RenameObject"]),
579579
new Operation(this, "PutBucketOwnershipControls", DocumentRoot[OperationsKey]["PutBucketOwnershipControls"]),
580+
new Operation(this, "PutBucketTagging", DocumentRoot[OperationsKey]["PutBucketTagging"]),
580581
};
581582
}
582583
return _s3AllowListOperations.Where(operation => operation.data != null).ToList();

generator/ServiceModels/s3/s3.customizations.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,9 @@
193193
]
194194
},
195195
"PutBucketTaggingRequest": {
196-
"exclude": [ "Tagging" ],
197-
"inject": [
196+
"modify":[
198197
{
199-
"TagSet": {
200-
"shape": "TagSet",
201-
"originalMember": "Tagging"
202-
}
198+
"ExpectedBucketOwner" :{"injectXmlIsSet":["return !string.IsNullOrEmpty(this._expectedBucketOwner);"]}
203199
}
204200
]
205201
},
@@ -1253,7 +1249,6 @@
12531249
}
12541250
]
12551251
}
1256-
12571252
},
12581253
"operationModifiers": {
12591254
"CreateBucket": {
@@ -1620,6 +1615,9 @@
16201615
],
16211616
"UploadPartCopyOutput" : [
16221617
"CopyPartResult"
1618+
],
1619+
"PutBucketTaggingRequest":[
1620+
"Tagging"
16231621
]
16241622
},
16251623
"excludeShapes":[

sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/PutBucketTaggingRequestMarshaller.cs

Lines changed: 0 additions & 117 deletions
This file was deleted.

sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/PutBucketTaggingResponseUnmarshaller.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the s3-2006-03-01.normal.json service model.
18+
*/
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Globalization;
22+
using System.IO;
23+
using System.Text;
24+
using System.Xml.Serialization;
25+
26+
using Amazon.S3.Model;
27+
using Amazon.Runtime;
28+
using Amazon.Runtime.Internal;
29+
using Amazon.Runtime.Internal.Transform;
30+
using Amazon.Runtime.Internal.Util;
31+
using System.Xml;
32+
33+
#pragma warning disable CS0612,CS0618
34+
namespace Amazon.S3.Model.Internal.MarshallTransformations
35+
{
36+
/// <summary>
37+
/// PutBucketTagging Request Marshaller
38+
/// </summary>
39+
public partial class PutBucketTaggingRequestMarshaller : IMarshaller<IRequest, PutBucketTaggingRequest> , IMarshaller<IRequest,AmazonWebServiceRequest>
40+
{
41+
/// <summary>
42+
/// Marshaller the request object to the HTTP request.
43+
/// </summary>
44+
/// <param name="input"></param>
45+
/// <returns></returns>
46+
public IRequest Marshall(AmazonWebServiceRequest input)
47+
{
48+
return this.Marshall((PutBucketTaggingRequest)input);
49+
}
50+
51+
/// <summary>
52+
/// Marshaller the request object to the HTTP request.
53+
/// </summary>
54+
/// <param name="publicRequest"></param>
55+
/// <returns></returns>
56+
public IRequest Marshall(PutBucketTaggingRequest publicRequest)
57+
{
58+
var request = new DefaultRequest(publicRequest, "Amazon.S3");
59+
PreMarshallCustomization(request, publicRequest);
60+
request.HttpMethod = "PUT";
61+
request.AddSubResource("tagging");
62+
63+
if (publicRequest.IsSetChecksumAlgorithm())
64+
{
65+
request.Headers["x-amz-sdk-checksum-algorithm"] = publicRequest.ChecksumAlgorithm;
66+
}
67+
68+
if (publicRequest.IsSetContentMD5())
69+
{
70+
request.Headers["Content-MD5"] = publicRequest.ContentMD5;
71+
}
72+
73+
if (publicRequest.IsSetExpectedBucketOwner())
74+
{
75+
request.Headers["x-amz-expected-bucket-owner"] = publicRequest.ExpectedBucketOwner;
76+
}
77+
if (string.IsNullOrEmpty(publicRequest.BucketName))
78+
throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketTaggingRequest.BucketName");
79+
request.ResourcePath = "/";
80+
var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture);
81+
using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize }))
82+
{
83+
xmlWriter.WriteStartElement("Tagging", "http://s3.amazonaws.com/doc/2006-03-01/");
84+
var publicRequestTagSet = publicRequest.TagSet;
85+
if (publicRequestTagSet != null && (publicRequestTagSet.Count > 0 || !AWSConfigs.InitializeCollections))
86+
{
87+
xmlWriter.WriteStartElement("TagSet");
88+
foreach (var publicRequestTagSetValue in publicRequestTagSet)
89+
{
90+
if (publicRequestTagSetValue != null)
91+
{
92+
xmlWriter.WriteStartElement("Tag");
93+
if(publicRequestTagSetValue.IsSetKey())
94+
xmlWriter.WriteElementString("Key", StringUtils.FromString(publicRequestTagSetValue.Key));
95+
if(publicRequestTagSetValue.IsSetValue())
96+
xmlWriter.WriteElementString("Value", StringUtils.FromString(publicRequestTagSetValue.Value));
97+
xmlWriter.WriteEndElement();
98+
}
99+
}
100+
xmlWriter.WriteEndElement();
101+
}
102+
103+
xmlWriter.WriteEndElement();
104+
}
105+
PostMarshallCustomization(request, publicRequest);
106+
try
107+
{
108+
string content = stringWriter.ToString();
109+
request.Content = System.Text.Encoding.UTF8.GetBytes(content);
110+
request.Headers["Content-Type"] = "application/xml";
111+
ChecksumUtils.SetChecksumData(
112+
request,
113+
publicRequest.ChecksumAlgorithm,
114+
fallbackToMD5: false,
115+
isRequestChecksumRequired: true,
116+
headerName: "x-amz-sdk-checksum-algorithm"
117+
);
118+
request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2006-03-01";
119+
}
120+
catch (EncoderFallbackException e)
121+
{
122+
throw new AmazonServiceException("Unable to marshall request to XML", e);
123+
}
124+
return request;
125+
}
126+
private static PutBucketTaggingRequestMarshaller _instance = new PutBucketTaggingRequestMarshaller();
127+
128+
internal static PutBucketTaggingRequestMarshaller GetInstance()
129+
{
130+
return _instance;
131+
}
132+
133+
/// <summary>
134+
/// Gets the singleton.
135+
/// </summary>
136+
public static PutBucketTaggingRequestMarshaller Instance
137+
{
138+
get
139+
{
140+
return _instance;
141+
}
142+
}
143+
144+
partial void PostMarshallCustomization(DefaultRequest defaultRequest, PutBucketTaggingRequest publicRequest);
145+
partial void PreMarshallCustomization(DefaultRequest defaultRequest, PutBucketTaggingRequest publicRequest);
146+
}
147+
}

0 commit comments

Comments
 (0)