Skip to content

query_what_if_forecast async

query_what_if_forecast(
    what_if_forecast_arn: LongArn,
    filters: Filters,
    *,
    config_overrides: Optional[AsyncforecastqueryClientConfig] = None,
    start_date: Optional[DateTime] = None,
    end_date: Optional[DateTime] = None,
    next_token: Optional[NextToken] = None,
) -> QueryWhatIfForecastResponse

Retrieves a what-if forecast.

Parameters:

  • what_if_forecast_arn (LongArn) –

    The Amazon Resource Name (ARN) of the what-if forecast to query.

  • start_date (Optional[DateTime], default: None ) –

    The start date for the what-if forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T08:00:00.

  • end_date (Optional[DateTime], default: None ) –

    The end date for the what-if forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T20:00:00.

  • filters (Filters) –

    The filtering criteria to apply when retrieving the forecast. For example, to get the forecast for client_21 in the electricity usage dataset, specify the following:

    {"item_id" : "client_21"}

    To get the full what-if forecast, use the CreateForecastExportJob operation.

  • next_token (Optional[NextToken], default: None ) –

    If the result of the previous request was truncated, the response includes a NextToken. To retrieve the next set of results, use the token in the next request. Tokens expire after 24 hours.

Raises:

Source code in docs_src/capo_forecastquery/_services/async_forecastquery.py
async def query_what_if_forecast(
    self,
    what_if_forecast_arn: "capo_forecastquery.types.long_arn.LongArn",
    filters: "capo_forecastquery.types.filters.Filters",
    *,
    config_overrides: Optional[AsyncforecastqueryClientConfig] = None,
    start_date: Optional["capo_forecastquery.types.date_time.DateTime"] = None,
    end_date: Optional["capo_forecastquery.types.date_time.DateTime"] = None,
    next_token: Optional["capo_forecastquery.types.next_token.NextToken"] = None,
) -> "capo_forecastquery.types.query_what_if_forecast_response.QueryWhatIfForecastResponse":
    """<p>Retrieves a what-if forecast.</p>

    Args:
        what_if_forecast_arn: <p>The Amazon Resource Name (ARN) of the what-if forecast to query.</p>
        start_date: <p>The start date for the what-if forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T08:00:00.</p>
        end_date: <p>The end date for the what-if forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T20:00:00. </p>
        filters: <p>The filtering criteria to apply when retrieving the forecast. For example, to get the forecast for <code>client_21</code> in the electricity usage dataset, specify the following:</p> <p> <code>{"item_id" : "client_21"}</code> </p> <p>To get the full what-if forecast, use the <a href="https://docs.aws.amazon.com/en_us/forecast/latest/dg/API_CreateWhatIfForecastExport.html">CreateForecastExportJob</a> operation.</p>
        next_token: <p>If the result of the previous request was truncated, the response includes a <code>NextToken</code>. To retrieve the next set of results, use the token in the next request. Tokens expire after 24 hours.</p>

    Raises:
        capo_forecastquery.errors.invalid_input_exception.InvalidInputException: <p>The value is invalid or is too long.</p>
        capo_forecastquery.errors.invalid_next_token_exception.InvalidNextTokenException: <p>The token is not valid. Tokens expire after 24 hours.</p>
        capo_forecastquery.errors.limit_exceeded_exception.LimitExceededException: <p>The limit on the number of requests per second has been exceeded.</p>
        capo_forecastquery.errors.resource_in_use_exception.ResourceInUseException: <p>The specified resource is in use.</p>
        capo_forecastquery.errors.resource_not_found_exception.ResourceNotFoundException: <p>We can't find that resource. Check the information that you've provided and try again.</p>
        capo_forecastquery.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_forecastquery.types.query_what_if_forecast_request.QueryWhatIfForecastRequest]",
    ) -> AsyncOperationResponse[
        "capo_forecastquery.types.query_what_if_forecast_response.QueryWhatIfForecastResponse"
    ]:
        import capo_forecastquery._operations.amazon_forecast_runtime.query_what_if_forecast

        (
            output,
            http_response,
        ) = await capo_forecastquery._operations.amazon_forecast_runtime.query_what_if_forecast.async_query_what_if_forecast(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("QueryWhatIfForecast")
    )
    input_: capo_forecastquery.types.query_what_if_forecast_request.QueryWhatIfForecastRequest = {
        "what_if_forecast_arn": what_if_forecast_arn,
        "filters": filters,
    }
    if start_date is not None:
        input_["start_date"] = start_date
    if end_date is not None:
        input_["end_date"] = end_date
    if next_token is not None:
        input_["next_token"] = next_token

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