checkCapacity method

Future<CheckCapacityResponse> checkCapacity({
  1. required List<Rule> rules,
  2. required Scope scope,
})
Returns the web ACL capacity unit (WCU) requirements for a specified scope and set of rules. You can use this to check the capacity requirements for the rules you want to use in a RuleGroup or WebACL.

AWS WAF uses WCUs to calculate and control the operating resources that are used to run your rules, rule groups, and web ACLs. AWS WAF calculates capacity differently for each rule type, to reflect the relative cost of each rule. Simple rules that cost little to run use fewer WCUs than more complex rules that use more processing power. Rule group capacity is fixed at creation, which helps users plan their web ACL WCU usage when they use a rule group. The WCU limit for web ACLs is 1,500.

May throw WAFInternalErrorException. May throw WAFInvalidParameterException. May throw WAFNonexistentItemException. May throw WAFLimitsExceededException. May throw WAFInvalidResourceException. May throw WAFUnavailableEntityException. May throw WAFSubscriptionNotFoundException.

Parameter rules : An array of Rule that you're configuring to use in a rule group or web ACL.

Parameter scope : Specifies whether this is for an AWS CloudFront distribution or for a regional application. A regional application can be an Application Load Balancer (ALB), an API Gateway REST API, or an AppSync GraphQL API.

To work with CloudFront, you must also specify the Region US East (N. Virginia) as follows:

  • CLI - Specify the Region when you use the CloudFront scope: --scope=CLOUDFRONT --region=us-east-1.
  • API and SDKs - For all calls, use the Region endpoint us-east-1.

Implementation

Future<CheckCapacityResponse> checkCapacity({
  required List<Rule> rules,
  required Scope scope,
}) async {
  ArgumentError.checkNotNull(rules, 'rules');
  ArgumentError.checkNotNull(scope, 'scope');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSWAF_20190729.CheckCapacity'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Rules': rules,
      'Scope': scope.toValue(),
    },
  );

  return CheckCapacityResponse.fromJson(jsonResponse.body);
}