Пример #1
0
 private Amazon.ECS.Model.UpdateCapacityProviderResponse CallAWSServiceOperation(IAmazonECS client, Amazon.ECS.Model.UpdateCapacityProviderRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon EC2 Container Service", "UpdateCapacityProvider");
     try
     {
         #if DESKTOP
         return(client.UpdateCapacityProvider(request));
         #elif CORECLR
         return(client.UpdateCapacityProviderAsync(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;
     }
 }
Пример #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.ECS.Model.UpdateCapacityProviderRequest();


            // populate AutoScalingGroupProvider
            var requestAutoScalingGroupProviderIsNull = true;

            request.AutoScalingGroupProvider = new Amazon.ECS.Model.AutoScalingGroupProviderUpdate();
            Amazon.ECS.ManagedTerminationProtection requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedTerminationProtection = null;
            if (cmdletContext.AutoScalingGroupProvider_ManagedTerminationProtection != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedTerminationProtection = cmdletContext.AutoScalingGroupProvider_ManagedTerminationProtection;
            }
            if (requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedTerminationProtection != null)
            {
                request.AutoScalingGroupProvider.ManagedTerminationProtection = requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedTerminationProtection;
                requestAutoScalingGroupProviderIsNull = false;
            }
            Amazon.ECS.Model.ManagedScaling requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling = null;

            // populate ManagedScaling
            var requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScalingIsNull = true;

            requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling = new Amazon.ECS.Model.ManagedScaling();
            System.Int32?requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_InstanceWarmupPeriod = null;
            if (cmdletContext.ManagedScaling_InstanceWarmupPeriod != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_InstanceWarmupPeriod = cmdletContext.ManagedScaling_InstanceWarmupPeriod.Value;
            }
            if (requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_InstanceWarmupPeriod != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling.InstanceWarmupPeriod = requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_InstanceWarmupPeriod.Value;
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScalingIsNull = false;
            }
            System.Int32?requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_MaximumScalingStepSize = null;
            if (cmdletContext.ManagedScaling_MaximumScalingStepSize != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_MaximumScalingStepSize = cmdletContext.ManagedScaling_MaximumScalingStepSize.Value;
            }
            if (requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_MaximumScalingStepSize != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling.MaximumScalingStepSize = requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_MaximumScalingStepSize.Value;
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScalingIsNull = false;
            }
            System.Int32?requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_MinimumScalingStepSize = null;
            if (cmdletContext.ManagedScaling_MinimumScalingStepSize != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_MinimumScalingStepSize = cmdletContext.ManagedScaling_MinimumScalingStepSize.Value;
            }
            if (requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_MinimumScalingStepSize != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling.MinimumScalingStepSize = requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_MinimumScalingStepSize.Value;
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScalingIsNull = false;
            }
            Amazon.ECS.ManagedScalingStatus requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_Status = null;
            if (cmdletContext.ManagedScaling_Status != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_Status = cmdletContext.ManagedScaling_Status;
            }
            if (requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_Status != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling.Status = requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_Status;
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScalingIsNull  = false;
            }
            System.Int32?requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_TargetCapacity = null;
            if (cmdletContext.ManagedScaling_TargetCapacity != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_TargetCapacity = cmdletContext.ManagedScaling_TargetCapacity.Value;
            }
            if (requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_TargetCapacity != null)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling.TargetCapacity = requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling_managedScaling_TargetCapacity.Value;
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScalingIsNull          = false;
            }
            // determine if requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling should be set to null
            if (requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScalingIsNull)
            {
                requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling = null;
            }
            if (requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling != null)
            {
                request.AutoScalingGroupProvider.ManagedScaling = requestAutoScalingGroupProvider_autoScalingGroupProvider_ManagedScaling;
                requestAutoScalingGroupProviderIsNull           = false;
            }
            // determine if request.AutoScalingGroupProvider should be set to null
            if (requestAutoScalingGroupProviderIsNull)
            {
                request.AutoScalingGroupProvider = null;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }

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