public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.EC2.Model.ModifyHostsRequest(); if (cmdletContext.AutoPlacement != null) { request.AutoPlacement = cmdletContext.AutoPlacement; } if (cmdletContext.HostId != null) { request.HostIds = cmdletContext.HostId; } if (cmdletContext.HostRecovery != null) { request.HostRecovery = cmdletContext.HostRecovery; } if (cmdletContext.InstanceFamily != null) { request.InstanceFamily = cmdletContext.InstanceFamily; } if (cmdletContext.InstanceType != null) { request.InstanceType = cmdletContext.InstanceType; } 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 ModifyHosts operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ModifyHosts 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 EndModifyHosts /// operation.</returns> public IAsyncResult BeginModifyHosts(ModifyHostsRequest request, AsyncCallback callback, object state) { var marshaller = new ModifyHostsRequestMarshaller(); var unmarshaller = ModifyHostsResponseUnmarshaller.Instance; return BeginInvoke<ModifyHostsRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Modify the auto-placement setting of a Dedicated Host. When auto-placement is enabled, /// AWS will place instances that you launch with a tenancy of <code>host</code>, but /// without targeting a specific host ID, onto any available Dedicated Host in your account /// which has auto-placement enabled. When auto-placement is disabled, you need to provide /// a host ID if you want the instance to launch onto a specific host. If no host ID is /// provided, the instance will be launched onto a suitable host which has auto-placement /// enabled. /// </summary> /// <param name="request">Container for the necessary parameters to execute the ModifyHosts service method.</param> /// /// <returns>The response from the ModifyHosts service method, as returned by EC2.</returns> public ModifyHostsResponse ModifyHosts(ModifyHostsRequest request) { var marshaller = new ModifyHostsRequestMarshaller(); var unmarshaller = ModifyHostsResponseUnmarshaller.Instance; return Invoke<ModifyHostsRequest,ModifyHostsResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the ModifyHosts operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ModifyHosts 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<ModifyHostsResponse> ModifyHostsAsync(ModifyHostsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ModifyHostsRequestMarshaller(); var unmarshaller = ModifyHostsResponseUnmarshaller.Instance; return InvokeAsync<ModifyHostsRequest,ModifyHostsResponse>(request, marshaller, unmarshaller, cancellationToken); }
private Amazon.EC2.Model.ModifyHostsResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.ModifyHostsRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "ModifyHosts"); try { #if DESKTOP return(client.ModifyHosts(request)); #elif CORECLR return(client.ModifyHostsAsync(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; } }