/// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(ListStorageLensConfigurationsRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "GET";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }

            if (publicRequest.IsSetNextToken())
            {
                request.Parameters.Add("nextToken", StringUtils.FromString(publicRequest.NextToken));
            }
            request.ResourcePath      = "/v20180820/storagelens";
            request.MarshallerVersion = 2;


            request.UseQueryString = true;

            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>  
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(DeleteBucketPolicyRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");
            request.HttpMethod = "DELETE";
        
            if(publicRequest.IsSetAccountId())
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            if (!publicRequest.IsSetBucket())
                throw new AmazonS3ControlException("Request object does not have required field Bucket set");
            request.AddPathResource("{name}", StringUtils.FromString(publicRequest.Bucket));
            request.ResourcePath = "/v20180820/bucket/{name}/policy";
            request.MarshallerVersion = 2;



            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");        
            
            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return request;
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(GetStorageLensConfigurationRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "GET";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetConfigId())
            {
                throw new AmazonS3ControlException("Request object does not have required field ConfigId set");
            }
            request.AddPathResource("{storagelensid}", StringUtils.FromString(publicRequest.ConfigId));
            request.ResourcePath      = "/v20180820/storagelens/{storagelensid}";
            request.MarshallerVersion = 2;



            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(DeletePublicAccessBlockRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "DELETE";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            request.ResourcePath = "/v20180820/configuration/publicAccessBlock";



            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(DeleteJobTaggingRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "DELETE";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetJobId())
            {
                throw new AmazonS3ControlException("Request object does not have required field JobId set");
            }
            request.AddPathResource("{id}", StringUtils.FromString(publicRequest.JobId));
            request.ResourcePath = "/v20180820/jobs/{id}/tagging";



            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
Example #6
0
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(DescribeMultiRegionAccessPointOperationRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "GET";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetRequestTokenARN())
            {
                throw new AmazonS3ControlException("Request object does not have required field RequestTokenARN set");
            }
            request.AddPathResource("{request_token+}", StringUtils.FromString(publicRequest.RequestTokenARN.TrimStart('/')));
            request.ResourcePath = "/v20180820/async-requests/mrap/{request_token+}";



            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(GetMultiRegionAccessPointRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "GET";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetName())
            {
                throw new AmazonS3ControlException("Request object does not have required field Name set");
            }
            request.AddPathResource("{name}", StringUtils.FromString(publicRequest.Name));
            request.ResourcePath = "/v20180820/mrap/instances/{name}";



            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(PutAccessPointPolicyForObjectLambdaRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "PUT";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetName())
            {
                throw new AmazonS3ControlException("Request object does not have required field Name set");
            }
            request.AddPathResource("{name}", StringUtils.FromString(publicRequest.Name));
            request.ResourcePath = "/v20180820/accesspointforobjectlambda/{name}/policy";

            var stringWriter = new StringWriter(CultureInfo.InvariantCulture);

            using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings()
            {
                Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true
            }))
            {
                xmlWriter.WriteStartElement("PutAccessPointPolicyForObjectLambdaRequest", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                if (publicRequest.IsSetPolicy())
                {
                    xmlWriter.WriteElementString("Policy", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Policy));
                }


                xmlWriter.WriteEndElement();
            }
            try
            {
                string content = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(content);
                request.Headers["Content-Type"] = "application/xml";
                request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2018-08-20";
            }
            catch (EncoderFallbackException e)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", e);
            }


            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(ListAccessPointsRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "GET";
            if (Arn.IsArn(publicRequest.Bucket))
            {
                publicRequest.AccountId = Amazon.S3Control.Internal.S3ArnUtils.GetAccountIdBasedOnArn(
                    publicRequest.AccountId,
                    Arn.Parse(publicRequest.Bucket).AccountId
                    );
            }

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }

            if (publicRequest.IsSetBucket())
            {
                request.Parameters.Add("bucket", StringUtils.FromString(publicRequest.Bucket));
            }

            if (publicRequest.IsSetMaxResults())
            {
                request.Parameters.Add("maxResults", StringUtils.FromInt(publicRequest.MaxResults));
            }

            if (publicRequest.IsSetNextToken())
            {
                request.Parameters.Add("nextToken", StringUtils.FromString(publicRequest.NextToken));
            }
            request.ResourcePath      = "/v20180820/accesspoint";
            request.MarshallerVersion = 2;


            request.UseQueryString = true;

            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(UpdateJobStatusRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "POST";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetJobId())
            {
                throw new AmazonS3ControlException("Request object does not have required field JobId set");
            }
            request.AddPathResource("{id}", StringUtils.FromString(publicRequest.JobId));

            if (publicRequest.IsSetRequestedJobStatus())
            {
                request.Parameters.Add("requestedJobStatus", StringUtils.FromString(publicRequest.RequestedJobStatus));
            }

            if (publicRequest.IsSetStatusUpdateReason())
            {
                request.Parameters.Add("statusUpdateReason", StringUtils.FromString(publicRequest.StatusUpdateReason));
            }
            request.ResourcePath      = "/v20180820/jobs/{id}/status";
            request.MarshallerVersion = 2;


            request.UseQueryString = true;

            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(GetBucketRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "GET";
            if (Arn.IsArn(publicRequest.Bucket))
            {
                publicRequest.AccountId = Amazon.S3Control.Internal.S3ArnUtils.GetAccountIdBasedOnArn(
                    publicRequest.AccountId,
                    Arn.Parse(publicRequest.Bucket).AccountId
                    );
            }

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetBucket())
            {
                throw new AmazonS3ControlException("Request object does not have required field Bucket set");
            }
            request.AddPathResource("{name}", StringUtils.FromString(publicRequest.Bucket));
            request.ResourcePath      = "/v20180820/bucket/{name}";
            request.MarshallerVersion = 2;



            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
Example #12
0
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(PutBucketPolicyRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "PUT";
            if (Arn.IsArn(publicRequest.Bucket))
            {
                publicRequest.AccountId = Amazon.S3Control.Internal.S3ArnUtils.GetAccountIdBasedOnArn(
                    publicRequest.AccountId,
                    Arn.Parse(publicRequest.Bucket).AccountId
                    );
            }

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }

            if (publicRequest.IsSetConfirmRemoveSelfBucketAccess())
            {
                request.Headers["x-amz-confirm-remove-self-bucket-access"] = StringUtils.FromBool(publicRequest.ConfirmRemoveSelfBucketAccess);
            }
            if (!publicRequest.IsSetBucket())
            {
                throw new AmazonS3ControlException("Request object does not have required field Bucket set");
            }
            request.AddPathResource("{name}", StringUtils.FromString(publicRequest.Bucket));
            request.ResourcePath = "/v20180820/bucket/{name}/policy";

            var stringWriter = new StringWriter(CultureInfo.InvariantCulture);

            using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings()
            {
                Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true
            }))
            {
                xmlWriter.WriteStartElement("PutBucketPolicyRequest", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                if (publicRequest.IsSetPolicy())
                {
                    xmlWriter.WriteElementString("Policy", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Policy));
                }


                xmlWriter.WriteEndElement();
            }
            try
            {
                string content = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(content);
                request.Headers["Content-Type"] = "application/xml";
                var checksum = Amazon.Util.AWSSDKUtils.GenerateChecksumForContent(content, true);
                request.Headers[Amazon.Util.HeaderKeys.ContentMD5Header] = checksum;
                request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion]   = "2018-08-20";
            }
            catch (EncoderFallbackException e)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", e);
            }


            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
Example #13
0
        public IRequest Marshall(WriteGetObjectResponseRequest writeGetObjectResponseRequest)
        {
            IRequest request = new DefaultRequest(writeGetObjectResponseRequest, "AmazonS3");

            request.HttpMethod = "POST";

            if (!writeGetObjectResponseRequest.IsSetRequestRoute())
            {
                throw new System.ArgumentException("RequestRoute is a required property and must be set before making this call.", "WriteGetObjectResponseRequest.RequestRoute");
            }
            if (!writeGetObjectResponseRequest.IsSetRequestToken())
            {
                throw new System.ArgumentException("RequestToken is a required property and must be set before making this call.", "WriteGetObjectResponseRequest.RequestToken");
            }

            if (writeGetObjectResponseRequest.IsSetRequestRoute())
            {
                request.Headers["x-amz-request-route"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.RequestRoute);
            }

            if (writeGetObjectResponseRequest.IsSetRequestToken())
            {
                request.Headers["x-amz-request-token"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.RequestToken);
            }

            if (writeGetObjectResponseRequest.IsSetStatusCode())
            {
                request.Headers["x-amz-fwd-status"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.StatusCode.Value);
            }

            if (writeGetObjectResponseRequest.IsSetErrorCode())
            {
                request.Headers["x-amz-fwd-error-code"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ErrorCode);
            }

            if (writeGetObjectResponseRequest.IsSetErrorMessage())
            {
                request.Headers["x-amz-fwd-error-message"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ErrorMessage);
            }

            if (writeGetObjectResponseRequest.IsSetAcceptRanges())
            {
                request.Headers["x-amz-fwd-header-accept-ranges"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.AcceptRanges);
            }

            if (writeGetObjectResponseRequest.IsSetCacheControl())
            {
                request.Headers["x-amz-fwd-header-Cache-Control"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.CacheControl);
            }

            if (writeGetObjectResponseRequest.IsSetChecksumCRC32())
            {
                request.Headers["x-amz-fwd-header-x-amz-checksum-crc32"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ChecksumCRC32);
            }

            if (writeGetObjectResponseRequest.IsSetChecksumCRC32C())
            {
                request.Headers["x-amz-fwd-header-x-amz-checksum-crc32c"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ChecksumCRC32C);
            }

            if (writeGetObjectResponseRequest.IsSetChecksumSHA1())
            {
                request.Headers["x-amz-fwd-header-x-amz-checksum-sha1"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ChecksumSHA1);
            }

            if (writeGetObjectResponseRequest.IsSetChecksumSHA256())
            {
                request.Headers["x-amz-fwd-header-x-amz-checksum-sha256"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ChecksumSHA256);
            }

            if (writeGetObjectResponseRequest.IsSetContentDisposition())
            {
                request.Headers["x-amz-fwd-header-Content-Disposition"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ContentDisposition);
            }

            if (writeGetObjectResponseRequest.IsSetContentEncoding())
            {
                request.Headers["x-amz-fwd-header-Content-Encoding"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ContentEncoding);
            }

            if (writeGetObjectResponseRequest.IsSetContentLanguage())
            {
                request.Headers["x-amz-fwd-header-Content-Language"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ContentLanguage);
            }

            if (writeGetObjectResponseRequest.IsSetContentRange())
            {
                request.Headers["x-amz-fwd-header-Content-Range"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ContentRange);
            }

            if (writeGetObjectResponseRequest.IsSetContentType())
            {
                request.Headers["x-amz-fwd-header-Content-Type"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ContentType);
            }

            if (writeGetObjectResponseRequest.IsSetDeleteMarker())
            {
                request.Headers["x-amz-fwd-header-x-amz-delete-marker"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.DeleteMarker);
            }

            if (writeGetObjectResponseRequest.IsSetETag())
            {
                request.Headers["x-amz-fwd-header-ETag"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ETag);
            }

            if (writeGetObjectResponseRequest.IsSetExpires())
            {
                request.Headers["x-amz-fwd-header-Expires"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.Expires);
            }

            if (writeGetObjectResponseRequest.IsSetExpiration())
            {
                request.Headers["x-amz-fwd-header-x-amz-expiration"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.Expiration);
            }

            if (writeGetObjectResponseRequest.IsSetLastModified())
            {
                request.Headers["x-amz-fwd-header-Last-Modified"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.LastModified);
            }

            if (writeGetObjectResponseRequest.IsSetMissingMeta())
            {
                request.Headers["x-amz-fwd-header-x-amz-missing-meta"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.MissingMeta.Value);
            }

            AmazonS3Util.SetMetadataHeaders(request, writeGetObjectResponseRequest.Metadata);

            if (writeGetObjectResponseRequest.IsSetObjectLockMode())
            {
                request.Headers["x-amz-fwd-header-x-amz-object-lock-mode"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ObjectLockMode);
            }

            if (writeGetObjectResponseRequest.IsSetObjectLockLegalHoldStatus())
            {
                request.Headers["x-amz-fwd-header-x-amz-object-lock-legal-hold"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ObjectLockLegalHoldStatus);
            }

            if (writeGetObjectResponseRequest.IsSetObjectLockRetainUntilDate())
            {
                request.Headers["x-amz-fwd-header-x-amz-object-lock-retain-until-date"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ObjectLockRetainUntilDate);
            }

            if (writeGetObjectResponseRequest.IsSetPartsCount())
            {
                request.Headers["x-amz-fwd-header-x-amz-mp-parts-count"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.PartsCount.Value);
            }

            if (writeGetObjectResponseRequest.IsSetReplicationStatus())
            {
                request.Headers["x-amz-fwd-header-x-amz-replication-status"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ReplicationStatus);
            }

            if (writeGetObjectResponseRequest.IsSetRequestCharged())
            {
                request.Headers["x-amz-fwd-header-x-amz-request-charged"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.RequestCharged);
            }

            if (writeGetObjectResponseRequest.IsSetRestore())
            {
                request.Headers["x-amz-fwd-header-x-amz-restore"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.Restore);
            }

            if (writeGetObjectResponseRequest.IsSetServerSideEncryptionMethod())
            {
                request.Headers["x-amz-fwd-header-x-amz-server-side-encryption"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.ServerSideEncryptionMethod);
            }

            if (writeGetObjectResponseRequest.IsSetSSECustomerAlgorithm())
            {
                request.Headers["x-amz-fwd-header-x-amz-server-side-encryption-customer-algorithm"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.SSECustomerAlgorithm);
            }

            if (writeGetObjectResponseRequest.IsSetSSEKMSKeyId())
            {
                request.Headers["x-amz-fwd-header-x-amz-server-side-encryption-aws-kms-key-id"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.SSEKMSKeyId);
            }

            if (writeGetObjectResponseRequest.IsSetSSECustomerKeyMD5())
            {
                request.Headers["x-amz-fwd-header-x-amz-server-side-encryption-customer-key-MD5"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.SSECustomerKeyMD5);
            }

            if (writeGetObjectResponseRequest.IsSetStorageClass())
            {
                request.Headers["x-amz-fwd-header-x-amz-storage-class"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.StorageClass);
            }

            if (writeGetObjectResponseRequest.IsSetTagCount())
            {
                request.Headers["x-amz-fwd-header-x-amz-tagging-count"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.TagCount.Value);
            }

            if (writeGetObjectResponseRequest.IsSetVersionId())
            {
                request.Headers["x-amz-fwd-header-x-amz-version-id"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.VersionId);
            }

            if (writeGetObjectResponseRequest.IsSetBucketKeyEnabled())
            {
                request.Headers["x-amz-fwd-header-x-amz-server-side-encryption-bucket-key-enabled"] = S3Transforms.ToStringValue(writeGetObjectResponseRequest.BucketKeyEnabled);
            }

            var stream = writeGetObjectResponseRequest.Body ?? new MemoryStream();

            request.ContentStream = stream;
            if (writeGetObjectResponseRequest.IsSetContentLength())
            {
                var length = writeGetObjectResponseRequest.ContentLength.Value;
                request.Headers["Content-Length"] = length.ToString(CultureInfo.InvariantCulture);
            }
            else if (request.ContentStream.CanSeek)
            {
                request.Headers["Content-Length"] = request.ContentStream.Length.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                request.Headers[HeaderKeys.TransferEncodingHeader] = "chunked";
            }

            request.DisablePayloadSigning = true;

            if (!writeGetObjectResponseRequest.IsSetContentType())
            {
                request.Headers["x-amz-fwd-header-Content-Type"] = "binary/octet-stream";
            }

            var hostPrefixLabels = new
            {
                RequestRoute = StringUtils.FromString(writeGetObjectResponseRequest.RequestRoute)
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.RequestRoute))
            {
                throw new AmazonS3Exception("RequestRoute can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.RequestRoute}.";

            request.ResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}",
                                                 S3Transforms.ToStringValue("WriteGetObjectResponse"));

            return(request);
        }
Example #14
0
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(PutAccessPointConfigurationForObjectLambdaRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "PUT";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetName())
            {
                throw new AmazonS3ControlException("Request object does not have required field Name set");
            }
            request.AddPathResource("{name}", StringUtils.FromString(publicRequest.Name));
            request.ResourcePath = "/v20180820/accesspointforobjectlambda/{name}/configuration";

            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("PutAccessPointConfigurationForObjectLambdaRequest", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                if (publicRequest.Configuration != null)
                {
                    xmlWriter.WriteStartElement("Configuration", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                    var publicRequestConfigurationAllowedFeatures = publicRequest.Configuration.AllowedFeatures;
                    if (publicRequestConfigurationAllowedFeatures != null && publicRequestConfigurationAllowedFeatures.Count > 0)
                    {
                        xmlWriter.WriteStartElement("AllowedFeatures", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        foreach (var publicRequestConfigurationAllowedFeaturesValue in publicRequestConfigurationAllowedFeatures)
                        {
                            xmlWriter.WriteStartElement("AllowedFeature", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            xmlWriter.WriteValue(publicRequestConfigurationAllowedFeaturesValue);
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();
                    }
                    if (publicRequest.Configuration.IsSetCloudWatchMetricsEnabled())
                    {
                        xmlWriter.WriteElementString("CloudWatchMetricsEnabled", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.Configuration.CloudWatchMetricsEnabled));
                    }

                    if (publicRequest.Configuration.IsSetSupportingAccessPoint())
                    {
                        xmlWriter.WriteElementString("SupportingAccessPoint", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Configuration.SupportingAccessPoint));
                    }

                    var publicRequestConfigurationTransformationConfigurations = publicRequest.Configuration.TransformationConfigurations;
                    if (publicRequestConfigurationTransformationConfigurations != null && publicRequestConfigurationTransformationConfigurations.Count > 0)
                    {
                        xmlWriter.WriteStartElement("TransformationConfigurations", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        foreach (var publicRequestConfigurationTransformationConfigurationsValue in publicRequestConfigurationTransformationConfigurations)
                        {
                            if (publicRequestConfigurationTransformationConfigurationsValue != null)
                            {
                                xmlWriter.WriteStartElement("TransformationConfiguration", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                var publicRequestConfigurationTransformationConfigurationsValueActions = publicRequestConfigurationTransformationConfigurationsValue.Actions;
                                if (publicRequestConfigurationTransformationConfigurationsValueActions != null && publicRequestConfigurationTransformationConfigurationsValueActions.Count > 0)
                                {
                                    xmlWriter.WriteStartElement("Actions", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    foreach (var publicRequestConfigurationTransformationConfigurationsValueActionsValue in publicRequestConfigurationTransformationConfigurationsValueActions)
                                    {
                                        xmlWriter.WriteStartElement("Action", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                        xmlWriter.WriteValue(publicRequestConfigurationTransformationConfigurationsValueActionsValue);
                                        xmlWriter.WriteEndElement();
                                    }
                                    xmlWriter.WriteEndElement();
                                }

                                if (publicRequestConfigurationTransformationConfigurationsValue.ContentTransformation != null)
                                {
                                    xmlWriter.WriteStartElement("ContentTransformation", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                                    if (publicRequestConfigurationTransformationConfigurationsValue.ContentTransformation.AwsLambda != null)
                                    {
                                        xmlWriter.WriteStartElement("AwsLambda", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                        if (publicRequestConfigurationTransformationConfigurationsValue.ContentTransformation.AwsLambda.IsSetFunctionArn())
                                        {
                                            xmlWriter.WriteElementString("FunctionArn", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestConfigurationTransformationConfigurationsValue.ContentTransformation.AwsLambda.FunctionArn));
                                        }

                                        if (publicRequestConfigurationTransformationConfigurationsValue.ContentTransformation.AwsLambda.IsSetFunctionPayload())
                                        {
                                            xmlWriter.WriteElementString("FunctionPayload", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestConfigurationTransformationConfigurationsValue.ContentTransformation.AwsLambda.FunctionPayload));
                                        }

                                        xmlWriter.WriteEndElement();
                                    }
                                    xmlWriter.WriteEndElement();
                                }
                                xmlWriter.WriteEndElement();
                            }
                        }
                        xmlWriter.WriteEndElement();
                    }
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement();
            }
            try
            {
                string content = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(content);
                request.Headers["Content-Type"] = "application/xml";
                request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2018-08-20";
            }
            catch (EncoderFallbackException e)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", e);
            }


            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
Example #15
0
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(PutPublicAccessBlockRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "PUT";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            request.ResourcePath = "/v20180820/configuration/publicAccessBlock";

            var stringWriter = new StringWriter(CultureInfo.InvariantCulture);

            using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings()
            {
                Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true
            }))
            {
                if (publicRequest.IsSetPublicAccessBlockConfiguration())
                {
                    xmlWriter.WriteStartElement("PublicAccessBlockConfiguration", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                    if (publicRequest.PublicAccessBlockConfiguration.IsSetBlockPublicAcls())
                    {
                        xmlWriter.WriteElementString("BlockPublicAcls", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.PublicAccessBlockConfiguration.BlockPublicAcls));
                    }

                    if (publicRequest.PublicAccessBlockConfiguration.IsSetBlockPublicPolicy())
                    {
                        xmlWriter.WriteElementString("BlockPublicPolicy", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.PublicAccessBlockConfiguration.BlockPublicPolicy));
                    }

                    if (publicRequest.PublicAccessBlockConfiguration.IsSetIgnorePublicAcls())
                    {
                        xmlWriter.WriteElementString("IgnorePublicAcls", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.PublicAccessBlockConfiguration.IgnorePublicAcls));
                    }

                    if (publicRequest.PublicAccessBlockConfiguration.IsSetRestrictPublicBuckets())
                    {
                        xmlWriter.WriteElementString("RestrictPublicBuckets", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.PublicAccessBlockConfiguration.RestrictPublicBuckets));
                    }


                    xmlWriter.WriteEndElement();
                }
            }
            try
            {
                string content = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(content);
                request.Headers["Content-Type"] = "application/xml";
                request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2018-08-20";
            }
            catch (EncoderFallbackException e)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", e);
            }


            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(CreateAccessPointRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "PUT";
            if (Arn.IsArn(publicRequest.Bucket))
            {
                publicRequest.AccountId = Amazon.S3Control.Internal.S3ArnUtils.GetAccountIdBasedOnArn(
                    publicRequest.AccountId,
                    Arn.Parse(publicRequest.Bucket).AccountId
                    );
            }

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetName())
            {
                throw new AmazonS3ControlException("Request object does not have required field Name set");
            }
            request.AddPathResource("{name}", StringUtils.FromString(publicRequest.Name));
            request.ResourcePath = "/v20180820/accesspoint/{name}";

            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("CreateAccessPointRequest", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                if (publicRequest.IsSetBucket())
                {
                    xmlWriter.WriteElementString("Bucket", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Bucket));
                }


                if (publicRequest.PublicAccessBlockConfiguration != null)
                {
                    xmlWriter.WriteStartElement("PublicAccessBlockConfiguration", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                    if (publicRequest.PublicAccessBlockConfiguration.IsSetBlockPublicAcls())
                    {
                        xmlWriter.WriteElementString("BlockPublicAcls", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.PublicAccessBlockConfiguration.BlockPublicAcls));
                    }

                    if (publicRequest.PublicAccessBlockConfiguration.IsSetBlockPublicPolicy())
                    {
                        xmlWriter.WriteElementString("BlockPublicPolicy", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.PublicAccessBlockConfiguration.BlockPublicPolicy));
                    }

                    if (publicRequest.PublicAccessBlockConfiguration.IsSetIgnorePublicAcls())
                    {
                        xmlWriter.WriteElementString("IgnorePublicAcls", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.PublicAccessBlockConfiguration.IgnorePublicAcls));
                    }

                    if (publicRequest.PublicAccessBlockConfiguration.IsSetRestrictPublicBuckets())
                    {
                        xmlWriter.WriteElementString("RestrictPublicBuckets", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.PublicAccessBlockConfiguration.RestrictPublicBuckets));
                    }

                    xmlWriter.WriteEndElement();
                }

                if (publicRequest.VpcConfiguration != null)
                {
                    xmlWriter.WriteStartElement("VpcConfiguration", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                    if (publicRequest.VpcConfiguration.IsSetVpcId())
                    {
                        xmlWriter.WriteElementString("VpcId", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.VpcConfiguration.VpcId));
                    }

                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement();
            }
            try
            {
                string content = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(content);
                request.Headers["Content-Type"] = "application/xml";
                request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2018-08-20";
            }
            catch (EncoderFallbackException e)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", e);
            }


            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
Example #17
0
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(CreateMultiRegionAccessPointRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "POST";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            request.ResourcePath = "/v20180820/async-requests/mrap/create";

            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("CreateMultiRegionAccessPointRequest", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                if (publicRequest.IsSetClientToken())
                {
                    xmlWriter.WriteElementString("ClientToken", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.ClientToken));
                }
                else
                {
                    xmlWriter.WriteElementString("ClientToken", "http://awss3control.amazonaws.com/doc/2018-08-20/", Guid.NewGuid().ToString());
                }


                if (publicRequest.Details != null)
                {
                    xmlWriter.WriteStartElement("Details", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                    if (publicRequest.Details.IsSetName())
                    {
                        xmlWriter.WriteElementString("Name", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Details.Name));
                    }


                    if (publicRequest.Details.PublicAccessBlock != null)
                    {
                        xmlWriter.WriteStartElement("PublicAccessBlock", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        if (publicRequest.Details.PublicAccessBlock.IsSetBlockPublicAcls())
                        {
                            xmlWriter.WriteElementString("BlockPublicAcls", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.Details.PublicAccessBlock.BlockPublicAcls));
                        }

                        if (publicRequest.Details.PublicAccessBlock.IsSetBlockPublicPolicy())
                        {
                            xmlWriter.WriteElementString("BlockPublicPolicy", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.Details.PublicAccessBlock.BlockPublicPolicy));
                        }

                        if (publicRequest.Details.PublicAccessBlock.IsSetIgnorePublicAcls())
                        {
                            xmlWriter.WriteElementString("IgnorePublicAcls", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.Details.PublicAccessBlock.IgnorePublicAcls));
                        }

                        if (publicRequest.Details.PublicAccessBlock.IsSetRestrictPublicBuckets())
                        {
                            xmlWriter.WriteElementString("RestrictPublicBuckets", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.Details.PublicAccessBlock.RestrictPublicBuckets));
                        }

                        xmlWriter.WriteEndElement();
                    }
                    var publicRequestDetailsRegions = publicRequest.Details.Regions;
                    if (publicRequestDetailsRegions != null && publicRequestDetailsRegions.Count > 0)
                    {
                        xmlWriter.WriteStartElement("Regions", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        foreach (var publicRequestDetailsRegionsValue in publicRequestDetailsRegions)
                        {
                            if (publicRequestDetailsRegionsValue != null)
                            {
                                xmlWriter.WriteStartElement("Region", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                if (publicRequestDetailsRegionsValue.IsSetBucket())
                                {
                                    xmlWriter.WriteElementString("Bucket", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestDetailsRegionsValue.Bucket));
                                }

                                xmlWriter.WriteEndElement();
                            }
                        }
                        xmlWriter.WriteEndElement();
                    }
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement();
            }
            try
            {
                string content = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(content);
                request.Headers["Content-Type"] = "application/xml";
                var checksum = Amazon.Util.AWSSDKUtils.GenerateChecksumForContent(content, true);
                request.Headers[Amazon.Util.HeaderKeys.ContentMD5Header] = checksum;
                request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion]   = "2018-08-20";
            }
            catch (EncoderFallbackException e)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", e);
            }


            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
Example #18
0
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(PutJobTaggingRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "PUT";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetJobId())
            {
                throw new AmazonS3ControlException("Request object does not have required field JobId set");
            }
            request.AddPathResource("{id}", StringUtils.FromString(publicRequest.JobId));
            request.ResourcePath = "/v20180820/jobs/{id}/tagging";

            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("PutJobTaggingRequest", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                var publicRequestTags = publicRequest.Tags;
                if (publicRequestTags != null && publicRequestTags.Count > 0)
                {
                    xmlWriter.WriteStartElement("Tags", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                    foreach (var publicRequestTagsValue in publicRequestTags)
                    {
                        if (publicRequestTagsValue != null)
                        {
                            xmlWriter.WriteStartElement("member", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            if (publicRequestTagsValue.IsSetKey())
                            {
                                xmlWriter.WriteElementString("Key", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestTagsValue.Key));
                            }

                            if (publicRequestTagsValue.IsSetValue())
                            {
                                xmlWriter.WriteElementString("Value", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestTagsValue.Value));
                            }

                            xmlWriter.WriteEndElement();
                        }
                    }
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement();
            }
            try
            {
                string content = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(content);
                request.Headers["Content-Type"] = "application/xml";
                request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2018-08-20";
            }
            catch (EncoderFallbackException e)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", e);
            }


            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(PutStorageLensConfigurationRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "PUT";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetConfigId())
            {
                throw new AmazonS3ControlException("Request object does not have required field ConfigId set");
            }
            request.AddPathResource("{storagelensid}", StringUtils.FromString(publicRequest.ConfigId));
            request.ResourcePath = "/v20180820/storagelens/{storagelensid}";

            var stringWriter = new StringWriter(CultureInfo.InvariantCulture);

            using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings()
            {
                Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true
            }))
            {
                xmlWriter.WriteStartElement("PutStorageLensConfigurationRequest", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                if (publicRequest.StorageLensConfiguration != null)
                {
                    xmlWriter.WriteStartElement("StorageLensConfiguration", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                    if (publicRequest.StorageLensConfiguration.AccountLevel != null)
                    {
                        xmlWriter.WriteStartElement("AccountLevel", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                        if (publicRequest.StorageLensConfiguration.AccountLevel.ActivityMetrics != null)
                        {
                            xmlWriter.WriteStartElement("ActivityMetrics", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            if (publicRequest.StorageLensConfiguration.AccountLevel.ActivityMetrics.IsSetIsEnabled())
                            {
                                xmlWriter.WriteElementString("IsEnabled", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.StorageLensConfiguration.AccountLevel.ActivityMetrics.IsEnabled));
                            }

                            xmlWriter.WriteEndElement();
                        }

                        if (publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel != null)
                        {
                            xmlWriter.WriteStartElement("BucketLevel", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                            if (publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.ActivityMetrics != null)
                            {
                                xmlWriter.WriteStartElement("ActivityMetrics", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                if (publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.ActivityMetrics.IsSetIsEnabled())
                                {
                                    xmlWriter.WriteElementString("IsEnabled", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.ActivityMetrics.IsEnabled));
                                }

                                xmlWriter.WriteEndElement();
                            }

                            if (publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel != null)
                            {
                                xmlWriter.WriteStartElement("PrefixLevel", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                                if (publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel.StorageMetrics != null)
                                {
                                    xmlWriter.WriteStartElement("StorageMetrics", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    if (publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel.StorageMetrics.IsSetIsEnabled())
                                    {
                                        xmlWriter.WriteElementString("IsEnabled", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel.StorageMetrics.IsEnabled));
                                    }


                                    if (publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel.StorageMetrics.SelectionCriteria != null)
                                    {
                                        xmlWriter.WriteStartElement("SelectionCriteria", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                        if (publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel.StorageMetrics.SelectionCriteria.IsSetDelimiter())
                                        {
                                            xmlWriter.WriteElementString("Delimiter", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel.StorageMetrics.SelectionCriteria.Delimiter));
                                        }

                                        if (publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel.StorageMetrics.SelectionCriteria.IsSetMaxDepth())
                                        {
                                            xmlWriter.WriteElementString("MaxDepth", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromInt(publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel.StorageMetrics.SelectionCriteria.MaxDepth));
                                        }

                                        if (publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel.StorageMetrics.SelectionCriteria.IsSetMinStorageBytesPercentage())
                                        {
                                            xmlWriter.WriteElementString("MinStorageBytesPercentage", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromDouble(publicRequest.StorageLensConfiguration.AccountLevel.BucketLevel.PrefixLevel.StorageMetrics.SelectionCriteria.MinStorageBytesPercentage));
                                        }

                                        xmlWriter.WriteEndElement();
                                    }
                                    xmlWriter.WriteEndElement();
                                }
                                xmlWriter.WriteEndElement();
                            }
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.StorageLensConfiguration.AwsOrg != null)
                    {
                        xmlWriter.WriteStartElement("AwsOrg", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        if (publicRequest.StorageLensConfiguration.AwsOrg.IsSetArn())
                        {
                            xmlWriter.WriteElementString("Arn", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.StorageLensConfiguration.AwsOrg.Arn));
                        }

                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.StorageLensConfiguration.DataExport != null)
                    {
                        xmlWriter.WriteStartElement("DataExport", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                        if (publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination != null)
                        {
                            xmlWriter.WriteStartElement("S3BucketDestination", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            if (publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.IsSetAccountId())
                            {
                                xmlWriter.WriteElementString("AccountId", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.AccountId));
                            }

                            if (publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.IsSetArn())
                            {
                                xmlWriter.WriteElementString("Arn", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.Arn));
                            }


                            if (publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.Encryption != null)
                            {
                                xmlWriter.WriteStartElement("Encryption", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                                if (publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.Encryption.SSEKMS != null)
                                {
                                    xmlWriter.WriteStartElement("SSE-KMS", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    if (publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.Encryption.SSEKMS.IsSetKeyId())
                                    {
                                        xmlWriter.WriteElementString("KeyId", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.Encryption.SSEKMS.KeyId));
                                    }

                                    xmlWriter.WriteEndElement();
                                }

                                if (publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.Encryption.SSES3 != null)
                                {
                                    xmlWriter.WriteStartElement("SSE-S3", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    xmlWriter.WriteEndElement();
                                }
                                xmlWriter.WriteEndElement();
                            }
                            if (publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.IsSetFormat())
                            {
                                xmlWriter.WriteElementString("Format", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.Format));
                            }

                            if (publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.IsSetOutputSchemaVersion())
                            {
                                xmlWriter.WriteElementString("OutputSchemaVersion", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.OutputSchemaVersion));
                            }

                            if (publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.IsSetPrefix())
                            {
                                xmlWriter.WriteElementString("Prefix", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.StorageLensConfiguration.DataExport.S3BucketDestination.Prefix));
                            }

                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.StorageLensConfiguration.Exclude != null)
                    {
                        xmlWriter.WriteStartElement("Exclude", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        var publicRequestStorageLensConfigurationExcludeBuckets = publicRequest.StorageLensConfiguration.Exclude.Buckets;
                        if (publicRequestStorageLensConfigurationExcludeBuckets != null && publicRequestStorageLensConfigurationExcludeBuckets.Count > 0)
                        {
                            xmlWriter.WriteStartElement("Buckets", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            foreach (var publicRequestStorageLensConfigurationExcludeBucketsValue in publicRequestStorageLensConfigurationExcludeBuckets)
                            {
                                xmlWriter.WriteStartElement("Arn", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                xmlWriter.WriteValue(publicRequestStorageLensConfigurationExcludeBucketsValue);
                                xmlWriter.WriteEndElement();
                            }
                            xmlWriter.WriteEndElement();
                        }
                        var publicRequestStorageLensConfigurationExcludeRegions = publicRequest.StorageLensConfiguration.Exclude.Regions;
                        if (publicRequestStorageLensConfigurationExcludeRegions != null && publicRequestStorageLensConfigurationExcludeRegions.Count > 0)
                        {
                            xmlWriter.WriteStartElement("Regions", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            foreach (var publicRequestStorageLensConfigurationExcludeRegionsValue in publicRequestStorageLensConfigurationExcludeRegions)
                            {
                                xmlWriter.WriteStartElement("Region", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                xmlWriter.WriteValue(publicRequestStorageLensConfigurationExcludeRegionsValue);
                                xmlWriter.WriteEndElement();
                            }
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();
                    }
                    if (publicRequest.StorageLensConfiguration.IsSetId())
                    {
                        xmlWriter.WriteElementString("Id", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.StorageLensConfiguration.Id));
                    }


                    if (publicRequest.StorageLensConfiguration.Include != null)
                    {
                        xmlWriter.WriteStartElement("Include", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        var publicRequestStorageLensConfigurationIncludeBuckets = publicRequest.StorageLensConfiguration.Include.Buckets;
                        if (publicRequestStorageLensConfigurationIncludeBuckets != null && publicRequestStorageLensConfigurationIncludeBuckets.Count > 0)
                        {
                            xmlWriter.WriteStartElement("Buckets", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            foreach (var publicRequestStorageLensConfigurationIncludeBucketsValue in publicRequestStorageLensConfigurationIncludeBuckets)
                            {
                                xmlWriter.WriteStartElement("Arn", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                xmlWriter.WriteValue(publicRequestStorageLensConfigurationIncludeBucketsValue);
                                xmlWriter.WriteEndElement();
                            }
                            xmlWriter.WriteEndElement();
                        }
                        var publicRequestStorageLensConfigurationIncludeRegions = publicRequest.StorageLensConfiguration.Include.Regions;
                        if (publicRequestStorageLensConfigurationIncludeRegions != null && publicRequestStorageLensConfigurationIncludeRegions.Count > 0)
                        {
                            xmlWriter.WriteStartElement("Regions", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            foreach (var publicRequestStorageLensConfigurationIncludeRegionsValue in publicRequestStorageLensConfigurationIncludeRegions)
                            {
                                xmlWriter.WriteStartElement("Region", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                xmlWriter.WriteValue(publicRequestStorageLensConfigurationIncludeRegionsValue);
                                xmlWriter.WriteEndElement();
                            }
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();
                    }
                    if (publicRequest.StorageLensConfiguration.IsSetIsEnabled())
                    {
                        xmlWriter.WriteElementString("IsEnabled", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.StorageLensConfiguration.IsEnabled));
                    }

                    if (publicRequest.StorageLensConfiguration.IsSetStorageLensArn())
                    {
                        xmlWriter.WriteElementString("StorageLensArn", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.StorageLensConfiguration.StorageLensArn));
                    }

                    xmlWriter.WriteEndElement();
                }
                var publicRequestTags = publicRequest.Tags;
                if (publicRequestTags != null && publicRequestTags.Count > 0)
                {
                    xmlWriter.WriteStartElement("Tags", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                    foreach (var publicRequestTagsValue in publicRequestTags)
                    {
                        if (publicRequestTagsValue != null)
                        {
                            xmlWriter.WriteStartElement("Tag", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            if (publicRequestTagsValue.IsSetKey())
                            {
                                xmlWriter.WriteElementString("Key", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestTagsValue.Key));
                            }

                            if (publicRequestTagsValue.IsSetValue())
                            {
                                xmlWriter.WriteElementString("Value", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestTagsValue.Value));
                            }

                            xmlWriter.WriteEndElement();
                        }
                    }
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement();
            }
            try
            {
                string content = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(content);
                request.Headers["Content-Type"] = "application/xml";
                request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2018-08-20";
            }
            catch (EncoderFallbackException e)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", e);
            }


            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
Example #20
0
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(CreateJobRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "POST";

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            request.ResourcePath = "/v20180820/jobs";

            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("CreateJobRequest", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                if (publicRequest.IsSetClientRequestToken())
                {
                    xmlWriter.WriteElementString("ClientRequestToken", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.ClientRequestToken));
                }
                else
                {
                    xmlWriter.WriteElementString("ClientRequestToken", "http://awss3control.amazonaws.com/doc/2018-08-20/", Guid.NewGuid().ToString());
                }

                if (publicRequest.IsSetConfirmationRequired())
                {
                    xmlWriter.WriteElementString("ConfirmationRequired", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.ConfirmationRequired));
                }

                if (publicRequest.IsSetDescription())
                {
                    xmlWriter.WriteElementString("Description", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Description));
                }


                if (publicRequest.Manifest != null)
                {
                    xmlWriter.WriteStartElement("Manifest", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                    if (publicRequest.Manifest.Location != null)
                    {
                        xmlWriter.WriteStartElement("Location", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        if (publicRequest.Manifest.Location.IsSetETag())
                        {
                            xmlWriter.WriteElementString("ETag", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Manifest.Location.ETag));
                        }

                        if (publicRequest.Manifest.Location.IsSetObjectArn())
                        {
                            xmlWriter.WriteElementString("ObjectArn", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Manifest.Location.ObjectArn));
                        }

                        if (publicRequest.Manifest.Location.IsSetObjectVersionId())
                        {
                            xmlWriter.WriteElementString("ObjectVersionId", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Manifest.Location.ObjectVersionId));
                        }

                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.Manifest.Spec != null)
                    {
                        xmlWriter.WriteStartElement("Spec", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        var publicRequestManifestSpecFields = publicRequest.Manifest.Spec.Fields;
                        if (publicRequestManifestSpecFields != null && publicRequestManifestSpecFields.Count > 0)
                        {
                            xmlWriter.WriteStartElement("Fields", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            foreach (var publicRequestManifestSpecFieldsValue in publicRequestManifestSpecFields)
                            {
                                xmlWriter.WriteStartElement("member", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                xmlWriter.WriteValue(publicRequestManifestSpecFieldsValue);
                                xmlWriter.WriteEndElement();
                            }
                            xmlWriter.WriteEndElement();
                        }
                        if (publicRequest.Manifest.Spec.IsSetFormat())
                        {
                            xmlWriter.WriteElementString("Format", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Manifest.Spec.Format));
                        }

                        xmlWriter.WriteEndElement();
                    }
                    xmlWriter.WriteEndElement();
                }

                if (publicRequest.ManifestGenerator != null)
                {
                    xmlWriter.WriteStartElement("ManifestGenerator", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                    if (publicRequest.ManifestGenerator.S3JobManifestGenerator != null)
                    {
                        xmlWriter.WriteStartElement("S3JobManifestGenerator", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        if (publicRequest.ManifestGenerator.S3JobManifestGenerator.IsSetEnableManifestOutput())
                        {
                            xmlWriter.WriteElementString("EnableManifestOutput", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.ManifestGenerator.S3JobManifestGenerator.EnableManifestOutput));
                        }

                        if (publicRequest.ManifestGenerator.S3JobManifestGenerator.IsSetExpectedBucketOwner())
                        {
                            xmlWriter.WriteElementString("ExpectedBucketOwner", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.ManifestGenerator.S3JobManifestGenerator.ExpectedBucketOwner));
                        }


                        if (publicRequest.ManifestGenerator.S3JobManifestGenerator.Filter != null)
                        {
                            xmlWriter.WriteStartElement("Filter", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            if (publicRequest.ManifestGenerator.S3JobManifestGenerator.Filter.IsSetCreatedAfter())
                            {
                                xmlWriter.WriteElementString("CreatedAfter", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromDateTimeToISO8601(publicRequest.ManifestGenerator.S3JobManifestGenerator.Filter.CreatedAfter));
                            }

                            if (publicRequest.ManifestGenerator.S3JobManifestGenerator.Filter.IsSetCreatedBefore())
                            {
                                xmlWriter.WriteElementString("CreatedBefore", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromDateTimeToISO8601(publicRequest.ManifestGenerator.S3JobManifestGenerator.Filter.CreatedBefore));
                            }

                            if (publicRequest.ManifestGenerator.S3JobManifestGenerator.Filter.IsSetEligibleForReplication())
                            {
                                xmlWriter.WriteElementString("EligibleForReplication", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.ManifestGenerator.S3JobManifestGenerator.Filter.EligibleForReplication));
                            }

                            var publicRequestManifestGeneratorS3JobManifestGeneratorFilterObjectReplicationStatuses = publicRequest.ManifestGenerator.S3JobManifestGenerator.Filter.ObjectReplicationStatuses;
                            if (publicRequestManifestGeneratorS3JobManifestGeneratorFilterObjectReplicationStatuses != null && publicRequestManifestGeneratorS3JobManifestGeneratorFilterObjectReplicationStatuses.Count > 0)
                            {
                                xmlWriter.WriteStartElement("ObjectReplicationStatuses", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                foreach (var publicRequestManifestGeneratorS3JobManifestGeneratorFilterObjectReplicationStatusesValue in publicRequestManifestGeneratorS3JobManifestGeneratorFilterObjectReplicationStatuses)
                                {
                                    xmlWriter.WriteStartElement("member", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    xmlWriter.WriteValue(publicRequestManifestGeneratorS3JobManifestGeneratorFilterObjectReplicationStatusesValue);
                                    xmlWriter.WriteEndElement();
                                }
                                xmlWriter.WriteEndElement();
                            }
                            xmlWriter.WriteEndElement();
                        }

                        if (publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation != null)
                        {
                            xmlWriter.WriteStartElement("ManifestOutputLocation", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            if (publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.IsSetBucket())
                            {
                                xmlWriter.WriteElementString("Bucket", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.Bucket));
                            }

                            if (publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.IsSetExpectedManifestBucketOwner())
                            {
                                xmlWriter.WriteElementString("ExpectedManifestBucketOwner", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.ExpectedManifestBucketOwner));
                            }


                            if (publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.ManifestEncryption != null)
                            {
                                xmlWriter.WriteStartElement("ManifestEncryption", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                                if (publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.ManifestEncryption.SSEKMS != null)
                                {
                                    xmlWriter.WriteStartElement("SSE-KMS", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    if (publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.ManifestEncryption.SSEKMS.IsSetKeyId())
                                    {
                                        xmlWriter.WriteElementString("KeyId", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.ManifestEncryption.SSEKMS.KeyId));
                                    }

                                    xmlWriter.WriteEndElement();
                                }

                                if (publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.ManifestEncryption.SSES3 != null)
                                {
                                    xmlWriter.WriteStartElement("SSE-S3", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    xmlWriter.WriteEndElement();
                                }
                                xmlWriter.WriteEndElement();
                            }
                            if (publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.IsSetManifestFormat())
                            {
                                xmlWriter.WriteElementString("ManifestFormat", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.ManifestFormat));
                            }

                            if (publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.IsSetManifestPrefix())
                            {
                                xmlWriter.WriteElementString("ManifestPrefix", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.ManifestGenerator.S3JobManifestGenerator.ManifestOutputLocation.ManifestPrefix));
                            }

                            xmlWriter.WriteEndElement();
                        }
                        if (publicRequest.ManifestGenerator.S3JobManifestGenerator.IsSetSourceBucket())
                        {
                            xmlWriter.WriteElementString("SourceBucket", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.ManifestGenerator.S3JobManifestGenerator.SourceBucket));
                        }

                        xmlWriter.WriteEndElement();
                    }
                    xmlWriter.WriteEndElement();
                }

                if (publicRequest.Operation != null)
                {
                    xmlWriter.WriteStartElement("Operation", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                    if (publicRequest.Operation.LambdaInvoke != null)
                    {
                        xmlWriter.WriteStartElement("LambdaInvoke", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        if (publicRequest.Operation.LambdaInvoke.IsSetFunctionArn())
                        {
                            xmlWriter.WriteElementString("FunctionArn", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.LambdaInvoke.FunctionArn));
                        }

                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.Operation.S3DeleteObjectTagging != null)
                    {
                        xmlWriter.WriteStartElement("S3DeleteObjectTagging", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.Operation.S3InitiateRestoreObject != null)
                    {
                        xmlWriter.WriteStartElement("S3InitiateRestoreObject", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        if (publicRequest.Operation.S3InitiateRestoreObject.IsSetExpirationInDays())
                        {
                            xmlWriter.WriteElementString("ExpirationInDays", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromInt(publicRequest.Operation.S3InitiateRestoreObject.ExpirationInDays));
                        }

                        if (publicRequest.Operation.S3InitiateRestoreObject.IsSetGlacierJobTier())
                        {
                            xmlWriter.WriteElementString("GlacierJobTier", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3InitiateRestoreObject.GlacierJobTier));
                        }

                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.Operation.S3PutObjectAcl != null)
                    {
                        xmlWriter.WriteStartElement("S3PutObjectAcl", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                        if (publicRequest.Operation.S3PutObjectAcl.AccessControlPolicy != null)
                        {
                            xmlWriter.WriteStartElement("AccessControlPolicy", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                            if (publicRequest.Operation.S3PutObjectAcl.AccessControlPolicy.AccessControlList != null)
                            {
                                xmlWriter.WriteStartElement("AccessControlList", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                var publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrants = publicRequest.Operation.S3PutObjectAcl.AccessControlPolicy.AccessControlList.Grants;
                                if (publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrants != null && publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrants.Count > 0)
                                {
                                    xmlWriter.WriteStartElement("Grants", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    foreach (var publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue in publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrants)
                                    {
                                        if (publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue != null)
                                        {
                                            xmlWriter.WriteStartElement("member", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                                            if (publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue.Grantee != null)
                                            {
                                                xmlWriter.WriteStartElement("Grantee", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                                if (publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue.Grantee.IsSetDisplayName())
                                                {
                                                    xmlWriter.WriteElementString("DisplayName", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue.Grantee.DisplayName));
                                                }

                                                if (publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue.Grantee.IsSetIdentifier())
                                                {
                                                    xmlWriter.WriteElementString("Identifier", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue.Grantee.Identifier));
                                                }

                                                if (publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue.Grantee.IsSetTypeIdentifier())
                                                {
                                                    xmlWriter.WriteElementString("TypeIdentifier", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue.Grantee.TypeIdentifier));
                                                }

                                                xmlWriter.WriteEndElement();
                                            }
                                            if (publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue.IsSetPermission())
                                            {
                                                xmlWriter.WriteElementString("Permission", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectAclAccessControlPolicyAccessControlListGrantsValue.Permission));
                                            }

                                            xmlWriter.WriteEndElement();
                                        }
                                    }
                                    xmlWriter.WriteEndElement();
                                }

                                if (publicRequest.Operation.S3PutObjectAcl.AccessControlPolicy.AccessControlList.Owner != null)
                                {
                                    xmlWriter.WriteStartElement("Owner", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    if (publicRequest.Operation.S3PutObjectAcl.AccessControlPolicy.AccessControlList.Owner.IsSetDisplayName())
                                    {
                                        xmlWriter.WriteElementString("DisplayName", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectAcl.AccessControlPolicy.AccessControlList.Owner.DisplayName));
                                    }

                                    if (publicRequest.Operation.S3PutObjectAcl.AccessControlPolicy.AccessControlList.Owner.IsSetID())
                                    {
                                        xmlWriter.WriteElementString("ID", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectAcl.AccessControlPolicy.AccessControlList.Owner.ID));
                                    }

                                    xmlWriter.WriteEndElement();
                                }
                                xmlWriter.WriteEndElement();
                            }
                            if (publicRequest.Operation.S3PutObjectAcl.AccessControlPolicy.IsSetCannedAccessControlList())
                            {
                                xmlWriter.WriteElementString("CannedAccessControlList", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectAcl.AccessControlPolicy.CannedAccessControlList));
                            }

                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.Operation.S3PutObjectCopy != null)
                    {
                        xmlWriter.WriteStartElement("S3PutObjectCopy", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        var publicRequestOperationS3PutObjectCopyAccessControlGrants = publicRequest.Operation.S3PutObjectCopy.AccessControlGrants;
                        if (publicRequestOperationS3PutObjectCopyAccessControlGrants != null && publicRequestOperationS3PutObjectCopyAccessControlGrants.Count > 0)
                        {
                            xmlWriter.WriteStartElement("AccessControlGrants", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            foreach (var publicRequestOperationS3PutObjectCopyAccessControlGrantsValue in publicRequestOperationS3PutObjectCopyAccessControlGrants)
                            {
                                if (publicRequestOperationS3PutObjectCopyAccessControlGrantsValue != null)
                                {
                                    xmlWriter.WriteStartElement("member", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                                    if (publicRequestOperationS3PutObjectCopyAccessControlGrantsValue.Grantee != null)
                                    {
                                        xmlWriter.WriteStartElement("Grantee", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                        if (publicRequestOperationS3PutObjectCopyAccessControlGrantsValue.Grantee.IsSetDisplayName())
                                        {
                                            xmlWriter.WriteElementString("DisplayName", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectCopyAccessControlGrantsValue.Grantee.DisplayName));
                                        }

                                        if (publicRequestOperationS3PutObjectCopyAccessControlGrantsValue.Grantee.IsSetIdentifier())
                                        {
                                            xmlWriter.WriteElementString("Identifier", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectCopyAccessControlGrantsValue.Grantee.Identifier));
                                        }

                                        if (publicRequestOperationS3PutObjectCopyAccessControlGrantsValue.Grantee.IsSetTypeIdentifier())
                                        {
                                            xmlWriter.WriteElementString("TypeIdentifier", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectCopyAccessControlGrantsValue.Grantee.TypeIdentifier));
                                        }

                                        xmlWriter.WriteEndElement();
                                    }
                                    if (publicRequestOperationS3PutObjectCopyAccessControlGrantsValue.IsSetPermission())
                                    {
                                        xmlWriter.WriteElementString("Permission", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectCopyAccessControlGrantsValue.Permission));
                                    }

                                    xmlWriter.WriteEndElement();
                                }
                            }
                            xmlWriter.WriteEndElement();
                        }
                        if (publicRequest.Operation.S3PutObjectCopy.IsSetBucketKeyEnabled())
                        {
                            xmlWriter.WriteElementString("BucketKeyEnabled", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.Operation.S3PutObjectCopy.BucketKeyEnabled));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetCannedAccessControlList())
                        {
                            xmlWriter.WriteElementString("CannedAccessControlList", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.CannedAccessControlList));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetChecksumAlgorithm())
                        {
                            xmlWriter.WriteElementString("ChecksumAlgorithm", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.ChecksumAlgorithm));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetMetadataDirective())
                        {
                            xmlWriter.WriteElementString("MetadataDirective", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.MetadataDirective));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetModifiedSinceConstraint())
                        {
                            xmlWriter.WriteElementString("ModifiedSinceConstraint", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromDateTimeToISO8601(publicRequest.Operation.S3PutObjectCopy.ModifiedSinceConstraint));
                        }


                        if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata != null)
                        {
                            xmlWriter.WriteStartElement("NewObjectMetadata", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.IsSetCacheControl())
                            {
                                xmlWriter.WriteElementString("CacheControl", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.CacheControl));
                            }

                            if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.IsSetContentDisposition())
                            {
                                xmlWriter.WriteElementString("ContentDisposition", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.ContentDisposition));
                            }

                            if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.IsSetContentEncoding())
                            {
                                xmlWriter.WriteElementString("ContentEncoding", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.ContentEncoding));
                            }

                            if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.IsSetContentLanguage())
                            {
                                xmlWriter.WriteElementString("ContentLanguage", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.ContentLanguage));
                            }

                            if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.IsSetContentLength())
                            {
                                xmlWriter.WriteElementString("ContentLength", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromLong(publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.ContentLength));
                            }

                            if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.IsSetContentMD5())
                            {
                                xmlWriter.WriteElementString("ContentMD5", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.ContentMD5));
                            }

                            if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.IsSetContentType())
                            {
                                xmlWriter.WriteElementString("ContentType", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.ContentType));
                            }

                            if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.IsSetHttpExpiresDate())
                            {
                                xmlWriter.WriteElementString("HttpExpiresDate", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromDateTimeToISO8601(publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.HttpExpiresDate));
                            }

                            if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.IsSetRequesterCharged())
                            {
                                xmlWriter.WriteElementString("RequesterCharged", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.RequesterCharged));
                            }

                            if (publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.IsSetSSEAlgorithm())
                            {
                                xmlWriter.WriteElementString("SSEAlgorithm", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.SSEAlgorithm));
                            }

                            xmlWriter.WriteStartElement("UserMetadata", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            foreach (var kvp in publicRequest.Operation.S3PutObjectCopy.NewObjectMetadata.UserMetadata)
                            {
                                xmlWriter.WriteStartElement("entry", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                xmlWriter.WriteElementString("key", "http://awss3control.amazonaws.com/doc/2018-08-20/", kvp.Key);
                                xmlWriter.WriteElementString("value", "http://awss3control.amazonaws.com/doc/2018-08-20/", kvp.Value);
                                xmlWriter.WriteEndElement();
                            }
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteEndElement();
                        }
                        var publicRequestOperationS3PutObjectCopyNewObjectTagging = publicRequest.Operation.S3PutObjectCopy.NewObjectTagging;
                        if (publicRequestOperationS3PutObjectCopyNewObjectTagging != null && publicRequestOperationS3PutObjectCopyNewObjectTagging.Count > 0)
                        {
                            xmlWriter.WriteStartElement("NewObjectTagging", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            foreach (var publicRequestOperationS3PutObjectCopyNewObjectTaggingValue in publicRequestOperationS3PutObjectCopyNewObjectTagging)
                            {
                                if (publicRequestOperationS3PutObjectCopyNewObjectTaggingValue != null)
                                {
                                    xmlWriter.WriteStartElement("member", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    if (publicRequestOperationS3PutObjectCopyNewObjectTaggingValue.IsSetKey())
                                    {
                                        xmlWriter.WriteElementString("Key", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectCopyNewObjectTaggingValue.Key));
                                    }

                                    if (publicRequestOperationS3PutObjectCopyNewObjectTaggingValue.IsSetValue())
                                    {
                                        xmlWriter.WriteElementString("Value", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectCopyNewObjectTaggingValue.Value));
                                    }

                                    xmlWriter.WriteEndElement();
                                }
                            }
                            xmlWriter.WriteEndElement();
                        }
                        if (publicRequest.Operation.S3PutObjectCopy.IsSetObjectLockLegalHoldStatus())
                        {
                            xmlWriter.WriteElementString("ObjectLockLegalHoldStatus", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.ObjectLockLegalHoldStatus));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetObjectLockMode())
                        {
                            xmlWriter.WriteElementString("ObjectLockMode", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.ObjectLockMode));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetObjectLockRetainUntilDate())
                        {
                            xmlWriter.WriteElementString("ObjectLockRetainUntilDate", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromDateTimeToISO8601(publicRequest.Operation.S3PutObjectCopy.ObjectLockRetainUntilDate));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetRedirectLocation())
                        {
                            xmlWriter.WriteElementString("RedirectLocation", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.RedirectLocation));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetRequesterPays())
                        {
                            xmlWriter.WriteElementString("RequesterPays", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.Operation.S3PutObjectCopy.RequesterPays));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetSSEAwsKmsKeyId())
                        {
                            xmlWriter.WriteElementString("SSEAwsKmsKeyId", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.SSEAwsKmsKeyId));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetStorageClass())
                        {
                            xmlWriter.WriteElementString("StorageClass", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.StorageClass));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetTargetKeyPrefix())
                        {
                            xmlWriter.WriteElementString("TargetKeyPrefix", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.TargetKeyPrefix));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetTargetResource())
                        {
                            xmlWriter.WriteElementString("TargetResource", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectCopy.TargetResource));
                        }

                        if (publicRequest.Operation.S3PutObjectCopy.IsSetUnModifiedSinceConstraint())
                        {
                            xmlWriter.WriteElementString("UnModifiedSinceConstraint", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromDateTimeToISO8601(publicRequest.Operation.S3PutObjectCopy.UnModifiedSinceConstraint));
                        }

                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.Operation.S3PutObjectLegalHold != null)
                    {
                        xmlWriter.WriteStartElement("S3PutObjectLegalHold", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                        if (publicRequest.Operation.S3PutObjectLegalHold.LegalHold != null)
                        {
                            xmlWriter.WriteStartElement("LegalHold", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            if (publicRequest.Operation.S3PutObjectLegalHold.LegalHold.IsSetStatus())
                            {
                                xmlWriter.WriteElementString("Status", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectLegalHold.LegalHold.Status));
                            }

                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.Operation.S3PutObjectRetention != null)
                    {
                        xmlWriter.WriteStartElement("S3PutObjectRetention", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        if (publicRequest.Operation.S3PutObjectRetention.IsSetBypassGovernanceRetention())
                        {
                            xmlWriter.WriteElementString("BypassGovernanceRetention", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.Operation.S3PutObjectRetention.BypassGovernanceRetention));
                        }


                        if (publicRequest.Operation.S3PutObjectRetention.Retention != null)
                        {
                            xmlWriter.WriteStartElement("Retention", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            if (publicRequest.Operation.S3PutObjectRetention.Retention.IsSetMode())
                            {
                                xmlWriter.WriteElementString("Mode", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Operation.S3PutObjectRetention.Retention.Mode));
                            }

                            if (publicRequest.Operation.S3PutObjectRetention.Retention.IsSetRetainUntilDate())
                            {
                                xmlWriter.WriteElementString("RetainUntilDate", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromDateTimeToISO8601(publicRequest.Operation.S3PutObjectRetention.Retention.RetainUntilDate));
                            }

                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.Operation.S3PutObjectTagging != null)
                    {
                        xmlWriter.WriteStartElement("S3PutObjectTagging", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        var publicRequestOperationS3PutObjectTaggingTagSet = publicRequest.Operation.S3PutObjectTagging.TagSet;
                        if (publicRequestOperationS3PutObjectTaggingTagSet != null && publicRequestOperationS3PutObjectTaggingTagSet.Count > 0)
                        {
                            xmlWriter.WriteStartElement("TagSet", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            foreach (var publicRequestOperationS3PutObjectTaggingTagSetValue in publicRequestOperationS3PutObjectTaggingTagSet)
                            {
                                if (publicRequestOperationS3PutObjectTaggingTagSetValue != null)
                                {
                                    xmlWriter.WriteStartElement("member", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    if (publicRequestOperationS3PutObjectTaggingTagSetValue.IsSetKey())
                                    {
                                        xmlWriter.WriteElementString("Key", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectTaggingTagSetValue.Key));
                                    }

                                    if (publicRequestOperationS3PutObjectTaggingTagSetValue.IsSetValue())
                                    {
                                        xmlWriter.WriteElementString("Value", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestOperationS3PutObjectTaggingTagSetValue.Value));
                                    }

                                    xmlWriter.WriteEndElement();
                                }
                            }
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();
                    }

                    if (publicRequest.Operation.S3ReplicateObject != null)
                    {
                        xmlWriter.WriteStartElement("S3ReplicateObject", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        xmlWriter.WriteEndElement();
                    }
                    xmlWriter.WriteEndElement();
                }
                if (publicRequest.IsSetPriority())
                {
                    xmlWriter.WriteElementString("Priority", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromInt(publicRequest.Priority));
                }


                if (publicRequest.Report != null)
                {
                    xmlWriter.WriteStartElement("Report", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                    if (publicRequest.Report.IsSetBucket())
                    {
                        xmlWriter.WriteElementString("Bucket", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Report.Bucket));
                    }

                    if (publicRequest.Report.IsSetEnabled())
                    {
                        xmlWriter.WriteElementString("Enabled", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequest.Report.Enabled));
                    }

                    if (publicRequest.Report.IsSetFormat())
                    {
                        xmlWriter.WriteElementString("Format", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Report.Format));
                    }

                    if (publicRequest.Report.IsSetPrefix())
                    {
                        xmlWriter.WriteElementString("Prefix", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Report.Prefix));
                    }

                    if (publicRequest.Report.IsSetReportScope())
                    {
                        xmlWriter.WriteElementString("ReportScope", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.Report.ReportScope));
                    }

                    xmlWriter.WriteEndElement();
                }
                if (publicRequest.IsSetRoleArn())
                {
                    xmlWriter.WriteElementString("RoleArn", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequest.RoleArn));
                }

                var publicRequestTags = publicRequest.Tags;
                if (publicRequestTags != null && publicRequestTags.Count > 0)
                {
                    xmlWriter.WriteStartElement("Tags", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                    foreach (var publicRequestTagsValue in publicRequestTags)
                    {
                        if (publicRequestTagsValue != null)
                        {
                            xmlWriter.WriteStartElement("member", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                            if (publicRequestTagsValue.IsSetKey())
                            {
                                xmlWriter.WriteElementString("Key", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestTagsValue.Key));
                            }

                            if (publicRequestTagsValue.IsSetValue())
                            {
                                xmlWriter.WriteElementString("Value", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestTagsValue.Value));
                            }

                            xmlWriter.WriteEndElement();
                        }
                    }
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement();
            }
            try
            {
                string content = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(content);
                request.Headers["Content-Type"] = "application/xml";
                request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2018-08-20";
            }
            catch (EncoderFallbackException e)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", e);
            }


            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>
        /// <param name="publicRequest"></param>
        /// <returns></returns>
        public IRequest Marshall(PutBucketLifecycleConfigurationRequest publicRequest)
        {
            var request = new DefaultRequest(publicRequest, "Amazon.S3Control");

            request.HttpMethod = "PUT";
            if (Arn.IsArn(publicRequest.Bucket))
            {
                publicRequest.AccountId = Amazon.S3Control.Internal.S3ArnUtils.GetAccountIdBasedOnArn(
                    publicRequest.AccountId,
                    Arn.Parse(publicRequest.Bucket).AccountId
                    );
            }

            if (publicRequest.IsSetAccountId())
            {
                request.Headers["x-amz-account-id"] = publicRequest.AccountId;
            }
            if (!publicRequest.IsSetBucket())
            {
                throw new AmazonS3ControlException("Request object does not have required field Bucket set");
            }
            request.AddPathResource("{name}", StringUtils.FromString(publicRequest.Bucket));
            request.ResourcePath      = "/v20180820/bucket/{name}/lifecycleconfiguration";
            request.MarshallerVersion = 2;

            var stringWriter = new StringWriter(CultureInfo.InvariantCulture);

            using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings()
            {
                Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true
            }))
            {
                if (publicRequest.IsSetLifecycleConfiguration())
                {
                    xmlWriter.WriteStartElement("LifecycleConfiguration", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                    var publicRequestLifecycleConfigurationRules = publicRequest.LifecycleConfiguration.Rules;
                    if (publicRequestLifecycleConfigurationRules != null && publicRequestLifecycleConfigurationRules.Count > 0)
                    {
                        xmlWriter.WriteStartElement("Rules", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                        foreach (var publicRequestLifecycleConfigurationRulesValue in publicRequestLifecycleConfigurationRules)
                        {
                            if (publicRequestLifecycleConfigurationRulesValue != null)
                            {
                                xmlWriter.WriteStartElement("Rule", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                                if (publicRequestLifecycleConfigurationRulesValue.AbortIncompleteMultipartUpload != null)
                                {
                                    xmlWriter.WriteStartElement("AbortIncompleteMultipartUpload", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    if (publicRequestLifecycleConfigurationRulesValue.AbortIncompleteMultipartUpload.IsSetDaysAfterInitiation())
                                    {
                                        xmlWriter.WriteElementString("DaysAfterInitiation", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromInt(publicRequestLifecycleConfigurationRulesValue.AbortIncompleteMultipartUpload.DaysAfterInitiation));
                                    }

                                    xmlWriter.WriteEndElement();
                                }

                                if (publicRequestLifecycleConfigurationRulesValue.Expiration != null)
                                {
                                    xmlWriter.WriteStartElement("Expiration", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    if (publicRequestLifecycleConfigurationRulesValue.Expiration.IsSetDate())
                                    {
                                        xmlWriter.WriteElementString("Date", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromDateTimeToISO8601(publicRequestLifecycleConfigurationRulesValue.Expiration.Date));
                                    }

                                    if (publicRequestLifecycleConfigurationRulesValue.Expiration.IsSetDays())
                                    {
                                        xmlWriter.WriteElementString("Days", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromInt(publicRequestLifecycleConfigurationRulesValue.Expiration.Days));
                                    }

                                    if (publicRequestLifecycleConfigurationRulesValue.Expiration.IsSetExpiredObjectDeleteMarker())
                                    {
                                        xmlWriter.WriteElementString("ExpiredObjectDeleteMarker", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromBool(publicRequestLifecycleConfigurationRulesValue.Expiration.ExpiredObjectDeleteMarker));
                                    }

                                    xmlWriter.WriteEndElement();
                                }

                                if (publicRequestLifecycleConfigurationRulesValue.Filter != null)
                                {
                                    xmlWriter.WriteStartElement("Filter", "http://awss3control.amazonaws.com/doc/2018-08-20/");

                                    if (publicRequestLifecycleConfigurationRulesValue.Filter.And != null)
                                    {
                                        xmlWriter.WriteStartElement("And", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                        if (publicRequestLifecycleConfigurationRulesValue.Filter.And.IsSetPrefix())
                                        {
                                            xmlWriter.WriteElementString("Prefix", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestLifecycleConfigurationRulesValue.Filter.And.Prefix));
                                        }

                                        var publicRequestLifecycleConfigurationRulesValueFilterAndTags = publicRequestLifecycleConfigurationRulesValue.Filter.And.Tags;
                                        if (publicRequestLifecycleConfigurationRulesValueFilterAndTags != null && publicRequestLifecycleConfigurationRulesValueFilterAndTags.Count > 0)
                                        {
                                            xmlWriter.WriteStartElement("Tags", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                            foreach (var publicRequestLifecycleConfigurationRulesValueFilterAndTagsValue in publicRequestLifecycleConfigurationRulesValueFilterAndTags)
                                            {
                                                if (publicRequestLifecycleConfigurationRulesValueFilterAndTagsValue != null)
                                                {
                                                    xmlWriter.WriteStartElement("member", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                                    if (publicRequestLifecycleConfigurationRulesValueFilterAndTagsValue.IsSetKey())
                                                    {
                                                        xmlWriter.WriteElementString("Key", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestLifecycleConfigurationRulesValueFilterAndTagsValue.Key));
                                                    }

                                                    if (publicRequestLifecycleConfigurationRulesValueFilterAndTagsValue.IsSetValue())
                                                    {
                                                        xmlWriter.WriteElementString("Value", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestLifecycleConfigurationRulesValueFilterAndTagsValue.Value));
                                                    }

                                                    xmlWriter.WriteEndElement();
                                                }
                                            }
                                            xmlWriter.WriteEndElement();
                                        }
                                        xmlWriter.WriteEndElement();
                                    }
                                    if (publicRequestLifecycleConfigurationRulesValue.Filter.IsSetPrefix())
                                    {
                                        xmlWriter.WriteElementString("Prefix", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestLifecycleConfigurationRulesValue.Filter.Prefix));
                                    }


                                    if (publicRequestLifecycleConfigurationRulesValue.Filter.Tag != null)
                                    {
                                        xmlWriter.WriteStartElement("Tag", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                        if (publicRequestLifecycleConfigurationRulesValue.Filter.Tag.IsSetKey())
                                        {
                                            xmlWriter.WriteElementString("Key", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestLifecycleConfigurationRulesValue.Filter.Tag.Key));
                                        }

                                        if (publicRequestLifecycleConfigurationRulesValue.Filter.Tag.IsSetValue())
                                        {
                                            xmlWriter.WriteElementString("Value", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestLifecycleConfigurationRulesValue.Filter.Tag.Value));
                                        }

                                        xmlWriter.WriteEndElement();
                                    }
                                    xmlWriter.WriteEndElement();
                                }
                                if (publicRequestLifecycleConfigurationRulesValue.IsSetID())
                                {
                                    xmlWriter.WriteElementString("ID", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestLifecycleConfigurationRulesValue.ID));
                                }


                                if (publicRequestLifecycleConfigurationRulesValue.NoncurrentVersionExpiration != null)
                                {
                                    xmlWriter.WriteStartElement("NoncurrentVersionExpiration", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    if (publicRequestLifecycleConfigurationRulesValue.NoncurrentVersionExpiration.IsSetNoncurrentDays())
                                    {
                                        xmlWriter.WriteElementString("NoncurrentDays", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromInt(publicRequestLifecycleConfigurationRulesValue.NoncurrentVersionExpiration.NoncurrentDays));
                                    }

                                    xmlWriter.WriteEndElement();
                                }
                                var publicRequestLifecycleConfigurationRulesValueNoncurrentVersionTransitions = publicRequestLifecycleConfigurationRulesValue.NoncurrentVersionTransitions;
                                if (publicRequestLifecycleConfigurationRulesValueNoncurrentVersionTransitions != null && publicRequestLifecycleConfigurationRulesValueNoncurrentVersionTransitions.Count > 0)
                                {
                                    xmlWriter.WriteStartElement("NoncurrentVersionTransitions", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    foreach (var publicRequestLifecycleConfigurationRulesValueNoncurrentVersionTransitionsValue in publicRequestLifecycleConfigurationRulesValueNoncurrentVersionTransitions)
                                    {
                                        if (publicRequestLifecycleConfigurationRulesValueNoncurrentVersionTransitionsValue != null)
                                        {
                                            xmlWriter.WriteStartElement("NoncurrentVersionTransition", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                            if (publicRequestLifecycleConfigurationRulesValueNoncurrentVersionTransitionsValue.IsSetNoncurrentDays())
                                            {
                                                xmlWriter.WriteElementString("NoncurrentDays", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromInt(publicRequestLifecycleConfigurationRulesValueNoncurrentVersionTransitionsValue.NoncurrentDays));
                                            }

                                            if (publicRequestLifecycleConfigurationRulesValueNoncurrentVersionTransitionsValue.IsSetStorageClass())
                                            {
                                                xmlWriter.WriteElementString("StorageClass", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestLifecycleConfigurationRulesValueNoncurrentVersionTransitionsValue.StorageClass));
                                            }

                                            xmlWriter.WriteEndElement();
                                        }
                                    }
                                    xmlWriter.WriteEndElement();
                                }
                                if (publicRequestLifecycleConfigurationRulesValue.IsSetStatus())
                                {
                                    xmlWriter.WriteElementString("Status", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestLifecycleConfigurationRulesValue.Status));
                                }

                                var publicRequestLifecycleConfigurationRulesValueTransitions = publicRequestLifecycleConfigurationRulesValue.Transitions;
                                if (publicRequestLifecycleConfigurationRulesValueTransitions != null && publicRequestLifecycleConfigurationRulesValueTransitions.Count > 0)
                                {
                                    xmlWriter.WriteStartElement("Transitions", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                    foreach (var publicRequestLifecycleConfigurationRulesValueTransitionsValue in publicRequestLifecycleConfigurationRulesValueTransitions)
                                    {
                                        if (publicRequestLifecycleConfigurationRulesValueTransitionsValue != null)
                                        {
                                            xmlWriter.WriteStartElement("Transition", "http://awss3control.amazonaws.com/doc/2018-08-20/");
                                            if (publicRequestLifecycleConfigurationRulesValueTransitionsValue.IsSetDate())
                                            {
                                                xmlWriter.WriteElementString("Date", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromDateTimeToISO8601(publicRequestLifecycleConfigurationRulesValueTransitionsValue.Date));
                                            }

                                            if (publicRequestLifecycleConfigurationRulesValueTransitionsValue.IsSetDays())
                                            {
                                                xmlWriter.WriteElementString("Days", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromInt(publicRequestLifecycleConfigurationRulesValueTransitionsValue.Days));
                                            }

                                            if (publicRequestLifecycleConfigurationRulesValueTransitionsValue.IsSetStorageClass())
                                            {
                                                xmlWriter.WriteElementString("StorageClass", "http://awss3control.amazonaws.com/doc/2018-08-20/", StringUtils.FromString(publicRequestLifecycleConfigurationRulesValueTransitionsValue.StorageClass));
                                            }

                                            xmlWriter.WriteEndElement();
                                        }
                                    }
                                    xmlWriter.WriteEndElement();
                                }
                                xmlWriter.WriteEndElement();
                            }
                        }
                        xmlWriter.WriteEndElement();
                    }

                    xmlWriter.WriteEndElement();
                }
            }
            try
            {
                string content = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(content);
                request.Headers["Content-Type"] = "application/xml";
                var checksum = Amazon.Util.AWSSDKUtils.GenerateChecksumForContent(content, true);
                request.Headers[Amazon.Util.HeaderKeys.ContentMD5Header] = checksum;
                request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion]   = "2018-08-20";
            }
            catch (EncoderFallbackException e)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", e);
            }


            var hostPrefixLabels = new
            {
                AccountId = StringUtils.FromString(publicRequest.AccountId),
            };

            if (!HostPrefixUtils.IsValidLabelValue(hostPrefixLabels.AccountId))
            {
                throw new AmazonS3ControlException("AccountId can only contain alphanumeric characters and dashes and must be between 1 and 63 characters long.");
            }

            request.HostPrefix = $"{hostPrefixLabels.AccountId}.";
            return(request);
        }