public IRequest Marshall(RestoreObjectRequest restoreObjectRequest) { IRequest request = new DefaultRequest(restoreObjectRequest, "AmazonS3"); request.HttpMethod = "POST"; if (restoreObjectRequest.IsSetRequestPayer()) { request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(restoreObjectRequest.RequestPayer.ToString())); } if (restoreObjectRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(restoreObjectRequest.ExpectedBucketOwner)); } if (string.IsNullOrEmpty(restoreObjectRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "RestoreObjectRequest.BucketName"); } if (string.IsNullOrEmpty(restoreObjectRequest.Key)) { throw new System.ArgumentException("Key is a required property and must be set before making this call.", "RestoreObjectRequest.Key"); } request.ResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(restoreObjectRequest.BucketName), S3Transforms.ToStringValue(restoreObjectRequest.Key)); request.AddSubResource("restore"); if (restoreObjectRequest.IsSetVersionId()) { request.AddSubResource("versionId", S3Transforms.ToStringValue(restoreObjectRequest.VersionId)); } var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { restoreObjectRequest.Marshall("RestoreRequest", xmlWriter); } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; ChecksumUtils.SetRequestChecksum(request, restoreObjectRequest.ChecksumAlgorithm, fallbackToMD5: false); } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
public IRequest Marshall(PutBucketRequestPaymentRequest putBucketRequestPaymentRequest) { IRequest request = new DefaultRequest(putBucketRequestPaymentRequest, "AmazonS3"); request.HttpMethod = "PUT"; if (putBucketRequestPaymentRequest.IsSetChecksumAlgorithm()) { request.Headers.Add(S3Constants.AmzHeaderSdkChecksumAlgorithm, S3Transforms.ToStringValue(putBucketRequestPaymentRequest.ChecksumAlgorithm)); } if (putBucketRequestPaymentRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putBucketRequestPaymentRequest.ExpectedBucketOwner)); } if (string.IsNullOrEmpty(putBucketRequestPaymentRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketRequestPaymentRequest.BucketName"); } request.ResourcePath = string.Concat("/", S3Transforms.ToStringValue(putBucketRequestPaymentRequest.BucketName)); request.AddSubResource("requestPayment"); var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { var requestPaymentConfigurationRequestPaymentConfiguration = putBucketRequestPaymentRequest.RequestPaymentConfiguration; if (requestPaymentConfigurationRequestPaymentConfiguration != null) { xmlWriter.WriteStartElement("RequestPaymentConfiguration", ""); if (requestPaymentConfigurationRequestPaymentConfiguration.IsSetPayer()) { xmlWriter.WriteElementString("Payer", "", S3Transforms.ToXmlStringValue(requestPaymentConfigurationRequestPaymentConfiguration.Payer)); } xmlWriter.WriteEndElement(); } } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; ChecksumUtils.SetRequestChecksum(request, putBucketRequestPaymentRequest.ChecksumAlgorithm); } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } 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 XMLEncodedStringWriter(CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { 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(CreateFunctionRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.CloudFront"); request.HttpMethod = "POST"; request.ResourcePath = "/2020-05-31/function"; 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("CreateFunctionRequest", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.IsSetFunctionCode()) { xmlWriter.WriteElementString("FunctionCode", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromMemoryStream(publicRequest.FunctionCode)); } if (publicRequest.FunctionConfig != null) { xmlWriter.WriteStartElement("FunctionConfig", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.FunctionConfig.IsSetComment()) { xmlWriter.WriteElementString("Comment", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.FunctionConfig.Comment)); } if (publicRequest.FunctionConfig.IsSetRuntime()) { xmlWriter.WriteElementString("Runtime", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.FunctionConfig.Runtime)); } xmlWriter.WriteEndElement(); } if (publicRequest.IsSetName()) { xmlWriter.WriteElementString("Name", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.Name)); } 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] = "2020-05-31"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(DisassociateVPCFromHostedZoneRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.Route53"); request.HttpMethod = "POST"; if (!publicRequest.IsSetHostedZoneId()) { throw new AmazonRoute53Exception("Request object does not have required field HostedZoneId set"); } request.AddPathResource("{Id}", StringUtils.FromString(publicRequest.HostedZoneId)); request.ResourcePath = "/2013-04-01/hostedzone/{Id}/disassociatevpc"; 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("DisassociateVPCFromHostedZoneRequest", "https://route53.amazonaws.com/doc/2013-04-01/"); if (publicRequest.VPC != null) { xmlWriter.WriteStartElement("VPC", "https://route53.amazonaws.com/doc/2013-04-01/"); if (publicRequest.VPC.IsSetVPCRegion()) { xmlWriter.WriteElementString("VPCRegion", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.VPC.VPCRegion)); } if (publicRequest.VPC.IsSetVPCId()) { xmlWriter.WriteElementString("VPCId", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.VPC.VPCId)); } xmlWriter.WriteEndElement(); } if (publicRequest.IsSetComment()) { xmlWriter.WriteElementString("Comment", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.Comment)); } 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] = "2013-04-01"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
public IRequest Marshall(PutBucketTaggingRequest putBucketTaggingRequest) { IRequest request = new DefaultRequest(putBucketTaggingRequest, "AmazonS3"); request.HttpMethod = "PUT"; if (putBucketTaggingRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putBucketTaggingRequest.ExpectedBucketOwner)); } if (string.IsNullOrEmpty(putBucketTaggingRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketTaggingRequest.BucketName"); } request.ResourcePath = string.Concat("/", S3Transforms.ToStringValue(putBucketTaggingRequest.BucketName)); request.AddSubResource("tagging"); var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { xmlWriter.WriteStartElement("Tagging", ""); var taggingTaggingtagSetList = putBucketTaggingRequest.TagSet; if (taggingTaggingtagSetList != null && taggingTaggingtagSetList.Count > 0) { xmlWriter.WriteStartElement("TagSet", ""); foreach (var taggingTaggingtagSetListValue in taggingTaggingtagSetList) { taggingTaggingtagSetListValue.Marshall("Tag", xmlWriter); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(CreateKeySigningKeyRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.Route53"); request.HttpMethod = "POST"; request.ResourcePath = "/2013-04-01/keysigningkey"; 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("CreateKeySigningKeyRequest", "https://route53.amazonaws.com/doc/2013-04-01/"); if (publicRequest.IsSetCallerReference()) { xmlWriter.WriteElementString("CallerReference", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.CallerReference)); } if (publicRequest.IsSetHostedZoneId()) { xmlWriter.WriteElementString("HostedZoneId", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.HostedZoneId)); } if (publicRequest.IsSetKeyManagementServiceArn()) { xmlWriter.WriteElementString("KeyManagementServiceArn", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.KeyManagementServiceArn)); } if (publicRequest.IsSetName()) { xmlWriter.WriteElementString("Name", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.Name)); } if (publicRequest.IsSetStatus()) { xmlWriter.WriteElementString("Status", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.Status)); } 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] = "2013-04-01"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(CreateKeyGroupRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.CloudFront"); request.HttpMethod = "POST"; request.ResourcePath = "/2020-05-31/key-group"; var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { if (publicRequest.IsSetKeyGroupConfig()) { xmlWriter.WriteStartElement("KeyGroupConfig", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.KeyGroupConfig.IsSetComment()) { xmlWriter.WriteElementString("Comment", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.KeyGroupConfig.Comment)); } var publicRequestKeyGroupConfigItems = publicRequest.KeyGroupConfig.Items; if (publicRequestKeyGroupConfigItems != null && publicRequestKeyGroupConfigItems.Count > 0) { xmlWriter.WriteStartElement("Items", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); foreach (var publicRequestKeyGroupConfigItemsValue in publicRequestKeyGroupConfigItems) { xmlWriter.WriteStartElement("PublicKey", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); xmlWriter.WriteValue(publicRequestKeyGroupConfigItemsValue); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (publicRequest.KeyGroupConfig.IsSetName()) { xmlWriter.WriteElementString("Name", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.KeyGroupConfig.Name)); } 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] = "2020-05-31"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(UpdateCloudFrontOriginAccessIdentityRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.CloudFront"); request.HttpMethod = "PUT"; if (publicRequest.IsSetIfMatch()) { request.Headers["If-Match"] = publicRequest.IfMatch; } if (!publicRequest.IsSetId()) { throw new AmazonCloudFrontException("Request object does not have required field Id set"); } request.AddPathResource("{Id}", StringUtils.FromString(publicRequest.Id)); request.ResourcePath = "/2020-05-31/origin-access-identity/cloudfront/{Id}/config"; var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { if (publicRequest.IsSetCloudFrontOriginAccessIdentityConfig()) { xmlWriter.WriteStartElement("CloudFrontOriginAccessIdentityConfig", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.CloudFrontOriginAccessIdentityConfig.IsSetCallerReference()) { xmlWriter.WriteElementString("CallerReference", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.CloudFrontOriginAccessIdentityConfig.CallerReference)); } if (publicRequest.CloudFrontOriginAccessIdentityConfig.IsSetComment()) { xmlWriter.WriteElementString("Comment", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.CloudFrontOriginAccessIdentityConfig.Comment)); } 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] = "2020-05-31"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(TestFunctionRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.CloudFront"); request.HttpMethod = "POST"; if (publicRequest.IsSetIfMatch()) { request.Headers["If-Match"] = publicRequest.IfMatch; } if (!publicRequest.IsSetName()) { throw new AmazonCloudFrontException("Request object does not have required field Name set"); } request.AddPathResource("{Name}", StringUtils.FromString(publicRequest.Name)); request.ResourcePath = "/2020-05-31/function/{Name}/test"; 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("TestFunctionRequest", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.IsSetEventObject()) { xmlWriter.WriteElementString("EventObject", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromMemoryStream(publicRequest.EventObject)); } if (publicRequest.IsSetStage()) { xmlWriter.WriteElementString("Stage", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.Stage)); } 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] = "2020-05-31"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(CreateMonitoringSubscriptionRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.CloudFront"); request.HttpMethod = "POST"; if (!publicRequest.IsSetDistributionId()) { throw new AmazonCloudFrontException("Request object does not have required field DistributionId set"); } request.AddPathResource("{DistributionId}", StringUtils.FromString(publicRequest.DistributionId)); request.ResourcePath = "/2020-05-31/distributions/{DistributionId}/monitoring-subscription"; var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { if (publicRequest.IsSetMonitoringSubscription()) { xmlWriter.WriteStartElement("MonitoringSubscription", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.MonitoringSubscription.RealtimeMetricsSubscriptionConfig != null) { xmlWriter.WriteStartElement("RealtimeMetricsSubscriptionConfig", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.MonitoringSubscription.RealtimeMetricsSubscriptionConfig.IsSetRealtimeMetricsSubscriptionStatus()) { xmlWriter.WriteElementString("RealtimeMetricsSubscriptionStatus", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.MonitoringSubscription.RealtimeMetricsSubscriptionConfig.RealtimeMetricsSubscriptionStatus)); } 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] = "2020-05-31"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(ListTagsForResourcesRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.Route53"); request.HttpMethod = "POST"; if (!publicRequest.IsSetResourceType()) { throw new AmazonRoute53Exception("Request object does not have required field ResourceType set"); } request.AddPathResource("{ResourceType}", StringUtils.FromString(publicRequest.ResourceType)); request.ResourcePath = "/2013-04-01/tags/{ResourceType}"; 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("ListTagsForResourcesRequest", "https://route53.amazonaws.com/doc/2013-04-01/"); var publicRequestResourceIds = publicRequest.ResourceIds; if (publicRequestResourceIds != null && publicRequestResourceIds.Count > 0) { xmlWriter.WriteStartElement("ResourceIds", "https://route53.amazonaws.com/doc/2013-04-01/"); foreach (var publicRequestResourceIdsValue in publicRequestResourceIds) { xmlWriter.WriteStartElement("ResourceId", "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.WriteValue(publicRequestResourceIdsValue); 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] = "2013-04-01"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
internal static string SerializeTaggingToXml(Tagging tagging) { var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { xmlWriter.WriteStartElement("Tagging", ""); SerializeTagSetToXml(xmlWriter, tagging.TagSet); xmlWriter.WriteEndElement(); } return(stringWriter.ToString()); }
public IRequest Marshall(CompleteMultipartUploadRequest completeMultipartUploadRequest) { IRequest request = new DefaultRequest(completeMultipartUploadRequest, "AmazonS3"); request.HttpMethod = "POST"; if (completeMultipartUploadRequest.IsSetRequestPayer()) { request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(completeMultipartUploadRequest.RequestPayer.ToString())); } if (completeMultipartUploadRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(completeMultipartUploadRequest.ExpectedBucketOwner)); } if (string.IsNullOrEmpty(completeMultipartUploadRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "CompleteMultipartUploadRequest.BucketName"); } if (string.IsNullOrEmpty(completeMultipartUploadRequest.Key)) { throw new System.ArgumentException("Key is a required property and must be set before making this call.", "CompleteMultipartUploadRequest.Key"); } request.ResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(completeMultipartUploadRequest.BucketName), S3Transforms.ToStringValue(completeMultipartUploadRequest.Key)); request.AddSubResource("uploadId", S3Transforms.ToStringValue(completeMultipartUploadRequest.UploadId)); var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { xmlWriter.WriteStartElement("CompleteMultipartUpload", ""); var multipartUploadMultipartUploadpartsList = completeMultipartUploadRequest.PartETags; multipartUploadMultipartUploadpartsList.Sort(); if (multipartUploadMultipartUploadpartsList != null && multipartUploadMultipartUploadpartsList.Count > 0) { foreach (var multipartUploadMultipartUploadpartsListValue in multipartUploadMultipartUploadpartsList) { xmlWriter.WriteStartElement("Part", ""); if (multipartUploadMultipartUploadpartsListValue.IsSetETag()) { xmlWriter.WriteElementString("ETag", "", S3Transforms.ToXmlStringValue(multipartUploadMultipartUploadpartsListValue.ETag)); } if (multipartUploadMultipartUploadpartsListValue.IsSetPartNumber()) { xmlWriter.WriteElementString("PartNumber", "", S3Transforms.ToXmlStringValue(multipartUploadMultipartUploadpartsListValue.PartNumber)); } xmlWriter.WriteEndElement(); } } xmlWriter.WriteEndElement(); } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <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); }
public IRequest Marshall(PutBucketIntelligentTieringConfigurationRequest PutBucketIntelligentTieringConfigurationRequest) { IRequest request = new DefaultRequest(PutBucketIntelligentTieringConfigurationRequest, "AmazonS3"); var intelligentTieringConfiguration = PutBucketIntelligentTieringConfigurationRequest.IntelligentTieringConfiguration; request.HttpMethod = "PUT"; if (string.IsNullOrEmpty(PutBucketIntelligentTieringConfigurationRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketIntelligentTieringConfigurationRequest.BucketName"); } if (intelligentTieringConfiguration == null) { throw new System.ArgumentException("IntelligentTieringConfiguration is a required property and must be set before making this call.", "PutBucketIntelligentTieringConfigurationRequest.IntelligentTieringConfiguration"); } if (string.IsNullOrEmpty(intelligentTieringConfiguration.IntelligentTieringId)) { throw new System.ArgumentException("IntelligentTieringId is a required property and must be set before making this call.", "IntelligentTieringConfiguration.IntelligentTieringId"); } if (string.IsNullOrEmpty(PutBucketIntelligentTieringConfigurationRequest.IntelligentTieringId)) { throw new System.ArgumentException("IntelligentTieringId is a required property and must be set before making this call.", "PutBucketIntelligentTieringConfigurationRequest.IntelligentTieringId"); } if (!intelligentTieringConfiguration.IsSetStatus()) { throw new System.ArgumentException("Status is a required property and must be set before making this call.", "IntelligentTieringConfiguration.Status"); } if (!intelligentTieringConfiguration.IsSetTieringList()) { throw new System.ArgumentException("TieringList is a required property and must be set before making this call.", "IntelligentTieringConfiguration.TieringList"); } request.ResourcePath = string.Concat("/", S3Transforms.ToStringValue(PutBucketIntelligentTieringConfigurationRequest.BucketName)); request.AddSubResource("intelligent-tiering"); request.AddSubResource("id", PutBucketIntelligentTieringConfigurationRequest.IntelligentTieringId); var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { if (intelligentTieringConfiguration != null) { xmlWriter.WriteStartElement("IntelligentTieringConfiguration", "http://s3.amazonaws.com/doc/2006-03-01/"); if (intelligentTieringConfiguration != null) { if (intelligentTieringConfiguration.IsSetIntelligentTieringId()) { xmlWriter.WriteElementString("Id", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(intelligentTieringConfiguration.IntelligentTieringId)); } if (intelligentTieringConfiguration.IsSetIntelligentTieringFilter()) { xmlWriter.WriteStartElement("Filter", "http://s3.amazonaws.com/doc/2006-03-01/"); var filterPredicate = intelligentTieringConfiguration.IntelligentTieringFilter.IntelligentTieringFilterPredicate; filterPredicate.Accept(new IntelligentTieringPredicateVisitor(xmlWriter)); xmlWriter.WriteEndElement(); } if (intelligentTieringConfiguration.IsSetStatus()) { xmlWriter.WriteElementString("Status", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(intelligentTieringConfiguration.Status)); } if (intelligentTieringConfiguration.IsSetTieringList()) { foreach (var tiering in intelligentTieringConfiguration.Tierings) { if (tiering != null) { xmlWriter.WriteStartElement("Tiering", "http://s3.amazonaws.com/doc/2006-03-01/"); xmlWriter.WriteElementString("Days", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(tiering.Days)); xmlWriter.WriteElementString("AccessTier", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(tiering.AccessTier)); xmlWriter.WriteEndElement(); } } } } xmlWriter.WriteEndElement(); } } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
public IRequest Marshall(PutACLRequest putObjectAclRequest) { IRequest request = new DefaultRequest(putObjectAclRequest, "AmazonS3"); request.HttpMethod = "PUT"; if (putObjectAclRequest.IsSetCannedACL()) { request.Headers.Add(HeaderKeys.XAmzAclHeader, S3Transforms.ToStringValue(putObjectAclRequest.CannedACL)); } if (putObjectAclRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putObjectAclRequest.ExpectedBucketOwner)); } if (string.IsNullOrEmpty(putObjectAclRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutACLRequest.BucketName"); } //Not checking if Key is null or empty because PutAcl allows to put an ACL for both a Bucket or an Object. TODO: deprecate PutAcl and create two separate operations // if we are putting the acl onto the bucket, the keyname component will collapse to empty string request.ResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(putObjectAclRequest.BucketName), S3Transforms.ToStringValue(putObjectAclRequest.Key)); request.AddSubResource("acl"); if (putObjectAclRequest.IsSetVersionId()) { request.AddSubResource("versionId", S3Transforms.ToStringValue(putObjectAclRequest.VersionId)); } var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using ( var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { var accessControlPolicyAccessControlPolicy = putObjectAclRequest.AccessControlList; if (accessControlPolicyAccessControlPolicy != null) { xmlWriter.WriteStartElement("AccessControlPolicy", ""); var accessControlPolicyAccessControlPolicygrantsList = accessControlPolicyAccessControlPolicy.Grants; if (accessControlPolicyAccessControlPolicygrantsList != null && accessControlPolicyAccessControlPolicygrantsList.Count > 0) { accessControlPolicyAccessControlPolicy.Marshall("AccessControlList", xmlWriter); var ownerOwner = accessControlPolicyAccessControlPolicy.Owner; if (ownerOwner != null) { xmlWriter.WriteStartElement("Owner", ""); if (ownerOwner.IsSetDisplayName()) { xmlWriter.WriteElementString("DisplayName", "", S3Transforms.ToXmlStringValue(ownerOwner.DisplayName)); } if (ownerOwner.IsSetId()) { xmlWriter.WriteElementString("ID", "", S3Transforms.ToXmlStringValue(ownerOwner.Id)); } xmlWriter.WriteEndElement(); } } xmlWriter.WriteEndElement(); } } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; string checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <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(CreateHealthCheckRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.Route53"); request.HttpMethod = "POST"; request.ResourcePath = "/2013-04-01/healthcheck"; 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("CreateHealthCheckRequest", "https://route53.amazonaws.com/doc/2013-04-01/"); if (publicRequest.IsSetCallerReference()) { xmlWriter.WriteElementString("CallerReference", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.CallerReference)); } if (publicRequest.HealthCheckConfig != null) { xmlWriter.WriteStartElement("HealthCheckConfig", "https://route53.amazonaws.com/doc/2013-04-01/"); if (publicRequest.HealthCheckConfig.IsSetIPAddress()) { xmlWriter.WriteElementString("IPAddress", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.HealthCheckConfig.IPAddress)); } if (publicRequest.HealthCheckConfig.IsSetPort()) { xmlWriter.WriteElementString("Port", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromInt(publicRequest.HealthCheckConfig.Port)); } if (publicRequest.HealthCheckConfig.IsSetType()) { xmlWriter.WriteElementString("Type", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.HealthCheckConfig.Type)); } if (publicRequest.HealthCheckConfig.IsSetResourcePath()) { xmlWriter.WriteElementString("ResourcePath", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.HealthCheckConfig.ResourcePath)); } if (publicRequest.HealthCheckConfig.IsSetFullyQualifiedDomainName()) { xmlWriter.WriteElementString("FullyQualifiedDomainName", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.HealthCheckConfig.FullyQualifiedDomainName)); } if (publicRequest.HealthCheckConfig.IsSetSearchString()) { xmlWriter.WriteElementString("SearchString", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.HealthCheckConfig.SearchString)); } if (publicRequest.HealthCheckConfig.IsSetRequestInterval()) { xmlWriter.WriteElementString("RequestInterval", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromInt(publicRequest.HealthCheckConfig.RequestInterval)); } if (publicRequest.HealthCheckConfig.IsSetFailureThreshold()) { xmlWriter.WriteElementString("FailureThreshold", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromInt(publicRequest.HealthCheckConfig.FailureThreshold)); } if (publicRequest.HealthCheckConfig.IsSetMeasureLatency()) { xmlWriter.WriteElementString("MeasureLatency", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromBool(publicRequest.HealthCheckConfig.MeasureLatency)); } if (publicRequest.HealthCheckConfig.IsSetInverted()) { xmlWriter.WriteElementString("Inverted", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromBool(publicRequest.HealthCheckConfig.Inverted)); } if (publicRequest.HealthCheckConfig.IsSetDisabled()) { xmlWriter.WriteElementString("Disabled", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromBool(publicRequest.HealthCheckConfig.Disabled)); } if (publicRequest.HealthCheckConfig.IsSetHealthThreshold()) { xmlWriter.WriteElementString("HealthThreshold", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromInt(publicRequest.HealthCheckConfig.HealthThreshold)); } var publicRequestHealthCheckConfigChildHealthChecks = publicRequest.HealthCheckConfig.ChildHealthChecks; if (publicRequestHealthCheckConfigChildHealthChecks != null && publicRequestHealthCheckConfigChildHealthChecks.Count > 0) { xmlWriter.WriteStartElement("ChildHealthChecks", "https://route53.amazonaws.com/doc/2013-04-01/"); foreach (var publicRequestHealthCheckConfigChildHealthChecksValue in publicRequestHealthCheckConfigChildHealthChecks) { xmlWriter.WriteStartElement("ChildHealthCheck", "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.WriteValue(publicRequestHealthCheckConfigChildHealthChecksValue); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (publicRequest.HealthCheckConfig.IsSetEnableSNI()) { xmlWriter.WriteElementString("EnableSNI", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromBool(publicRequest.HealthCheckConfig.EnableSNI)); } var publicRequestHealthCheckConfigRegions = publicRequest.HealthCheckConfig.Regions; if (publicRequestHealthCheckConfigRegions != null && publicRequestHealthCheckConfigRegions.Count > 0) { xmlWriter.WriteStartElement("Regions", "https://route53.amazonaws.com/doc/2013-04-01/"); foreach (var publicRequestHealthCheckConfigRegionsValue in publicRequestHealthCheckConfigRegions) { xmlWriter.WriteStartElement("Region", "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.WriteValue(publicRequestHealthCheckConfigRegionsValue); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (publicRequest.HealthCheckConfig.AlarmIdentifier != null) { xmlWriter.WriteStartElement("AlarmIdentifier", "https://route53.amazonaws.com/doc/2013-04-01/"); if (publicRequest.HealthCheckConfig.AlarmIdentifier.IsSetRegion()) { xmlWriter.WriteElementString("Region", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.HealthCheckConfig.AlarmIdentifier.Region)); } if (publicRequest.HealthCheckConfig.AlarmIdentifier.IsSetName()) { xmlWriter.WriteElementString("Name", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.HealthCheckConfig.AlarmIdentifier.Name)); } xmlWriter.WriteEndElement(); } if (publicRequest.HealthCheckConfig.IsSetInsufficientDataHealthStatus()) { xmlWriter.WriteElementString("InsufficientDataHealthStatus", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.HealthCheckConfig.InsufficientDataHealthStatus)); } if (publicRequest.HealthCheckConfig.IsSetRoutingControlArn()) { xmlWriter.WriteElementString("RoutingControlArn", "https://route53.amazonaws.com/doc/2013-04-01/", StringUtils.FromString(publicRequest.HealthCheckConfig.RoutingControlArn)); } 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] = "2013-04-01"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
public IRequest Marshall(PutBucketNotificationRequest putBucketNotificationRequest) { IRequest request = new DefaultRequest(putBucketNotificationRequest, "AmazonS3"); request.HttpMethod = "PUT"; if (putBucketNotificationRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putBucketNotificationRequest.ExpectedBucketOwner)); } if (putBucketNotificationRequest.IsSetSkipDestinationValidation()) { request.Headers[S3Constants.AmzHeaderSkipDestinationValidation] = StringUtils.FromBool(putBucketNotificationRequest.SkipDestinationValidation); } if (putBucketNotificationRequest.IsSetChecksumAlgorithm()) { request.Headers[S3Constants.AmzHeaderSdkChecksumAlgorithm] = S3Transforms.ToStringValue(putBucketNotificationRequest.ChecksumAlgorithm); } if (string.IsNullOrEmpty(putBucketNotificationRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketNotificationRequest.BucketName"); } request.ResourcePath = string.Concat("/", S3Transforms.ToStringValue(putBucketNotificationRequest.BucketName)); request.AddSubResource("notification"); var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { xmlWriter.WriteStartElement("NotificationConfiguration", ""); if (putBucketNotificationRequest.IsSetTopicConfigurations()) { foreach (var topicConfiguartion in putBucketNotificationRequest.TopicConfigurations) { if (topicConfiguartion != null) { xmlWriter.WriteStartElement("TopicConfiguration", ""); if (topicConfiguartion.IsSetId()) { xmlWriter.WriteElementString("Id", "", S3Transforms.ToXmlStringValue(topicConfiguartion.Id)); } if (topicConfiguartion.IsSetTopic()) { xmlWriter.WriteElementString("Topic", "", S3Transforms.ToXmlStringValue(topicConfiguartion.Topic)); } WriteConfigurationCommon(xmlWriter, topicConfiguartion); xmlWriter.WriteEndElement(); } } } if (putBucketNotificationRequest.IsSetQueueConfigurations()) { foreach (var queueConfiguartion in putBucketNotificationRequest.QueueConfigurations) { if (queueConfiguartion != null) { xmlWriter.WriteStartElement("QueueConfiguration", ""); if (queueConfiguartion.IsSetId()) { xmlWriter.WriteElementString("Id", "", S3Transforms.ToXmlStringValue(queueConfiguartion.Id)); } if (queueConfiguartion.IsSetQueue()) { xmlWriter.WriteElementString("Queue", "", S3Transforms.ToXmlStringValue(queueConfiguartion.Queue)); } WriteConfigurationCommon(xmlWriter, queueConfiguartion); xmlWriter.WriteEndElement(); } } } if (putBucketNotificationRequest.IsSetLambdaFunctionConfigurations()) { foreach (var lambdaFunctionConfiguartion in putBucketNotificationRequest.LambdaFunctionConfigurations) { if (lambdaFunctionConfiguartion != null) { xmlWriter.WriteStartElement("CloudFunctionConfiguration", ""); if (lambdaFunctionConfiguartion.IsSetId()) { xmlWriter.WriteElementString("Id", "", S3Transforms.ToXmlStringValue(lambdaFunctionConfiguartion.Id)); } if (lambdaFunctionConfiguartion.IsSetFunctionArn()) { xmlWriter.WriteElementString("CloudFunction", "", S3Transforms.ToXmlStringValue(lambdaFunctionConfiguartion.FunctionArn)); } WriteConfigurationCommon(xmlWriter, lambdaFunctionConfiguartion); xmlWriter.WriteEndElement(); } } } if (putBucketNotificationRequest.IsSetEventBridgeConfiguration()) { xmlWriter.WriteStartElement("EventBridgeConfiguration", "http://s3.amazonaws.com/doc/2006-03-01/"); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } try { var content = stringWriter.ToString(); request.Content = System.Text.Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; ChecksumUtils.SetRequestChecksum(request, putBucketNotificationRequest.ChecksumAlgorithm); } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <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); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(PutObjectRetentionRequest publicRequest) { var request = new DefaultRequest(publicRequest, "AmazonS3"); request.HttpMethod = "PUT"; string uriResourcePath = "/{Bucket}/{Key+}"; request.AddSubResource("retention"); if (publicRequest.IsSetBypassGovernanceRetention()) { request.Headers.Add("x-amz-bypass-governance-retention", S3Transforms.ToStringValue(publicRequest.BypassGovernanceRetention)); } if (publicRequest.IsSetContentMD5()) { request.Headers.Add(HeaderKeys.ContentMD5Header, S3Transforms.ToStringValue(publicRequest.ContentMD5)); } if (publicRequest.IsSetRequestPayer()) { request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(publicRequest.RequestPayer.ToString())); } if (publicRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(publicRequest.ExpectedBucketOwner)); } if (!publicRequest.IsSetBucketName()) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "publicRequest.BucketName"); } uriResourcePath = uriResourcePath.Replace("{Bucket}", StringUtils.FromString(publicRequest.BucketName)); if (!publicRequest.IsSetKey()) { throw new System.ArgumentException("Key is a required property and must be set before making this call.", "publicRequest.Key"); } uriResourcePath = uriResourcePath.Replace("{Key+}", StringUtils.FromString(publicRequest.Key)); if (publicRequest.IsSetVersionId()) { request.Parameters.Add("versionId", StringUtils.FromString(publicRequest.VersionId)); } request.ResourcePath = uriResourcePath; var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { if (publicRequest.IsSetRetention()) { xmlWriter.WriteStartElement("Retention", "http://s3.amazonaws.com/doc/2006-03-01/"); if (publicRequest.Retention.IsSetMode()) { xmlWriter.WriteElementString("Mode", "http://s3.amazonaws.com/doc/2006-03-01/", StringUtils.FromString(publicRequest.Retention.Mode)); } if (publicRequest.Retention.IsSetRetainUntilDate()) { xmlWriter.WriteElementString("RetainUntilDate", "http://s3.amazonaws.com/doc/2006-03-01/", StringUtils.FromDateTimeToISO8601(publicRequest.Retention.RetainUntilDate)); } xmlWriter.WriteEndElement(); } } try { string content = stringWriter.ToString(); request.Content = System.Text.Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } request.UseQueryString = true; return(request); }
public IRequest Marshall(SelectObjectContentRequest selectObjectContentRequest) { // Required Parameters // Bucket if (string.IsNullOrEmpty(selectObjectContentRequest.Bucket)) { throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.Bucket)); } // Key if (string.IsNullOrEmpty(selectObjectContentRequest.Key)) { throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.Key)); } // Expression if (string.IsNullOrEmpty(selectObjectContentRequest.Expression)) { throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.Expression)); } // ExpressionType if (!selectObjectContentRequest.IsSetExpressionType()) { throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.ExpressionType)); } // InputSerialization if (!selectObjectContentRequest.IsSetInputSerialization()) { throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.InputSerialization)); } // OutputSerialization if (!selectObjectContentRequest.IsSetOutputSerialization()) { throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.OutputSerialization)); } var request = new DefaultRequest(selectObjectContentRequest, "AmazonS3") { HttpMethod = "POST", ResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(selectObjectContentRequest.Bucket), S3Transforms.ToStringValue(selectObjectContentRequest.Key)), UseQueryString = true, }; // Headers if (selectObjectContentRequest.IsSetServerSideCustomerEncryptionMethod()) { request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, selectObjectContentRequest.ServerSideCustomerEncryptionMethod); } if (selectObjectContentRequest.IsSetServerSideEncryptionCustomerProvidedKey()) { request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyHeader, selectObjectContentRequest.ServerSideEncryptionCustomerProvidedKey); if (selectObjectContentRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5()) { request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, selectObjectContentRequest.ServerSideEncryptionCustomerProvidedKeyMD5); } else { request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(selectObjectContentRequest .ServerSideEncryptionCustomerProvidedKey)); } } if (selectObjectContentRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(selectObjectContentRequest.ExpectedBucketOwner)); } // Subresources request.AddSubResource("select"); request.AddSubResource("select-type", "2"); // Parameters using (var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture)) { var xmlWriterSettings = new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize }; using (var xmlWriter = XmlWriter.Create(stringWriter, xmlWriterSettings)) { xmlWriter.WriteStartElement("SelectRequest"); xmlWriter.WriteElementString("Expression", S3Transforms.ToXmlStringValue(selectObjectContentRequest.Expression)); xmlWriter.WriteElementString("ExpressionType", S3Transforms.ToXmlStringValue(selectObjectContentRequest.ExpressionType.Value)); selectObjectContentRequest.InputSerialization.Marshall("InputSerialization", xmlWriter); selectObjectContentRequest.OutputSerialization.Marshall("OutputSerialization", xmlWriter); xmlWriter.WriteStartElement("RequestProgress"); xmlWriter.WriteElementString("Enabled", selectObjectContentRequest.RequestProgress.GetValueOrDefault(false).ToString() .ToUpperInvariant()); xmlWriter.WriteEndElement(); if (selectObjectContentRequest.IsSetScanRange()) { selectObjectContentRequest.ScanRange.Marshall("ScanRange", xmlWriter); } xmlWriter.WriteEndElement(); } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } } return(request); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(CreateStreamingDistributionRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.CloudFront"); request.HttpMethod = "POST"; request.ResourcePath = "/2020-05-31/streaming-distribution"; var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { if (publicRequest.IsSetStreamingDistributionConfig()) { xmlWriter.WriteStartElement("StreamingDistributionConfig", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.StreamingDistributionConfig.Aliases != null) { xmlWriter.WriteStartElement("Aliases", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); var publicRequestStreamingDistributionConfigAliasesItems = publicRequest.StreamingDistributionConfig.Aliases.Items; if (publicRequestStreamingDistributionConfigAliasesItems != null && publicRequestStreamingDistributionConfigAliasesItems.Count > 0) { xmlWriter.WriteStartElement("Items", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); foreach (var publicRequestStreamingDistributionConfigAliasesItemsValue in publicRequestStreamingDistributionConfigAliasesItems) { xmlWriter.WriteStartElement("CNAME", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); xmlWriter.WriteValue(publicRequestStreamingDistributionConfigAliasesItemsValue); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (publicRequest.StreamingDistributionConfig.Aliases.IsSetQuantity()) { xmlWriter.WriteElementString("Quantity", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromInt(publicRequest.StreamingDistributionConfig.Aliases.Quantity)); } xmlWriter.WriteEndElement(); } if (publicRequest.StreamingDistributionConfig.IsSetCallerReference()) { xmlWriter.WriteElementString("CallerReference", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.StreamingDistributionConfig.CallerReference)); } if (publicRequest.StreamingDistributionConfig.IsSetComment()) { xmlWriter.WriteElementString("Comment", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.StreamingDistributionConfig.Comment)); } if (publicRequest.StreamingDistributionConfig.IsSetEnabled()) { xmlWriter.WriteElementString("Enabled", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromBool(publicRequest.StreamingDistributionConfig.Enabled)); } if (publicRequest.StreamingDistributionConfig.Logging != null) { xmlWriter.WriteStartElement("Logging", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.StreamingDistributionConfig.Logging.IsSetBucket()) { xmlWriter.WriteElementString("Bucket", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.StreamingDistributionConfig.Logging.Bucket)); } if (publicRequest.StreamingDistributionConfig.Logging.IsSetEnabled()) { xmlWriter.WriteElementString("Enabled", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromBool(publicRequest.StreamingDistributionConfig.Logging.Enabled)); } if (publicRequest.StreamingDistributionConfig.Logging.IsSetPrefix()) { xmlWriter.WriteElementString("Prefix", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.StreamingDistributionConfig.Logging.Prefix)); } xmlWriter.WriteEndElement(); } if (publicRequest.StreamingDistributionConfig.IsSetPriceClass()) { xmlWriter.WriteElementString("PriceClass", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.StreamingDistributionConfig.PriceClass)); } if (publicRequest.StreamingDistributionConfig.S3Origin != null) { xmlWriter.WriteStartElement("S3Origin", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.StreamingDistributionConfig.S3Origin.IsSetDomainName()) { xmlWriter.WriteElementString("DomainName", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.StreamingDistributionConfig.S3Origin.DomainName)); } if (publicRequest.StreamingDistributionConfig.S3Origin.IsSetOriginAccessIdentity()) { xmlWriter.WriteElementString("OriginAccessIdentity", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.StreamingDistributionConfig.S3Origin.OriginAccessIdentity)); } xmlWriter.WriteEndElement(); } if (publicRequest.StreamingDistributionConfig.TrustedSigners != null) { xmlWriter.WriteStartElement("TrustedSigners", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.StreamingDistributionConfig.TrustedSigners.IsSetEnabled()) { xmlWriter.WriteElementString("Enabled", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromBool(publicRequest.StreamingDistributionConfig.TrustedSigners.Enabled)); } var publicRequestStreamingDistributionConfigTrustedSignersItems = publicRequest.StreamingDistributionConfig.TrustedSigners.Items; if (publicRequestStreamingDistributionConfigTrustedSignersItems != null && publicRequestStreamingDistributionConfigTrustedSignersItems.Count > 0) { xmlWriter.WriteStartElement("Items", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); foreach (var publicRequestStreamingDistributionConfigTrustedSignersItemsValue in publicRequestStreamingDistributionConfigTrustedSignersItems) { xmlWriter.WriteStartElement("AwsAccountNumber", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); xmlWriter.WriteValue(publicRequestStreamingDistributionConfigTrustedSignersItemsValue); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (publicRequest.StreamingDistributionConfig.TrustedSigners.IsSetQuantity()) { xmlWriter.WriteElementString("Quantity", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromInt(publicRequest.StreamingDistributionConfig.TrustedSigners.Quantity)); } 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] = "2020-05-31"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
public IRequest Marshall(PutBucketReplicationRequest putBucketreplicationRequest) { IRequest request = new DefaultRequest(putBucketreplicationRequest, "AmazonS3"); request.HttpMethod = "PUT"; if (string.IsNullOrEmpty(putBucketreplicationRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketReplicationRequest.BucketName"); } request.ResourcePath = string.Concat("/", S3Transforms.ToStringValue(putBucketreplicationRequest.BucketName)); request.AddSubResource("replication"); if (putBucketreplicationRequest.IsSetToken()) { request.Headers.Add("x-amz-bucket-object-lock-token", putBucketreplicationRequest.Token); } if (putBucketreplicationRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putBucketreplicationRequest.ExpectedBucketOwner)); } var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { var replicationConfiguration = putBucketreplicationRequest.Configuration; if (replicationConfiguration != null) { xmlWriter.WriteStartElement("ReplicationConfiguration", ""); if (replicationConfiguration.Role != null) { xmlWriter.WriteElementString("Role", "", S3Transforms.ToXmlStringValue(replicationConfiguration.Role)); } if (replicationConfiguration.Rules != null) { foreach (var rule in replicationConfiguration.Rules) { xmlWriter.WriteStartElement("Rule"); if (rule.IsSetId()) { xmlWriter.WriteElementString("ID", "", S3Transforms.ToXmlStringValue(rule.Id)); } if (rule.IsSetPriority()) { xmlWriter.WriteElementString("Priority", "", S3Transforms.ToXmlStringValue(rule.Priority)); } if (rule.IsSetPrefix()) { xmlWriter.WriteElementString("Prefix", "", S3Transforms.ToXmlStringValue(rule.Prefix)); } if (rule.IsSetFilter()) { xmlWriter.WriteStartElement("Filter", ""); if (rule.Filter.IsSetPrefix()) { xmlWriter.WriteElementString("Prefix", "", S3Transforms.ToXmlStringValue(rule.Filter.Prefix)); } if (rule.Filter.IsSetTag()) { rule.Filter.Tag.Marshall("Tag", xmlWriter); } if (rule.Filter.IsSetAnd()) { xmlWriter.WriteStartElement("And"); if (rule.Filter.And.IsSetPrefix()) { xmlWriter.WriteElementString("Prefix", "", S3Transforms.ToXmlStringValue(rule.Filter.And.Prefix)); } if (rule.Filter.And.IsSetTags()) { foreach (var tag in rule.Filter.And.Tags) { tag.Marshall("Tag", xmlWriter); } } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (rule.IsSetStatus()) { xmlWriter.WriteElementString("Status", "", S3Transforms.ToXmlStringValue(rule.Status.ToString())); } if (rule.IsSetSourceSelectionCriteria()) { xmlWriter.WriteStartElement("SourceSelectionCriteria"); if (rule.SourceSelectionCriteria.IsSetSseKmsEncryptedObjects()) { xmlWriter.WriteStartElement("SseKmsEncryptedObjects"); if (rule.SourceSelectionCriteria.SseKmsEncryptedObjects.IsSetSseKmsEncryptedObjectsStatus()) { xmlWriter.WriteElementString("Status", "", rule.SourceSelectionCriteria.SseKmsEncryptedObjects.SseKmsEncryptedObjectsStatus); } xmlWriter.WriteEndElement(); } if (rule.SourceSelectionCriteria.IsSetReplicaModifications()) { xmlWriter.WriteStartElement("ReplicaModifications"); if (rule.SourceSelectionCriteria.ReplicaModifications.IsSetStatus()) { xmlWriter.WriteElementString("Status", "", rule.SourceSelectionCriteria.ReplicaModifications.Status); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (rule.IsSetExistingObjectReplication()) { xmlWriter.WriteStartElement("ExistingObjectReplication"); if (rule.ExistingObjectReplication.IsSetExistingObjectReplicationStatus()) { xmlWriter.WriteElementString("Status", "", rule.ExistingObjectReplication.Status); } xmlWriter.WriteEndElement(); } if (rule.IsSetDeleteMarkerReplication()) { xmlWriter.WriteStartElement("DeleteMarkerReplication"); if (rule.DeleteMarkerReplication.IsSetStatus()) { xmlWriter.WriteElementString("Status", "", rule.DeleteMarkerReplication.Status); } xmlWriter.WriteEndElement(); } if (rule.IsSetDestination()) { xmlWriter.WriteStartElement("Destination", ""); if (rule.Destination.IsSetBucketArn()) { xmlWriter.WriteElementString("Bucket", "", rule.Destination.BucketArn); } if (rule.Destination.IsSetStorageClass()) { xmlWriter.WriteElementString("StorageClass", "", rule.Destination.StorageClass); } if (rule.Destination.IsSetAccountId()) { xmlWriter.WriteElementString("Account", "", S3Transforms.ToXmlStringValue(rule.Destination.AccountId)); } if (rule.Destination.IsSetEncryptionConfiguration()) { xmlWriter.WriteStartElement("EncryptionConfiguration"); if (rule.Destination.EncryptionConfiguration.isSetReplicaKmsKeyID()) { xmlWriter.WriteElementString("ReplicaKmsKeyID", "", S3Transforms.ToXmlStringValue(rule.Destination.EncryptionConfiguration.ReplicaKmsKeyID)); } xmlWriter.WriteEndElement(); } if (rule.Destination.IsSetMetrics()) { xmlWriter.WriteStartElement("Metrics"); if (rule.Destination.Metrics.IsSetStatus()) { xmlWriter.WriteElementString("Status", "", S3Transforms.ToXmlStringValue(rule.Destination.Metrics.Status)); } if (rule.Destination.Metrics.IsSetEventThreshold()) { xmlWriter.WriteStartElement("EventThreshold"); if (rule.Destination.Metrics.EventThreshold.IsSetMinutes()) { xmlWriter.WriteElementString("Minutes", "", S3Transforms.ToXmlStringValue(rule.Destination.Metrics.EventThreshold.Minutes)); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (rule.Destination.IsSetReplicationTime()) { xmlWriter.WriteStartElement("ReplicationTime"); if (rule.Destination.ReplicationTime.IsSetStatus()) { xmlWriter.WriteElementString("Status", "", S3Transforms.ToXmlStringValue(rule.Destination.ReplicationTime.Status)); } if (rule.Destination.ReplicationTime.IsSetTime()) { xmlWriter.WriteStartElement("Time"); if (rule.Destination.ReplicationTime.Time.IsSetMinutes()) { xmlWriter.WriteElementString("Minutes", "", S3Transforms.ToXmlStringValue(rule.Destination.ReplicationTime.Time.Minutes)); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (rule.Destination.IsSetAccessControlTranslation()) { xmlWriter.WriteStartElement("AccessControlTranslation"); if (rule.Destination.AccessControlTranslation.IsSetOwner()) { xmlWriter.WriteElementString("Owner", "", S3Transforms.ToXmlStringValue(rule.Destination.AccessControlTranslation.Owner)); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } } xmlWriter.WriteEndElement(); } } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
public IRequest Marshall(PutCORSConfigurationRequest putCORSConfigurationRequest) { IRequest request = new DefaultRequest(putCORSConfigurationRequest, "AmazonS3"); request.HttpMethod = "PUT"; if (putCORSConfigurationRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putCORSConfigurationRequest.ExpectedBucketOwner)); } if (string.IsNullOrEmpty(putCORSConfigurationRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutCORSConfigurationRequest.BucketName"); } request.ResourcePath = string.Concat("/", S3Transforms.ToStringValue(putCORSConfigurationRequest.BucketName)); request.AddSubResource("cors"); var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { var configuration = putCORSConfigurationRequest.Configuration; if (configuration != null) { xmlWriter.WriteStartElement("CORSConfiguration", ""); if (configuration != null) { var cORSConfigurationCORSConfigurationcORSRulesList = configuration.Rules; if (cORSConfigurationCORSConfigurationcORSRulesList != null && cORSConfigurationCORSConfigurationcORSRulesList.Count > 0) { foreach (var cORSConfigurationCORSConfigurationcORSRulesListValue in cORSConfigurationCORSConfigurationcORSRulesList) { xmlWriter.WriteStartElement("CORSRule", ""); if (cORSConfigurationCORSConfigurationcORSRulesListValue != null) { var cORSRuleMemberallowedMethodsList = cORSConfigurationCORSConfigurationcORSRulesListValue.AllowedMethods; if (cORSRuleMemberallowedMethodsList != null && cORSRuleMemberallowedMethodsList.Count > 0) { foreach (string cORSRuleMemberallowedMethodsListValue in cORSRuleMemberallowedMethodsList) { xmlWriter.WriteStartElement("AllowedMethod", ""); xmlWriter.WriteValue(cORSRuleMemberallowedMethodsListValue); xmlWriter.WriteEndElement(); } } } if (cORSConfigurationCORSConfigurationcORSRulesListValue != null) { var cORSRuleMemberallowedOriginsList = cORSConfigurationCORSConfigurationcORSRulesListValue.AllowedOrigins; if (cORSRuleMemberallowedOriginsList != null && cORSRuleMemberallowedOriginsList.Count > 0) { foreach (string cORSRuleMemberallowedOriginsListValue in cORSRuleMemberallowedOriginsList) { xmlWriter.WriteStartElement("AllowedOrigin", ""); xmlWriter.WriteValue(cORSRuleMemberallowedOriginsListValue); xmlWriter.WriteEndElement(); } } } if (cORSConfigurationCORSConfigurationcORSRulesListValue != null) { var cORSRuleMemberexposeHeadersList = cORSConfigurationCORSConfigurationcORSRulesListValue.ExposeHeaders; if (cORSRuleMemberexposeHeadersList != null && cORSRuleMemberexposeHeadersList.Count > 0) { foreach (string cORSRuleMemberexposeHeadersListValue in cORSRuleMemberexposeHeadersList) { xmlWriter.WriteStartElement("ExposeHeader", ""); xmlWriter.WriteValue(cORSRuleMemberexposeHeadersListValue); xmlWriter.WriteEndElement(); } } } if (cORSConfigurationCORSConfigurationcORSRulesListValue != null) { var cORSRuleMemberallowedHeadersList = cORSConfigurationCORSConfigurationcORSRulesListValue.AllowedHeaders; if (cORSRuleMemberallowedHeadersList != null && cORSRuleMemberallowedHeadersList.Count > 0) { foreach (string cORSRuleMemberallowedHeadersListValue in cORSRuleMemberallowedHeadersList) { xmlWriter.WriteStartElement("AllowedHeader", ""); xmlWriter.WriteValue(cORSRuleMemberallowedHeadersListValue); xmlWriter.WriteEndElement(); } } } if (cORSConfigurationCORSConfigurationcORSRulesListValue.IsSetMaxAgeSeconds()) { xmlWriter.WriteElementString("MaxAgeSeconds", "", S3Transforms.ToXmlStringValue(cORSConfigurationCORSConfigurationcORSRulesListValue.MaxAgeSeconds)); } if (cORSConfigurationCORSConfigurationcORSRulesListValue.IsSetId()) { xmlWriter.WriteElementString("ID", "", S3Transforms.ToXmlStringValue(cORSConfigurationCORSConfigurationcORSRulesListValue.Id)); } xmlWriter.WriteEndElement(); } } } xmlWriter.WriteEndElement(); } } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(PutObjectLockConfigurationRequest publicRequest) { var request = new DefaultRequest(publicRequest, "AmazonS3"); request.HttpMethod = "PUT"; string uriResourcePath = "/{Bucket}"; request.AddSubResource("object-lock"); if (publicRequest.IsSetContentMD5()) { request.Headers.Add(HeaderKeys.ContentMD5Header, S3Transforms.ToStringValue(publicRequest.ContentMD5)); } if (publicRequest.IsSetRequestPayer()) { request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(publicRequest.RequestPayer.ToString())); } if (publicRequest.IsSetToken()) { request.Headers.Add("x-amz-bucket-object-lock-token", publicRequest.Token); } if (publicRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(publicRequest.ExpectedBucketOwner)); } if (!publicRequest.IsSetBucketName()) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "publicRequest.BucketName"); } uriResourcePath = uriResourcePath.Replace("{Bucket}", StringUtils.FromString(publicRequest.BucketName)); request.ResourcePath = uriResourcePath; var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { if (publicRequest.IsSetObjectLockConfiguration()) { xmlWriter.WriteStartElement("ObjectLockConfiguration", "http://s3.amazonaws.com/doc/2006-03-01/"); if (publicRequest.ObjectLockConfiguration.IsSetObjectLockEnabled()) { xmlWriter.WriteElementString("ObjectLockEnabled", "http://s3.amazonaws.com/doc/2006-03-01/", StringUtils.FromString(publicRequest.ObjectLockConfiguration.ObjectLockEnabled)); } if (publicRequest.ObjectLockConfiguration.Rule != null) { xmlWriter.WriteStartElement("Rule", "http://s3.amazonaws.com/doc/2006-03-01/"); if (publicRequest.ObjectLockConfiguration.Rule.DefaultRetention != null) { xmlWriter.WriteStartElement("DefaultRetention", "http://s3.amazonaws.com/doc/2006-03-01/"); if (publicRequest.ObjectLockConfiguration.Rule.DefaultRetention.IsSetDays()) { xmlWriter.WriteElementString("Days", "http://s3.amazonaws.com/doc/2006-03-01/", StringUtils.FromInt(publicRequest.ObjectLockConfiguration.Rule.DefaultRetention.Days)); } if (publicRequest.ObjectLockConfiguration.Rule.DefaultRetention.IsSetMode()) { xmlWriter.WriteElementString("Mode", "http://s3.amazonaws.com/doc/2006-03-01/", StringUtils.FromString(publicRequest.ObjectLockConfiguration.Rule.DefaultRetention.Mode)); } if (publicRequest.ObjectLockConfiguration.Rule.DefaultRetention.IsSetYears()) { xmlWriter.WriteElementString("Years", "http://s3.amazonaws.com/doc/2006-03-01/", StringUtils.FromInt(publicRequest.ObjectLockConfiguration.Rule.DefaultRetention.Years)); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } } try { string content = stringWriter.ToString(); request.Content = System.Text.Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
/// <summary> /// Marshaller the request object to the HTTP request. /// </summary> /// <param name="publicRequest"></param> /// <returns></returns> public IRequest Marshall(CreateInvalidationRequest publicRequest) { var request = new DefaultRequest(publicRequest, "Amazon.CloudFront"); request.HttpMethod = "POST"; if (!publicRequest.IsSetDistributionId()) { throw new AmazonCloudFrontException("Request object does not have required field DistributionId set"); } request.AddPathResource("{DistributionId}", StringUtils.FromString(publicRequest.DistributionId)); request.ResourcePath = "/2020-05-31/distribution/{DistributionId}/invalidation"; var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { if (publicRequest.IsSetInvalidationBatch()) { xmlWriter.WriteStartElement("InvalidationBatch", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); if (publicRequest.InvalidationBatch.IsSetCallerReference()) { xmlWriter.WriteElementString("CallerReference", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromString(publicRequest.InvalidationBatch.CallerReference)); } if (publicRequest.InvalidationBatch.Paths != null) { xmlWriter.WriteStartElement("Paths", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); var publicRequestInvalidationBatchPathsItems = publicRequest.InvalidationBatch.Paths.Items; if (publicRequestInvalidationBatchPathsItems != null && publicRequestInvalidationBatchPathsItems.Count > 0) { xmlWriter.WriteStartElement("Items", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); foreach (var publicRequestInvalidationBatchPathsItemsValue in publicRequestInvalidationBatchPathsItems) { xmlWriter.WriteStartElement("Path", "http://cloudfront.amazonaws.com/doc/2020-05-31/"); xmlWriter.WriteValue(publicRequestInvalidationBatchPathsItemsValue); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (publicRequest.InvalidationBatch.Paths.IsSetQuantity()) { xmlWriter.WriteElementString("Quantity", "http://cloudfront.amazonaws.com/doc/2020-05-31/", StringUtils.FromInt(publicRequest.InvalidationBatch.Paths.Quantity)); } 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] = "2020-05-31"; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
public IRequest Marshall(PutBucketLoggingRequest putBucketLoggingRequest) { IRequest request = new DefaultRequest(putBucketLoggingRequest, "AmazonS3"); request.HttpMethod = "PUT"; if (putBucketLoggingRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putBucketLoggingRequest.ExpectedBucketOwner)); } if (string.IsNullOrEmpty(putBucketLoggingRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketLoggingRequest.BucketName"); } request.ResourcePath = string.Concat("/", S3Transforms.ToStringValue(putBucketLoggingRequest.BucketName)); request.AddSubResource("logging"); var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { xmlWriter.WriteStartElement("BucketLoggingStatus", ""); var bucketLoggingStatusBucketLoggingStatus = putBucketLoggingRequest.LoggingConfig; if (bucketLoggingStatusBucketLoggingStatus != null) { if (bucketLoggingStatusBucketLoggingStatus != null) { var loggingEnabledLoggingEnabled = bucketLoggingStatusBucketLoggingStatus; if (loggingEnabledLoggingEnabled != null && loggingEnabledLoggingEnabled.IsSetTargetBucket()) { xmlWriter.WriteStartElement("LoggingEnabled", ""); xmlWriter.WriteElementString("TargetBucket", "", S3Transforms.ToXmlStringValue(loggingEnabledLoggingEnabled.TargetBucketName)); var loggingEnabledLoggingEnabledtargetGrantsList = loggingEnabledLoggingEnabled.Grants; if (loggingEnabledLoggingEnabledtargetGrantsList != null && loggingEnabledLoggingEnabledtargetGrantsList.Count > 0) { xmlWriter.WriteStartElement("TargetGrants", ""); foreach (var loggingEnabledLoggingEnabledtargetGrantsListValue in loggingEnabledLoggingEnabledtargetGrantsList) { xmlWriter.WriteStartElement("Grant", ""); if (loggingEnabledLoggingEnabledtargetGrantsListValue != null) { var granteeGrantee = loggingEnabledLoggingEnabledtargetGrantsListValue.Grantee; if (granteeGrantee != null) { xmlWriter.WriteStartElement("Grantee", ""); if (granteeGrantee.IsSetType()) { xmlWriter.WriteAttributeString("xsi", "type", "http://www.w3.org/2001/XMLSchema-instance", granteeGrantee.Type.ToString()); } if (granteeGrantee.IsSetDisplayName()) { xmlWriter.WriteElementString("DisplayName", "", S3Transforms.ToXmlStringValue(granteeGrantee.DisplayName)); } if (granteeGrantee.IsSetEmailAddress()) { xmlWriter.WriteElementString("EmailAddress", "", S3Transforms.ToXmlStringValue(granteeGrantee.EmailAddress)); } if (granteeGrantee.IsSetCanonicalUser()) { xmlWriter.WriteElementString("ID", "", S3Transforms.ToXmlStringValue(granteeGrantee.CanonicalUser)); } if (granteeGrantee.IsSetURI()) { xmlWriter.WriteElementString("URI", "", S3Transforms.ToXmlStringValue(granteeGrantee.URI)); } xmlWriter.WriteEndElement(); } if (loggingEnabledLoggingEnabledtargetGrantsListValue.IsSetPermission()) { xmlWriter.WriteElementString("Permission", "", S3Transforms.ToXmlStringValue(loggingEnabledLoggingEnabledtargetGrantsListValue.Permission)); } } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } if (loggingEnabledLoggingEnabled.IsSetTargetPrefix()) { xmlWriter.WriteElementString("TargetPrefix", "", S3Transforms.ToXmlStringValue(loggingEnabledLoggingEnabled.TargetPrefix)); } else { xmlWriter.WriteStartElement("TargetPrefix"); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } } } xmlWriter.WriteEndElement(); } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }
public IRequest Marshall(PutBucketAnalyticsConfigurationRequest putBucketAnalyticsConfigurationRequest) { IRequest request = new DefaultRequest(putBucketAnalyticsConfigurationRequest, "AmazonS3"); request.HttpMethod = "PUT"; if (putBucketAnalyticsConfigurationRequest.IsSetExpectedBucketOwner()) { request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putBucketAnalyticsConfigurationRequest.ExpectedBucketOwner)); } if (string.IsNullOrEmpty(putBucketAnalyticsConfigurationRequest.BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutBucketAnalyticsConfigurationRequest.BucketName"); } request.ResourcePath = string.Concat("/", S3Transforms.ToStringValue(putBucketAnalyticsConfigurationRequest.BucketName)); request.AddSubResource("analytics"); if (putBucketAnalyticsConfigurationRequest.IsSetAnalyticsId()) { request.AddSubResource("id", S3Transforms.ToStringValue(putBucketAnalyticsConfigurationRequest.AnalyticsId)); } var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize })) { if (putBucketAnalyticsConfigurationRequest.IsSetAnalyticsConfiguration()) { var analyticsConfiguration = putBucketAnalyticsConfigurationRequest.AnalyticsConfiguration; xmlWriter.WriteStartElement("AnalyticsConfiguration", "http://s3.amazonaws.com/doc/2006-03-01/"); if (analyticsConfiguration.IsSetAnalyticsId()) { xmlWriter.WriteElementString("Id", "http://s3.amazonaws.com/doc/2006-03-01/", analyticsConfiguration.AnalyticsId); } if (analyticsConfiguration.IsSetAnalyticsFilter()) { xmlWriter.WriteStartElement("Filter", "http://s3.amazonaws.com/doc/2006-03-01/"); var predicate = analyticsConfiguration.AnalyticsFilter.AnalyticsFilterPredicate; predicate.Accept(new AnalyticsPredicateVisitor(xmlWriter)); xmlWriter.WriteEndElement(); } if (analyticsConfiguration.IsSetStorageClassAnalysis()) { if (analyticsConfiguration.IsSetStorageClassAnalysis()) { StorageClassAnalysis storageClassAnalysis = analyticsConfiguration.StorageClassAnalysis; xmlWriter.WriteStartElement("StorageClassAnalysis", "http://s3.amazonaws.com/doc/2006-03-01/"); if (storageClassAnalysis.IsSetDataExport()) { xmlWriter.WriteStartElement("DataExport", "http://s3.amazonaws.com/doc/2006-03-01/"); StorageClassAnalysisDataExport storageClassAnalysisDataExport = storageClassAnalysis.DataExport; if (storageClassAnalysisDataExport.IsSetOutputSchemaVersion()) { StorageClassAnalysisSchemaVersion storageClassAnalysisSchemaVersion = storageClassAnalysisDataExport.OutputSchemaVersion; if (storageClassAnalysisSchemaVersion != null) { xmlWriter.WriteElementString("OutputSchemaVersion", "http://s3.amazonaws.com/doc/2006-03-01/", storageClassAnalysisSchemaVersion); } } if (storageClassAnalysisDataExport.IsSetDestination()) { xmlWriter.WriteStartElement("Destination", "http://s3.amazonaws.com/doc/2006-03-01/"); AnalyticsExportDestination analyticsExportDestination = storageClassAnalysisDataExport.Destination; if (analyticsExportDestination.IsSetS3BucketDestination()) { xmlWriter.WriteStartElement("S3BucketDestination", "http://s3.amazonaws.com/doc/2006-03-01/"); AnalyticsS3BucketDestination analyticsS3BucketDestination = analyticsExportDestination.S3BucketDestination; if (analyticsS3BucketDestination.IsSetFormat()) { xmlWriter.WriteElementString("Format", "http://s3.amazonaws.com/doc/2006-03-01/", analyticsS3BucketDestination.Format); } if (analyticsS3BucketDestination.IsSetBucketAccountId()) { xmlWriter.WriteElementString("BucketAccountId", "http://s3.amazonaws.com/doc/2006-03-01/", analyticsS3BucketDestination.BucketAccountId); } if (analyticsS3BucketDestination.IsSetBucketName()) { xmlWriter.WriteElementString("Bucket", "http://s3.amazonaws.com/doc/2006-03-01/", analyticsS3BucketDestination.BucketName); } if (analyticsS3BucketDestination.IsSetPrefix()) { xmlWriter.WriteElementString("Prefix", "http://s3.amazonaws.com/doc/2006-03-01/", analyticsS3BucketDestination.Prefix); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } } xmlWriter.WriteEndElement(); } } try { var content = stringWriter.ToString(); request.Content = Encoding.UTF8.GetBytes(content); request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml"; var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true); request.Headers[HeaderKeys.ContentMD5Header] = checksum; } catch (EncoderFallbackException e) { throw new AmazonServiceException("Unable to marshall request to XML", e); } return(request); }