/// <summary> /// Initiates the asynchronous execution of the ImportSnapshot operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ImportSnapshot 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<ImportSnapshotResponse> ImportSnapshotAsync(ImportSnapshotRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ImportSnapshotRequestMarshaller(); var unmarshaller = ImportSnapshotResponseUnmarshaller.Instance; return InvokeAsync<ImportSnapshotRequest,ImportSnapshotResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Imports a disk into an EBS snapshot. /// </summary> /// <param name="request">Container for the necessary parameters to execute the ImportSnapshot service method.</param> /// /// <returns>The response from the ImportSnapshot service method, as returned by EC2.</returns> public ImportSnapshotResponse ImportSnapshot(ImportSnapshotRequest request) { var marshaller = new ImportSnapshotRequestMarshaller(); var unmarshaller = ImportSnapshotResponseUnmarshaller.Instance; return Invoke<ImportSnapshotRequest,ImportSnapshotResponse>(request, marshaller, unmarshaller); }
private Amazon.EC2.Model.ImportSnapshotResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.ImportSnapshotRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "ImportSnapshot"); try { #if DESKTOP return(client.ImportSnapshot(request)); #elif CORECLR return(client.ImportSnapshotAsync(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> /// Initiates the asynchronous execution of the ImportSnapshot operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ImportSnapshot 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 EndImportSnapshot /// operation.</returns> public IAsyncResult BeginImportSnapshot(ImportSnapshotRequest request, AsyncCallback callback, object state) { var marshaller = new ImportSnapshotRequestMarshaller(); var unmarshaller = ImportSnapshotResponseUnmarshaller.Instance; return BeginInvoke<ImportSnapshotRequest>(request, marshaller, unmarshaller, callback, state); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.EC2.Model.ImportSnapshotRequest(); // populate ClientData var requestClientDataIsNull = true; request.ClientData = new Amazon.EC2.Model.ClientData(); System.String requestClientData_clientData_Comment = null; if (cmdletContext.ClientData_Comment != null) { requestClientData_clientData_Comment = cmdletContext.ClientData_Comment; } if (requestClientData_clientData_Comment != null) { request.ClientData.Comment = requestClientData_clientData_Comment; requestClientDataIsNull = false; } System.DateTime?requestClientData_clientData_UtcUploadEnd = null; if (cmdletContext.ClientData_UtcUploadEnd != null) { requestClientData_clientData_UtcUploadEnd = cmdletContext.ClientData_UtcUploadEnd.Value; } if (requestClientData_clientData_UtcUploadEnd != null) { request.ClientData.UploadEndUtc = requestClientData_clientData_UtcUploadEnd.Value; requestClientDataIsNull = false; } System.Double?requestClientData_clientData_UploadSize = null; if (cmdletContext.ClientData_UploadSize != null) { requestClientData_clientData_UploadSize = cmdletContext.ClientData_UploadSize.Value; } if (requestClientData_clientData_UploadSize != null) { request.ClientData.UploadSize = requestClientData_clientData_UploadSize.Value; requestClientDataIsNull = false; } System.DateTime?requestClientData_clientData_UtcUploadStart = null; if (cmdletContext.ClientData_UtcUploadStart != null) { requestClientData_clientData_UtcUploadStart = cmdletContext.ClientData_UtcUploadStart.Value; } if (requestClientData_clientData_UtcUploadStart != null) { request.ClientData.UploadStartUtc = requestClientData_clientData_UtcUploadStart.Value; requestClientDataIsNull = false; } #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute System.DateTime?requestClientData_clientData_UploadEnd = null; if (cmdletContext.ClientData_UploadEnd != null) { if (cmdletContext.ClientData_UtcUploadEnd != null) { throw new System.ArgumentException("Parameters ClientData_UploadEnd and ClientData_UtcUploadEnd are mutually exclusive.", nameof(this.ClientData_UploadEnd)); } requestClientData_clientData_UploadEnd = cmdletContext.ClientData_UploadEnd.Value; } if (requestClientData_clientData_UploadEnd != null) { request.ClientData.UploadEnd = requestClientData_clientData_UploadEnd.Value; requestClientDataIsNull = false; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute System.DateTime?requestClientData_clientData_UploadStart = null; if (cmdletContext.ClientData_UploadStart != null) { if (cmdletContext.ClientData_UtcUploadStart != null) { throw new System.ArgumentException("Parameters ClientData_UploadStart and ClientData_UtcUploadStart are mutually exclusive.", nameof(this.ClientData_UploadStart)); } requestClientData_clientData_UploadStart = cmdletContext.ClientData_UploadStart.Value; } if (requestClientData_clientData_UploadStart != null) { request.ClientData.UploadStart = requestClientData_clientData_UploadStart.Value; requestClientDataIsNull = false; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute // determine if request.ClientData should be set to null if (requestClientDataIsNull) { request.ClientData = null; } if (cmdletContext.ClientToken != null) { request.ClientToken = cmdletContext.ClientToken; } if (cmdletContext.Description != null) { request.Description = cmdletContext.Description; } // populate DiskContainer var requestDiskContainerIsNull = true; request.DiskContainer = new Amazon.EC2.Model.SnapshotDiskContainer(); System.String requestDiskContainer_diskContainer_Description = null; if (cmdletContext.DiskContainer_Description != null) { requestDiskContainer_diskContainer_Description = cmdletContext.DiskContainer_Description; } if (requestDiskContainer_diskContainer_Description != null) { request.DiskContainer.Description = requestDiskContainer_diskContainer_Description; requestDiskContainerIsNull = false; } System.String requestDiskContainer_diskContainer_Format = null; if (cmdletContext.DiskContainer_Format != null) { requestDiskContainer_diskContainer_Format = cmdletContext.DiskContainer_Format; } if (requestDiskContainer_diskContainer_Format != null) { request.DiskContainer.Format = requestDiskContainer_diskContainer_Format; requestDiskContainerIsNull = false; } System.String requestDiskContainer_diskContainer_Url = null; if (cmdletContext.DiskContainer_Url != null) { requestDiskContainer_diskContainer_Url = cmdletContext.DiskContainer_Url; } if (requestDiskContainer_diskContainer_Url != null) { request.DiskContainer.Url = requestDiskContainer_diskContainer_Url; requestDiskContainerIsNull = false; } Amazon.EC2.Model.UserBucket requestDiskContainer_diskContainer_UserBucket = null; // populate UserBucket var requestDiskContainer_diskContainer_UserBucketIsNull = true; requestDiskContainer_diskContainer_UserBucket = new Amazon.EC2.Model.UserBucket(); System.String requestDiskContainer_diskContainer_UserBucket_diskContainer_S3Bucket = null; if (cmdletContext.DiskContainer_S3Bucket != null) { requestDiskContainer_diskContainer_UserBucket_diskContainer_S3Bucket = cmdletContext.DiskContainer_S3Bucket; } if (requestDiskContainer_diskContainer_UserBucket_diskContainer_S3Bucket != null) { requestDiskContainer_diskContainer_UserBucket.S3Bucket = requestDiskContainer_diskContainer_UserBucket_diskContainer_S3Bucket; requestDiskContainer_diskContainer_UserBucketIsNull = false; } System.String requestDiskContainer_diskContainer_UserBucket_diskContainer_S3Key = null; if (cmdletContext.DiskContainer_S3Key != null) { requestDiskContainer_diskContainer_UserBucket_diskContainer_S3Key = cmdletContext.DiskContainer_S3Key; } if (requestDiskContainer_diskContainer_UserBucket_diskContainer_S3Key != null) { requestDiskContainer_diskContainer_UserBucket.S3Key = requestDiskContainer_diskContainer_UserBucket_diskContainer_S3Key; requestDiskContainer_diskContainer_UserBucketIsNull = false; } // determine if requestDiskContainer_diskContainer_UserBucket should be set to null if (requestDiskContainer_diskContainer_UserBucketIsNull) { requestDiskContainer_diskContainer_UserBucket = null; } if (requestDiskContainer_diskContainer_UserBucket != null) { request.DiskContainer.UserBucket = requestDiskContainer_diskContainer_UserBucket; requestDiskContainerIsNull = false; } // determine if request.DiskContainer should be set to null if (requestDiskContainerIsNull) { request.DiskContainer = null; } if (cmdletContext.Encrypted != null) { request.Encrypted = cmdletContext.Encrypted.Value; } if (cmdletContext.KmsKeyId != null) { request.KmsKeyId = cmdletContext.KmsKeyId; } if (cmdletContext.RoleName != null) { request.RoleName = cmdletContext.RoleName; } 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); }