Skip to content

get_reservation_utilization async

get_reservation_utilization(
    time_period: DateInterval,
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    group_by: Optional[GroupDefinitions] = None,
    granularity: Optional[Granularity] = None,
    filter: Optional[Expression] = None,
    sort_by: Optional[SortDefinition] = None,
    next_page_token: Optional[NextPageToken] = None,
    max_results: Optional[MaxResults] = None,
) -> GetReservationUtilizationResponse

Retrieves the reservation utilization for your account. Management account in an organization have access to member accounts. You can filter data by dimensions in a time period. You can use GetDimensionValues to determine the possible dimension values. Currently, you can group only by SUBSCRIPTION_ID.

Parameters:

  • time_period (DateInterval) –

    Sets the start and end dates for retrieving Reserved Instance (RI) utilization. The start date is inclusive, but the end date is exclusive. For example, if start is 2017-01-01 and end is 2017-05-01, then the cost and usage data is retrieved from 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01.

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

    Groups only by SUBSCRIPTION_ID. Metadata is included.

  • granularity (Optional[Granularity], default: None ) –

    If GroupBy is set, Granularity can't be set. If Granularity isn't set, the response object doesn't include Granularity, either MONTHLY or DAILY. If both GroupBy and Granularity aren't set, GetReservationUtilization defaults to DAILY.

    The GetReservationUtilization operation supports only DAILY and MONTHLY granularities.

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

    Filters utilization data by dimensions. You can filter by the following dimensions:

    • AZ

    • CACHE_ENGINE

    • DEPLOYMENT_OPTION

    • INSTANCE_TYPE

    • LINKED_ACCOUNT

    • OPERATING_SYSTEM

    • PLATFORM

    • REGION

    • SERVICE

      If not specified, the SERVICE filter defaults to Amazon Elastic Compute Cloud - Compute. Supported values for SERVICE are Amazon Elastic Compute Cloud - Compute, Amazon Relational Database Service, Amazon ElastiCache, Amazon Redshift, and Amazon Elasticsearch Service. The value for the SERVICE filter should not exceed "1".

    • SCOPE

    • TENANCY

    GetReservationUtilization uses the same Expression object as the other operations, but only AND is supported among each dimension, and nesting is supported up to only one level deep. If there are multiple values for a dimension, they are OR'd together.

  • sort_by (Optional[SortDefinition], default: None ) –

    The value that you want to sort the data by.

    The following values are supported for Key:

    • UtilizationPercentage

    • UtilizationPercentageInUnits

    • PurchasedHours

    • PurchasedUnits

    • TotalActualHours

    • TotalActualUnits

    • UnusedHours

    • UnusedUnits

    • OnDemandCostOfRIHoursUsed

    • NetRISavings

    • TotalPotentialRISavings

    • AmortizedUpfrontFee

    • AmortizedRecurringFee

    • TotalAmortizedFee

    • RICostForUnusedHours

    • RealizedSavings

    • UnrealizedSavings

    The supported values for SortOrder are ASCENDING and DESCENDING.

  • next_page_token (Optional[NextPageToken], default: None ) –

    The token to retrieve the next set of results. Amazon Web Services provides the token when the response from a previous call has more results than the maximum page size.

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

    The maximum number of objects that you returned for this request. If more objects are available, in the response, Amazon Web Services provides a NextPageToken value that you can use in a subsequent call to get the next batch of objects.

Raises:

Source code in docs_src/capo_cost_explorer/_services/async_cost_explorer.py
async def get_reservation_utilization(
    self,
    time_period: "capo_cost_explorer.types.date_interval.DateInterval",
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    group_by: Optional[
        "capo_cost_explorer.types.group_definitions.GroupDefinitions"
    ] = None,
    granularity: Optional[
        "capo_cost_explorer.types.granularity.Granularity"
    ] = None,
    filter: Optional["capo_cost_explorer.types.expression.Expression"] = None,
    sort_by: Optional[
        "capo_cost_explorer.types.sort_definition.SortDefinition"
    ] = None,
    next_page_token: Optional[
        "capo_cost_explorer.types.next_page_token.NextPageToken"
    ] = None,
    max_results: Optional["capo_cost_explorer.types.max_results.MaxResults"] = None,
) -> "capo_cost_explorer.types.get_reservation_utilization_response.GetReservationUtilizationResponse":
    """<p>Retrieves the reservation utilization for your account. Management account in an organization have access to member accounts. You can filter data by dimensions in a time period. You can use <code>GetDimensionValues</code> to determine the possible dimension values. Currently, you can group only by <code>SUBSCRIPTION_ID</code>. </p>

    Args:
        time_period: <p>Sets the start and end dates for retrieving Reserved Instance (RI) utilization. The start date is inclusive, but the end date is exclusive. For example, if <code>start</code> is <code>2017-01-01</code> and <code>end</code> is <code>2017-05-01</code>, then the cost and usage data is retrieved from <code>2017-01-01</code> up to and including <code>2017-04-30</code> but not including <code>2017-05-01</code>. </p>
        group_by: <p>Groups only by <code>SUBSCRIPTION_ID</code>. Metadata is included.</p>
        granularity: <p>If <code>GroupBy</code> is set, <code>Granularity</code> can't be set. If <code>Granularity</code> isn't set, the response object doesn't include <code>Granularity</code>, either <code>MONTHLY</code> or <code>DAILY</code>. If both <code>GroupBy</code> and <code>Granularity</code> aren't set, <code>GetReservationUtilization</code> defaults to <code>DAILY</code>.</p> <p>The <code>GetReservationUtilization</code> operation supports only <code>DAILY</code> and <code>MONTHLY</code> granularities.</p>
        filter: <p>Filters utilization data by dimensions. You can filter by the following dimensions:</p> <ul> <li> <p>AZ</p> </li> <li> <p>CACHE_ENGINE</p> </li> <li> <p>DEPLOYMENT_OPTION</p> </li> <li> <p>INSTANCE_TYPE</p> </li> <li> <p>LINKED_ACCOUNT</p> </li> <li> <p>OPERATING_SYSTEM</p> </li> <li> <p>PLATFORM</p> </li> <li> <p>REGION</p> </li> <li> <p>SERVICE</p> <note> <p>If not specified, the <code>SERVICE</code> filter defaults to Amazon Elastic Compute Cloud - Compute. Supported values for <code>SERVICE</code> are Amazon Elastic Compute Cloud - Compute, Amazon Relational Database Service, Amazon ElastiCache, Amazon Redshift, and Amazon Elasticsearch Service. The value for the <code>SERVICE</code> filter should not exceed "1".</p> </note> </li> <li> <p>SCOPE</p> </li> <li> <p>TENANCY</p> </li> </ul> <p> <code>GetReservationUtilization</code> uses the same <a href="https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html">Expression</a> object as the other operations, but only <code>AND</code> is supported among each dimension, and nesting is supported up to only one level deep. If there are multiple values for a dimension, they are OR'd together.</p>
        sort_by: <p>The value that you want to sort the data by.</p> <p>The following values are supported for <code>Key</code>:</p> <ul> <li> <p> <code>UtilizationPercentage</code> </p> </li> <li> <p> <code>UtilizationPercentageInUnits</code> </p> </li> <li> <p> <code>PurchasedHours</code> </p> </li> <li> <p> <code>PurchasedUnits</code> </p> </li> <li> <p> <code>TotalActualHours</code> </p> </li> <li> <p> <code>TotalActualUnits</code> </p> </li> <li> <p> <code>UnusedHours</code> </p> </li> <li> <p> <code>UnusedUnits</code> </p> </li> <li> <p> <code>OnDemandCostOfRIHoursUsed</code> </p> </li> <li> <p> <code>NetRISavings</code> </p> </li> <li> <p> <code>TotalPotentialRISavings</code> </p> </li> <li> <p> <code>AmortizedUpfrontFee</code> </p> </li> <li> <p> <code>AmortizedRecurringFee</code> </p> </li> <li> <p> <code>TotalAmortizedFee</code> </p> </li> <li> <p> <code>RICostForUnusedHours</code> </p> </li> <li> <p> <code>RealizedSavings</code> </p> </li> <li> <p> <code>UnrealizedSavings</code> </p> </li> </ul> <p>The supported values for <code>SortOrder</code> are <code>ASCENDING</code> and <code>DESCENDING</code>.</p>
        next_page_token: <p>The token to retrieve the next set of results. Amazon Web Services provides the token when the response from a previous call has more results than the maximum page size.</p>
        max_results: <p>The maximum number of objects that you returned for this request. If more objects are available, in the response, Amazon Web Services provides a NextPageToken value that you can use in a subsequent call to get the next batch of objects.</p>

    Raises:
        capo_cost_explorer.errors.data_unavailable_exception.DataUnavailableException: <p>The requested data is unavailable.</p>
        capo_cost_explorer.errors.invalid_next_token_exception.InvalidNextTokenException: <p>The pagination token is invalid. Try again without a pagination token.</p>
        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.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cost_explorer.types.get_reservation_utilization_request.GetReservationUtilizationRequest]",
    ) -> AsyncOperationResponse[
        "capo_cost_explorer.types.get_reservation_utilization_response.GetReservationUtilizationResponse"
    ]:
        import capo_cost_explorer._operations.aws_insights_index_service.get_reservation_utilization

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetReservationUtilization")
    )
    input_: capo_cost_explorer.types.get_reservation_utilization_request.GetReservationUtilizationRequest = {
        "time_period": time_period
    }
    if group_by is not None:
        input_["group_by"] = group_by
    if granularity is not None:
        input_["granularity"] = granularity
    if filter is not None:
        input_["filter"] = filter
    if sort_by is not None:
        input_["sort_by"] = sort_by
    if next_page_token is not None:
        input_["next_page_token"] = next_page_token
    if max_results is not None:
        input_["max_results"] = max_results

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