Skip to content

get_usage_forecast async

get_usage_forecast(
    time_period: DateInterval,
    metric: Metric,
    granularity: Granularity,
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    filter: Optional[Expression] = None,
    billing_view_arn: Optional[BillingViewArn] = None,
    prediction_interval_level: Optional[PredictionIntervalLevel] = None,
) -> GetUsageForecastResponse

Retrieves a forecast for how much Amazon Web Services predicts that you will use over the forecast time period that you select, based on your past usage.

Parameters:

  • time_period (DateInterval) –

    The start and end dates of the period that you want to retrieve usage forecast for. The start date is included in the period, but the end date isn't included in the period. 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. The start date must be equal to or later than the current date to avoid a validation error.

  • metric (Metric) –

    Which metric Cost Explorer uses to create your forecast.

    Valid values for a GetUsageForecast call are the following:

    • USAGE_QUANTITY

    • NORMALIZED_USAGE_AMOUNT

  • granularity (Granularity) –

    How granular you want the forecast to be. You can get 3 months of DAILY forecasts or 18 months of MONTHLY forecasts.

    The GetUsageForecast operation supports only DAILY and MONTHLY granularities.

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

    The filters that you want to use to filter your forecast. The GetUsageForecast API supports filtering by the following dimensions:

    • AZ

    • INSTANCE_TYPE

    • LINKED_ACCOUNT

    • LINKED_ACCOUNT_NAME

    • OPERATION

    • PURCHASE_TYPE

    • REGION

    • SERVICE

    • USAGE_TYPE

    • USAGE_TYPE_GROUP

    • RECORD_TYPE

    • OPERATING_SYSTEM

    • TENANCY

    • SCOPE

    • PLATFORM

    • SUBSCRIPTION_ID

    • LEGAL_ENTITY_NAME

    • DEPLOYMENT_OPTION

    • DATABASE_ENGINE

    • INSTANCE_TYPE_FAMILY

    • BILLING_ENTITY

    • RESERVATION_ID

    • SAVINGS_PLAN_ARN

  • billing_view_arn (Optional[BillingViewArn], default: None ) –

    The Amazon Resource Name (ARN) that uniquely identifies a specific billing view. The ARN is used to specify which particular billing view you want to interact with or retrieve information from when making API calls related to Amazon Web Services Billing and Cost Management features. The BillingViewArn can be retrieved by calling the ListBillingViews API.

  • prediction_interval_level (Optional[PredictionIntervalLevel], default: None ) –

    Amazon Web Services Cost Explorer always returns the mean forecast as a single point. You can request a prediction interval around the mean by specifying a confidence level. The higher the confidence level, the more confident Cost Explorer is about the actual value falling in the prediction interval. Higher confidence levels result in wider prediction intervals.

Raises:

Source code in docs_src/capo_cost_explorer/_services/async_cost_explorer.py
async def get_usage_forecast(
    self,
    time_period: "capo_cost_explorer.types.date_interval.DateInterval",
    metric: "capo_cost_explorer.types.metric.Metric",
    granularity: "capo_cost_explorer.types.granularity.Granularity",
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    filter: Optional["capo_cost_explorer.types.expression.Expression"] = None,
    billing_view_arn: Optional[
        "capo_cost_explorer.types.billing_view_arn.BillingViewArn"
    ] = None,
    prediction_interval_level: Optional[
        "capo_cost_explorer.types.prediction_interval_level.PredictionIntervalLevel"
    ] = None,
) -> (
    "capo_cost_explorer.types.get_usage_forecast_response.GetUsageForecastResponse"
):
    """<p>Retrieves a forecast for how much Amazon Web Services predicts that you will use over the forecast time period that you select, based on your past usage. </p>

    Args:
        time_period: <p>The start and end dates of the period that you want to retrieve usage forecast for. The start date is included in the period, but the end date isn't included in the period. 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>. The start date must be equal to or later than the current date to avoid a validation error.</p>
        metric: <p>Which metric Cost Explorer uses to create your forecast.</p> <p>Valid values for a <code>GetUsageForecast</code> call are the following:</p> <ul> <li> <p>USAGE_QUANTITY</p> </li> <li> <p>NORMALIZED_USAGE_AMOUNT</p> </li> </ul>
        granularity: <p>How granular you want the forecast to be. You can get 3 months of <code>DAILY</code> forecasts or 18 months of <code>MONTHLY</code> forecasts.</p> <p>The <code>GetUsageForecast</code> operation supports only <code>DAILY</code> and <code>MONTHLY</code> granularities.</p>
        filter: <p>The filters that you want to use to filter your forecast. The <code>GetUsageForecast</code> API supports filtering by the following dimensions:</p> <ul> <li> <p> <code>AZ</code> </p> </li> <li> <p> <code>INSTANCE_TYPE</code> </p> </li> <li> <p> <code>LINKED_ACCOUNT</code> </p> </li> <li> <p> <code>LINKED_ACCOUNT_NAME</code> </p> </li> <li> <p> <code>OPERATION</code> </p> </li> <li> <p> <code>PURCHASE_TYPE</code> </p> </li> <li> <p> <code>REGION</code> </p> </li> <li> <p> <code>SERVICE</code> </p> </li> <li> <p> <code>USAGE_TYPE</code> </p> </li> <li> <p> <code>USAGE_TYPE_GROUP</code> </p> </li> <li> <p> <code>RECORD_TYPE</code> </p> </li> <li> <p> <code>OPERATING_SYSTEM</code> </p> </li> <li> <p> <code>TENANCY</code> </p> </li> <li> <p> <code>SCOPE</code> </p> </li> <li> <p> <code>PLATFORM</code> </p> </li> <li> <p> <code>SUBSCRIPTION_ID</code> </p> </li> <li> <p> <code>LEGAL_ENTITY_NAME</code> </p> </li> <li> <p> <code>DEPLOYMENT_OPTION</code> </p> </li> <li> <p> <code>DATABASE_ENGINE</code> </p> </li> <li> <p> <code>INSTANCE_TYPE_FAMILY</code> </p> </li> <li> <p> <code>BILLING_ENTITY</code> </p> </li> <li> <p> <code>RESERVATION_ID</code> </p> </li> <li> <p> <code>SAVINGS_PLAN_ARN</code> </p> </li> </ul>
        billing_view_arn: <p>The Amazon Resource Name (ARN) that uniquely identifies a specific billing view. The ARN is used to specify which particular billing view you want to interact with or retrieve information from when making API calls related to Amazon Web Services Billing and Cost Management features. The BillingViewArn can be retrieved by calling the ListBillingViews API.</p>
        prediction_interval_level: <p>Amazon Web Services Cost Explorer always returns the mean forecast as a single point. You can request a prediction interval around the mean by specifying a confidence level. The higher the confidence level, the more confident Cost Explorer is about the actual value falling in the prediction interval. Higher confidence levels result in wider prediction intervals.</p>

    Raises:
        capo_cost_explorer.errors.billing_view_health_status_exception.BillingViewHealthStatusException: <p> The billing view status must be <code>HEALTHY</code> to perform this action. Try again when the status is <code>HEALTHY</code>. </p>
        capo_cost_explorer.errors.data_unavailable_exception.DataUnavailableException: <p>The requested data is unavailable.</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.resource_not_found_exception.ResourceNotFoundException: <p> The specified ARN in the request doesn't exist. </p>
        capo_cost_explorer.errors.unresolvable_usage_unit_exception.UnresolvableUsageUnitException: <p>Cost Explorer was unable to identify the usage unit. Provide <code>UsageType/UsageTypeGroup</code> filter selections that contain matching units, for example: <code>hours</code>.</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_usage_forecast_request.GetUsageForecastRequest]",
    ) -> AsyncOperationResponse[
        "capo_cost_explorer.types.get_usage_forecast_response.GetUsageForecastResponse"
    ]:
        import capo_cost_explorer._operations.aws_insights_index_service.get_usage_forecast

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetUsageForecast")
    )
    input_: capo_cost_explorer.types.get_usage_forecast_request.GetUsageForecastRequest = {
        "time_period": time_period,
        "metric": metric,
        "granularity": granularity,
    }
    if filter is not None:
        input_["filter"] = filter
    if billing_view_arn is not None:
        input_["billing_view_arn"] = billing_view_arn
    if prediction_interval_level is not None:
        input_["prediction_interval_level"] = prediction_interval_level

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