private Amazon.EC2.Model.ModifyFleetResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.ModifyFleetRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "ModifyFleet"); try { #if DESKTOP return(client.ModifyFleet(request)); #elif CORECLR return(client.ModifyFleetAsync(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; } }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.EC2.Model.ModifyFleetRequest(); if (cmdletContext.ExcessCapacityTerminationPolicy != null) { request.ExcessCapacityTerminationPolicy = cmdletContext.ExcessCapacityTerminationPolicy; } if (cmdletContext.FleetId != null) { request.FleetId = cmdletContext.FleetId; } if (cmdletContext.LaunchTemplateConfig != null) { request.LaunchTemplateConfigs = cmdletContext.LaunchTemplateConfig; } // populate TargetCapacitySpecification var requestTargetCapacitySpecificationIsNull = true; request.TargetCapacitySpecification = new Amazon.EC2.Model.TargetCapacitySpecificationRequest(); Amazon.EC2.DefaultTargetCapacityType requestTargetCapacitySpecification_targetCapacitySpecification_DefaultTargetCapacityType = null; if (cmdletContext.TargetCapacitySpecification_DefaultTargetCapacityType != null) { requestTargetCapacitySpecification_targetCapacitySpecification_DefaultTargetCapacityType = cmdletContext.TargetCapacitySpecification_DefaultTargetCapacityType; } if (requestTargetCapacitySpecification_targetCapacitySpecification_DefaultTargetCapacityType != null) { request.TargetCapacitySpecification.DefaultTargetCapacityType = requestTargetCapacitySpecification_targetCapacitySpecification_DefaultTargetCapacityType; requestTargetCapacitySpecificationIsNull = false; } System.Int32?requestTargetCapacitySpecification_targetCapacitySpecification_OnDemandTargetCapacity = null; if (cmdletContext.TargetCapacitySpecification_OnDemandTargetCapacity != null) { requestTargetCapacitySpecification_targetCapacitySpecification_OnDemandTargetCapacity = cmdletContext.TargetCapacitySpecification_OnDemandTargetCapacity.Value; } if (requestTargetCapacitySpecification_targetCapacitySpecification_OnDemandTargetCapacity != null) { request.TargetCapacitySpecification.OnDemandTargetCapacity = requestTargetCapacitySpecification_targetCapacitySpecification_OnDemandTargetCapacity.Value; requestTargetCapacitySpecificationIsNull = false; } System.Int32?requestTargetCapacitySpecification_targetCapacitySpecification_SpotTargetCapacity = null; if (cmdletContext.TargetCapacitySpecification_SpotTargetCapacity != null) { requestTargetCapacitySpecification_targetCapacitySpecification_SpotTargetCapacity = cmdletContext.TargetCapacitySpecification_SpotTargetCapacity.Value; } if (requestTargetCapacitySpecification_targetCapacitySpecification_SpotTargetCapacity != null) { request.TargetCapacitySpecification.SpotTargetCapacity = requestTargetCapacitySpecification_targetCapacitySpecification_SpotTargetCapacity.Value; requestTargetCapacitySpecificationIsNull = false; } System.Int32?requestTargetCapacitySpecification_targetCapacitySpecification_TotalTargetCapacity = null; if (cmdletContext.TargetCapacitySpecification_TotalTargetCapacity != null) { requestTargetCapacitySpecification_targetCapacitySpecification_TotalTargetCapacity = cmdletContext.TargetCapacitySpecification_TotalTargetCapacity.Value; } if (requestTargetCapacitySpecification_targetCapacitySpecification_TotalTargetCapacity != null) { request.TargetCapacitySpecification.TotalTargetCapacity = requestTargetCapacitySpecification_targetCapacitySpecification_TotalTargetCapacity.Value; requestTargetCapacitySpecificationIsNull = false; } // determine if request.TargetCapacitySpecification should be set to null if (requestTargetCapacitySpecificationIsNull) { request.TargetCapacitySpecification = null; } 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); }