createRateBasedRule method

Future<CreateRateBasedRuleResponse> createRateBasedRule({
  1. required String changeToken,
  2. required String metricName,
  3. required String name,
  4. required RateKey rateKey,
  5. required int rateLimit,
  6. List<Tag>? tags,
})

Implementation

Future<CreateRateBasedRuleResponse> createRateBasedRule({
  required String changeToken,
  required String metricName,
  required String name,
  required RateKey rateKey,
  required int rateLimit,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(changeToken, 'changeToken');
  _s.validateStringLength(
    'changeToken',
    changeToken,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(metricName, 'metricName');
  _s.validateStringLength(
    'metricName',
    metricName,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(rateKey, 'rateKey');
  ArgumentError.checkNotNull(rateLimit, 'rateLimit');
  _s.validateNumRange(
    'rateLimit',
    rateLimit,
    100,
    2000000000,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSWAF_Regional_20161128.CreateRateBasedRule'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ChangeToken': changeToken,
      'MetricName': metricName,
      'Name': name,
      'RateKey': rateKey.toValue(),
      'RateLimit': rateLimit,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateRateBasedRuleResponse.fromJson(jsonResponse.body);
}