Container for the parameters to the ExecutePolicy operation.

Runs the policy you create for your Auto Scaling group in PutScalingPolicy.

Inheritance: Amazon.Runtime.AmazonWebServiceRequest
Example #1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.AutoScaling.Model.ExecutePolicyRequest();

            if (cmdletContext.AutoScalingGroupName != null)
            {
                request.AutoScalingGroupName = cmdletContext.AutoScalingGroupName;
            }
            if (cmdletContext.BreachThreshold != null)
            {
                request.BreachThreshold = cmdletContext.BreachThreshold.Value;
            }
            if (cmdletContext.HonorCooldown != null)
            {
                request.HonorCooldown = cmdletContext.HonorCooldown.Value;
            }
            if (cmdletContext.MetricValue != null)
            {
                request.MetricValue = cmdletContext.MetricValue.Value;
            }
            if (cmdletContext.PolicyName != null)
            {
                request.PolicyName = cmdletContext.PolicyName;
            }

            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 ExecutePolicy operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ExecutePolicy 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<ExecutePolicyResponse> ExecutePolicyAsync(ExecutePolicyRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ExecutePolicyRequestMarshaller();
            var unmarshaller = ExecutePolicyResponseUnmarshaller.Instance;

            return InvokeAsync<ExecutePolicyRequest,ExecutePolicyResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        internal ExecutePolicyResponse ExecutePolicy(ExecutePolicyRequest request)
        {
            var marshaller = new ExecutePolicyRequestMarshaller();
            var unmarshaller = ExecutePolicyResponseUnmarshaller.Instance;

            return Invoke<ExecutePolicyRequest,ExecutePolicyResponse>(request, marshaller, unmarshaller);
        }
 IAsyncResult invokeExecutePolicy(ExecutePolicyRequest executePolicyRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new ExecutePolicyRequestMarshaller().Marshall(executePolicyRequest);
     var unmarshaller = ExecutePolicyResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
 /// <summary>
 /// Initiates the asynchronous execution of the ExecutePolicy operation.
 /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling.ExecutePolicy"/>
 /// </summary>
 /// 
 /// <param name="executePolicyRequest">Container for the necessary parameters to execute the ExecutePolicy operation on
 ///          AmazonAutoScaling.</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>
 public IAsyncResult BeginExecutePolicy(ExecutePolicyRequest executePolicyRequest, AsyncCallback callback, object state)
 {
     return invokeExecutePolicy(executePolicyRequest, callback, state, false);
 }
 /// <summary>
 /// <para>Executes the specified policy. </para>
 /// </summary>
 /// 
 /// <param name="executePolicyRequest">Container for the necessary parameters to execute the ExecutePolicy service method on
 ///          AmazonAutoScaling.</param>
 /// 
 /// <exception cref="ScalingActivityInProgressException"/>
 public ExecutePolicyResponse ExecutePolicy(ExecutePolicyRequest executePolicyRequest)
 {
     IAsyncResult asyncResult = invokeExecutePolicy(executePolicyRequest, null, null, true);
     return EndExecutePolicy(asyncResult);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the ExecutePolicy operation.
        /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling.ExecutePolicy"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ExecutePolicy 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<ExecutePolicyResponse> ExecutePolicyAsync(ExecutePolicyRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ExecutePolicyRequestMarshaller();
            var unmarshaller = ExecutePolicyResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, ExecutePolicyRequest, ExecutePolicyResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
        /// <summary>
        /// <para>Executes the specified policy. </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ExecutePolicy service method on
        /// AmazonAutoScaling.</param>
        /// 
        /// <exception cref="T:Amazon.AutoScaling.Model.ScalingActivityInProgressException" />
		public ExecutePolicyResponse ExecutePolicy(ExecutePolicyRequest request)
        {
            var task = ExecutePolicyAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the ExecutePolicy operation.
        /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ExecutePolicy operation on AmazonAutoScalingClient.</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 EndExecutePolicy
        ///         operation.</returns>
        public IAsyncResult BeginExecutePolicy(ExecutePolicyRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new ExecutePolicyRequestMarshaller();
            var unmarshaller = ExecutePolicyResponseUnmarshaller.Instance;

            return BeginInvoke<ExecutePolicyRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 /// <summary>
 /// <para>Runs the policy you create for your Auto Scaling group in PutScalingPolicy.</para>
 /// </summary>
 /// 
 /// <param name="executePolicyRequest">Container for the necessary parameters to execute the ExecutePolicy service method on
 ///           AmazonAutoScaling.</param>
 /// 
 /// <exception cref="ScalingActivityInProgressException"/>
 public ExecutePolicyResponse ExecutePolicy(ExecutePolicyRequest executePolicyRequest)
 {
     IRequest<ExecutePolicyRequest> request = new ExecutePolicyRequestMarshaller().Marshall(executePolicyRequest);
     ExecutePolicyResponse response = Invoke<ExecutePolicyRequest, ExecutePolicyResponse> (request, this.signer, ExecutePolicyResponseUnmarshaller.GetInstance());
     return response;
 }
		internal ExecutePolicyResponse ExecutePolicy(ExecutePolicyRequest request)
        {
            var task = ExecutePolicyAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
Example #12
0
 private Amazon.AutoScaling.Model.ExecutePolicyResponse CallAWSServiceOperation(IAmazonAutoScaling client, Amazon.AutoScaling.Model.ExecutePolicyRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Auto Scaling", "ExecutePolicy");
     try
     {
         #if DESKTOP
         return(client.ExecutePolicy(request));
         #elif CORECLR
         return(client.ExecutePolicyAsync(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;
     }
 }
        /// <summary>
        /// Initiates the asynchronous execution of the ExecutePolicy operation.
        /// <seealso cref="Amazon.AutoScaling.IAmazonAutoScaling.ExecutePolicy"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ExecutePolicy 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 async Task<ExecutePolicyResponse> ExecutePolicyAsync(ExecutePolicyRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ExecutePolicyRequestMarshaller();
            var unmarshaller = ExecutePolicyResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, ExecutePolicyRequest, ExecutePolicyResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }