Skip to content

describe_budget_spend_for_principal async

describe_budget_spend_for_principal(
    account_id: AccountId,
    principal: SpendPrincipal,
    *,
    config_overrides: Optional[AsyncBudgetsClientConfig] = None,
    max_results: Optional[MaxResultsDescribeBudgets] = None,
    next_token: Optional[SpendPaginationToken] = None,
) -> DescribeBudgetSpendForPrincipalResponse

Describes one principal's spend in each user-based budget in the account, for each budget's current period. A user-based budget uses the PublicOnDemandCost or EstimatedContractedCost metric.

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

Parameters:

  • account_id (AccountId) –

    The accountId that is associated with the budgets.

  • principal (SpendPrincipal) –

    The principal whose spend you want to describe.

  • 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_for_principal(
    self,
    account_id: "capo_budgets.types.account_id.AccountId",
    principal: "capo_budgets.types.spend_principal.SpendPrincipal",
    *,
    config_overrides: Optional[AsyncBudgetsClientConfig] = 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_for_principal_response.DescribeBudgetSpendForPrincipalResponse":
    """<p>Describes one principal's spend in each user-based budget in the account, for each budget's current period. A user-based budget uses the <code>PublicOnDemandCost</code> or <code>EstimatedContractedCost</code> metric.</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 budgets.</p>
        principal: <p>The principal whose spend you want to describe.</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.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_for_principal_request.DescribeBudgetSpendForPrincipalRequest]",
    ) -> AsyncOperationResponse[
        "capo_budgets.types.describe_budget_spend_for_principal_response.DescribeBudgetSpendForPrincipalResponse"
    ]:
        import capo_budgets._operations.aws_budget_service_gateway.describe_budget_spend_for_principal

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

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

        return capo_budgets.types.describe_budget_spend_for_principal_request.redact_sensitive(
            input_
        )

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

        return capo_budgets.types.describe_budget_spend_for_principal_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "DescribeBudgetSpendForPrincipal",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_budgets.types.describe_budget_spend_for_principal_request.DescribeBudgetSpendForPrincipalRequest = {
        "account_id": account_id,
        "principal": principal,
    }
    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