executePolicy method

Future<void> executePolicy({
  1. required String policyName,
  2. String? autoScalingGroupName,
  3. double? breachThreshold,
  4. bool? honorCooldown,
  5. double? metricValue,
})

Executes the specified policy. This can be useful for testing the design of your scaling policy.

May throw ScalingActivityInProgressFault. May throw ResourceContentionFault.

Parameter policyName : The name or ARN of the policy.

Parameter autoScalingGroupName : The name of the Auto Scaling group.

Parameter breachThreshold : The breach threshold for the alarm.

Required if the policy type is StepScaling and not supported otherwise.

Parameter honorCooldown : Indicates whether Amazon EC2 Auto Scaling waits for the cooldown period to complete before executing the policy.

Valid only if the policy type is SimpleScaling. For more information, see Scaling cooldowns for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.

Parameter metricValue : The metric value to compare to BreachThreshold. This enables you to execute a policy of type StepScaling and determine which step adjustment to use. For example, if the breach threshold is 50 and you want to use a step adjustment with a lower bound of 0 and an upper bound of 10, you can set the metric value to 59.

If you specify a metric value that doesn't correspond to a step adjustment for the policy, the call returns an error.

Required if the policy type is StepScaling and not supported otherwise.

Implementation

Future<void> executePolicy({
  required String policyName,
  String? autoScalingGroupName,
  double? breachThreshold,
  bool? honorCooldown,
  double? metricValue,
}) async {
  ArgumentError.checkNotNull(policyName, 'policyName');
  _s.validateStringLength(
    'policyName',
    policyName,
    1,
    1600,
    isRequired: true,
  );
  _s.validateStringLength(
    'autoScalingGroupName',
    autoScalingGroupName,
    1,
    255,
  );
  final $request = <String, dynamic>{};
  $request['PolicyName'] = policyName;
  autoScalingGroupName?.also((arg) => $request['AutoScalingGroupName'] = arg);
  breachThreshold?.also((arg) => $request['BreachThreshold'] = arg);
  honorCooldown?.also((arg) => $request['HonorCooldown'] = arg);
  metricValue?.also((arg) => $request['MetricValue'] = arg);
  await _protocol.send(
    $request,
    action: 'ExecutePolicy',
    version: '2011-01-01',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['ExecutePolicyType'],
    shapes: shapes,
  );
}