Ejemplo n.º 1
0
 private Amazon.S3.Model.PutObjectLockConfigurationResponse CallAWSServiceOperation(IAmazonS3 client, Amazon.S3.Model.PutObjectLockConfigurationRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Storage Service (S3)", "PutObjectLockConfiguration");
     try
     {
         #if DESKTOP
         return(client.PutObjectLockConfiguration(request));
         #elif CORECLR
         return(client.PutObjectLockConfigurationAsync(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;
     }
 }
Ejemplo n.º 2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.S3.Model.PutObjectLockConfigurationRequest();

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

            // populate ObjectLockConfiguration
            var requestObjectLockConfigurationIsNull = true;

            request.ObjectLockConfiguration = new Amazon.S3.Model.ObjectLockConfiguration();
            Amazon.S3.ObjectLockEnabled requestObjectLockConfiguration_objectLockConfiguration_ObjectLockEnabled = null;
            if (cmdletContext.ObjectLockConfiguration_ObjectLockEnabled != null)
            {
                requestObjectLockConfiguration_objectLockConfiguration_ObjectLockEnabled = cmdletContext.ObjectLockConfiguration_ObjectLockEnabled;
            }
            if (requestObjectLockConfiguration_objectLockConfiguration_ObjectLockEnabled != null)
            {
                request.ObjectLockConfiguration.ObjectLockEnabled = requestObjectLockConfiguration_objectLockConfiguration_ObjectLockEnabled;
                requestObjectLockConfigurationIsNull = false;
            }
            Amazon.S3.Model.ObjectLockRule requestObjectLockConfiguration_objectLockConfiguration_Rule = null;

            // populate Rule
            var requestObjectLockConfiguration_objectLockConfiguration_RuleIsNull = true;

            requestObjectLockConfiguration_objectLockConfiguration_Rule = new Amazon.S3.Model.ObjectLockRule();
            Amazon.S3.Model.DefaultRetention requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention = null;

            // populate DefaultRetention
            var requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetentionIsNull = true;

            requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention = new Amazon.S3.Model.DefaultRetention();
            System.Int32?requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Day = null;
            if (cmdletContext.DefaultRetention_Day != null)
            {
                requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Day = cmdletContext.DefaultRetention_Day.Value;
            }
            if (requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Day != null)
            {
                requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention.Days  = requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Day.Value;
                requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetentionIsNull = false;
            }
            Amazon.S3.ObjectLockRetentionMode requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Mode = null;
            if (cmdletContext.DefaultRetention_Mode != null)
            {
                requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Mode = cmdletContext.DefaultRetention_Mode;
            }
            if (requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Mode != null)
            {
                requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention.Mode  = requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Mode;
                requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetentionIsNull = false;
            }
            System.Int32?requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Year = null;
            if (cmdletContext.DefaultRetention_Year != null)
            {
                requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Year = cmdletContext.DefaultRetention_Year.Value;
            }
            if (requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Year != null)
            {
                requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention.Years = requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention_defaultRetention_Year.Value;
                requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetentionIsNull = false;
            }
            // determine if requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention should be set to null
            if (requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetentionIsNull)
            {
                requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention = null;
            }
            if (requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention != null)
            {
                requestObjectLockConfiguration_objectLockConfiguration_Rule.DefaultRetention = requestObjectLockConfiguration_objectLockConfiguration_Rule_objectLockConfiguration_Rule_DefaultRetention;
                requestObjectLockConfiguration_objectLockConfiguration_RuleIsNull            = false;
            }
            // determine if requestObjectLockConfiguration_objectLockConfiguration_Rule should be set to null
            if (requestObjectLockConfiguration_objectLockConfiguration_RuleIsNull)
            {
                requestObjectLockConfiguration_objectLockConfiguration_Rule = null;
            }
            if (requestObjectLockConfiguration_objectLockConfiguration_Rule != null)
            {
                request.ObjectLockConfiguration.Rule = requestObjectLockConfiguration_objectLockConfiguration_Rule;
                requestObjectLockConfigurationIsNull = false;
            }
            // determine if request.ObjectLockConfiguration should be set to null
            if (requestObjectLockConfigurationIsNull)
            {
                request.ObjectLockConfiguration = null;
            }
            if (cmdletContext.RequestPayer != null)
            {
                request.RequestPayer = cmdletContext.RequestPayer;
            }
            if (cmdletContext.Token != null)
            {
                request.Token = cmdletContext.Token;
            }
            if (cmdletContext.ExpectedBucketOwner != null)
            {
                request.ExpectedBucketOwner = cmdletContext.ExpectedBucketOwner;
            }

            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);
        }