{-# 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.Forecast.CreateForecast
(
CreateForecast (..),
newCreateForecast,
createForecast_forecastTypes,
createForecast_tags,
createForecast_forecastName,
createForecast_predictorArn,
CreateForecastResponse (..),
newCreateForecastResponse,
createForecastResponse_forecastArn,
createForecastResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.Forecast.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 CreateForecast = CreateForecast'
{
CreateForecast -> Maybe (NonEmpty Text)
forecastTypes :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
CreateForecast -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateForecast -> Text
forecastName :: Prelude.Text,
CreateForecast -> Text
predictorArn :: Prelude.Text
}
deriving (CreateForecast -> CreateForecast -> Bool
(CreateForecast -> CreateForecast -> Bool)
-> (CreateForecast -> CreateForecast -> Bool) -> Eq CreateForecast
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateForecast -> CreateForecast -> Bool
$c/= :: CreateForecast -> CreateForecast -> Bool
== :: CreateForecast -> CreateForecast -> Bool
$c== :: CreateForecast -> CreateForecast -> Bool
Prelude.Eq, Int -> CreateForecast -> ShowS
[CreateForecast] -> ShowS
CreateForecast -> String
(Int -> CreateForecast -> ShowS)
-> (CreateForecast -> String)
-> ([CreateForecast] -> ShowS)
-> Show CreateForecast
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateForecast] -> ShowS
$cshowList :: [CreateForecast] -> ShowS
show :: CreateForecast -> String
$cshow :: CreateForecast -> String
showsPrec :: Int -> CreateForecast -> ShowS
$cshowsPrec :: Int -> CreateForecast -> ShowS
Prelude.Show, (forall x. CreateForecast -> Rep CreateForecast x)
-> (forall x. Rep CreateForecast x -> CreateForecast)
-> Generic CreateForecast
forall x. Rep CreateForecast x -> CreateForecast
forall x. CreateForecast -> Rep CreateForecast x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateForecast x -> CreateForecast
$cfrom :: forall x. CreateForecast -> Rep CreateForecast x
Prelude.Generic)
newCreateForecast ::
Prelude.Text ->
Prelude.Text ->
CreateForecast
newCreateForecast :: Text -> Text -> CreateForecast
newCreateForecast Text
pForecastName_ Text
pPredictorArn_ =
CreateForecast' :: Maybe (NonEmpty Text)
-> Maybe [Tag] -> Text -> Text -> CreateForecast
CreateForecast'
{ $sel:forecastTypes:CreateForecast' :: Maybe (NonEmpty Text)
forecastTypes = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateForecast' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:forecastName:CreateForecast' :: Text
forecastName = Text
pForecastName_,
$sel:predictorArn:CreateForecast' :: Text
predictorArn = Text
pPredictorArn_
}
createForecast_forecastTypes :: Lens.Lens' CreateForecast (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
createForecast_forecastTypes :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> CreateForecast -> f CreateForecast
createForecast_forecastTypes = (CreateForecast -> Maybe (NonEmpty Text))
-> (CreateForecast -> Maybe (NonEmpty Text) -> CreateForecast)
-> Lens
CreateForecast
CreateForecast
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateForecast' {Maybe (NonEmpty Text)
forecastTypes :: Maybe (NonEmpty Text)
$sel:forecastTypes:CreateForecast' :: CreateForecast -> Maybe (NonEmpty Text)
forecastTypes} -> Maybe (NonEmpty Text)
forecastTypes) (\s :: CreateForecast
s@CreateForecast' {} Maybe (NonEmpty Text)
a -> CreateForecast
s {$sel:forecastTypes:CreateForecast' :: Maybe (NonEmpty Text)
forecastTypes = Maybe (NonEmpty Text)
a} :: CreateForecast) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> CreateForecast -> f CreateForecast)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> CreateForecast
-> f CreateForecast
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createForecast_tags :: Lens.Lens' CreateForecast (Prelude.Maybe [Tag])
createForecast_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateForecast -> f CreateForecast
createForecast_tags = (CreateForecast -> Maybe [Tag])
-> (CreateForecast -> Maybe [Tag] -> CreateForecast)
-> Lens CreateForecast CreateForecast (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateForecast' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateForecast' :: CreateForecast -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateForecast
s@CreateForecast' {} Maybe [Tag]
a -> CreateForecast
s {$sel:tags:CreateForecast' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateForecast) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateForecast -> f CreateForecast)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateForecast
-> f CreateForecast
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createForecast_forecastName :: Lens.Lens' CreateForecast Prelude.Text
createForecast_forecastName :: (Text -> f Text) -> CreateForecast -> f CreateForecast
createForecast_forecastName = (CreateForecast -> Text)
-> (CreateForecast -> Text -> CreateForecast)
-> Lens CreateForecast CreateForecast Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateForecast' {Text
forecastName :: Text
$sel:forecastName:CreateForecast' :: CreateForecast -> Text
forecastName} -> Text
forecastName) (\s :: CreateForecast
s@CreateForecast' {} Text
a -> CreateForecast
s {$sel:forecastName:CreateForecast' :: Text
forecastName = Text
a} :: CreateForecast)
createForecast_predictorArn :: Lens.Lens' CreateForecast Prelude.Text
createForecast_predictorArn :: (Text -> f Text) -> CreateForecast -> f CreateForecast
createForecast_predictorArn = (CreateForecast -> Text)
-> (CreateForecast -> Text -> CreateForecast)
-> Lens CreateForecast CreateForecast Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateForecast' {Text
predictorArn :: Text
$sel:predictorArn:CreateForecast' :: CreateForecast -> Text
predictorArn} -> Text
predictorArn) (\s :: CreateForecast
s@CreateForecast' {} Text
a -> CreateForecast
s {$sel:predictorArn:CreateForecast' :: Text
predictorArn = Text
a} :: CreateForecast)
instance Core.AWSRequest CreateForecast where
type
AWSResponse CreateForecast =
CreateForecastResponse
request :: CreateForecast -> Request CreateForecast
request = Service -> CreateForecast -> Request CreateForecast
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateForecast
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateForecast)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateForecast))
-> Logger
-> Service
-> Proxy CreateForecast
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateForecast)))
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 Text -> Int -> CreateForecastResponse
CreateForecastResponse'
(Maybe Text -> Int -> CreateForecastResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateForecastResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ForecastArn")
Either String (Int -> CreateForecastResponse)
-> Either String Int -> Either String CreateForecastResponse
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 CreateForecast
instance Prelude.NFData CreateForecast
instance Core.ToHeaders CreateForecast where
toHeaders :: CreateForecast -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateForecast -> 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
"AmazonForecast.CreateForecast" ::
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 CreateForecast where
toJSON :: CreateForecast -> Value
toJSON CreateForecast' {Maybe [Tag]
Maybe (NonEmpty Text)
Text
predictorArn :: Text
forecastName :: Text
tags :: Maybe [Tag]
forecastTypes :: Maybe (NonEmpty Text)
$sel:predictorArn:CreateForecast' :: CreateForecast -> Text
$sel:forecastName:CreateForecast' :: CreateForecast -> Text
$sel:tags:CreateForecast' :: CreateForecast -> Maybe [Tag]
$sel:forecastTypes:CreateForecast' :: CreateForecast -> Maybe (NonEmpty Text)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ForecastTypes" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
forecastTypes,
(Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ForecastName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
forecastName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PredictorArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
predictorArn)
]
)
instance Core.ToPath CreateForecast where
toPath :: CreateForecast -> ByteString
toPath = ByteString -> CreateForecast -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateForecast where
toQuery :: CreateForecast -> QueryString
toQuery = QueryString -> CreateForecast -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateForecastResponse = CreateForecastResponse'
{
CreateForecastResponse -> Maybe Text
forecastArn :: Prelude.Maybe Prelude.Text,
CreateForecastResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateForecastResponse -> CreateForecastResponse -> Bool
(CreateForecastResponse -> CreateForecastResponse -> Bool)
-> (CreateForecastResponse -> CreateForecastResponse -> Bool)
-> Eq CreateForecastResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateForecastResponse -> CreateForecastResponse -> Bool
$c/= :: CreateForecastResponse -> CreateForecastResponse -> Bool
== :: CreateForecastResponse -> CreateForecastResponse -> Bool
$c== :: CreateForecastResponse -> CreateForecastResponse -> Bool
Prelude.Eq, ReadPrec [CreateForecastResponse]
ReadPrec CreateForecastResponse
Int -> ReadS CreateForecastResponse
ReadS [CreateForecastResponse]
(Int -> ReadS CreateForecastResponse)
-> ReadS [CreateForecastResponse]
-> ReadPrec CreateForecastResponse
-> ReadPrec [CreateForecastResponse]
-> Read CreateForecastResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateForecastResponse]
$creadListPrec :: ReadPrec [CreateForecastResponse]
readPrec :: ReadPrec CreateForecastResponse
$creadPrec :: ReadPrec CreateForecastResponse
readList :: ReadS [CreateForecastResponse]
$creadList :: ReadS [CreateForecastResponse]
readsPrec :: Int -> ReadS CreateForecastResponse
$creadsPrec :: Int -> ReadS CreateForecastResponse
Prelude.Read, Int -> CreateForecastResponse -> ShowS
[CreateForecastResponse] -> ShowS
CreateForecastResponse -> String
(Int -> CreateForecastResponse -> ShowS)
-> (CreateForecastResponse -> String)
-> ([CreateForecastResponse] -> ShowS)
-> Show CreateForecastResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateForecastResponse] -> ShowS
$cshowList :: [CreateForecastResponse] -> ShowS
show :: CreateForecastResponse -> String
$cshow :: CreateForecastResponse -> String
showsPrec :: Int -> CreateForecastResponse -> ShowS
$cshowsPrec :: Int -> CreateForecastResponse -> ShowS
Prelude.Show, (forall x. CreateForecastResponse -> Rep CreateForecastResponse x)
-> (forall x.
Rep CreateForecastResponse x -> CreateForecastResponse)
-> Generic CreateForecastResponse
forall x. Rep CreateForecastResponse x -> CreateForecastResponse
forall x. CreateForecastResponse -> Rep CreateForecastResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateForecastResponse x -> CreateForecastResponse
$cfrom :: forall x. CreateForecastResponse -> Rep CreateForecastResponse x
Prelude.Generic)
newCreateForecastResponse ::
Prelude.Int ->
CreateForecastResponse
newCreateForecastResponse :: Int -> CreateForecastResponse
newCreateForecastResponse Int
pHttpStatus_ =
CreateForecastResponse' :: Maybe Text -> Int -> CreateForecastResponse
CreateForecastResponse'
{ $sel:forecastArn:CreateForecastResponse' :: Maybe Text
forecastArn =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateForecastResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createForecastResponse_forecastArn :: Lens.Lens' CreateForecastResponse (Prelude.Maybe Prelude.Text)
createForecastResponse_forecastArn :: (Maybe Text -> f (Maybe Text))
-> CreateForecastResponse -> f CreateForecastResponse
createForecastResponse_forecastArn = (CreateForecastResponse -> Maybe Text)
-> (CreateForecastResponse -> Maybe Text -> CreateForecastResponse)
-> Lens
CreateForecastResponse
CreateForecastResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateForecastResponse' {Maybe Text
forecastArn :: Maybe Text
$sel:forecastArn:CreateForecastResponse' :: CreateForecastResponse -> Maybe Text
forecastArn} -> Maybe Text
forecastArn) (\s :: CreateForecastResponse
s@CreateForecastResponse' {} Maybe Text
a -> CreateForecastResponse
s {$sel:forecastArn:CreateForecastResponse' :: Maybe Text
forecastArn = Maybe Text
a} :: CreateForecastResponse)
createForecastResponse_httpStatus :: Lens.Lens' CreateForecastResponse Prelude.Int
createForecastResponse_httpStatus :: (Int -> f Int)
-> CreateForecastResponse -> f CreateForecastResponse
createForecastResponse_httpStatus = (CreateForecastResponse -> Int)
-> (CreateForecastResponse -> Int -> CreateForecastResponse)
-> Lens CreateForecastResponse CreateForecastResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateForecastResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateForecastResponse' :: CreateForecastResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateForecastResponse
s@CreateForecastResponse' {} Int
a -> CreateForecastResponse
s {$sel:httpStatus:CreateForecastResponse' :: Int
httpStatus = Int
a} :: CreateForecastResponse)
instance Prelude.NFData CreateForecastResponse