Skip to content

create_budget async

create_budget(
    account_id: AccountId,
    budget: Budget,
    *,
    config_overrides: Optional[AsyncBudgetsClientConfig] = None,
    notifications_with_subscribers: Optional[NotificationWithSubscribersList] = None,
    resource_tags: Optional[ResourceTagList] = None,
) -> CreateBudgetResponse

Creates a budget and, if included, notifications and subscribers.

Only one of BudgetLimit or PlannedBudgetLimits can be present in the syntax at one time. Use the syntax that matches your use case. The Request Syntax section shows the BudgetLimit syntax. For PlannedBudgetLimits, see the Examples section.

Similarly, only one set of filter and metric selections can be present in the syntax at one time. Either FilterExpression and Metrics or CostFilters and CostTypes, not both or a different combination. We recommend using FilterExpression and Metrics as they provide more flexible and powerful filtering capabilities. The Request Syntax section shows the FilterExpression/Metrics syntax.

Parameters:

  • account_id (AccountId) –

    The accountId that is associated with the budget.

  • budget (Budget) –

    The budget object that you want to create.

  • notifications_with_subscribers (Optional[NotificationWithSubscribersList], default: None ) –

    A notification that you want to associate with a budget. A budget can have up to five notifications, and each notification can have one SNS subscriber and up to 10 email subscribers. If you include notifications and subscribers in your CreateBudget call, Amazon Web Services creates the notifications and subscribers for you.

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

    An optional list of tags to associate with the specified budget. Each tag consists of a key and a value, and each key must be unique for the resource.

Raises:

Source code in docs_src/capo_budgets/_services/async_budgets.py
async def create_budget(
    self,
    account_id: "capo_budgets.types.account_id.AccountId",
    budget: "capo_budgets.types.budget.Budget",
    *,
    config_overrides: Optional[AsyncBudgetsClientConfig] = None,
    notifications_with_subscribers: Optional[
        "capo_budgets.types.notification_with_subscribers_list.NotificationWithSubscribersList"
    ] = None,
    resource_tags: Optional[
        "capo_budgets.types.resource_tag_list.ResourceTagList"
    ] = None,
) -> "capo_budgets.types.create_budget_response.CreateBudgetResponse":
    """<p>Creates a budget and, if included, notifications and subscribers. </p> <important> <p>Only one of <code>BudgetLimit</code> or <code>PlannedBudgetLimits</code> can be present in the syntax at one time. Use the syntax that matches your use case. The Request Syntax section shows the <code>BudgetLimit</code> syntax. For <code>PlannedBudgetLimits</code>, see the <a href="https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_budgets_CreateBudget.html#API_CreateBudget_Examples">Examples</a> section.</p> <p>Similarly, only one set of filter and metric selections can be present in the syntax at one time. Either <code>FilterExpression</code> and <code>Metrics</code> or <code>CostFilters</code> and <code>CostTypes</code>, not both or a different combination. We recommend using <code>FilterExpression</code> and <code>Metrics</code> as they provide more flexible and powerful filtering capabilities. The Request Syntax section shows the <code>FilterExpression</code>/<code>Metrics</code> syntax.</p> </important>

    Args:
        account_id: <p>The <code>accountId</code> that is associated with the budget.</p>
        budget: <p>The budget object that you want to create.</p>
        notifications_with_subscribers: <p>A notification that you want to associate with a budget. A budget can have up to five notifications, and each notification can have one SNS subscriber and up to 10 email subscribers. If you include notifications and subscribers in your <code>CreateBudget</code> call, Amazon Web Services creates the notifications and subscribers for you.</p>
        resource_tags: <p>An optional list of tags to associate with the specified budget. Each tag consists of a key and a value, and each key must be unique for the resource.</p>

    Raises:
        capo_budgets.errors.access_denied_exception.AccessDeniedException: <p>You are not authorized to use this operation with the given parameters.</p>
        capo_budgets.errors.billing_view_health_status_exception.BillingViewHealthStatusException: <p> The billing view status must be HEALTHY to perform this action. Try again when the status is HEALTHY. </p>
        capo_budgets.errors.creation_limit_exceeded_exception.CreationLimitExceededException: <p>You've exceeded the notification or subscriber limit.</p>
        capo_budgets.errors.duplicate_record_exception.DuplicateRecordException: <p>The budget name already exists. Budget names must be unique within an account.</p>
        capo_budgets.errors.internal_error_exception.InternalErrorException: <p>An error on the server occurred during the processing of your request. Try again later.</p>
        capo_budgets.errors.invalid_parameter_exception.InvalidParameterException: <p>An error on the client occurred. Typically, the cause is an invalid input value.</p>
        capo_budgets.errors.not_found_exception.NotFoundException: <p>We can’t locate the resource that you specified.</p>
        capo_budgets.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You've reached a Service Quota limit on this resource.</p>
        capo_budgets.errors.throttling_exception.ThrottlingException: <p>The number of API requests has exceeded the maximum allowed API request throttling limit for the account.</p>
        capo_budgets.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_budgets.types.create_budget_request.CreateBudgetRequest]",
    ) -> AsyncOperationResponse[
        "capo_budgets.types.create_budget_response.CreateBudgetResponse"
    ]:
        import capo_budgets._operations.aws_budget_service_gateway.create_budget

        (
            output,
            http_response,
        ) = await capo_budgets._operations.aws_budget_service_gateway.create_budget.async_create_budget(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_budgets.types.create_budget_request.CreateBudgetRequest",
    ) -> dict[str, Any]:
        import capo_budgets.types.create_budget_request

        return capo_budgets.types.create_budget_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateBudget", redact_input=_redact_input),
    )
    input_: capo_budgets.types.create_budget_request.CreateBudgetRequest = {
        "account_id": account_id,
        "budget": budget,
    }
    if notifications_with_subscribers is not None:
        input_["notifications_with_subscribers"] = notifications_with_subscribers
    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