public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.EC2.Model.CopyImageRequest(); if (cmdletContext.ClientToken != null) { request.ClientToken = cmdletContext.ClientToken; } if (cmdletContext.Description != null) { request.Description = cmdletContext.Description; } if (cmdletContext.Encrypted != null) { request.Encrypted = cmdletContext.Encrypted.Value; } if (cmdletContext.KmsKeyId != null) { request.KmsKeyId = cmdletContext.KmsKeyId; } if (cmdletContext.Name != null) { request.Name = cmdletContext.Name; } if (cmdletContext.SourceImageId != null) { request.SourceImageId = cmdletContext.SourceImageId; } if (cmdletContext.SourceRegion != null) { request.SourceRegion = cmdletContext.SourceRegion; } 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 CopyImage operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CopyImage 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<CopyImageResponse> CopyImageAsync(CopyImageRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CopyImageRequestMarshaller(); var unmarshaller = CopyImageResponseUnmarshaller.Instance; return InvokeAsync<CopyImageRequest,CopyImageResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Initiates the copy of an AMI from the specified source region to the current region. /// You specify the destination region by using its endpoint when making the request. /// AMIs that use encrypted EBS snapshots cannot be copied with this method. /// /// /// <para> /// For more information, see <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/CopyingAMIs.html">Copying /// AMIs</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the CopyImage service method.</param> /// /// <returns>The response from the CopyImage service method, as returned by EC2.</returns> public CopyImageResponse CopyImage(CopyImageRequest request) { var marshaller = new CopyImageRequestMarshaller(); var unmarshaller = CopyImageResponseUnmarshaller.Instance; return Invoke<CopyImageRequest,CopyImageResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the CopyImage operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CopyImage 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 EndCopyImage /// operation.</returns> public IAsyncResult BeginCopyImage(CopyImageRequest request, AsyncCallback callback, object state) { var marshaller = new CopyImageRequestMarshaller(); var unmarshaller = CopyImageResponseUnmarshaller.Instance; return BeginInvoke<CopyImageRequest>(request, marshaller, unmarshaller, callback, state); }
IAsyncResult invokeCopyImage(CopyImageRequest copyImageRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new CopyImageRequestMarshaller().Marshall(copyImageRequest); var unmarshaller = CopyImageResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the CopyImage operation. /// <seealso cref="Amazon.EC2.IAmazonEC2.CopyImage"/> /// </summary> /// /// <param name="copyImageRequest">Container for the necessary parameters to execute the CopyImage 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 EndCopyImage /// operation.</returns> public IAsyncResult BeginCopyImage(CopyImageRequest copyImageRequest, AsyncCallback callback, object state) { return invokeCopyImage(copyImageRequest, callback, state, false); }
/// <summary> /// <para>Initiates the copy of an AMI from the specified source region to the region in which the request was made.</para> <para>For more /// information, see <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/CopyingAMIs.html" >Copying AMIs</a> in the <i>Amazon Elastic /// Compute Cloud User Guide</i> .</para> /// </summary> /// /// <param name="copyImageRequest">Container for the necessary parameters to execute the CopyImage service method on AmazonEC2.</param> /// /// <returns>The response from the CopyImage service method, as returned by AmazonEC2.</returns> /// public CopyImageResponse CopyImage(CopyImageRequest copyImageRequest) { IAsyncResult asyncResult = invokeCopyImage(copyImageRequest, null, null, true); return EndCopyImage(asyncResult); }
/// <summary> /// <para>Initiates the copy of an AMI from the specified source region to the region in which the request was made.</para> <para>For more /// information, see <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/CopyingAMIs.html">Copying AMIs</a> in the <i>Amazon Elastic /// Compute Cloud User Guide</i> .</para> /// </summary> /// /// <param name="copyImageRequest">Container for the necessary parameters to execute the CopyImage service method on AmazonEC2.</param> /// /// <returns>The response from the CopyImage 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<CopyImageResponse> CopyImageAsync(CopyImageRequest copyImageRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CopyImageRequestMarshaller(); var unmarshaller = CopyImageResponseUnmarshaller.GetInstance(); return Invoke<IRequest, CopyImageRequest, CopyImageResponse>(copyImageRequest, marshaller, unmarshaller, signer, cancellationToken); }
internal CopyImageResponse CopyImage(CopyImageRequest request) { var task = CopyImageAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
private Amazon.EC2.Model.CopyImageResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.CopyImageRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "CopyImage"); try { #if DESKTOP return(client.CopyImage(request)); #elif CORECLR return(client.CopyImageAsync(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; } }
/// <summary> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CopyImage service method on AmazonEC2.</param> /// /// <returns>The response from the CopyImage service method, as returned by AmazonEC2.</returns> public CopyImageResponse CopyImage(CopyImageRequest request) { var task = CopyImageAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// Initiates the asynchronous execution of the CopyImage operation. /// <seealso cref="Amazon.EC2.IAmazonEC2.CopyImage"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CopyImage 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<CopyImageResponse> CopyImageAsync(CopyImageRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CopyImageRequestMarshaller(); var unmarshaller = CopyImageResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, CopyImageRequest, CopyImageResponse>(request, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }