{-# 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 #-}
module Amazonka.ForecastQuery.QueryForecast
(
QueryForecast (..),
newQueryForecast,
queryForecast_endDate,
queryForecast_startDate,
queryForecast_nextToken,
queryForecast_forecastArn,
queryForecast_filters,
QueryForecastResponse (..),
newQueryForecastResponse,
queryForecastResponse_forecast,
queryForecastResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.ForecastQuery.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data QueryForecast = QueryForecast'
{
QueryForecast -> Maybe Text
endDate :: Prelude.Maybe Prelude.Text,
QueryForecast -> Maybe Text
startDate :: Prelude.Maybe Prelude.Text,
QueryForecast -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
QueryForecast -> Text
forecastArn :: Prelude.Text,
QueryForecast -> HashMap Text Text
filters :: Prelude.HashMap Prelude.Text Prelude.Text
}
deriving (QueryForecast -> QueryForecast -> Bool
(QueryForecast -> QueryForecast -> Bool)
-> (QueryForecast -> QueryForecast -> Bool) -> Eq QueryForecast
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryForecast -> QueryForecast -> Bool
$c/= :: QueryForecast -> QueryForecast -> Bool
== :: QueryForecast -> QueryForecast -> Bool
$c== :: QueryForecast -> QueryForecast -> Bool
Prelude.Eq, ReadPrec [QueryForecast]
ReadPrec QueryForecast
Int -> ReadS QueryForecast
ReadS [QueryForecast]
(Int -> ReadS QueryForecast)
-> ReadS [QueryForecast]
-> ReadPrec QueryForecast
-> ReadPrec [QueryForecast]
-> Read QueryForecast
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QueryForecast]
$creadListPrec :: ReadPrec [QueryForecast]
readPrec :: ReadPrec QueryForecast
$creadPrec :: ReadPrec QueryForecast
readList :: ReadS [QueryForecast]
$creadList :: ReadS [QueryForecast]
readsPrec :: Int -> ReadS QueryForecast
$creadsPrec :: Int -> ReadS QueryForecast
Prelude.Read, Int -> QueryForecast -> ShowS
[QueryForecast] -> ShowS
QueryForecast -> String
(Int -> QueryForecast -> ShowS)
-> (QueryForecast -> String)
-> ([QueryForecast] -> ShowS)
-> Show QueryForecast
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryForecast] -> ShowS
$cshowList :: [QueryForecast] -> ShowS
show :: QueryForecast -> String
$cshow :: QueryForecast -> String
showsPrec :: Int -> QueryForecast -> ShowS
$cshowsPrec :: Int -> QueryForecast -> ShowS
Prelude.Show, (forall x. QueryForecast -> Rep QueryForecast x)
-> (forall x. Rep QueryForecast x -> QueryForecast)
-> Generic QueryForecast
forall x. Rep QueryForecast x -> QueryForecast
forall x. QueryForecast -> Rep QueryForecast x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryForecast x -> QueryForecast
$cfrom :: forall x. QueryForecast -> Rep QueryForecast x
Prelude.Generic)
newQueryForecast ::
Prelude.Text ->
QueryForecast
newQueryForecast :: Text -> QueryForecast
newQueryForecast Text
pForecastArn_ =
QueryForecast' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> HashMap Text Text
-> QueryForecast
QueryForecast'
{ $sel:endDate:QueryForecast' :: Maybe Text
endDate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:startDate:QueryForecast' :: Maybe Text
startDate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:QueryForecast' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:forecastArn:QueryForecast' :: Text
forecastArn = Text
pForecastArn_,
$sel:filters:QueryForecast' :: HashMap Text Text
filters = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
}
queryForecast_endDate :: Lens.Lens' QueryForecast (Prelude.Maybe Prelude.Text)
queryForecast_endDate :: (Maybe Text -> f (Maybe Text)) -> QueryForecast -> f QueryForecast
queryForecast_endDate = (QueryForecast -> Maybe Text)
-> (QueryForecast -> Maybe Text -> QueryForecast)
-> Lens QueryForecast QueryForecast (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryForecast' {Maybe Text
endDate :: Maybe Text
$sel:endDate:QueryForecast' :: QueryForecast -> Maybe Text
endDate} -> Maybe Text
endDate) (\s :: QueryForecast
s@QueryForecast' {} Maybe Text
a -> QueryForecast
s {$sel:endDate:QueryForecast' :: Maybe Text
endDate = Maybe Text
a} :: QueryForecast)
queryForecast_startDate :: Lens.Lens' QueryForecast (Prelude.Maybe Prelude.Text)
queryForecast_startDate :: (Maybe Text -> f (Maybe Text)) -> QueryForecast -> f QueryForecast
queryForecast_startDate = (QueryForecast -> Maybe Text)
-> (QueryForecast -> Maybe Text -> QueryForecast)
-> Lens QueryForecast QueryForecast (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryForecast' {Maybe Text
startDate :: Maybe Text
$sel:startDate:QueryForecast' :: QueryForecast -> Maybe Text
startDate} -> Maybe Text
startDate) (\s :: QueryForecast
s@QueryForecast' {} Maybe Text
a -> QueryForecast
s {$sel:startDate:QueryForecast' :: Maybe Text
startDate = Maybe Text
a} :: QueryForecast)
queryForecast_nextToken :: Lens.Lens' QueryForecast (Prelude.Maybe Prelude.Text)
queryForecast_nextToken :: (Maybe Text -> f (Maybe Text)) -> QueryForecast -> f QueryForecast
queryForecast_nextToken = (QueryForecast -> Maybe Text)
-> (QueryForecast -> Maybe Text -> QueryForecast)
-> Lens QueryForecast QueryForecast (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryForecast' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:QueryForecast' :: QueryForecast -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: QueryForecast
s@QueryForecast' {} Maybe Text
a -> QueryForecast
s {$sel:nextToken:QueryForecast' :: Maybe Text
nextToken = Maybe Text
a} :: QueryForecast)
queryForecast_forecastArn :: Lens.Lens' QueryForecast Prelude.Text
queryForecast_forecastArn :: (Text -> f Text) -> QueryForecast -> f QueryForecast
queryForecast_forecastArn = (QueryForecast -> Text)
-> (QueryForecast -> Text -> QueryForecast)
-> Lens QueryForecast QueryForecast Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryForecast' {Text
forecastArn :: Text
$sel:forecastArn:QueryForecast' :: QueryForecast -> Text
forecastArn} -> Text
forecastArn) (\s :: QueryForecast
s@QueryForecast' {} Text
a -> QueryForecast
s {$sel:forecastArn:QueryForecast' :: Text
forecastArn = Text
a} :: QueryForecast)
queryForecast_filters :: Lens.Lens' QueryForecast (Prelude.HashMap Prelude.Text Prelude.Text)
queryForecast_filters :: (HashMap Text Text -> f (HashMap Text Text))
-> QueryForecast -> f QueryForecast
queryForecast_filters = (QueryForecast -> HashMap Text Text)
-> (QueryForecast -> HashMap Text Text -> QueryForecast)
-> Lens
QueryForecast QueryForecast (HashMap Text Text) (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryForecast' {HashMap Text Text
filters :: HashMap Text Text
$sel:filters:QueryForecast' :: QueryForecast -> HashMap Text Text
filters} -> HashMap Text Text
filters) (\s :: QueryForecast
s@QueryForecast' {} HashMap Text Text
a -> QueryForecast
s {$sel:filters:QueryForecast' :: HashMap Text Text
filters = HashMap Text Text
a} :: QueryForecast) ((HashMap Text Text -> f (HashMap Text Text))
-> QueryForecast -> f QueryForecast)
-> ((HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> QueryForecast
-> f QueryForecast
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest QueryForecast where
type
AWSResponse QueryForecast =
QueryForecastResponse
request :: QueryForecast -> Request QueryForecast
request = Service -> QueryForecast -> Request QueryForecast
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy QueryForecast
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse QueryForecast)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse QueryForecast))
-> Logger
-> Service
-> Proxy QueryForecast
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse QueryForecast)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Forecast -> Int -> QueryForecastResponse
QueryForecastResponse'
(Maybe Forecast -> Int -> QueryForecastResponse)
-> Either String (Maybe Forecast)
-> Either String (Int -> QueryForecastResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Forecast)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Forecast")
Either String (Int -> QueryForecastResponse)
-> Either String Int -> Either String QueryForecastResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable QueryForecast
instance Prelude.NFData QueryForecast
instance Core.ToHeaders QueryForecast where
toHeaders :: QueryForecast -> ResponseHeaders
toHeaders =
ResponseHeaders -> QueryForecast -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AmazonForecastRuntime.QueryForecast" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON QueryForecast where
toJSON :: QueryForecast -> Value
toJSON QueryForecast' {Maybe Text
Text
HashMap Text Text
filters :: HashMap Text Text
forecastArn :: Text
nextToken :: Maybe Text
startDate :: Maybe Text
endDate :: Maybe Text
$sel:filters:QueryForecast' :: QueryForecast -> HashMap Text Text
$sel:forecastArn:QueryForecast' :: QueryForecast -> Text
$sel:nextToken:QueryForecast' :: QueryForecast -> Maybe Text
$sel:startDate:QueryForecast' :: QueryForecast -> Maybe Text
$sel:endDate:QueryForecast' :: QueryForecast -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"EndDate" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
endDate,
(Text
"StartDate" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
startDate,
(Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ForecastArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
forecastArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Filters" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text Text
filters)
]
)
instance Core.ToPath QueryForecast where
toPath :: QueryForecast -> ByteString
toPath = ByteString -> QueryForecast -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery QueryForecast where
toQuery :: QueryForecast -> QueryString
toQuery = QueryString -> QueryForecast -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data QueryForecastResponse = QueryForecastResponse'
{
QueryForecastResponse -> Maybe Forecast
forecast :: Prelude.Maybe Forecast,
QueryForecastResponse -> Int
httpStatus :: Prelude.Int
}
deriving (QueryForecastResponse -> QueryForecastResponse -> Bool
(QueryForecastResponse -> QueryForecastResponse -> Bool)
-> (QueryForecastResponse -> QueryForecastResponse -> Bool)
-> Eq QueryForecastResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryForecastResponse -> QueryForecastResponse -> Bool
$c/= :: QueryForecastResponse -> QueryForecastResponse -> Bool
== :: QueryForecastResponse -> QueryForecastResponse -> Bool
$c== :: QueryForecastResponse -> QueryForecastResponse -> Bool
Prelude.Eq, ReadPrec [QueryForecastResponse]
ReadPrec QueryForecastResponse
Int -> ReadS QueryForecastResponse
ReadS [QueryForecastResponse]
(Int -> ReadS QueryForecastResponse)
-> ReadS [QueryForecastResponse]
-> ReadPrec QueryForecastResponse
-> ReadPrec [QueryForecastResponse]
-> Read QueryForecastResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QueryForecastResponse]
$creadListPrec :: ReadPrec [QueryForecastResponse]
readPrec :: ReadPrec QueryForecastResponse
$creadPrec :: ReadPrec QueryForecastResponse
readList :: ReadS [QueryForecastResponse]
$creadList :: ReadS [QueryForecastResponse]
readsPrec :: Int -> ReadS QueryForecastResponse
$creadsPrec :: Int -> ReadS QueryForecastResponse
Prelude.Read, Int -> QueryForecastResponse -> ShowS
[QueryForecastResponse] -> ShowS
QueryForecastResponse -> String
(Int -> QueryForecastResponse -> ShowS)
-> (QueryForecastResponse -> String)
-> ([QueryForecastResponse] -> ShowS)
-> Show QueryForecastResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryForecastResponse] -> ShowS
$cshowList :: [QueryForecastResponse] -> ShowS
show :: QueryForecastResponse -> String
$cshow :: QueryForecastResponse -> String
showsPrec :: Int -> QueryForecastResponse -> ShowS
$cshowsPrec :: Int -> QueryForecastResponse -> ShowS
Prelude.Show, (forall x. QueryForecastResponse -> Rep QueryForecastResponse x)
-> (forall x. Rep QueryForecastResponse x -> QueryForecastResponse)
-> Generic QueryForecastResponse
forall x. Rep QueryForecastResponse x -> QueryForecastResponse
forall x. QueryForecastResponse -> Rep QueryForecastResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryForecastResponse x -> QueryForecastResponse
$cfrom :: forall x. QueryForecastResponse -> Rep QueryForecastResponse x
Prelude.Generic)
newQueryForecastResponse ::
Prelude.Int ->
QueryForecastResponse
newQueryForecastResponse :: Int -> QueryForecastResponse
newQueryForecastResponse Int
pHttpStatus_ =
QueryForecastResponse' :: Maybe Forecast -> Int -> QueryForecastResponse
QueryForecastResponse'
{ $sel:forecast:QueryForecastResponse' :: Maybe Forecast
forecast = Maybe Forecast
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:QueryForecastResponse' :: Int
httpStatus = Int
pHttpStatus_
}
queryForecastResponse_forecast :: Lens.Lens' QueryForecastResponse (Prelude.Maybe Forecast)
queryForecastResponse_forecast :: (Maybe Forecast -> f (Maybe Forecast))
-> QueryForecastResponse -> f QueryForecastResponse
queryForecastResponse_forecast = (QueryForecastResponse -> Maybe Forecast)
-> (QueryForecastResponse
-> Maybe Forecast -> QueryForecastResponse)
-> Lens
QueryForecastResponse
QueryForecastResponse
(Maybe Forecast)
(Maybe Forecast)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryForecastResponse' {Maybe Forecast
forecast :: Maybe Forecast
$sel:forecast:QueryForecastResponse' :: QueryForecastResponse -> Maybe Forecast
forecast} -> Maybe Forecast
forecast) (\s :: QueryForecastResponse
s@QueryForecastResponse' {} Maybe Forecast
a -> QueryForecastResponse
s {$sel:forecast:QueryForecastResponse' :: Maybe Forecast
forecast = Maybe Forecast
a} :: QueryForecastResponse)
queryForecastResponse_httpStatus :: Lens.Lens' QueryForecastResponse Prelude.Int
queryForecastResponse_httpStatus :: (Int -> f Int) -> QueryForecastResponse -> f QueryForecastResponse
queryForecastResponse_httpStatus = (QueryForecastResponse -> Int)
-> (QueryForecastResponse -> Int -> QueryForecastResponse)
-> Lens QueryForecastResponse QueryForecastResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryForecastResponse' {Int
httpStatus :: Int
$sel:httpStatus:QueryForecastResponse' :: QueryForecastResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: QueryForecastResponse
s@QueryForecastResponse' {} Int
a -> QueryForecastResponse
s {$sel:httpStatus:QueryForecastResponse' :: Int
httpStatus = Int
a} :: QueryForecastResponse)
instance Prelude.NFData QueryForecastResponse