{-# 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.Personalize.CreateCampaign
(
CreateCampaign (..),
newCreateCampaign,
createCampaign_campaignConfig,
createCampaign_minProvisionedTPS,
createCampaign_name,
createCampaign_solutionVersionArn,
CreateCampaignResponse (..),
newCreateCampaignResponse,
createCampaignResponse_campaignArn,
createCampaignResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Personalize.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateCampaign = CreateCampaign'
{
CreateCampaign -> Maybe CampaignConfig
campaignConfig :: Prelude.Maybe CampaignConfig,
CreateCampaign -> Maybe Natural
minProvisionedTPS :: Prelude.Maybe Prelude.Natural,
CreateCampaign -> Text
name :: Prelude.Text,
CreateCampaign -> Text
solutionVersionArn :: Prelude.Text
}
deriving (CreateCampaign -> CreateCampaign -> Bool
(CreateCampaign -> CreateCampaign -> Bool)
-> (CreateCampaign -> CreateCampaign -> Bool) -> Eq CreateCampaign
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCampaign -> CreateCampaign -> Bool
$c/= :: CreateCampaign -> CreateCampaign -> Bool
== :: CreateCampaign -> CreateCampaign -> Bool
$c== :: CreateCampaign -> CreateCampaign -> Bool
Prelude.Eq, ReadPrec [CreateCampaign]
ReadPrec CreateCampaign
Int -> ReadS CreateCampaign
ReadS [CreateCampaign]
(Int -> ReadS CreateCampaign)
-> ReadS [CreateCampaign]
-> ReadPrec CreateCampaign
-> ReadPrec [CreateCampaign]
-> Read CreateCampaign
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCampaign]
$creadListPrec :: ReadPrec [CreateCampaign]
readPrec :: ReadPrec CreateCampaign
$creadPrec :: ReadPrec CreateCampaign
readList :: ReadS [CreateCampaign]
$creadList :: ReadS [CreateCampaign]
readsPrec :: Int -> ReadS CreateCampaign
$creadsPrec :: Int -> ReadS CreateCampaign
Prelude.Read, Int -> CreateCampaign -> ShowS
[CreateCampaign] -> ShowS
CreateCampaign -> String
(Int -> CreateCampaign -> ShowS)
-> (CreateCampaign -> String)
-> ([CreateCampaign] -> ShowS)
-> Show CreateCampaign
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCampaign] -> ShowS
$cshowList :: [CreateCampaign] -> ShowS
show :: CreateCampaign -> String
$cshow :: CreateCampaign -> String
showsPrec :: Int -> CreateCampaign -> ShowS
$cshowsPrec :: Int -> CreateCampaign -> ShowS
Prelude.Show, (forall x. CreateCampaign -> Rep CreateCampaign x)
-> (forall x. Rep CreateCampaign x -> CreateCampaign)
-> Generic CreateCampaign
forall x. Rep CreateCampaign x -> CreateCampaign
forall x. CreateCampaign -> Rep CreateCampaign x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCampaign x -> CreateCampaign
$cfrom :: forall x. CreateCampaign -> Rep CreateCampaign x
Prelude.Generic)
newCreateCampaign ::
Prelude.Text ->
Prelude.Text ->
CreateCampaign
newCreateCampaign :: Text -> Text -> CreateCampaign
newCreateCampaign Text
pName_ Text
pSolutionVersionArn_ =
CreateCampaign' :: Maybe CampaignConfig
-> Maybe Natural -> Text -> Text -> CreateCampaign
CreateCampaign'
{ $sel:campaignConfig:CreateCampaign' :: Maybe CampaignConfig
campaignConfig = Maybe CampaignConfig
forall a. Maybe a
Prelude.Nothing,
$sel:minProvisionedTPS:CreateCampaign' :: Maybe Natural
minProvisionedTPS = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:name:CreateCampaign' :: Text
name = Text
pName_,
$sel:solutionVersionArn:CreateCampaign' :: Text
solutionVersionArn = Text
pSolutionVersionArn_
}
createCampaign_campaignConfig :: Lens.Lens' CreateCampaign (Prelude.Maybe CampaignConfig)
createCampaign_campaignConfig :: (Maybe CampaignConfig -> f (Maybe CampaignConfig))
-> CreateCampaign -> f CreateCampaign
createCampaign_campaignConfig = (CreateCampaign -> Maybe CampaignConfig)
-> (CreateCampaign -> Maybe CampaignConfig -> CreateCampaign)
-> Lens
CreateCampaign
CreateCampaign
(Maybe CampaignConfig)
(Maybe CampaignConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCampaign' {Maybe CampaignConfig
campaignConfig :: Maybe CampaignConfig
$sel:campaignConfig:CreateCampaign' :: CreateCampaign -> Maybe CampaignConfig
campaignConfig} -> Maybe CampaignConfig
campaignConfig) (\s :: CreateCampaign
s@CreateCampaign' {} Maybe CampaignConfig
a -> CreateCampaign
s {$sel:campaignConfig:CreateCampaign' :: Maybe CampaignConfig
campaignConfig = Maybe CampaignConfig
a} :: CreateCampaign)
createCampaign_minProvisionedTPS :: Lens.Lens' CreateCampaign (Prelude.Maybe Prelude.Natural)
createCampaign_minProvisionedTPS :: (Maybe Natural -> f (Maybe Natural))
-> CreateCampaign -> f CreateCampaign
createCampaign_minProvisionedTPS = (CreateCampaign -> Maybe Natural)
-> (CreateCampaign -> Maybe Natural -> CreateCampaign)
-> Lens
CreateCampaign CreateCampaign (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCampaign' {Maybe Natural
minProvisionedTPS :: Maybe Natural
$sel:minProvisionedTPS:CreateCampaign' :: CreateCampaign -> Maybe Natural
minProvisionedTPS} -> Maybe Natural
minProvisionedTPS) (\s :: CreateCampaign
s@CreateCampaign' {} Maybe Natural
a -> CreateCampaign
s {$sel:minProvisionedTPS:CreateCampaign' :: Maybe Natural
minProvisionedTPS = Maybe Natural
a} :: CreateCampaign)
createCampaign_name :: Lens.Lens' CreateCampaign Prelude.Text
createCampaign_name :: (Text -> f Text) -> CreateCampaign -> f CreateCampaign
createCampaign_name = (CreateCampaign -> Text)
-> (CreateCampaign -> Text -> CreateCampaign)
-> Lens CreateCampaign CreateCampaign Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCampaign' {Text
name :: Text
$sel:name:CreateCampaign' :: CreateCampaign -> Text
name} -> Text
name) (\s :: CreateCampaign
s@CreateCampaign' {} Text
a -> CreateCampaign
s {$sel:name:CreateCampaign' :: Text
name = Text
a} :: CreateCampaign)
createCampaign_solutionVersionArn :: Lens.Lens' CreateCampaign Prelude.Text
createCampaign_solutionVersionArn :: (Text -> f Text) -> CreateCampaign -> f CreateCampaign
createCampaign_solutionVersionArn = (CreateCampaign -> Text)
-> (CreateCampaign -> Text -> CreateCampaign)
-> Lens CreateCampaign CreateCampaign Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCampaign' {Text
solutionVersionArn :: Text
$sel:solutionVersionArn:CreateCampaign' :: CreateCampaign -> Text
solutionVersionArn} -> Text
solutionVersionArn) (\s :: CreateCampaign
s@CreateCampaign' {} Text
a -> CreateCampaign
s {$sel:solutionVersionArn:CreateCampaign' :: Text
solutionVersionArn = Text
a} :: CreateCampaign)
instance Core.AWSRequest CreateCampaign where
type
AWSResponse CreateCampaign =
CreateCampaignResponse
request :: CreateCampaign -> Request CreateCampaign
request = Service -> CreateCampaign -> Request CreateCampaign
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateCampaign
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCampaign)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateCampaign))
-> Logger
-> Service
-> Proxy CreateCampaign
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCampaign)))
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 -> CreateCampaignResponse
CreateCampaignResponse'
(Maybe Text -> Int -> CreateCampaignResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateCampaignResponse)
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
"campaignArn")
Either String (Int -> CreateCampaignResponse)
-> Either String Int -> Either String CreateCampaignResponse
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 CreateCampaign
instance Prelude.NFData CreateCampaign
instance Core.ToHeaders CreateCampaign where
toHeaders :: CreateCampaign -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateCampaign -> 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
"AmazonPersonalize.CreateCampaign" ::
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 CreateCampaign where
toJSON :: CreateCampaign -> Value
toJSON CreateCampaign' {Maybe Natural
Maybe CampaignConfig
Text
solutionVersionArn :: Text
name :: Text
minProvisionedTPS :: Maybe Natural
campaignConfig :: Maybe CampaignConfig
$sel:solutionVersionArn:CreateCampaign' :: CreateCampaign -> Text
$sel:name:CreateCampaign' :: CreateCampaign -> Text
$sel:minProvisionedTPS:CreateCampaign' :: CreateCampaign -> Maybe Natural
$sel:campaignConfig:CreateCampaign' :: CreateCampaign -> Maybe CampaignConfig
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"campaignConfig" Text -> CampaignConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(CampaignConfig -> Pair) -> Maybe CampaignConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CampaignConfig
campaignConfig,
(Text
"minProvisionedTPS" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
minProvisionedTPS,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"solutionVersionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
solutionVersionArn)
]
)
instance Core.ToPath CreateCampaign where
toPath :: CreateCampaign -> ByteString
toPath = ByteString -> CreateCampaign -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateCampaign where
toQuery :: CreateCampaign -> QueryString
toQuery = QueryString -> CreateCampaign -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateCampaignResponse = CreateCampaignResponse'
{
CreateCampaignResponse -> Maybe Text
campaignArn :: Prelude.Maybe Prelude.Text,
CreateCampaignResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateCampaignResponse -> CreateCampaignResponse -> Bool
(CreateCampaignResponse -> CreateCampaignResponse -> Bool)
-> (CreateCampaignResponse -> CreateCampaignResponse -> Bool)
-> Eq CreateCampaignResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCampaignResponse -> CreateCampaignResponse -> Bool
$c/= :: CreateCampaignResponse -> CreateCampaignResponse -> Bool
== :: CreateCampaignResponse -> CreateCampaignResponse -> Bool
$c== :: CreateCampaignResponse -> CreateCampaignResponse -> Bool
Prelude.Eq, ReadPrec [CreateCampaignResponse]
ReadPrec CreateCampaignResponse
Int -> ReadS CreateCampaignResponse
ReadS [CreateCampaignResponse]
(Int -> ReadS CreateCampaignResponse)
-> ReadS [CreateCampaignResponse]
-> ReadPrec CreateCampaignResponse
-> ReadPrec [CreateCampaignResponse]
-> Read CreateCampaignResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCampaignResponse]
$creadListPrec :: ReadPrec [CreateCampaignResponse]
readPrec :: ReadPrec CreateCampaignResponse
$creadPrec :: ReadPrec CreateCampaignResponse
readList :: ReadS [CreateCampaignResponse]
$creadList :: ReadS [CreateCampaignResponse]
readsPrec :: Int -> ReadS CreateCampaignResponse
$creadsPrec :: Int -> ReadS CreateCampaignResponse
Prelude.Read, Int -> CreateCampaignResponse -> ShowS
[CreateCampaignResponse] -> ShowS
CreateCampaignResponse -> String
(Int -> CreateCampaignResponse -> ShowS)
-> (CreateCampaignResponse -> String)
-> ([CreateCampaignResponse] -> ShowS)
-> Show CreateCampaignResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCampaignResponse] -> ShowS
$cshowList :: [CreateCampaignResponse] -> ShowS
show :: CreateCampaignResponse -> String
$cshow :: CreateCampaignResponse -> String
showsPrec :: Int -> CreateCampaignResponse -> ShowS
$cshowsPrec :: Int -> CreateCampaignResponse -> ShowS
Prelude.Show, (forall x. CreateCampaignResponse -> Rep CreateCampaignResponse x)
-> (forall x.
Rep CreateCampaignResponse x -> CreateCampaignResponse)
-> Generic CreateCampaignResponse
forall x. Rep CreateCampaignResponse x -> CreateCampaignResponse
forall x. CreateCampaignResponse -> Rep CreateCampaignResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCampaignResponse x -> CreateCampaignResponse
$cfrom :: forall x. CreateCampaignResponse -> Rep CreateCampaignResponse x
Prelude.Generic)
newCreateCampaignResponse ::
Prelude.Int ->
CreateCampaignResponse
newCreateCampaignResponse :: Int -> CreateCampaignResponse
newCreateCampaignResponse Int
pHttpStatus_ =
CreateCampaignResponse' :: Maybe Text -> Int -> CreateCampaignResponse
CreateCampaignResponse'
{ $sel:campaignArn:CreateCampaignResponse' :: Maybe Text
campaignArn =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateCampaignResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createCampaignResponse_campaignArn :: Lens.Lens' CreateCampaignResponse (Prelude.Maybe Prelude.Text)
createCampaignResponse_campaignArn :: (Maybe Text -> f (Maybe Text))
-> CreateCampaignResponse -> f CreateCampaignResponse
createCampaignResponse_campaignArn = (CreateCampaignResponse -> Maybe Text)
-> (CreateCampaignResponse -> Maybe Text -> CreateCampaignResponse)
-> Lens
CreateCampaignResponse
CreateCampaignResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCampaignResponse' {Maybe Text
campaignArn :: Maybe Text
$sel:campaignArn:CreateCampaignResponse' :: CreateCampaignResponse -> Maybe Text
campaignArn} -> Maybe Text
campaignArn) (\s :: CreateCampaignResponse
s@CreateCampaignResponse' {} Maybe Text
a -> CreateCampaignResponse
s {$sel:campaignArn:CreateCampaignResponse' :: Maybe Text
campaignArn = Maybe Text
a} :: CreateCampaignResponse)
createCampaignResponse_httpStatus :: Lens.Lens' CreateCampaignResponse Prelude.Int
createCampaignResponse_httpStatus :: (Int -> f Int)
-> CreateCampaignResponse -> f CreateCampaignResponse
createCampaignResponse_httpStatus = (CreateCampaignResponse -> Int)
-> (CreateCampaignResponse -> Int -> CreateCampaignResponse)
-> Lens CreateCampaignResponse CreateCampaignResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCampaignResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateCampaignResponse' :: CreateCampaignResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateCampaignResponse
s@CreateCampaignResponse' {} Int
a -> CreateCampaignResponse
s {$sel:httpStatus:CreateCampaignResponse' :: Int
httpStatus = Int
a} :: CreateCampaignResponse)
instance Prelude.NFData CreateCampaignResponse