createCostCategoryDefinition method

Future<CreateCostCategoryDefinitionResponse> createCostCategoryDefinition({
  1. required String name,
  2. required CostCategoryRuleVersion ruleVersion,
  3. required List<CostCategoryRule> rules,
})

Creates a new Cost Category with the requested name and rules.

May throw ServiceQuotaExceededException. May throw LimitExceededException.

Parameter rules : The Cost Category rules used to categorize costs. For more information, see CostCategoryRule.

Implementation

Future<CreateCostCategoryDefinitionResponse> createCostCategoryDefinition({
  required String name,
  required CostCategoryRuleVersion ruleVersion,
  required List<CostCategoryRule> rules,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(ruleVersion, 'ruleVersion');
  ArgumentError.checkNotNull(rules, 'rules');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSInsightsIndexService.CreateCostCategoryDefinition'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'RuleVersion': ruleVersion.toValue(),
      'Rules': rules,
    },
  );

  return CreateCostCategoryDefinitionResponse.fromJson(jsonResponse.body);
}