Skip to content

get_reservation_coverage

get_reservation_coverage(
    time_period: DateInterval,
    *,
    config_overrides: Optional[CostExplorerClientConfig] = None,
    group_by: Optional[GroupDefinitions] = None,
    granularity: Optional[Granularity] = None,
    filter: Optional[Expression] = None,
    metrics: Optional[MetricNames] = None,
    next_page_token: Optional[NextPageToken] = None,
    sort_by: Optional[SortDefinition] = None,
    max_results: Optional[MaxResults] = None,
) -> GetReservationCoverageResponse

Retrieves the reservation coverage for your account, which you can use to see how much of your Amazon Elastic Compute Cloud, Amazon ElastiCache, Amazon Relational Database Service, or Amazon Redshift usage is covered by a reservation. An organization's management account can see the coverage of the associated member accounts. This supports dimensions, cost categories, and nested expressions. For any time period, you can filter data about reservation usage by the following dimensions:

  • AZ

  • CACHE_ENGINE

  • DATABASE_ENGINE

  • DEPLOYMENT_OPTION

  • INSTANCE_TYPE

  • LINKED_ACCOUNT

  • OPERATING_SYSTEM

  • PLATFORM

  • REGION

  • SERVICE

  • TAG

  • TENANCY

To determine valid values for a dimension, use the GetDimensionValues operation.

Parameters:

  • time_period (DateInterval) –

    The start and end dates of the period that you want to retrieve data about reservation coverage for. You can retrieve data for a maximum of 13 months: the last 12 months and the current month. 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 ) –

    You can group the data by the following attributes:

    • AZ

    • CACHE_ENGINE

    • DATABASE_ENGINE

    • DEPLOYMENT_OPTION

    • INSTANCE_TYPE

    • INVOICING_ENTITY

    • LINKED_ACCOUNT

    • OPERATING_SYSTEM

    • PLATFORM

    • REGION

    • TENANCY

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

    The granularity of the Amazon Web Services cost data for the reservation. Valid values are MONTHLY and DAILY.

    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.

    The GetReservationCoverage 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

    • DATABASE_ENGINE

    • DEPLOYMENT_OPTION

    • INSTANCE_TYPE

    • LINKED_ACCOUNT

    • OPERATING_SYSTEM

    • PLATFORM

    • REGION

    • SERVICE

    • TAG

    • TENANCY

    GetReservationCoverage uses the same Expression object as the other operations, but only AND is supported among each dimension. You can nest only one level deep. If there are multiple values for a dimension, they are OR'd together.

    If you don't provide a SERVICE filter, Cost Explorer defaults to EC2.

    Cost category is also supported.

  • metrics (Optional[MetricNames], default: None ) –

    The measurement that you want your reservation coverage reported in.

    Valid values are Hour, Unit, and Cost. You can use multiple values in a request.

  • 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.

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

    The value by which you want to sort the data.

    The following values are supported for Key:

    • OnDemandCost

    • CoverageHoursPercentage

    • OnDemandHours

    • ReservedHours

    • TotalRunningHours

    • CoverageNormalizedUnitsPercentage

    • OnDemandNormalizedUnits

    • ReservedNormalizedUnits

    • TotalRunningNormalizedUnits

    • Time

    Supported values for SortOrder are ASCENDING or DESCENDING.

  • 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/cost_explorer.py
def get_reservation_coverage(
    self,
    time_period: "capo_cost_explorer.types.date_interval.DateInterval",
    *,
    config_overrides: Optional[CostExplorerClientConfig] = 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,
    metrics: Optional["capo_cost_explorer.types.metric_names.MetricNames"] = None,
    next_page_token: Optional[
        "capo_cost_explorer.types.next_page_token.NextPageToken"
    ] = None,
    sort_by: Optional[
        "capo_cost_explorer.types.sort_definition.SortDefinition"
    ] = None,
    max_results: Optional["capo_cost_explorer.types.max_results.MaxResults"] = None,
) -> "capo_cost_explorer.types.get_reservation_coverage_response.GetReservationCoverageResponse":
    """<p>Retrieves the reservation coverage for your account, which you can use to see how much of your Amazon Elastic Compute Cloud, Amazon ElastiCache, Amazon Relational Database Service, or Amazon Redshift usage is covered by a reservation. An organization's management account can see the coverage of the associated member accounts. This supports dimensions, cost categories, and nested expressions. For any time period, you can filter data about reservation usage by the following dimensions:</p> <ul> <li> <p>AZ</p> </li> <li> <p>CACHE_ENGINE</p> </li> <li> <p>DATABASE_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> </li> <li> <p>TAG</p> </li> <li> <p>TENANCY</p> </li> </ul> <p>To determine valid values for a dimension, use the <code>GetDimensionValues</code> operation. </p>

    Args:
        time_period: <p>The start and end dates of the period that you want to retrieve data about reservation coverage for. You can retrieve data for a maximum of 13 months: the last 12 months and the current month. 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>You can group the data by the following attributes:</p> <ul> <li> <p>AZ</p> </li> <li> <p>CACHE_ENGINE</p> </li> <li> <p>DATABASE_ENGINE</p> </li> <li> <p>DEPLOYMENT_OPTION</p> </li> <li> <p>INSTANCE_TYPE</p> </li> <li> <p>INVOICING_ENTITY</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>TENANCY</p> </li> </ul>
        granularity: <p>The granularity of the Amazon Web Services cost data for the reservation. Valid values are <code>MONTHLY</code> and <code>DAILY</code>.</p> <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>.</p> <p>The <code>GetReservationCoverage</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>DATABASE_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> </li> <li> <p>TAG</p> </li> <li> <p>TENANCY</p> </li> </ul> <p> <code>GetReservationCoverage</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. You can nest only one level deep. If there are multiple values for a dimension, they are OR'd together.</p> <p>If you don't provide a <code>SERVICE</code> filter, Cost Explorer defaults to EC2.</p> <p>Cost category is also supported.</p>
        metrics: <p>The measurement that you want your reservation coverage reported in.</p> <p>Valid values are <code>Hour</code>, <code>Unit</code>, and <code>Cost</code>. You can use multiple values in a request.</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>
        sort_by: <p>The value by which you want to sort the data.</p> <p>The following values are supported for <code>Key</code>:</p> <ul> <li> <p> <code>OnDemandCost</code> </p> </li> <li> <p> <code>CoverageHoursPercentage</code> </p> </li> <li> <p> <code>OnDemandHours</code> </p> </li> <li> <p> <code>ReservedHours</code> </p> </li> <li> <p> <code>TotalRunningHours</code> </p> </li> <li> <p> <code>CoverageNormalizedUnitsPercentage</code> </p> </li> <li> <p> <code>OnDemandNormalizedUnits</code> </p> </li> <li> <p> <code>ReservedNormalizedUnits</code> </p> </li> <li> <p> <code>TotalRunningNormalizedUnits</code> </p> </li> <li> <p> <code>Time</code> </p> </li> </ul> <p>Supported values for <code>SortOrder</code> are <code>ASCENDING</code> or <code>DESCENDING</code>.</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.
    """

    def _handler(
        req: "OperationRequest[capo_cost_explorer.types.get_reservation_coverage_request.GetReservationCoverageRequest]",
    ) -> OperationResponse[
        "capo_cost_explorer.types.get_reservation_coverage_response.GetReservationCoverageResponse"
    ]:
        import capo_cost_explorer._operations.aws_insights_index_service.get_reservation_coverage

        output, http_response = (
            capo_cost_explorer._operations.aws_insights_index_service.get_reservation_coverage.get_reservation_coverage(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetReservationCoverage")
    )
    input_: capo_cost_explorer.types.get_reservation_coverage_request.GetReservationCoverageRequest = {
        "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 metrics is not None:
        input_["metrics"] = metrics
    if next_page_token is not None:
        input_["next_page_token"] = next_page_token
    if sort_by is not None:
        input_["sort_by"] = sort_by
    if max_results is not None:
        input_["max_results"] = max_results

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output