Container for the parameters to the PutAutoScalingPolicy operation. Creates or updates an automatic scaling policy for a core instance group or task instance group in an Amazon EMR cluster. The automatic scaling policy defines how an instance group dynamically adds and terminates EC2 instances in response to the value of a CloudWatch metric.
Inheritance: AmazonElasticMapReduceRequest
 private Amazon.ElasticMapReduce.Model.PutAutoScalingPolicyResponse CallAWSServiceOperation(IAmazonElasticMapReduce client, Amazon.ElasticMapReduce.Model.PutAutoScalingPolicyRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic MapReduce", "PutAutoScalingPolicy");
     try
     {
         #if DESKTOP
         return(client.PutAutoScalingPolicy(request));
         #elif CORECLR
         return(client.PutAutoScalingPolicyAsync(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.ElasticMapReduce.Model.PutAutoScalingPolicyRequest();


            // populate AutoScalingPolicy
            var requestAutoScalingPolicyIsNull = true;

            request.AutoScalingPolicy = new Amazon.ElasticMapReduce.Model.AutoScalingPolicy();
            List <Amazon.ElasticMapReduce.Model.ScalingRule> requestAutoScalingPolicy_autoScalingPolicy_Rule = null;

            if (cmdletContext.AutoScalingPolicy_Rule != null)
            {
                requestAutoScalingPolicy_autoScalingPolicy_Rule = cmdletContext.AutoScalingPolicy_Rule;
            }
            if (requestAutoScalingPolicy_autoScalingPolicy_Rule != null)
            {
                request.AutoScalingPolicy.Rules = requestAutoScalingPolicy_autoScalingPolicy_Rule;
                requestAutoScalingPolicyIsNull  = false;
            }
            Amazon.ElasticMapReduce.Model.ScalingConstraints requestAutoScalingPolicy_autoScalingPolicy_Constraints = null;

            // populate Constraints
            var requestAutoScalingPolicy_autoScalingPolicy_ConstraintsIsNull = true;

            requestAutoScalingPolicy_autoScalingPolicy_Constraints = new Amazon.ElasticMapReduce.Model.ScalingConstraints();
            System.Int32?requestAutoScalingPolicy_autoScalingPolicy_Constraints_constraints_MaxCapacity = null;
            if (cmdletContext.Constraints_MaxCapacity != null)
            {
                requestAutoScalingPolicy_autoScalingPolicy_Constraints_constraints_MaxCapacity = cmdletContext.Constraints_MaxCapacity.Value;
            }
            if (requestAutoScalingPolicy_autoScalingPolicy_Constraints_constraints_MaxCapacity != null)
            {
                requestAutoScalingPolicy_autoScalingPolicy_Constraints.MaxCapacity = requestAutoScalingPolicy_autoScalingPolicy_Constraints_constraints_MaxCapacity.Value;
                requestAutoScalingPolicy_autoScalingPolicy_ConstraintsIsNull       = false;
            }
            System.Int32?requestAutoScalingPolicy_autoScalingPolicy_Constraints_constraints_MinCapacity = null;
            if (cmdletContext.Constraints_MinCapacity != null)
            {
                requestAutoScalingPolicy_autoScalingPolicy_Constraints_constraints_MinCapacity = cmdletContext.Constraints_MinCapacity.Value;
            }
            if (requestAutoScalingPolicy_autoScalingPolicy_Constraints_constraints_MinCapacity != null)
            {
                requestAutoScalingPolicy_autoScalingPolicy_Constraints.MinCapacity = requestAutoScalingPolicy_autoScalingPolicy_Constraints_constraints_MinCapacity.Value;
                requestAutoScalingPolicy_autoScalingPolicy_ConstraintsIsNull       = false;
            }
            // determine if requestAutoScalingPolicy_autoScalingPolicy_Constraints should be set to null
            if (requestAutoScalingPolicy_autoScalingPolicy_ConstraintsIsNull)
            {
                requestAutoScalingPolicy_autoScalingPolicy_Constraints = null;
            }
            if (requestAutoScalingPolicy_autoScalingPolicy_Constraints != null)
            {
                request.AutoScalingPolicy.Constraints = requestAutoScalingPolicy_autoScalingPolicy_Constraints;
                requestAutoScalingPolicyIsNull        = false;
            }
            // determine if request.AutoScalingPolicy should be set to null
            if (requestAutoScalingPolicyIsNull)
            {
                request.AutoScalingPolicy = null;
            }
            if (cmdletContext.ClusterId != null)
            {
                request.ClusterId = cmdletContext.ClusterId;
            }
            if (cmdletContext.InstanceGroupId != null)
            {
                request.InstanceGroupId = cmdletContext.InstanceGroupId;
            }

            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);
        }
        internal PutAutoScalingPolicyResponse PutAutoScalingPolicy(PutAutoScalingPolicyRequest request)
        {
            var marshaller = new PutAutoScalingPolicyRequestMarshaller();
            var unmarshaller = PutAutoScalingPolicyResponseUnmarshaller.Instance;

            return Invoke<PutAutoScalingPolicyRequest,PutAutoScalingPolicyResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the PutAutoScalingPolicy operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutAutoScalingPolicy 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<PutAutoScalingPolicyResponse> PutAutoScalingPolicyAsync(PutAutoScalingPolicyRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new PutAutoScalingPolicyRequestMarshaller();
            var unmarshaller = PutAutoScalingPolicyResponseUnmarshaller.Instance;

            return InvokeAsync<PutAutoScalingPolicyRequest,PutAutoScalingPolicyResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the PutAutoScalingPolicy operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutAutoScalingPolicy operation on AmazonElasticMapReduceClient.</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 EndPutAutoScalingPolicy
        ///         operation.</returns>
        public IAsyncResult BeginPutAutoScalingPolicy(PutAutoScalingPolicyRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new PutAutoScalingPolicyRequestMarshaller();
            var unmarshaller = PutAutoScalingPolicyResponseUnmarshaller.Instance;

            return BeginInvoke<PutAutoScalingPolicyRequest>(request, marshaller, unmarshaller,
                callback, state);
        }