Skip to content

create_pricing_rule

create_pricing_rule(
    name: PricingRuleName,
    scope: PricingRuleScope,
    type: PricingRuleType,
    *,
    config_overrides: Optional[billingconductorClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    description: Optional[PricingRuleDescription] = None,
    modifier_percentage: Optional[ModifierPercentage] = None,
    service: Optional[Service] = None,
    tags: Optional[TagMap] = None,
    billing_entity: Optional[BillingEntity] = None,
    tiering: Optional[CreateTieringInput] = None,
    usage_type: Optional[UsageType] = None,
    operation: Optional[Operation] = None,
) -> CreatePricingRuleOutput

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

Parameters:

  • client_token (Optional[ClientToken], default: None ) –

    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.

  • name (PricingRuleName) –

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

  • description (Optional[PricingRuleDescription], default: None ) –

    The pricing rule description.

  • scope (PricingRuleScope) –

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

  • type (PricingRuleType) –

    The type of pricing rule.

  • modifier_percentage (Optional[ModifierPercentage], default: None ) –

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

  • service (Optional[Service], default: None ) –

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

  • tags (Optional[TagMap], default: None ) –

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

  • billing_entity (Optional[BillingEntity], default: None ) –

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

  • tiering (Optional[CreateTieringInput], default: None ) –

    The set of tiering configurations for the pricing rule.

  • usage_type (Optional[UsageType], default: None ) –

    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.

  • operation (Optional[Operation], default: None ) –

    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.

Raises:

Source code in docs_src/capo_billingconductor/_services/billingconductor.py
def create_pricing_rule(
    self,
    name: "capo_billingconductor.types.pricing_rule_name.PricingRuleName",
    scope: "capo_billingconductor.types.pricing_rule_scope.PricingRuleScope",
    type: "capo_billingconductor.types.pricing_rule_type.PricingRuleType",
    *,
    config_overrides: Optional[billingconductorClientConfig] = None,
    client_token: Optional[
        "capo_billingconductor.types.client_token.ClientToken"
    ] = None,
    description: Optional[
        "capo_billingconductor.types.pricing_rule_description.PricingRuleDescription"
    ] = None,
    modifier_percentage: Optional[
        "capo_billingconductor.types.modifier_percentage.ModifierPercentage"
    ] = None,
    service: Optional["capo_billingconductor.types.service.Service"] = None,
    tags: Optional["capo_billingconductor.types.tag_map.TagMap"] = None,
    billing_entity: Optional[
        "capo_billingconductor.types.billing_entity.BillingEntity"
    ] = None,
    tiering: Optional[
        "capo_billingconductor.types.create_tiering_input.CreateTieringInput"
    ] = None,
    usage_type: Optional["capo_billingconductor.types.usage_type.UsageType"] = None,
    operation: Optional["capo_billingconductor.types.operation.Operation"] = None,
) -> (
    "capo_billingconductor.types.create_pricing_rule_output.CreatePricingRuleOutput"
):
    """<p> Creates a pricing rule can be associated to a pricing plan, or a set of pricing plans. </p>

    Args:
        client_token: <p>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.</p>
        name: <p> The pricing rule name. The names must be unique to each pricing rule. </p>
        description: <p> The pricing rule description. </p>
        scope: <p> The scope of pricing rule that indicates if it's globally applicable, or it's service-specific. </p>
        type: <p> The type of pricing rule. </p>
        modifier_percentage: <p>A percentage modifier that's applied on the public pricing rates. Your entry will be rounded to the nearest 2 decimal places.</p>
        service: <p> If the <code>Scope</code> attribute is set to <code>SERVICE</code> or <code>SKU</code>, the attribute indicates which service the <code>PricingRule</code> is applicable for. </p>
        tags: <p> A map that contains tag keys and tag values that are attached to a pricing rule. </p>
        billing_entity: <p> The seller of services provided by Amazon Web Services, their affiliates, or third-party providers selling services via Amazon Web Services Marketplace. </p>
        tiering: <p> The set of tiering configurations for the pricing rule. </p>
        usage_type: <p> Usage type is the unit that each service uses to measure the usage of a specific type of resource.</p> <p>If the <code>Scope</code> attribute is set to <code>SKU</code>, this attribute indicates which usage type the <code>PricingRule</code> is modifying. For example, <code>USW2-BoxUsage:m2.2xlarge</code> describes an<code> M2 High Memory Double Extra Large</code> instance in the US West (Oregon) Region. </p>
        operation: <p> Operation is the specific Amazon Web Services action covered by this line item. This describes the specific usage of the line item.</p> <p> If the <code>Scope</code> attribute is set to <code>SKU</code>, this attribute indicates which operation the <code>PricingRule</code> is modifying. For example, a value of <code>RunInstances:0202</code> indicates the operation of running an Amazon EC2 instance.</p>

    Raises:
        capo_billingconductor.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action. </p>
        capo_billingconductor.errors.conflict_exception.ConflictException: <p>You can cause an inconsistent state by updating or deleting a resource. </p>
        capo_billingconductor.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred while processing a request. </p>
        capo_billingconductor.errors.service_limit_exceeded_exception.ServiceLimitExceededException: <p>The request would cause a service limit to exceed. </p>
        capo_billingconductor.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling. </p>
        capo_billingconductor.errors.validation_exception.ValidationException: <p>The input doesn't match with the constraints specified by Amazon Web Services services.</p>
        capo_billingconductor.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_billingconductor.types.create_pricing_rule_input.CreatePricingRuleInput]",
    ) -> OperationResponse[
        "capo_billingconductor.types.create_pricing_rule_output.CreatePricingRuleOutput"
    ]:
        import capo_billingconductor._operations.aws_billing_conductor.create_pricing_rule

        output, http_response = (
            capo_billingconductor._operations.aws_billing_conductor.create_pricing_rule.create_pricing_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_billingconductor.types.create_pricing_rule_input.CreatePricingRuleInput",
    ) -> dict[str, Any]:
        import capo_billingconductor.types.create_pricing_rule_input

        return (
            capo_billingconductor.types.create_pricing_rule_input.redact_sensitive(
                input_
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreatePricingRule", redact_input=_redact_input),
    )
    input_: capo_billingconductor.types.create_pricing_rule_input.CreatePricingRuleInput = {
        "name": name,
        "scope": scope,
        "type": type,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    if modifier_percentage is not None:
        input_["modifier_percentage"] = modifier_percentage
    if service is not None:
        input_["service"] = service
    if tags is not None:
        input_["tags"] = tags
    if billing_entity is not None:
        input_["billing_entity"] = billing_entity
    if tiering is not None:
        input_["tiering"] = tiering
    if usage_type is not None:
        input_["usage_type"] = usage_type
    if operation is not None:
        input_["operation"] = operation

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output