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); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.S3.Model.PutObjectRetentionRequest(); if (cmdletContext.BucketName != null) { request.BucketName = cmdletContext.BucketName; } if (cmdletContext.BypassGovernanceRetention != null) { request.BypassGovernanceRetention = cmdletContext.BypassGovernanceRetention.Value; } if (cmdletContext.ContentMD5 != null) { request.ContentMD5 = cmdletContext.ContentMD5; } if (cmdletContext.Key != null) { request.Key = cmdletContext.Key; } if (cmdletContext.RequestPayer != null) { request.RequestPayer = cmdletContext.RequestPayer; } // populate Retention var requestRetentionIsNull = true; request.Retention = new Amazon.S3.Model.ObjectLockRetention(); Amazon.S3.ObjectLockRetentionMode requestRetention_retention_Mode = null; if (cmdletContext.Retention_Mode != null) { requestRetention_retention_Mode = cmdletContext.Retention_Mode; } if (requestRetention_retention_Mode != null) { request.Retention.Mode = requestRetention_retention_Mode; requestRetentionIsNull = false; } System.DateTime?requestRetention_retention_RetainUntilDate = null; if (cmdletContext.Retention_RetainUntilDate != null) { requestRetention_retention_RetainUntilDate = cmdletContext.Retention_RetainUntilDate.Value; } if (requestRetention_retention_RetainUntilDate != null) { request.Retention.RetainUntilDate = requestRetention_retention_RetainUntilDate.Value; requestRetentionIsNull = false; } // determine if request.Retention should be set to null if (requestRetentionIsNull) { request.Retention = null; } if (cmdletContext.VersionId != null) { request.VersionId = cmdletContext.VersionId; } 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); }