public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.EC2.Model.CancelBundleTaskRequest();

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

            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);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CancelBundleTask operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CancelBundleTask operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<CancelBundleTaskResponse> CancelBundleTaskAsync(CancelBundleTaskRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CancelBundleTaskRequestMarshaller();
            var unmarshaller = CancelBundleTaskResponseUnmarshaller.Instance;

            return InvokeAsync<CancelBundleTaskRequest,CancelBundleTaskResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        /// <summary>
        /// Cancels a bundling operation for an instance store-backed Windows instance.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CancelBundleTask service method.</param>
        /// 
        /// <returns>The response from the CancelBundleTask service method, as returned by EC2.</returns>
        public CancelBundleTaskResponse CancelBundleTask(CancelBundleTaskRequest request)
        {
            var marshaller = new CancelBundleTaskRequestMarshaller();
            var unmarshaller = CancelBundleTaskResponseUnmarshaller.Instance;

            return Invoke<CancelBundleTaskRequest,CancelBundleTaskResponse>(request, marshaller, unmarshaller);
        }
예제 #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the CancelBundleTask operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CancelBundleTask operation on AmazonEC2Client.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCancelBundleTask
        ///         operation.</returns>
        public IAsyncResult BeginCancelBundleTask(CancelBundleTaskRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new CancelBundleTaskRequestMarshaller();
            var unmarshaller = CancelBundleTaskResponseUnmarshaller.Instance;

            return BeginInvoke<CancelBundleTaskRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
예제 #5
0
 IAsyncResult invokeCancelBundleTask(CancelBundleTaskRequest cancelBundleTaskRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new CancelBundleTaskRequestMarshaller().Marshall(cancelBundleTaskRequest);
     var unmarshaller = CancelBundleTaskResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
예제 #6
0
 /// <summary>
 /// Initiates the asynchronous execution of the CancelBundleTask operation.
 /// <seealso cref="Amazon.EC2.IAmazonEC2.CancelBundleTask"/>
 /// </summary>
 /// 
 /// <param name="cancelBundleTaskRequest">Container for the necessary parameters to execute the CancelBundleTask operation on AmazonEC2.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// 
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCancelBundleTask
 ///         operation.</returns>
 public IAsyncResult BeginCancelBundleTask(CancelBundleTaskRequest cancelBundleTaskRequest, AsyncCallback callback, object state)
 {
     return invokeCancelBundleTask(cancelBundleTaskRequest, callback, state, false);
 }
예제 #7
0
 /// <summary>
 /// <para>Cancels a bundling operation for an instance store-backed Windows instance.</para>
 /// </summary>
 /// 
 /// <param name="cancelBundleTaskRequest">Container for the necessary parameters to execute the CancelBundleTask service method on
 ///          AmazonEC2.</param>
 /// 
 /// <returns>The response from the CancelBundleTask service method, as returned by AmazonEC2.</returns>
 /// 
 public CancelBundleTaskResponse CancelBundleTask(CancelBundleTaskRequest cancelBundleTaskRequest)
 {
     IAsyncResult asyncResult = invokeCancelBundleTask(cancelBundleTaskRequest, null, null, true);
     return EndCancelBundleTask(asyncResult);
 }
예제 #8
0
        /// <summary>
        /// <para>Cancels a bundling operation for an instance store-backed Windows instance.</para>
        /// </summary>
        /// 
        /// <param name="cancelBundleTaskRequest">Container for the necessary parameters to execute the CancelBundleTask service method on
        /// AmazonEC2.</param>
        /// 
        /// <returns>The response from the CancelBundleTask service method, as returned by AmazonEC2.</returns>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<CancelBundleTaskResponse> CancelBundleTaskAsync(CancelBundleTaskRequest cancelBundleTaskRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CancelBundleTaskRequestMarshaller();
            var unmarshaller = CancelBundleTaskResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, CancelBundleTaskRequest, CancelBundleTaskResponse>(cancelBundleTaskRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
예제 #9
0
		internal CancelBundleTaskResponse CancelBundleTask(CancelBundleTaskRequest request)
        {
            var task = CancelBundleTaskAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
예제 #10
0
        /// <summary>
        /// Initiates the asynchronous execution of the CancelBundleTask operation.
        /// <seealso cref="Amazon.EC2.IAmazonEC2.CancelBundleTask"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CancelBundleTask operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
		public async Task<CancelBundleTaskResponse> CancelBundleTaskAsync(CancelBundleTaskRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CancelBundleTaskRequestMarshaller();
            var unmarshaller = CancelBundleTaskResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, CancelBundleTaskRequest, CancelBundleTaskResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
예제 #11
0
        /// <summary>
        /// <para> CancelBundleTask operation cancels a pending or in-progress bundling task. This is an asynchronous call and it make take a while for
        /// the task to be canceled. If a task is canceled while it is storing items, there may be parts of the incomplete AMI stored in S3. It is up to
        /// the caller to clean up these parts from S3. </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CancelBundleTask service method on
        /// AmazonEC2.</param>
        /// 
        /// <returns>The response from the CancelBundleTask service method, as returned by AmazonEC2.</returns>
		public CancelBundleTaskResponse CancelBundleTask(CancelBundleTaskRequest request)
        {
            var task = CancelBundleTaskAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
예제 #12
0
        /// <summary>
        /// CancelBundleTask operation cancels a pending or
        /// in-progress bundling task. This is an asynchronous
        /// call and it make take a while for the task to be cancelled.
        /// If a task is cancelled while it is storing items,
        /// there may be parts of the incomplete AMI stored in S3.
        /// It is up to the caller to clean up these parts from S3.
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonEC2 service</param>
        /// <param name="request">CancelBundleTaskRequest request</param>
        public static void InvokeCancelBundleTask(AmazonEC2 service, CancelBundleTaskRequest request)
        {
            try 
            {
                CancelBundleTaskResponse response = service.CancelBundleTask(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        CancelBundleTaskResponse");
                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata  responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }
                if (response.IsSetCancelBundleTaskResult())
                {
                    Console.WriteLine("            CancelBundleTaskResult");
                    CancelBundleTaskResult  cancelBundleTaskResult = response.CancelBundleTaskResult;
                    List<BundleTask> bundleTaskList = cancelBundleTaskResult.BundleTask;
                    foreach (BundleTask bundleTask in bundleTaskList)
                    {
                        Console.WriteLine("                BundleTask");
                        if (bundleTask.IsSetInstanceId())
                        {
                            Console.WriteLine("                    InstanceId");
                            Console.WriteLine("                        {0}", bundleTask.InstanceId);
                        }
                        if (bundleTask.IsSetBundleId())
                        {
                            Console.WriteLine("                    BundleId");
                            Console.WriteLine("                        {0}", bundleTask.BundleId);
                        }
                        if (bundleTask.IsSetBundleState())
                        {
                            Console.WriteLine("                    BundleState");
                            Console.WriteLine("                        {0}", bundleTask.BundleState);
                        }
                        if (bundleTask.IsSetStartTime())
                        {
                            Console.WriteLine("                    StartTime");
                            Console.WriteLine("                        {0}", bundleTask.StartTime);
                        }
                        if (bundleTask.IsSetUpdateTime())
                        {
                            Console.WriteLine("                    UpdateTime");
                            Console.WriteLine("                        {0}", bundleTask.UpdateTime);
                        }
                        if (bundleTask.IsSetStorage())
                        {
                            Console.WriteLine("                    Storage");
                            Storage  storage = bundleTask.Storage;
                            if (storage.IsSetS3())
                            {
                                Console.WriteLine("                        S3");
                                S3Storage  s3 = storage.S3;
                                if (s3.IsSetBucket())
                                {
                                    Console.WriteLine("                            Bucket");
                                    Console.WriteLine("                                {0}", s3.Bucket);
                                }
                                if (s3.IsSetPrefix())
                                {
                                    Console.WriteLine("                            Prefix");
                                    Console.WriteLine("                                {0}", s3.Prefix);
                                }
                                if (s3.IsSetAWSAccessKeyId())
                                {
                                    Console.WriteLine("                            AWSAccessKeyId");
                                    Console.WriteLine("                                {0}", s3.AWSAccessKeyId);
                                }
                                if (s3.IsSetUploadPolicy())
                                {
                                    Console.WriteLine("                            UploadPolicy");
                                    Console.WriteLine("                                {0}", s3.UploadPolicy);
                                }
                                if (s3.IsSetUploadPolicySignature())
                                {
                                    Console.WriteLine("                            UploadPolicySignature");
                                    Console.WriteLine("                                {0}", s3.UploadPolicySignature);
                                }
                            }
                        }
                        if (bundleTask.IsSetProgress())
                        {
                            Console.WriteLine("                    Progress");
                            Console.WriteLine("                        {0}", bundleTask.Progress);
                        }
                        if (bundleTask.IsSetBundleTaskError())
                        {
                            Console.WriteLine("                    BundleTaskError");
                            BundleTaskError  bundleTaskError = bundleTask.BundleTaskError;
                            if (bundleTaskError.IsSetCode())
                            {
                                Console.WriteLine("                        Code");
                                Console.WriteLine("                            {0}", bundleTaskError.Code);
                            }
                            if (bundleTaskError.IsSetMessage())
                            {
                                Console.WriteLine("                        Message");
                                Console.WriteLine("                            {0}", bundleTaskError.Message);
                            }
                        }
                    }
                }

            } 
            catch (AmazonEC2Exception ex) 
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }
        }
 private Amazon.EC2.Model.CancelBundleTaskResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.CancelBundleTaskRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "CancelBundleTask");
     try
     {
         #if DESKTOP
         return(client.CancelBundleTask(request));
         #elif CORECLR
         return(client.CancelBundleTaskAsync(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;
     }
 }