createPricingRule method

Future<CreatePricingRuleOutput> createPricingRule({
  1. required String name,
  2. required PricingRuleScope scope,
  3. required PricingRuleType type,
  4. String? billingEntity,
  5. String? clientToken,
  6. String? description,
  7. double? modifierPercentage,
  8. String? operation,
  9. String? service,
  10. Map<String, String>? tags,
  11. CreateTieringInput? tiering,
  12. String? usageType,
})

Creates a pricing rule can be associated to a pricing plan, or a set of pricing plans.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ServiceLimitExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter name : The pricing rule name. The names must be unique to each pricing rule.

Parameter scope : The scope of pricing rule that indicates if it's globally applicable, or it's service-specific.

Parameter type : The type of pricing rule.

Parameter billingEntity : The seller of services provided by Amazon Web Services, their affiliates, or third-party providers selling services via Amazon Web Services Marketplace.

Parameter clientToken : A unique, case-sensitive identifier that you specify to ensure idempotency of the request. Idempotency ensures that an API request completes no more than one time. With an idempotent request, if the original request completes successfully, any subsequent retries complete successfully without performing any further actions.

Parameter description : The pricing rule description.

Parameter modifierPercentage : A percentage modifier that's applied on the public pricing rates. Your entry will be rounded to the nearest 2 decimal places.

Parameter operation : Operation is the specific Amazon Web Services action covered by this line item. This describes the specific usage of the line item.

If the Scope attribute is set to SKU, this attribute indicates which operation the PricingRule is modifying. For example, a value of RunInstances:0202 indicates the operation of running an Amazon EC2 instance.

Parameter service : If the Scope attribute is set to SERVICE or SKU, the attribute indicates which service the PricingRule is applicable for.

Parameter tags : A map that contains tag keys and tag values that are attached to a pricing rule.

Parameter tiering : The set of tiering configurations for the pricing rule.

Parameter usageType : Usage type is the unit that each service uses to measure the usage of a specific type of resource.

If the Scope attribute is set to SKU, this attribute indicates which usage type the PricingRule is modifying. For example, USW2-BoxUsage:m2.2xlarge describes an M2 High Memory Double Extra Large instance in the US West (Oregon) Region.

Implementation

Future<CreatePricingRuleOutput> createPricingRule({
  required String name,
  required PricingRuleScope scope,
  required PricingRuleType type,
  String? billingEntity,
  String? clientToken,
  String? description,
  double? modifierPercentage,
  String? operation,
  String? service,
  Map<String, String>? tags,
  CreateTieringInput? tiering,
  String? usageType,
}) async {
  _s.validateNumRange(
    'modifierPercentage',
    modifierPercentage,
    0,
    1152921504606846976,
  );
  final headers = <String, String>{
    if (clientToken != null) 'X-Amzn-Client-Token': clientToken.toString(),
  };
  final $payload = <String, dynamic>{
    'Name': name,
    'Scope': scope.value,
    'Type': type.value,
    if (billingEntity != null) 'BillingEntity': billingEntity,
    if (description != null) 'Description': description,
    if (modifierPercentage != null) 'ModifierPercentage': modifierPercentage,
    if (operation != null) 'Operation': operation,
    if (service != null) 'Service': service,
    if (tags != null) 'Tags': tags,
    if (tiering != null) 'Tiering': tiering,
    if (usageType != null) 'UsageType': usageType,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/create-pricing-rule',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return CreatePricingRuleOutput.fromJson(response);
}