Skip to content

Commit c6e3388

Browse files
Generate PutBucketTagging S3 operation
1 parent 92e8bd1 commit c6e3388

File tree

8 files changed

+323
-166
lines changed

8 files changed

+323
-166
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@
201201
"originalMember": "Tagging"
202202
}
203203
}
204+
],
205+
"modify":[
206+
{
207+
"ExpectedBucketOwner" :{"injectXmlIsSet":["return !string.IsNullOrEmpty(this._expectedBucketOwner);"]}
208+
}
204209
]
205210
},
206211
"PutBucketVersioningRequest": {
@@ -1253,7 +1258,6 @@
12531258
}
12541259
]
12551260
}
1256-
12571261
},
12581262
"operationModifiers": {
12591263
"CreateBucket": {

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

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,16 @@ namespace Amazon.S3.Model.Internal.MarshallTransformations
3030
/// <summary>
3131
/// Put Bucket Tagging Request Marshaller
3232
/// </summary>
33-
public class PutBucketTaggingRequestMarshaller : IMarshaller<IRequest, PutBucketTaggingRequest> ,IMarshaller<IRequest,Amazon.Runtime.AmazonWebServiceRequest>
34-
{
35-
public IRequest Marshall(Amazon.Runtime.AmazonWebServiceRequest input)
36-
{
37-
return this.Marshall((PutBucketTaggingRequest)input);
38-
}
39-
40-
public IRequest Marshall(PutBucketTaggingRequest putBucketTaggingRequest)
33+
public partial class PutBucketTaggingRequestMarshaller : IMarshaller<IRequest, PutBucketTaggingRequest>, IMarshaller<IRequest, Amazon.Runtime.AmazonWebServiceRequest>
34+
{
35+
partial void PostMarshallCustomization(DefaultRequest defaultRequest, PutBucketTaggingRequest publicRequest)
4136
{
42-
IRequest request = new DefaultRequest(putBucketTaggingRequest, "Amazon.S3");
43-
44-
request.HttpMethod = "PUT";
45-
46-
if (putBucketTaggingRequest.IsSetExpectedBucketOwner())
47-
request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putBucketTaggingRequest.ExpectedBucketOwner));
48-
49-
if (putBucketTaggingRequest.IsSetChecksumAlgorithm())
50-
request.Headers.Add(S3Constants.AmzHeaderSdkChecksumAlgorithm, S3Transforms.ToStringValue(putBucketTaggingRequest.ChecksumAlgorithm));
51-
52-
if (string.IsNullOrEmpty(putBucketTaggingRequest.BucketName))
53-
throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketTaggingRequest.BucketName");
54-
55-
request.ResourcePath = "/";
56-
57-
request.AddSubResource("tagging");
58-
5937
var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture);
6038
using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize }))
6139
{
6240
xmlWriter.WriteStartElement("Tagging", S3Constants.S3RequestXmlNamespace);
6341

64-
var taggingTaggingtagSetList = putBucketTaggingRequest.TagSet;
42+
var taggingTaggingtagSetList = publicRequest.TagSet;
6543
if (taggingTaggingtagSetList != null && taggingTaggingtagSetList.Count > 0)
6644
{
6745
xmlWriter.WriteStartElement("TagSet");
@@ -77,41 +55,14 @@ public IRequest Marshall(PutBucketTaggingRequest putBucketTaggingRequest)
7755
try
7856
{
7957
var content = stringWriter.ToString();
80-
request.Content = Encoding.UTF8.GetBytes(content);
81-
request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml";
82-
83-
ChecksumUtils.SetChecksumData(
84-
request,
85-
putBucketTaggingRequest.ChecksumAlgorithm,
86-
fallbackToMD5: false,
87-
isRequestChecksumRequired: true,
88-
headerName: S3Constants.AmzHeaderSdkChecksumAlgorithm
89-
);
58+
defaultRequest.Content = Encoding.UTF8.GetBytes(content);
59+
defaultRequest.Headers[HeaderKeys.ContentTypeHeader] = "application/xml";
9060
}
9161
catch (EncoderFallbackException e)
9262
{
9363
throw new AmazonServiceException("Unable to marshall request to XML", e);
9464
}
95-
96-
return request;
9765
}
98-
99-
private static PutBucketTaggingRequestMarshaller _instance;
100-
101-
/// <summary>
102-
/// Singleton for marshaller
103-
/// </summary>
104-
public static PutBucketTaggingRequestMarshaller Instance
105-
{
106-
get
107-
{
108-
if (_instance == null)
109-
{
110-
_instance = new PutBucketTaggingRequestMarshaller();
111-
}
112-
return _instance;
113-
}
114-
}
11566
}
11667
}
11768

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

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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+
PostMarshallCustomization(request, publicRequest);
81+
ChecksumUtils.SetChecksumData(
82+
request,
83+
publicRequest.ChecksumAlgorithm,
84+
fallbackToMD5: false,
85+
isRequestChecksumRequired: true,
86+
headerName: "x-amz-sdk-checksum-algorithm"
87+
);
88+
return request;
89+
}
90+
private static PutBucketTaggingRequestMarshaller _instance = new PutBucketTaggingRequestMarshaller();
91+
92+
internal static PutBucketTaggingRequestMarshaller GetInstance()
93+
{
94+
return _instance;
95+
}
96+
97+
/// <summary>
98+
/// Gets the singleton.
99+
/// </summary>
100+
public static PutBucketTaggingRequestMarshaller Instance
101+
{
102+
get
103+
{
104+
return _instance;
105+
}
106+
}
107+
108+
partial void PostMarshallCustomization(DefaultRequest defaultRequest, PutBucketTaggingRequest publicRequest);
109+
partial void PreMarshallCustomization(DefaultRequest defaultRequest, PutBucketTaggingRequest publicRequest);
110+
}
111+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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.Net;
24+
using System.Text;
25+
using System.Xml.Serialization;
26+
27+
using Amazon.S3.Model;
28+
using Amazon.Runtime;
29+
using Amazon.Runtime.Internal;
30+
using Amazon.Runtime.Internal.Transform;
31+
using Amazon.Runtime.Internal.Util;
32+
33+
#pragma warning disable CS0612,CS0618
34+
namespace Amazon.S3.Model.Internal.MarshallTransformations
35+
{
36+
/// <summary>
37+
/// Response Unmarshaller for PutBucketTagging operation
38+
/// </summary>
39+
public partial class PutBucketTaggingResponseUnmarshaller : S3ReponseUnmarshaller
40+
{
41+
/// <summary>
42+
/// Unmarshaller the response from the service to the response class.
43+
/// </summary>
44+
/// <param name="context"></param>
45+
/// <returns></returns>
46+
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
47+
{
48+
PutBucketTaggingResponse response = new PutBucketTaggingResponse();
49+
50+
PostUnmarshallCustomization(context, response);
51+
return response;
52+
}
53+
54+
55+
/// <summary>
56+
/// Unmarshaller error response to exception.
57+
/// </summary>
58+
/// <param name="context"></param>
59+
/// <param name="innerException"></param>
60+
/// <param name="statusCode"></param>
61+
/// <returns></returns>
62+
public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
63+
{
64+
S3ErrorResponse errorResponse = S3ErrorResponseUnmarshaller.Instance.Unmarshall(context);
65+
errorResponse.InnerException = innerException;
66+
errorResponse.StatusCode = statusCode;
67+
68+
var responseBodyBytes = context.GetResponseBodyBytes();
69+
70+
using (var streamCopy = new MemoryStream(responseBodyBytes))
71+
using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null))
72+
{
73+
}
74+
return base.ConstructS3Exception(context, errorResponse, innerException, statusCode);
75+
}
76+
77+
partial void PostUnmarshallCustomization(XmlUnmarshallerContext context, PutBucketTaggingResponse response);
78+
79+
private static PutBucketTaggingResponseUnmarshaller _instance = new PutBucketTaggingResponseUnmarshaller();
80+
81+
internal static PutBucketTaggingResponseUnmarshaller GetInstance()
82+
{
83+
return _instance;
84+
}
85+
86+
/// <summary>
87+
/// Gets the singleton.
88+
/// </summary>
89+
public static PutBucketTaggingResponseUnmarshaller Instance
90+
{
91+
get
92+
{
93+
return _instance;
94+
}
95+
}
96+
97+
}
98+
}

0 commit comments

Comments
 (0)