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 Relational Database Service, Amazon ElastiCache, Amazon MemoryDB, Amazon Redshift, Amazon Elasticsearch Service, or Amazon OpenSearch Service usage a reservation covers. An organization's management account can see the coverage of the associated member accounts. The filter supports dimensions, tags, and cost categories, combined with one level of And or Not. For any time period, you can filter data about reservation usage by the following dimensions:

  • AZ

  • CACHE_ENGINE

  • DATABASE_ENGINE

  • DEPLOYMENT_OPTION

  • INSTANCE_TYPE

  • INSTANCE_TYPE_FAMILY

  • LINKED_ACCOUNT

  • PLATFORM

  • REGION

  • SERVICE

  • TAG

  • TENANCY

The dimensions that you can use depend on the service in the SERVICE filter. For details, see Filter.

To determine valid values for a dimension, use the GetDimensionValues operation with Context set to COST_AND_USAGE. Coverage filters apply to cost and usage data, so RESERVATIONS values such as Windows or Aurora don't match any coverage data. Use the COST_AND_USAGE spelling, such as Windows (Amazon VPC) or Aurora MySQL.

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. The attributes that you can use depend on the service in the SERVICE filter. If you don't provide a SERVICE filter, Cost Explorer uses Amazon Elastic Compute Cloud - Compute.

    • Amazon Elastic Compute Cloud - Compute: AZ, INSTANCE_TYPE, INSTANCE_TYPE_FAMILY, LINKED_ACCOUNT, PLATFORM, REGION, and TENANCY

    • Amazon Relational Database Service: AZ, DATABASE_ENGINE, DEPLOYMENT_OPTION, INSTANCE_TYPE, LINKED_ACCOUNT, and REGION

    • Amazon ElastiCache and Amazon MemoryDB: AZ, CACHE_ENGINE, INSTANCE_TYPE, LINKED_ACCOUNT, and REGION

    • Amazon Redshift, Amazon Elasticsearch Service, and Amazon OpenSearch Service: AZ, INSTANCE_TYPE, LINKED_ACCOUNT, and REGION

    If you specify two SERVICE values, use only attributes that both services support. You can specify up to four attributes, and only the DIMENSION type is supported.

  • 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 coverage data by dimensions. You can filter by the following dimensions:

    • AZ

    • CACHE_ENGINE

    • DATABASE_ENGINE

    • DEPLOYMENT_OPTION

    • INSTANCE_TYPE

    • INSTANCE_TYPE_FAMILY

    • LINKED_ACCOUNT

    • PLATFORM

    • REGION

    • SERVICE

      Supported values for SERVICE are Amazon Elastic Compute Cloud - Compute, Amazon Relational Database Service, Amazon ElastiCache, Amazon MemoryDB, Amazon Redshift, Amazon Elasticsearch Service, and Amazon OpenSearch Service. You can specify up to two SERVICE values.

    • TAG

    • TENANCY

    The dimensions that you can use depend on the service in the SERVICE filter. CACHE_ENGINE applies only to Amazon ElastiCache and Amazon MemoryDB. DATABASE_ENGINE and DEPLOYMENT_OPTION apply only to Amazon Relational Database Service. INSTANCE_TYPE_FAMILY, PLATFORM, and TENANCY apply only to Amazon Elastic Compute Cloud - Compute. If you specify two SERVICE values, use only dimensions that both services support.

    GetReservationCoverage uses the same Expression object as the other operations, with the following limits. Filter accepts one Dimensions, Tags, or CostCategories expression, a Not of one of these expressions, or one And of two or more of these. The operation doesn't support Or, an And inside an And, or a Not around any other expression.

    Each dimension can appear only once in a filter, including inside a Not. Tags is the only exception: you can filter on more than one tag key. You can use only one CostCategories expression. To filter on several values of a dimension, put them in one expression. The operation ORs multiple values for a dimension together.

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

  • 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. Hour returns CoverageHours, Unit returns CoverageNormalizedUnits, and Cost returns CoverageCost. Unit is supported only for Amazon Elastic Compute Cloud - Compute. If you don't specify Metrics, the response includes only CoverageHours.

  • 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

    If you specify SortBy, you must also specify SortOrder. There is no default. 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 Relational Database Service, Amazon ElastiCache, Amazon MemoryDB, Amazon Redshift, Amazon Elasticsearch Service, or Amazon OpenSearch Service usage a reservation covers. An organization's management account can see the coverage of the associated member accounts. The filter supports dimensions, tags, and cost categories, combined with one level of <code>And</code> or <code>Not</code>. 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>INSTANCE_TYPE_FAMILY</p> </li> <li> <p>LINKED_ACCOUNT</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>The dimensions that you can use depend on the service in the <code>SERVICE</code> filter. For details, see <code>Filter</code>.</p> <p>To determine valid values for a dimension, use the <code>GetDimensionValues</code> operation with <code>Context</code> set to <code>COST_AND_USAGE</code>. Coverage filters apply to cost and usage data, so <code>RESERVATIONS</code> values such as <code>Windows</code> or <code>Aurora</code> don't match any coverage data. Use the <code>COST_AND_USAGE</code> spelling, such as <code>Windows (Amazon VPC)</code> or <code>Aurora MySQL</code>.</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. The attributes that you can use depend on the service in the <code>SERVICE</code> filter. If you don't provide a <code>SERVICE</code> filter, Cost Explorer uses Amazon Elastic Compute Cloud - Compute.</p> <ul> <li> <p>Amazon Elastic Compute Cloud - Compute: <code>AZ</code>, <code>INSTANCE_TYPE</code>, <code>INSTANCE_TYPE_FAMILY</code>, <code>LINKED_ACCOUNT</code>, <code>PLATFORM</code>, <code>REGION</code>, and <code>TENANCY</code> </p> </li> <li> <p>Amazon Relational Database Service: <code>AZ</code>, <code>DATABASE_ENGINE</code>, <code>DEPLOYMENT_OPTION</code>, <code>INSTANCE_TYPE</code>, <code>LINKED_ACCOUNT</code>, and <code>REGION</code> </p> </li> <li> <p>Amazon ElastiCache and Amazon MemoryDB: <code>AZ</code>, <code>CACHE_ENGINE</code>, <code>INSTANCE_TYPE</code>, <code>LINKED_ACCOUNT</code>, and <code>REGION</code> </p> </li> <li> <p>Amazon Redshift, Amazon Elasticsearch Service, and Amazon OpenSearch Service: <code>AZ</code>, <code>INSTANCE_TYPE</code>, <code>LINKED_ACCOUNT</code>, and <code>REGION</code> </p> </li> </ul> <p>If you specify two <code>SERVICE</code> values, use only attributes that both services support. You can specify up to four attributes, and only the <code>DIMENSION</code> type is supported.</p>
        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 coverage 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>INSTANCE_TYPE_FAMILY</p> </li> <li> <p>LINKED_ACCOUNT</p> </li> <li> <p>PLATFORM</p> </li> <li> <p>REGION</p> </li> <li> <p>SERVICE</p> <note> <p>Supported values for <code>SERVICE</code> are Amazon Elastic Compute Cloud - Compute, Amazon Relational Database Service, Amazon ElastiCache, Amazon MemoryDB, Amazon Redshift, Amazon Elasticsearch Service, and Amazon OpenSearch Service. You can specify up to two <code>SERVICE</code> values.</p> </note> </li> <li> <p>TAG</p> </li> <li> <p>TENANCY</p> </li> </ul> <p>The dimensions that you can use depend on the service in the <code>SERVICE</code> filter. <code>CACHE_ENGINE</code> applies only to Amazon ElastiCache and Amazon MemoryDB. <code>DATABASE_ENGINE</code> and <code>DEPLOYMENT_OPTION</code> apply only to Amazon Relational Database Service. <code>INSTANCE_TYPE_FAMILY</code>, <code>PLATFORM</code>, and <code>TENANCY</code> apply only to Amazon Elastic Compute Cloud - Compute. If you specify two <code>SERVICE</code> values, use only dimensions that both services support.</p> <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, with the following limits. <code>Filter</code> accepts one <code>Dimensions</code>, <code>Tags</code>, or <code>CostCategories</code> expression, a <code>Not</code> of one of these expressions, or one <code>And</code> of two or more of these. The operation doesn't support <code>Or</code>, an <code>And</code> inside an <code>And</code>, or a <code>Not</code> around any other expression.</p> <p>Each dimension can appear only once in a filter, including inside a <code>Not</code>. <code>Tags</code> is the only exception: you can filter on more than one tag key. You can use only one <code>CostCategories</code> expression. To filter on several values of a dimension, put them in one expression. The operation ORs multiple values for a dimension together.</p> <p>If you don't provide a <code>SERVICE</code> filter, Cost Explorer defaults to EC2.</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. <code>Hour</code> returns <code>CoverageHours</code>, <code>Unit</code> returns <code>CoverageNormalizedUnits</code>, and <code>Cost</code> returns <code>CoverageCost</code>. <code>Unit</code> is supported only for Amazon Elastic Compute Cloud - Compute. If you don't specify <code>Metrics</code>, the response includes only <code>CoverageHours</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>
        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>If you specify <code>SortBy</code>, you must also specify <code>SortOrder</code>. There is no default. 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