Skip to content

create_cost_category_definition async

create_cost_category_definition(
    name: CostCategoryName,
    rule_version: CostCategoryRuleVersion,
    rules: CostCategoryRulesList,
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    effective_start: Optional[ZonedDateTime] = None,
    default_value: Optional[CostCategoryValue] = None,
    split_charge_rules: Optional[CostCategorySplitChargeRulesList] = None,
    resource_tags: Optional[ResourceTagList] = None,
) -> CreateCostCategoryDefinitionResponse

Creates a new cost category with the requested name and rules.

Parameters:

  • effective_start (Optional[ZonedDateTime], default: None ) –

    The cost category's effective start date. It can only be a billing start date (first day of the month). If the date isn't provided, it's the first day of the current month. Dates can't be before the previous twelve months, or in the future.

  • rules (CostCategoryRulesList) –

    The cost category rules used to categorize costs. For more information, see CostCategoryRule.

  • split_charge_rules (Optional[CostCategorySplitChargeRulesList], default: None ) –

    The split charge rules used to allocate your charges between your cost category values.

  • resource_tags (Optional[ResourceTagList], default: None ) –

    An optional list of tags to associate with the specified CostCategory . You can use resource tags to control access to your cost category using IAM policies.

    Each tag consists of a key and a value, and each key must be unique for the resource. The following restrictions apply to resource tags:

    • Although the maximum number of array members is 200, you can assign a maximum of 50 user-tags to one resource. The remaining are reserved for Amazon Web Services use

    • The maximum length of a key is 128 characters

    • The maximum length of a value is 256 characters

    • Keys and values can only contain alphanumeric characters, spaces, and any of the following: _.:/=+@-

    • Keys and values are case sensitive

    • Keys and values are trimmed for any leading or trailing whitespaces

    • Don’t use aws: as a prefix for your keys. This prefix is reserved for Amazon Web Services use

Raises:

Source code in docs_src/capo_cost_explorer/_services/async_cost_explorer.py
async def create_cost_category_definition(
    self,
    name: "capo_cost_explorer.types.cost_category_name.CostCategoryName",
    rule_version: "capo_cost_explorer.types.cost_category_rule_version.CostCategoryRuleVersion",
    rules: "capo_cost_explorer.types.cost_category_rules_list.CostCategoryRulesList",
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    effective_start: Optional[
        "capo_cost_explorer.types.zoned_date_time.ZonedDateTime"
    ] = None,
    default_value: Optional[
        "capo_cost_explorer.types.cost_category_value.CostCategoryValue"
    ] = None,
    split_charge_rules: Optional[
        "capo_cost_explorer.types.cost_category_split_charge_rules_list.CostCategorySplitChargeRulesList"
    ] = None,
    resource_tags: Optional[
        "capo_cost_explorer.types.resource_tag_list.ResourceTagList"
    ] = None,
) -> "capo_cost_explorer.types.create_cost_category_definition_response.CreateCostCategoryDefinitionResponse":
    """<p>Creates a new cost category with the requested name and rules.</p>

    Args:
        effective_start: <p>The cost category's effective start date. It can only be a billing start date (first day of the month). If the date isn't provided, it's the first day of the current month. Dates can't be before the previous twelve months, or in the future.</p>
        rules: <p>The cost category rules used to categorize costs. For more information, see <a href="https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategoryRule.html">CostCategoryRule</a>.</p>
        split_charge_rules: <p> The split charge rules used to allocate your charges between your cost category values. </p>
        resource_tags: <p>An optional list of tags to associate with the specified <a href="https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CostCategory.html"> <code>CostCategory</code> </a>. You can use resource tags to control access to your <code>cost category</code> using IAM policies.</p> <p>Each tag consists of a key and a value, and each key must be unique for the resource. The following restrictions apply to resource tags:</p> <ul> <li> <p>Although the maximum number of array members is 200, you can assign a maximum of 50 user-tags to one resource. The remaining are reserved for Amazon Web Services use</p> </li> <li> <p>The maximum length of a key is 128 characters</p> </li> <li> <p>The maximum length of a value is 256 characters</p> </li> <li> <p>Keys and values can only contain alphanumeric characters, spaces, and any of the following: <code>_.:/=+@-</code> </p> </li> <li> <p>Keys and values are case sensitive</p> </li> <li> <p>Keys and values are trimmed for any leading or trailing whitespaces</p> </li> <li> <p>Don’t use <code>aws:</code> as a prefix for your keys. This prefix is reserved for Amazon Web Services use</p> </li> </ul>

    Raises:
        capo_cost_explorer.errors.limit_exceeded_exception.LimitExceededException: <p>You made too many calls in a short period of time. Try again later.</p>
        capo_cost_explorer.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p> You've reached the limit on the number of resources you can create, or exceeded the size of an individual resource. </p>
        capo_cost_explorer.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cost_explorer.types.create_cost_category_definition_request.CreateCostCategoryDefinitionRequest]",
    ) -> AsyncOperationResponse[
        "capo_cost_explorer.types.create_cost_category_definition_response.CreateCostCategoryDefinitionResponse"
    ]:
        import capo_cost_explorer._operations.aws_insights_index_service.create_cost_category_definition

        (
            output,
            http_response,
        ) = await capo_cost_explorer._operations.aws_insights_index_service.create_cost_category_definition.async_create_cost_category_definition(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateCostCategoryDefinition")
    )
    input_: capo_cost_explorer.types.create_cost_category_definition_request.CreateCostCategoryDefinitionRequest = {
        "name": name,
        "rule_version": rule_version,
        "rules": rules,
    }
    if effective_start is not None:
        input_["effective_start"] = effective_start
    if default_value is not None:
        input_["default_value"] = default_value
    if split_charge_rules is not None:
        input_["split_charge_rules"] = split_charge_rules
    if resource_tags is not None:
        input_["resource_tags"] = resource_tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output