Skip to content

describe_budget_spend async

describe_budget_spend(
    account_id: AccountId,
    budget_name: BudgetName,
    *,
    config_overrides: Optional[AsyncBudgetsClientConfig] = None,
    group_by: Optional[GroupDefinitions] = None,
    filter_expression: Optional[Expression] = None,
    max_results: Optional[MaxResultsDescribeBudgets] = None,
    next_token: Optional[SpendPaginationToken] = None,
) -> DescribeBudgetSpendResponse

Describes the spend of a budget for the budget's current period. Use this operation with a budget that uses the PublicOnDemandCost or EstimatedContractedCost metric.

By default, the response has one row for each budget limit. If the budget has BudgetLimitDimensions, set GroupBy to the budget's SpendAttributions key to get one row for each principal instead. Use FilterExpression to return only some principals. Rows are sorted by spend, from highest to lowest.

Results are paginated. Use the NextToken parameter to retrieve additional results.

Parameters:

  • account_id (AccountId) –

    The accountId that is associated with the budget.

  • budget_name (BudgetName) –

    The name of the budget whose spend you want to describe.

  • group_by (Optional[GroupDefinitions], default: None ) –

    How to group the spend. You can specify no entry or one entry. To get one row for each principal, specify one DIMENSION entry whose key is the budget's SpendAttributions value. If you don't specify GroupBy, the response uses the budget's BudgetLimitDimensions.

  • filter_expression (Optional[Expression], default: None ) –

    The principals to return spend for. Specify one Dimensions clause whose key is the budget's SpendAttributions value, with the EQUALS match option and 1 to 20 principal IDs. If you don't specify FilterExpression, Amazon Web Services Budgets returns spend for every principal that has spend in the budget.

  • max_results (Optional[MaxResultsDescribeBudgets], default: None ) –

    The maximum number of results to return in one page. Valid range is 1 to 1000. If you don't specify MaxResults, the default is 100.

  • next_token (Optional[SpendPaginationToken], default: None ) –

    The pagination token that you include in your request to indicate the next set of results that you want to retrieve.

Raises:

Source code in docs_src/capo_budgets/_services/async_budgets.py
async def describe_budget_spend(
    self,
    account_id: "capo_budgets.types.account_id.AccountId",
    budget_name: "capo_budgets.types.budget_name.BudgetName",
    *,
    config_overrides: Optional[AsyncBudgetsClientConfig] = None,
    group_by: Optional[
        "capo_budgets.types.group_definitions.GroupDefinitions"
    ] = None,
    filter_expression: Optional["capo_budgets.types.expression.Expression"] = None,
    max_results: Optional[
        "capo_budgets.types.max_results_describe_budgets.MaxResultsDescribeBudgets"
    ] = None,
    next_token: Optional[
        "capo_budgets.types.spend_pagination_token.SpendPaginationToken"
    ] = None,
) -> (
    "capo_budgets.types.describe_budget_spend_response.DescribeBudgetSpendResponse"
):
    """<p>Describes the spend of a budget for the budget's current period. Use this operation with a budget that uses the <code>PublicOnDemandCost</code> or <code>EstimatedContractedCost</code> metric.</p> <p>By default, the response has one row for each budget limit. If the budget has <code>BudgetLimitDimensions</code>, set <code>GroupBy</code> to the budget's <code>SpendAttributions</code> key to get one row for each principal instead. Use <code>FilterExpression</code> to return only some principals. Rows are sorted by spend, from highest to lowest.</p> <p>Results are paginated. Use the <code>NextToken</code> parameter to retrieve additional results.</p>

    Args:
        account_id: <p>The <code>accountId</code> that is associated with the budget.</p>
        budget_name: <p>The name of the budget whose spend you want to describe.</p>
        group_by: <p>How to group the spend. You can specify no entry or one entry. To get one row for each principal, specify one <code>DIMENSION</code> entry whose key is the budget's <code>SpendAttributions</code> value. If you don't specify <code>GroupBy</code>, the response uses the budget's <code>BudgetLimitDimensions</code>.</p>
        filter_expression: <p>The principals to return spend for. Specify one <code>Dimensions</code> clause whose key is the budget's <code>SpendAttributions</code> value, with the <code>EQUALS</code> match option and 1 to 20 principal IDs. If you don't specify <code>FilterExpression</code>, Amazon Web Services Budgets returns spend for every principal that has spend in the budget.</p>
        max_results: <p>The maximum number of results to return in one page. Valid range is 1 to 1000. If you don't specify <code>MaxResults</code>, the default is 100.</p>
        next_token: <p>The pagination token that you include in your request to indicate the next set of results that you want to retrieve.</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.expired_next_token_exception.ExpiredNextTokenException: <p>The pagination token expired.</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_next_token_exception.InvalidNextTokenException: <p>The pagination token is invalid.</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.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.describe_budget_spend_request.DescribeBudgetSpendRequest]",
    ) -> AsyncOperationResponse[
        "capo_budgets.types.describe_budget_spend_response.DescribeBudgetSpendResponse"
    ]:
        import capo_budgets._operations.aws_budget_service_gateway.describe_budget_spend

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

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

        return capo_budgets.types.describe_budget_spend_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_budgets.types.describe_budget_spend_response.DescribeBudgetSpendResponse",
    ) -> dict[str, Any]:
        import capo_budgets.types.describe_budget_spend_response

        return capo_budgets.types.describe_budget_spend_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "DescribeBudgetSpend",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_budgets.types.describe_budget_spend_request.DescribeBudgetSpendRequest = {
        "account_id": account_id,
        "budget_name": budget_name,
    }
    if group_by is not None:
        input_["group_by"] = group_by
    if filter_expression is not None:
        input_["filter_expression"] = filter_expression
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

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