Beispiel #1
0
 private Amazon.EC2.Model.ExportImageResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.ExportImageRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "ExportImage");
     try
     {
         #if DESKTOP
         return(client.ExportImage(request));
         #elif CORECLR
         return(client.ExportImageAsync(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;
     }
 }
Beispiel #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.EC2.Model.ExportImageRequest();

            if (cmdletContext.ClientToken != null)
            {
                request.ClientToken = cmdletContext.ClientToken;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.DiskImageFormat != null)
            {
                request.DiskImageFormat = cmdletContext.DiskImageFormat;
            }
            if (cmdletContext.ImageId != null)
            {
                request.ImageId = cmdletContext.ImageId;
            }
            if (cmdletContext.RoleName != null)
            {
                request.RoleName = cmdletContext.RoleName;
            }

            // populate S3ExportLocation
            var requestS3ExportLocationIsNull = true;

            request.S3ExportLocation = new Amazon.EC2.Model.ExportTaskS3LocationRequest();
            System.String requestS3ExportLocation_s3ExportLocation_S3Bucket = null;
            if (cmdletContext.S3ExportLocation_S3Bucket != null)
            {
                requestS3ExportLocation_s3ExportLocation_S3Bucket = cmdletContext.S3ExportLocation_S3Bucket;
            }
            if (requestS3ExportLocation_s3ExportLocation_S3Bucket != null)
            {
                request.S3ExportLocation.S3Bucket = requestS3ExportLocation_s3ExportLocation_S3Bucket;
                requestS3ExportLocationIsNull     = false;
            }
            System.String requestS3ExportLocation_s3ExportLocation_S3Prefix = null;
            if (cmdletContext.S3ExportLocation_S3Prefix != null)
            {
                requestS3ExportLocation_s3ExportLocation_S3Prefix = cmdletContext.S3ExportLocation_S3Prefix;
            }
            if (requestS3ExportLocation_s3ExportLocation_S3Prefix != null)
            {
                request.S3ExportLocation.S3Prefix = requestS3ExportLocation_s3ExportLocation_S3Prefix;
                requestS3ExportLocationIsNull     = false;
            }
            // determine if request.S3ExportLocation should be set to null
            if (requestS3ExportLocationIsNull)
            {
                request.S3ExportLocation = 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);
        }