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