private Amazon.DataSync.Model.CreateLocationS3Response CallAWSServiceOperation(IAmazonDataSync client, Amazon.DataSync.Model.CreateLocationS3Request request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS DataSync", "CreateLocationS3"); try { #if DESKTOP return(client.CreateLocationS3(request)); #elif CORECLR return(client.CreateLocationS3Async(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; } }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.DataSync.Model.CreateLocationS3Request(); if (cmdletContext.AgentArn != null) { request.AgentArns = cmdletContext.AgentArn; } if (cmdletContext.S3BucketArn != null) { request.S3BucketArn = cmdletContext.S3BucketArn; } // populate S3Config var requestS3ConfigIsNull = true; request.S3Config = new Amazon.DataSync.Model.S3Config(); System.String requestS3Config_s3Config_BucketAccessRoleArn = null; if (cmdletContext.S3Config_BucketAccessRoleArn != null) { requestS3Config_s3Config_BucketAccessRoleArn = cmdletContext.S3Config_BucketAccessRoleArn; } if (requestS3Config_s3Config_BucketAccessRoleArn != null) { request.S3Config.BucketAccessRoleArn = requestS3Config_s3Config_BucketAccessRoleArn; requestS3ConfigIsNull = false; } // determine if request.S3Config should be set to null if (requestS3ConfigIsNull) { request.S3Config = null; } if (cmdletContext.S3StorageClass != null) { request.S3StorageClass = cmdletContext.S3StorageClass; } if (cmdletContext.Subdirectory != null) { request.Subdirectory = cmdletContext.Subdirectory; } if (cmdletContext.Tag != null) { request.Tags = cmdletContext.Tag; } 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); }