public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.EC2.Model.ModifyInstancePlacementRequest(); if (cmdletContext.Affinity != null) { request.Affinity = cmdletContext.Affinity; } if (cmdletContext.GroupName != null) { request.GroupName = cmdletContext.GroupName; } if (cmdletContext.HostId != null) { request.HostId = cmdletContext.HostId; } if (cmdletContext.HostResourceGroupArn != null) { request.HostResourceGroupArn = cmdletContext.HostResourceGroupArn; } if (cmdletContext.InstanceId != null) { request.InstanceId = cmdletContext.InstanceId; } if (cmdletContext.PartitionNumber != null) { request.PartitionNumber = cmdletContext.PartitionNumber.Value; } if (cmdletContext.Tenancy != null) { request.Tenancy = cmdletContext.Tenancy; } 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 ModifyInstancePlacement operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ModifyInstancePlacement 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 EndModifyInstancePlacement /// operation.</returns> public IAsyncResult BeginModifyInstancePlacement(ModifyInstancePlacementRequest request, AsyncCallback callback, object state) { var marshaller = new ModifyInstancePlacementRequestMarshaller(); var unmarshaller = ModifyInstancePlacementResponseUnmarshaller.Instance; return BeginInvoke<ModifyInstancePlacementRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Set the instance affinity value for a specific stopped instance and modify the instance /// tenancy setting. /// /// /// <para> /// Instance affinity is disabled by default. When instance affinity is <code>host</code> /// and it is not associated with a specific Dedicated Host, the next time it is launched /// it will automatically be associated with the host it lands on. This relationship will /// persist if the instance is stopped/started, or rebooted. /// </para> /// /// <para> /// You can modify the host ID associated with a stopped instance. If a stopped instance /// has a new host ID association, the instance will target that host when restarted. /// </para> /// /// <para> /// You can modify the tenancy of a stopped instance with a tenancy of <code>host</code> /// or <code>dedicated</code>. /// </para> /// /// <para> /// Affinity, hostID, and tenancy are not required parameters, but at least one of them /// must be specified in the request. Affinity and tenancy can be modified in the same /// request, but tenancy can only be modified on instances that are stopped. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the ModifyInstancePlacement service method.</param> /// /// <returns>The response from the ModifyInstancePlacement service method, as returned by EC2.</returns> public ModifyInstancePlacementResponse ModifyInstancePlacement(ModifyInstancePlacementRequest request) { var marshaller = new ModifyInstancePlacementRequestMarshaller(); var unmarshaller = ModifyInstancePlacementResponseUnmarshaller.Instance; return Invoke<ModifyInstancePlacementRequest,ModifyInstancePlacementResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the ModifyInstancePlacement operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ModifyInstancePlacement 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<ModifyInstancePlacementResponse> ModifyInstancePlacementAsync(ModifyInstancePlacementRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ModifyInstancePlacementRequestMarshaller(); var unmarshaller = ModifyInstancePlacementResponseUnmarshaller.Instance; return InvokeAsync<ModifyInstancePlacementRequest,ModifyInstancePlacementResponse>(request, marshaller, unmarshaller, cancellationToken); }
private Amazon.EC2.Model.ModifyInstancePlacementResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.ModifyInstancePlacementRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "ModifyInstancePlacement"); try { #if DESKTOP return(client.ModifyInstancePlacement(request)); #elif CORECLR return(client.ModifyInstancePlacementAsync(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; } }