private Amazon.EC2.Model.CreateFleetResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.CreateFleetRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "CreateFleet");
     try
     {
         #if DESKTOP
         return(client.CreateFleet(request));
         #elif CORECLR
         return(client.CreateFleetAsync(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.CreateFleetRequest();

            if (cmdletContext.ClientToken != null)
            {
                request.ClientToken = cmdletContext.ClientToken;
            }
            if (cmdletContext.ExcessCapacityTerminationPolicy != null)
            {
                request.ExcessCapacityTerminationPolicy = cmdletContext.ExcessCapacityTerminationPolicy;
            }
            if (cmdletContext.LaunchTemplateConfig != null)
            {
                request.LaunchTemplateConfigs = cmdletContext.LaunchTemplateConfig;
            }

            // populate OnDemandOptions
            var requestOnDemandOptionsIsNull = true;

            request.OnDemandOptions = new Amazon.EC2.Model.OnDemandOptionsRequest();
            Amazon.EC2.FleetOnDemandAllocationStrategy requestOnDemandOptions_onDemandOptions_AllocationStrategy = null;
            if (cmdletContext.OnDemandOptions_AllocationStrategy != null)
            {
                requestOnDemandOptions_onDemandOptions_AllocationStrategy = cmdletContext.OnDemandOptions_AllocationStrategy;
            }
            if (requestOnDemandOptions_onDemandOptions_AllocationStrategy != null)
            {
                request.OnDemandOptions.AllocationStrategy = requestOnDemandOptions_onDemandOptions_AllocationStrategy;
                requestOnDemandOptionsIsNull = false;
            }
            System.String requestOnDemandOptions_onDemandOptions_MaxTotalPrice = null;
            if (cmdletContext.OnDemandOptions_MaxTotalPrice != null)
            {
                requestOnDemandOptions_onDemandOptions_MaxTotalPrice = cmdletContext.OnDemandOptions_MaxTotalPrice;
            }
            if (requestOnDemandOptions_onDemandOptions_MaxTotalPrice != null)
            {
                request.OnDemandOptions.MaxTotalPrice = requestOnDemandOptions_onDemandOptions_MaxTotalPrice;
                requestOnDemandOptionsIsNull          = false;
            }
            System.Int32?requestOnDemandOptions_onDemandOptions_MinTargetCapacity = null;
            if (cmdletContext.OnDemandOptions_MinTargetCapacity != null)
            {
                requestOnDemandOptions_onDemandOptions_MinTargetCapacity = cmdletContext.OnDemandOptions_MinTargetCapacity.Value;
            }
            if (requestOnDemandOptions_onDemandOptions_MinTargetCapacity != null)
            {
                request.OnDemandOptions.MinTargetCapacity = requestOnDemandOptions_onDemandOptions_MinTargetCapacity.Value;
                requestOnDemandOptionsIsNull = false;
            }
            System.Boolean?requestOnDemandOptions_onDemandOptions_SingleAvailabilityZone = null;
            if (cmdletContext.OnDemandOptions_SingleAvailabilityZone != null)
            {
                requestOnDemandOptions_onDemandOptions_SingleAvailabilityZone = cmdletContext.OnDemandOptions_SingleAvailabilityZone.Value;
            }
            if (requestOnDemandOptions_onDemandOptions_SingleAvailabilityZone != null)
            {
                request.OnDemandOptions.SingleAvailabilityZone = requestOnDemandOptions_onDemandOptions_SingleAvailabilityZone.Value;
                requestOnDemandOptionsIsNull = false;
            }
            System.Boolean?requestOnDemandOptions_onDemandOptions_SingleInstanceType = null;
            if (cmdletContext.OnDemandOptions_SingleInstanceType != null)
            {
                requestOnDemandOptions_onDemandOptions_SingleInstanceType = cmdletContext.OnDemandOptions_SingleInstanceType.Value;
            }
            if (requestOnDemandOptions_onDemandOptions_SingleInstanceType != null)
            {
                request.OnDemandOptions.SingleInstanceType = requestOnDemandOptions_onDemandOptions_SingleInstanceType.Value;
                requestOnDemandOptionsIsNull = false;
            }
            // determine if request.OnDemandOptions should be set to null
            if (requestOnDemandOptionsIsNull)
            {
                request.OnDemandOptions = null;
            }
            if (cmdletContext.ReplaceUnhealthyInstance != null)
            {
                request.ReplaceUnhealthyInstances = cmdletContext.ReplaceUnhealthyInstance.Value;
            }

            // populate SpotOptions
            var requestSpotOptionsIsNull = true;

            request.SpotOptions = new Amazon.EC2.Model.SpotOptionsRequest();
            Amazon.EC2.SpotAllocationStrategy requestSpotOptions_spotOptions_AllocationStrategy = null;
            if (cmdletContext.SpotOptions_AllocationStrategy != null)
            {
                requestSpotOptions_spotOptions_AllocationStrategy = cmdletContext.SpotOptions_AllocationStrategy;
            }
            if (requestSpotOptions_spotOptions_AllocationStrategy != null)
            {
                request.SpotOptions.AllocationStrategy = requestSpotOptions_spotOptions_AllocationStrategy;
                requestSpotOptionsIsNull = false;
            }
            Amazon.EC2.SpotInstanceInterruptionBehavior requestSpotOptions_spotOptions_InstanceInterruptionBehavior = null;
            if (cmdletContext.SpotOptions_InstanceInterruptionBehavior != null)
            {
                requestSpotOptions_spotOptions_InstanceInterruptionBehavior = cmdletContext.SpotOptions_InstanceInterruptionBehavior;
            }
            if (requestSpotOptions_spotOptions_InstanceInterruptionBehavior != null)
            {
                request.SpotOptions.InstanceInterruptionBehavior = requestSpotOptions_spotOptions_InstanceInterruptionBehavior;
                requestSpotOptionsIsNull = false;
            }
            System.Int32?requestSpotOptions_spotOptions_InstancePoolsToUseCount = null;
            if (cmdletContext.SpotOptions_InstancePoolsToUseCount != null)
            {
                requestSpotOptions_spotOptions_InstancePoolsToUseCount = cmdletContext.SpotOptions_InstancePoolsToUseCount.Value;
            }
            if (requestSpotOptions_spotOptions_InstancePoolsToUseCount != null)
            {
                request.SpotOptions.InstancePoolsToUseCount = requestSpotOptions_spotOptions_InstancePoolsToUseCount.Value;
                requestSpotOptionsIsNull = false;
            }
            System.String requestSpotOptions_spotOptions_MaxTotalPrice = null;
            if (cmdletContext.SpotOptions_MaxTotalPrice != null)
            {
                requestSpotOptions_spotOptions_MaxTotalPrice = cmdletContext.SpotOptions_MaxTotalPrice;
            }
            if (requestSpotOptions_spotOptions_MaxTotalPrice != null)
            {
                request.SpotOptions.MaxTotalPrice = requestSpotOptions_spotOptions_MaxTotalPrice;
                requestSpotOptionsIsNull          = false;
            }
            System.Int32?requestSpotOptions_spotOptions_MinTargetCapacity = null;
            if (cmdletContext.SpotOptions_MinTargetCapacity != null)
            {
                requestSpotOptions_spotOptions_MinTargetCapacity = cmdletContext.SpotOptions_MinTargetCapacity.Value;
            }
            if (requestSpotOptions_spotOptions_MinTargetCapacity != null)
            {
                request.SpotOptions.MinTargetCapacity = requestSpotOptions_spotOptions_MinTargetCapacity.Value;
                requestSpotOptionsIsNull = false;
            }
            System.Boolean?requestSpotOptions_spotOptions_SingleAvailabilityZone = null;
            if (cmdletContext.SpotOptions_SingleAvailabilityZone != null)
            {
                requestSpotOptions_spotOptions_SingleAvailabilityZone = cmdletContext.SpotOptions_SingleAvailabilityZone.Value;
            }
            if (requestSpotOptions_spotOptions_SingleAvailabilityZone != null)
            {
                request.SpotOptions.SingleAvailabilityZone = requestSpotOptions_spotOptions_SingleAvailabilityZone.Value;
                requestSpotOptionsIsNull = false;
            }
            System.Boolean?requestSpotOptions_spotOptions_SingleInstanceType = null;
            if (cmdletContext.SpotOptions_SingleInstanceType != null)
            {
                requestSpotOptions_spotOptions_SingleInstanceType = cmdletContext.SpotOptions_SingleInstanceType.Value;
            }
            if (requestSpotOptions_spotOptions_SingleInstanceType != null)
            {
                request.SpotOptions.SingleInstanceType = requestSpotOptions_spotOptions_SingleInstanceType.Value;
                requestSpotOptionsIsNull = false;
            }
            // determine if request.SpotOptions should be set to null
            if (requestSpotOptionsIsNull)
            {
                request.SpotOptions = null;
            }
            if (cmdletContext.TagSpecification != null)
            {
                request.TagSpecifications = cmdletContext.TagSpecification;
            }

            // 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;
            }
            if (cmdletContext.TerminateInstancesWithExpiration != null)
            {
                request.TerminateInstancesWithExpiration = cmdletContext.TerminateInstancesWithExpiration.Value;
            }
            if (cmdletContext.Type != null)
            {
                request.Type = cmdletContext.Type;
            }
            if (cmdletContext.UtcValidFrom != null)
            {
                request.ValidFromUtc = cmdletContext.UtcValidFrom.Value;
            }
            if (cmdletContext.UtcValidUntil != null)
            {
                request.ValidUntilUtc = cmdletContext.UtcValidUntil.Value;
            }
            #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
            if (cmdletContext.ValidFrom != null)
            {
                if (cmdletContext.UtcValidFrom != null)
                {
                    throw new System.ArgumentException("Parameters ValidFrom and UtcValidFrom are mutually exclusive.", nameof(this.ValidFrom));
                }
                request.ValidFrom = cmdletContext.ValidFrom.Value;
            }
            #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
            if (cmdletContext.ValidUntil != null)
            {
                if (cmdletContext.UtcValidUntil != null)
                {
                    throw new System.ArgumentException("Parameters ValidUntil and UtcValidUntil are mutually exclusive.", nameof(this.ValidUntil));
                }
                request.ValidUntil = cmdletContext.ValidUntil.Value;
            }
            #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute

            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);
        }