createRegexPatternSet method

Future<CreateRegexPatternSetResponse> createRegexPatternSet({
  1. required String name,
  2. required List<Regex> regularExpressionList,
  3. required Scope scope,
  4. String? description,
  5. List<Tag>? tags,
})
Creates a RegexPatternSet, which you reference in a RegexPatternSetReferenceStatement, to have AWS WAF inspect a web request component for the specified patterns.

May throw WAFInternalErrorException. May throw WAFInvalidParameterException. May throw WAFDuplicateItemException. May throw WAFOptimisticLockException. May throw WAFLimitsExceededException. May throw WAFTagOperationException. May throw WAFTagOperationInternalErrorException. May throw WAFInvalidOperationException.

Parameter name : The name of the set. You cannot change the name after you create the set.

Parameter regularExpressionList : Array of regular expression strings.

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.

Parameter description : A description of the set that helps with identification. You cannot change the description of a set after you create it.

Parameter tags : An array of key:value pairs to associate with the resource.

Implementation

Future<CreateRegexPatternSetResponse> createRegexPatternSet({
  required String name,
  required List<Regex> regularExpressionList,
  required Scope scope,
  String? description,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(regularExpressionList, 'regularExpressionList');
  ArgumentError.checkNotNull(scope, 'scope');
  _s.validateStringLength(
    'description',
    description,
    1,
    256,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSWAF_20190729.CreateRegexPatternSet'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'RegularExpressionList': regularExpressionList,
      'Scope': scope.toValue(),
      if (description != null) 'Description': description,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateRegexPatternSetResponse.fromJson(jsonResponse.body);
}