Exemple #1
0
 private Amazon.S3.Model.PutObjectLegalHoldResponse CallAWSServiceOperation(IAmazonS3 client, Amazon.S3.Model.PutObjectLegalHoldRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Storage Service (S3)", "PutObjectLegalHold");
     try
     {
         #if DESKTOP
         return(client.PutObjectLegalHold(request));
         #elif CORECLR
         return(client.PutObjectLegalHoldAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
Exemple #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.S3.Model.PutObjectLegalHoldRequest();

            if (cmdletContext.BucketName != null)
            {
                request.BucketName = cmdletContext.BucketName;
            }
            if (cmdletContext.ContentMD5 != null)
            {
                request.ContentMD5 = cmdletContext.ContentMD5;
            }
            if (cmdletContext.Key != null)
            {
                request.Key = cmdletContext.Key;
            }

            // populate LegalHold
            var requestLegalHoldIsNull = true;

            request.LegalHold = new Amazon.S3.Model.ObjectLockLegalHold();
            Amazon.S3.ObjectLockLegalHoldStatus requestLegalHold_legalHold_Status = null;
            if (cmdletContext.LegalHold_Status != null)
            {
                requestLegalHold_legalHold_Status = cmdletContext.LegalHold_Status;
            }
            if (requestLegalHold_legalHold_Status != null)
            {
                request.LegalHold.Status = requestLegalHold_legalHold_Status;
                requestLegalHoldIsNull   = false;
            }
            // determine if request.LegalHold should be set to null
            if (requestLegalHoldIsNull)
            {
                request.LegalHold = null;
            }
            if (cmdletContext.RequestPayer != null)
            {
                request.RequestPayer = cmdletContext.RequestPayer;
            }
            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);
        }