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

            if (cmdletContext.CopyTagsFromSource != null)
            {
                request.CopyTagsFromSource = cmdletContext.CopyTagsFromSource;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }

            // populate InstanceSpecification
            var requestInstanceSpecificationIsNull = true;

            request.InstanceSpecification = new Amazon.EC2.Model.InstanceSpecification();
            System.Boolean?requestInstanceSpecification_instanceSpecification_ExcludeBootVolume = null;
            if (cmdletContext.InstanceSpecification_ExcludeBootVolume != null)
            {
                requestInstanceSpecification_instanceSpecification_ExcludeBootVolume = cmdletContext.InstanceSpecification_ExcludeBootVolume.Value;
            }
            if (requestInstanceSpecification_instanceSpecification_ExcludeBootVolume != null)
            {
                request.InstanceSpecification.ExcludeBootVolume = requestInstanceSpecification_instanceSpecification_ExcludeBootVolume.Value;
                requestInstanceSpecificationIsNull = false;
            }
            System.String requestInstanceSpecification_instanceSpecification_InstanceId = null;
            if (cmdletContext.InstanceSpecification_InstanceId != null)
            {
                requestInstanceSpecification_instanceSpecification_InstanceId = cmdletContext.InstanceSpecification_InstanceId;
            }
            if (requestInstanceSpecification_instanceSpecification_InstanceId != null)
            {
                request.InstanceSpecification.InstanceId = requestInstanceSpecification_instanceSpecification_InstanceId;
                requestInstanceSpecificationIsNull       = false;
            }
            // determine if request.InstanceSpecification should be set to null
            if (requestInstanceSpecificationIsNull)
            {
                request.InstanceSpecification = null;
            }
            if (cmdletContext.OutpostArn != null)
            {
                request.OutpostArn = cmdletContext.OutpostArn;
            }
            if (cmdletContext.TagSpecification != null)
            {
                request.TagSpecifications = cmdletContext.TagSpecification;
            }

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