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 WAF inspect a web request component for the specified patterns.

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

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 a global resource type, such as a Amazon CloudFront distribution. For an Amplify application, use CLOUDFRONT.

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.

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 {
  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.value,
      if (description != null) 'Description': description,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateRegexPatternSetResponse.fromJson(jsonResponse.body);
}