{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE StrictData #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} -- Derived from AWS service descriptions, licensed under Apache 2.0. -- | -- Module : Amazonka.ForecastQuery.QueryForecast -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Retrieves a forecast for a single item, filtered by the supplied -- criteria. -- -- The criteria is a key-value pair. The key is either @item_id@ (or the -- equivalent non-timestamp, non-target field) from the -- @TARGET_TIME_SERIES@ dataset, or one of the forecast dimensions -- specified as part of the @FeaturizationConfig@ object. -- -- By default, @QueryForecast@ returns the complete date range for the -- filtered forecast. You can request a specific date range. -- -- To get the full forecast, use the -- -- operation. -- -- The forecasts generated by Amazon Forecast are in the same timezone as -- the dataset that was used to create the predictor. module Amazonka.ForecastQuery.QueryForecast ( -- * Creating a Request QueryForecast (..), newQueryForecast, -- * Request Lenses queryForecast_endDate, queryForecast_nextToken, queryForecast_startDate, queryForecast_forecastArn, queryForecast_filters, -- * Destructuring the Response QueryForecastResponse (..), newQueryForecastResponse, -- * Response Lenses queryForecastResponse_forecast, queryForecastResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.ForecastQuery.Types import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newQueryForecast' smart constructor. data QueryForecast = QueryForecast' { -- | The end date for the forecast. Specify the date using this format: -- yyyy-MM-dd\'T\'HH:mm:ss (ISO 8601 format). For example, -- 2015-01-01T20:00:00. endDate :: Prelude.Maybe Prelude.Text, -- | 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. nextToken :: Prelude.Maybe Prelude.Text, -- | The start date for the forecast. Specify the date using this format: -- yyyy-MM-dd\'T\'HH:mm:ss (ISO 8601 format). For example, -- 2015-01-01T08:00:00. startDate :: Prelude.Maybe Prelude.Text, -- | The Amazon Resource Name (ARN) of the forecast to query. forecastArn :: Prelude.Text, -- | 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 forecast, use the -- -- operation. filters :: Prelude.HashMap Prelude.Text Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'QueryForecast' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'endDate', 'queryForecast_endDate' - The end date for the forecast. Specify the date using this format: -- yyyy-MM-dd\'T\'HH:mm:ss (ISO 8601 format). For example, -- 2015-01-01T20:00:00. -- -- 'nextToken', 'queryForecast_nextToken' - 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. -- -- 'startDate', 'queryForecast_startDate' - The start date for the forecast. Specify the date using this format: -- yyyy-MM-dd\'T\'HH:mm:ss (ISO 8601 format). For example, -- 2015-01-01T08:00:00. -- -- 'forecastArn', 'queryForecast_forecastArn' - The Amazon Resource Name (ARN) of the forecast to query. -- -- 'filters', 'queryForecast_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 forecast, use the -- -- operation. newQueryForecast :: -- | 'forecastArn' Prelude.Text -> QueryForecast newQueryForecast pForecastArn_ = QueryForecast' { endDate = Prelude.Nothing, nextToken = Prelude.Nothing, startDate = Prelude.Nothing, forecastArn = pForecastArn_, filters = Prelude.mempty } -- | The end date for the forecast. Specify the date using this format: -- yyyy-MM-dd\'T\'HH:mm:ss (ISO 8601 format). For example, -- 2015-01-01T20:00:00. queryForecast_endDate :: Lens.Lens' QueryForecast (Prelude.Maybe Prelude.Text) queryForecast_endDate = Lens.lens (\QueryForecast' {endDate} -> endDate) (\s@QueryForecast' {} a -> s {endDate = a} :: QueryForecast) -- | 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. queryForecast_nextToken :: Lens.Lens' QueryForecast (Prelude.Maybe Prelude.Text) queryForecast_nextToken = Lens.lens (\QueryForecast' {nextToken} -> nextToken) (\s@QueryForecast' {} a -> s {nextToken = a} :: QueryForecast) -- | The start date for the forecast. Specify the date using this format: -- yyyy-MM-dd\'T\'HH:mm:ss (ISO 8601 format). For example, -- 2015-01-01T08:00:00. queryForecast_startDate :: Lens.Lens' QueryForecast (Prelude.Maybe Prelude.Text) queryForecast_startDate = Lens.lens (\QueryForecast' {startDate} -> startDate) (\s@QueryForecast' {} a -> s {startDate = a} :: QueryForecast) -- | The Amazon Resource Name (ARN) of the forecast to query. queryForecast_forecastArn :: Lens.Lens' QueryForecast Prelude.Text queryForecast_forecastArn = Lens.lens (\QueryForecast' {forecastArn} -> forecastArn) (\s@QueryForecast' {} a -> s {forecastArn = a} :: QueryForecast) -- | 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 forecast, use the -- -- operation. queryForecast_filters :: Lens.Lens' QueryForecast (Prelude.HashMap Prelude.Text Prelude.Text) queryForecast_filters = Lens.lens (\QueryForecast' {filters} -> filters) (\s@QueryForecast' {} a -> s {filters = a} :: QueryForecast) Prelude.. Lens.coerced instance Core.AWSRequest QueryForecast where type AWSResponse QueryForecast = QueryForecastResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> QueryForecastResponse' Prelude.<$> (x Data..?> "Forecast") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable QueryForecast where hashWithSalt _salt QueryForecast' {..} = _salt `Prelude.hashWithSalt` endDate `Prelude.hashWithSalt` nextToken `Prelude.hashWithSalt` startDate `Prelude.hashWithSalt` forecastArn `Prelude.hashWithSalt` filters instance Prelude.NFData QueryForecast where rnf QueryForecast' {..} = Prelude.rnf endDate `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf startDate `Prelude.seq` Prelude.rnf forecastArn `Prelude.seq` Prelude.rnf filters instance Data.ToHeaders QueryForecast where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "AmazonForecastRuntime.QueryForecast" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON QueryForecast where toJSON QueryForecast' {..} = Data.object ( Prelude.catMaybes [ ("EndDate" Data..=) Prelude.<$> endDate, ("NextToken" Data..=) Prelude.<$> nextToken, ("StartDate" Data..=) Prelude.<$> startDate, Prelude.Just ("ForecastArn" Data..= forecastArn), Prelude.Just ("Filters" Data..= filters) ] ) instance Data.ToPath QueryForecast where toPath = Prelude.const "/" instance Data.ToQuery QueryForecast where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newQueryForecastResponse' smart constructor. data QueryForecastResponse = QueryForecastResponse' { -- | The forecast. forecast :: Prelude.Maybe Forecast, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'QueryForecastResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'forecast', 'queryForecastResponse_forecast' - The forecast. -- -- 'httpStatus', 'queryForecastResponse_httpStatus' - The response's http status code. newQueryForecastResponse :: -- | 'httpStatus' Prelude.Int -> QueryForecastResponse newQueryForecastResponse pHttpStatus_ = QueryForecastResponse' { forecast = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | The forecast. queryForecastResponse_forecast :: Lens.Lens' QueryForecastResponse (Prelude.Maybe Forecast) queryForecastResponse_forecast = Lens.lens (\QueryForecastResponse' {forecast} -> forecast) (\s@QueryForecastResponse' {} a -> s {forecast = a} :: QueryForecastResponse) -- | The response's http status code. queryForecastResponse_httpStatus :: Lens.Lens' QueryForecastResponse Prelude.Int queryForecastResponse_httpStatus = Lens.lens (\QueryForecastResponse' {httpStatus} -> httpStatus) (\s@QueryForecastResponse' {} a -> s {httpStatus = a} :: QueryForecastResponse) instance Prelude.NFData QueryForecastResponse where rnf QueryForecastResponse' {..} = Prelude.rnf forecast `Prelude.seq` Prelude.rnf httpStatus