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); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.S3.Model.PutACLRequest(); // populate AccessControlList var requestAccessControlListIsNull = true; request.AccessControlList = new Amazon.S3.Model.S3AccessControlList(); List <Amazon.S3.Model.S3Grant> requestAccessControlList_accessControlList_Grant = null; if (cmdletContext.AccessControlList_Grant != null) { requestAccessControlList_accessControlList_Grant = cmdletContext.AccessControlList_Grant; } if (requestAccessControlList_accessControlList_Grant != null) { request.AccessControlList.Grants = requestAccessControlList_accessControlList_Grant; requestAccessControlListIsNull = false; } Amazon.S3.Model.Owner requestAccessControlList_accessControlList_Owner = null; // populate Owner var requestAccessControlList_accessControlList_OwnerIsNull = true; requestAccessControlList_accessControlList_Owner = new Amazon.S3.Model.Owner(); System.String requestAccessControlList_accessControlList_Owner_owner_DisplayName = null; if (cmdletContext.Owner_DisplayName != null) { requestAccessControlList_accessControlList_Owner_owner_DisplayName = cmdletContext.Owner_DisplayName; } if (requestAccessControlList_accessControlList_Owner_owner_DisplayName != null) { requestAccessControlList_accessControlList_Owner.DisplayName = requestAccessControlList_accessControlList_Owner_owner_DisplayName; requestAccessControlList_accessControlList_OwnerIsNull = false; } System.String requestAccessControlList_accessControlList_Owner_owner_Id = null; if (cmdletContext.Owner_Id != null) { requestAccessControlList_accessControlList_Owner_owner_Id = cmdletContext.Owner_Id; } if (requestAccessControlList_accessControlList_Owner_owner_Id != null) { requestAccessControlList_accessControlList_Owner.Id = requestAccessControlList_accessControlList_Owner_owner_Id; requestAccessControlList_accessControlList_OwnerIsNull = false; } // determine if requestAccessControlList_accessControlList_Owner should be set to null if (requestAccessControlList_accessControlList_OwnerIsNull) { requestAccessControlList_accessControlList_Owner = null; } if (requestAccessControlList_accessControlList_Owner != null) { request.AccessControlList.Owner = requestAccessControlList_accessControlList_Owner; requestAccessControlListIsNull = false; } // determine if request.AccessControlList should be set to null if (requestAccessControlListIsNull) { request.AccessControlList = null; } if (cmdletContext.CannedACL != null) { request.CannedACL = cmdletContext.CannedACL; } if (cmdletContext.BucketName != null) { request.BucketName = cmdletContext.BucketName; } if (cmdletContext.ExpectedBucketOwner != null) { request.ExpectedBucketOwner = cmdletContext.ExpectedBucketOwner; } if (cmdletContext.Key != null) { request.Key = cmdletContext.Key; } if (cmdletContext.VersionId != null) { request.VersionId = cmdletContext.VersionId; } 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); }
/// <summary> /// Sets the owner of the bucket or object. /// </summary> /// <param name="owner">Owner property</param> /// <returns>this instance</returns> public S3AccessControlList WithOwner(Owner owner) { this.owner = owner; return this; }