internal void Marshall(string memberName, XmlWriter xmlWriter) { if (string.IsNullOrEmpty(BucketName)) { throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "S3Location.BucketName"); } if (string.IsNullOrEmpty(Prefix)) { throw new System.ArgumentException("Prefix is a required property and must be set before making this call.", "S3Location.Prefix"); } xmlWriter.WriteStartElement(memberName); { xmlWriter.WriteElementString("BucketName", S3Transforms.ToXmlStringValue(BucketName)); xmlWriter.WriteElementString("Prefix", S3Transforms.ToXmlStringValue(Prefix)); if (IsSetEncryption()) { Encryption.Marshall("Encryption", xmlWriter); } if (IsSetCannedACL()) { xmlWriter.WriteElementString("CannedACL", S3Transforms.ToXmlStringValue(CannedACL.Value)); } if (IsSetAccessControlList()) { AccessControlList.Marshall("AccessControlList", xmlWriter); } if (IsSetTagging()) { Tagging.Marshall("Tagging", xmlWriter); } if (IsSetUserMetadata()) { UserMetadata.Marshall("UserMetadata", xmlWriter); } if (IsSetStorageClass()) { xmlWriter.WriteElementString("StorageClass", S3Transforms.ToXmlStringValue(StorageClass.Value)); } } xmlWriter.WriteEndElement(); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.S3.Model.RestoreObjectRequest(); if (cmdletContext.BucketName != null) { request.BucketName = cmdletContext.BucketName; } if (cmdletContext.Key != null) { request.Key = cmdletContext.Key; } if (cmdletContext.CopyLifetimeInDays != null) { request.Days = cmdletContext.CopyLifetimeInDays.Value; } if (cmdletContext.VersionId != null) { request.VersionId = cmdletContext.VersionId; } if (cmdletContext.RequestPayer != null) { request.RequestPayer = cmdletContext.RequestPayer; } if (cmdletContext.Tier != null) { request.Tier = cmdletContext.Tier; } if (cmdletContext.RetrievalTier != null) { request.RetrievalTier = cmdletContext.RetrievalTier; } if (cmdletContext.RestoreRequestType != null) { request.RestoreRequestType = cmdletContext.RestoreRequestType; } if (cmdletContext.Description != null) { request.Description = cmdletContext.Description; } if (cmdletContext.SelectParameter != null) { request.SelectParameters = cmdletContext.SelectParameter; } // populate OutputLocation var requestOutputLocationIsNull = true; request.OutputLocation = new Amazon.S3.Model.OutputLocation(); Amazon.S3.Model.S3Location requestOutputLocation_outputLocation_S3 = null; // populate S3 var requestOutputLocation_outputLocation_S3IsNull = true; requestOutputLocation_outputLocation_S3 = new Amazon.S3.Model.S3Location(); System.String requestOutputLocation_outputLocation_S3_s3_BucketName = null; if (cmdletContext.S3_BucketName != null) { requestOutputLocation_outputLocation_S3_s3_BucketName = cmdletContext.S3_BucketName; } if (requestOutputLocation_outputLocation_S3_s3_BucketName != null) { requestOutputLocation_outputLocation_S3.BucketName = requestOutputLocation_outputLocation_S3_s3_BucketName; requestOutputLocation_outputLocation_S3IsNull = false; } System.String requestOutputLocation_outputLocation_S3_s3_Prefix = null; if (cmdletContext.S3_Prefix != null) { requestOutputLocation_outputLocation_S3_s3_Prefix = cmdletContext.S3_Prefix; } if (requestOutputLocation_outputLocation_S3_s3_Prefix != null) { requestOutputLocation_outputLocation_S3.Prefix = requestOutputLocation_outputLocation_S3_s3_Prefix; requestOutputLocation_outputLocation_S3IsNull = false; } Amazon.S3.S3CannedACL requestOutputLocation_outputLocation_S3_s3_CannedACL = null; if (cmdletContext.S3_CannedACL != null) { requestOutputLocation_outputLocation_S3_s3_CannedACL = cmdletContext.S3_CannedACL; } if (requestOutputLocation_outputLocation_S3_s3_CannedACL != null) { requestOutputLocation_outputLocation_S3.CannedACL = requestOutputLocation_outputLocation_S3_s3_CannedACL; requestOutputLocation_outputLocation_S3IsNull = false; } Amazon.S3.Model.MetadataCollection requestOutputLocation_outputLocation_S3_s3_UserMetadata = null; if (cmdletContext.S3_UserMetadata != null) { requestOutputLocation_outputLocation_S3_s3_UserMetadata = cmdletContext.S3_UserMetadata; } if (requestOutputLocation_outputLocation_S3_s3_UserMetadata != null) { requestOutputLocation_outputLocation_S3.UserMetadata = requestOutputLocation_outputLocation_S3_s3_UserMetadata; requestOutputLocation_outputLocation_S3IsNull = false; } Amazon.S3.S3StorageClass requestOutputLocation_outputLocation_S3_s3_StorageClass = null; if (cmdletContext.S3_StorageClass != null) { requestOutputLocation_outputLocation_S3_s3_StorageClass = cmdletContext.S3_StorageClass; } if (requestOutputLocation_outputLocation_S3_s3_StorageClass != null) { requestOutputLocation_outputLocation_S3.StorageClass = requestOutputLocation_outputLocation_S3_s3_StorageClass; requestOutputLocation_outputLocation_S3IsNull = false; } Amazon.S3.Model.Tagging requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging = null; // populate Tagging var requestOutputLocation_outputLocation_S3_outputLocation_S3_TaggingIsNull = true; requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging = new Amazon.S3.Model.Tagging(); List <Amazon.S3.Model.Tag> requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging_tagging_TagSet = null; if (cmdletContext.Tagging_TagSet != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging_tagging_TagSet = cmdletContext.Tagging_TagSet; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging_tagging_TagSet != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging.TagSet = requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging_tagging_TagSet; requestOutputLocation_outputLocation_S3_outputLocation_S3_TaggingIsNull = false; } // determine if requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging should be set to null if (requestOutputLocation_outputLocation_S3_outputLocation_S3_TaggingIsNull) { requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging = null; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging != null) { requestOutputLocation_outputLocation_S3.Tagging = requestOutputLocation_outputLocation_S3_outputLocation_S3_Tagging; requestOutputLocation_outputLocation_S3IsNull = false; } Amazon.S3.Model.S3AccessControlList requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList = null; // populate AccessControlList var requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlListIsNull = true; requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList = new Amazon.S3.Model.S3AccessControlList(); List <Amazon.S3.Model.S3Grant> requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_accessControlList_Grant = null; if (cmdletContext.AccessControlList_Grant != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_accessControlList_Grant = cmdletContext.AccessControlList_Grant; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_accessControlList_Grant != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList.Grants = requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_accessControlList_Grant; requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlListIsNull = false; } Amazon.S3.Model.Owner requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner = null; // populate Owner var requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_OwnerIsNull = true; requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner = new Amazon.S3.Model.Owner(); System.String requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner_owner_DisplayName = null; if (cmdletContext.Owner_DisplayName != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner_owner_DisplayName = cmdletContext.Owner_DisplayName; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner_owner_DisplayName != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner.DisplayName = requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner_owner_DisplayName; requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_OwnerIsNull = false; } System.String requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner_owner_Id = null; if (cmdletContext.Owner_Id != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner_owner_Id = cmdletContext.Owner_Id; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner_owner_Id != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner.Id = requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner_owner_Id; requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_OwnerIsNull = false; } // determine if requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner should be set to null if (requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_OwnerIsNull) { requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner = null; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList.Owner = requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList_outputLocation_S3_AccessControlList_Owner; requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlListIsNull = false; } // determine if requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList should be set to null if (requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlListIsNull) { requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList = null; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList != null) { requestOutputLocation_outputLocation_S3.AccessControlList = requestOutputLocation_outputLocation_S3_outputLocation_S3_AccessControlList; requestOutputLocation_outputLocation_S3IsNull = false; } Amazon.S3.Model.S3Encryption requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption = null; // populate Encryption var requestOutputLocation_outputLocation_S3_outputLocation_S3_EncryptionIsNull = true; requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption = new Amazon.S3.Model.S3Encryption(); Amazon.S3.ServerSideEncryptionMethod requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_EncryptionType = null; if (cmdletContext.Encryption_EncryptionType != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_EncryptionType = cmdletContext.Encryption_EncryptionType; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_EncryptionType != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption.EncryptionType = requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_EncryptionType; requestOutputLocation_outputLocation_S3_outputLocation_S3_EncryptionIsNull = false; } System.String requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_KMSKeyId = null; if (cmdletContext.Encryption_KMSKeyId != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_KMSKeyId = cmdletContext.Encryption_KMSKeyId; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_KMSKeyId != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption.KMSKeyId = requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_KMSKeyId; requestOutputLocation_outputLocation_S3_outputLocation_S3_EncryptionIsNull = false; } System.String requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_KMSContext = null; if (cmdletContext.Encryption_KMSContext != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_KMSContext = cmdletContext.Encryption_KMSContext; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_KMSContext != null) { requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption.KMSContext = requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption_encryption_KMSContext; requestOutputLocation_outputLocation_S3_outputLocation_S3_EncryptionIsNull = false; } // determine if requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption should be set to null if (requestOutputLocation_outputLocation_S3_outputLocation_S3_EncryptionIsNull) { requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption = null; } if (requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption != null) { requestOutputLocation_outputLocation_S3.Encryption = requestOutputLocation_outputLocation_S3_outputLocation_S3_Encryption; requestOutputLocation_outputLocation_S3IsNull = false; } // determine if requestOutputLocation_outputLocation_S3 should be set to null if (requestOutputLocation_outputLocation_S3IsNull) { requestOutputLocation_outputLocation_S3 = null; } if (requestOutputLocation_outputLocation_S3 != null) { request.OutputLocation.S3 = requestOutputLocation_outputLocation_S3; requestOutputLocationIsNull = false; } // determine if request.OutputLocation should be set to null if (requestOutputLocationIsNull) { request.OutputLocation = null; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); }
internal static string SerializeTaggingToXml(Tagging tagging) { var stringWriter = new StringWriter(CultureInfo.InvariantCulture); using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true })) { xmlWriter.WriteStartElement("Tagging", ""); SerializeTagSetToXml(xmlWriter, tagging.TagSet); xmlWriter.WriteEndElement(); } return stringWriter.ToString(); }