Skip to content

get_savings_plans_coverage async

get_savings_plans_coverage(
    time_period: DateInterval,
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    group_by: Optional[GroupDefinitions] = None,
    granularity: Optional[Granularity] = None,
    filter: Optional[Expression] = None,
    metrics: Optional[MetricNames] = None,
    next_token: Optional[NextPageToken] = None,
    max_results: Optional[MaxResults] = None,
    sort_by: Optional[SortDefinition] = None,
) -> GetSavingsPlansCoverageResponse

Retrieves the Savings Plans covered for your account. This enables you to see how much of your cost is covered by a Savings Plan. 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 for Savings Plans usage with the following dimensions:

  • LINKED_ACCOUNT

  • REGION

  • SERVICE

  • INSTANCE_FAMILY

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

Parameters:

  • time_period (DateInterval) –

    The time period that you want the usage and costs for. The Start date must be within 13 months. The End date must be after the Start date, and before the current date. Future dates can't be used as an End date.

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

    You can group the data using the attributes INSTANCE_FAMILY, REGION, or SERVICE.

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

    The granularity of the Amazon Web Services cost data for your Savings Plans. Granularity can't be set if GroupBy is set.

    The GetSavingsPlansCoverage operation supports only DAILY and MONTHLY granularities.

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

    Filters Savings Plans coverage data by dimensions. You can filter data for Savings Plans usage with the following dimensions:

    • LINKED_ACCOUNT

    • REGION

    • SERVICE

    • INSTANCE_FAMILY

    GetSavingsPlansCoverage uses the same Expression object as the other operations, but only AND is supported among each dimension. If there are multiple values for a dimension, they are OR'd together.

    Cost category is also supported.

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

    The measurement that you want your Savings Plans coverage reported in. The only valid value is SpendCoveredBySavingsPlans.

  • next_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 number of items to be returned in a response. The default is 20, with a minimum value of 1.

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

    The value that you want to sort the data by.

    The following values are supported for Key:

    • SpendCoveredBySavingsPlan

    • OnDemandCost

    • CoveragePercentage

    • TotalCost

    • InstanceFamily

    • Region

    • Service

    The supported values for SortOrder are ASCENDING and DESCENDING.

Raises:

Source code in docs_src/capo_cost_explorer/_services/async_cost_explorer.py
async def get_savings_plans_coverage(
    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,
    metrics: Optional["capo_cost_explorer.types.metric_names.MetricNames"] = None,
    next_token: Optional[
        "capo_cost_explorer.types.next_page_token.NextPageToken"
    ] = None,
    max_results: Optional["capo_cost_explorer.types.max_results.MaxResults"] = None,
    sort_by: Optional[
        "capo_cost_explorer.types.sort_definition.SortDefinition"
    ] = None,
) -> "capo_cost_explorer.types.get_savings_plans_coverage_response.GetSavingsPlansCoverageResponse":
    """<p>Retrieves the Savings Plans covered for your account. This enables you to see how much of your cost is covered by a Savings Plan. 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 for Savings Plans usage with the following dimensions:</p> <ul> <li> <p> <code>LINKED_ACCOUNT</code> </p> </li> <li> <p> <code>REGION</code> </p> </li> <li> <p> <code>SERVICE</code> </p> </li> <li> <p> <code>INSTANCE_FAMILY</code> </p> </li> </ul> <p>To determine valid values for a dimension, use the <code>GetDimensionValues</code> operation.</p>

    Args:
        time_period: <p>The time period that you want the usage and costs for. The <code>Start</code> date must be within 13 months. The <code>End</code> date must be after the <code>Start</code> date, and before the current date. Future dates can't be used as an <code>End</code> date.</p>
        group_by: <p>You can group the data using the attributes <code>INSTANCE_FAMILY</code>, <code>REGION</code>, or <code>SERVICE</code>.</p>
        granularity: <p>The granularity of the Amazon Web Services cost data for your Savings Plans. <code>Granularity</code> can't be set if <code>GroupBy</code> is set.</p> <p>The <code>GetSavingsPlansCoverage</code> operation supports only <code>DAILY</code> and <code>MONTHLY</code> granularities.</p>
        filter: <p>Filters Savings Plans coverage data by dimensions. You can filter data for Savings Plans usage with the following dimensions:</p> <ul> <li> <p> <code>LINKED_ACCOUNT</code> </p> </li> <li> <p> <code>REGION</code> </p> </li> <li> <p> <code>SERVICE</code> </p> </li> <li> <p> <code>INSTANCE_FAMILY</code> </p> </li> </ul> <p> <code>GetSavingsPlansCoverage</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. If there are multiple values for a dimension, they are OR'd together.</p> <p>Cost category is also supported.</p>
        metrics: <p>The measurement that you want your Savings Plans coverage reported in. The only valid value is <code>SpendCoveredBySavingsPlans</code>.</p>
        next_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 number of items to be returned in a response. The default is <code>20</code>, with a minimum value of <code>1</code>.</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>SpendCoveredBySavingsPlan</code> </p> </li> <li> <p> <code>OnDemandCost</code> </p> </li> <li> <p> <code>CoveragePercentage</code> </p> </li> <li> <p> <code>TotalCost</code> </p> </li> <li> <p> <code>InstanceFamily</code> </p> </li> <li> <p> <code>Region</code> </p> </li> <li> <p> <code>Service</code> </p> </li> </ul> <p>The supported values for <code>SortOrder</code> are <code>ASCENDING</code> and <code>DESCENDING</code>.</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_savings_plans_coverage_request.GetSavingsPlansCoverageRequest]",
    ) -> AsyncOperationResponse[
        "capo_cost_explorer.types.get_savings_plans_coverage_response.GetSavingsPlansCoverageResponse"
    ]:
        import capo_cost_explorer._operations.aws_insights_index_service.get_savings_plans_coverage

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetSavingsPlansCoverage")
    )
    input_: capo_cost_explorer.types.get_savings_plans_coverage_request.GetSavingsPlansCoverageRequest = {
        "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_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if sort_by is not None:
        input_["sort_by"] = sort_by

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