{-# 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.DescribeCampaign
(
DescribeCampaign (..),
newDescribeCampaign,
describeCampaign_campaignArn,
DescribeCampaignResponse (..),
newDescribeCampaignResponse,
describeCampaignResponse_campaign,
describeCampaignResponse_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 DescribeCampaign = DescribeCampaign'
{
DescribeCampaign -> Text
campaignArn :: Prelude.Text
}
deriving (DescribeCampaign -> DescribeCampaign -> Bool
(DescribeCampaign -> DescribeCampaign -> Bool)
-> (DescribeCampaign -> DescribeCampaign -> Bool)
-> Eq DescribeCampaign
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCampaign -> DescribeCampaign -> Bool
$c/= :: DescribeCampaign -> DescribeCampaign -> Bool
== :: DescribeCampaign -> DescribeCampaign -> Bool
$c== :: DescribeCampaign -> DescribeCampaign -> Bool
Prelude.Eq, ReadPrec [DescribeCampaign]
ReadPrec DescribeCampaign
Int -> ReadS DescribeCampaign
ReadS [DescribeCampaign]
(Int -> ReadS DescribeCampaign)
-> ReadS [DescribeCampaign]
-> ReadPrec DescribeCampaign
-> ReadPrec [DescribeCampaign]
-> Read DescribeCampaign
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCampaign]
$creadListPrec :: ReadPrec [DescribeCampaign]
readPrec :: ReadPrec DescribeCampaign
$creadPrec :: ReadPrec DescribeCampaign
readList :: ReadS [DescribeCampaign]
$creadList :: ReadS [DescribeCampaign]
readsPrec :: Int -> ReadS DescribeCampaign
$creadsPrec :: Int -> ReadS DescribeCampaign
Prelude.Read, Int -> DescribeCampaign -> ShowS
[DescribeCampaign] -> ShowS
DescribeCampaign -> String
(Int -> DescribeCampaign -> ShowS)
-> (DescribeCampaign -> String)
-> ([DescribeCampaign] -> ShowS)
-> Show DescribeCampaign
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCampaign] -> ShowS
$cshowList :: [DescribeCampaign] -> ShowS
show :: DescribeCampaign -> String
$cshow :: DescribeCampaign -> String
showsPrec :: Int -> DescribeCampaign -> ShowS
$cshowsPrec :: Int -> DescribeCampaign -> ShowS
Prelude.Show, (forall x. DescribeCampaign -> Rep DescribeCampaign x)
-> (forall x. Rep DescribeCampaign x -> DescribeCampaign)
-> Generic DescribeCampaign
forall x. Rep DescribeCampaign x -> DescribeCampaign
forall x. DescribeCampaign -> Rep DescribeCampaign x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeCampaign x -> DescribeCampaign
$cfrom :: forall x. DescribeCampaign -> Rep DescribeCampaign x
Prelude.Generic)
newDescribeCampaign ::
Prelude.Text ->
DescribeCampaign
newDescribeCampaign :: Text -> DescribeCampaign
newDescribeCampaign Text
pCampaignArn_ =
DescribeCampaign' :: Text -> DescribeCampaign
DescribeCampaign' {$sel:campaignArn:DescribeCampaign' :: Text
campaignArn = Text
pCampaignArn_}
describeCampaign_campaignArn :: Lens.Lens' DescribeCampaign Prelude.Text
describeCampaign_campaignArn :: (Text -> f Text) -> DescribeCampaign -> f DescribeCampaign
describeCampaign_campaignArn = (DescribeCampaign -> Text)
-> (DescribeCampaign -> Text -> DescribeCampaign)
-> Lens DescribeCampaign DescribeCampaign Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCampaign' {Text
campaignArn :: Text
$sel:campaignArn:DescribeCampaign' :: DescribeCampaign -> Text
campaignArn} -> Text
campaignArn) (\s :: DescribeCampaign
s@DescribeCampaign' {} Text
a -> DescribeCampaign
s {$sel:campaignArn:DescribeCampaign' :: Text
campaignArn = Text
a} :: DescribeCampaign)
instance Core.AWSRequest DescribeCampaign where
type
AWSResponse DescribeCampaign =
DescribeCampaignResponse
request :: DescribeCampaign -> Request DescribeCampaign
request = Service -> DescribeCampaign -> Request DescribeCampaign
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DescribeCampaign
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeCampaign)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DescribeCampaign))
-> Logger
-> Service
-> Proxy DescribeCampaign
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeCampaign)))
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 Campaign -> Int -> DescribeCampaignResponse
DescribeCampaignResponse'
(Maybe Campaign -> Int -> DescribeCampaignResponse)
-> Either String (Maybe Campaign)
-> Either String (Int -> DescribeCampaignResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Campaign)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"campaign")
Either String (Int -> DescribeCampaignResponse)
-> Either String Int -> Either String DescribeCampaignResponse
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 DescribeCampaign
instance Prelude.NFData DescribeCampaign
instance Core.ToHeaders DescribeCampaign where
toHeaders :: DescribeCampaign -> ResponseHeaders
toHeaders =
ResponseHeaders -> DescribeCampaign -> 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.DescribeCampaign" ::
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 DescribeCampaign where
toJSON :: DescribeCampaign -> Value
toJSON DescribeCampaign' {Text
campaignArn :: Text
$sel:campaignArn:DescribeCampaign' :: DescribeCampaign -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"campaignArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
campaignArn)]
)
instance Core.ToPath DescribeCampaign where
toPath :: DescribeCampaign -> ByteString
toPath = ByteString -> DescribeCampaign -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DescribeCampaign where
toQuery :: DescribeCampaign -> QueryString
toQuery = QueryString -> DescribeCampaign -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DescribeCampaignResponse = DescribeCampaignResponse'
{
DescribeCampaignResponse -> Maybe Campaign
campaign :: Prelude.Maybe Campaign,
DescribeCampaignResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DescribeCampaignResponse -> DescribeCampaignResponse -> Bool
(DescribeCampaignResponse -> DescribeCampaignResponse -> Bool)
-> (DescribeCampaignResponse -> DescribeCampaignResponse -> Bool)
-> Eq DescribeCampaignResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCampaignResponse -> DescribeCampaignResponse -> Bool
$c/= :: DescribeCampaignResponse -> DescribeCampaignResponse -> Bool
== :: DescribeCampaignResponse -> DescribeCampaignResponse -> Bool
$c== :: DescribeCampaignResponse -> DescribeCampaignResponse -> Bool
Prelude.Eq, ReadPrec [DescribeCampaignResponse]
ReadPrec DescribeCampaignResponse
Int -> ReadS DescribeCampaignResponse
ReadS [DescribeCampaignResponse]
(Int -> ReadS DescribeCampaignResponse)
-> ReadS [DescribeCampaignResponse]
-> ReadPrec DescribeCampaignResponse
-> ReadPrec [DescribeCampaignResponse]
-> Read DescribeCampaignResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCampaignResponse]
$creadListPrec :: ReadPrec [DescribeCampaignResponse]
readPrec :: ReadPrec DescribeCampaignResponse
$creadPrec :: ReadPrec DescribeCampaignResponse
readList :: ReadS [DescribeCampaignResponse]
$creadList :: ReadS [DescribeCampaignResponse]
readsPrec :: Int -> ReadS DescribeCampaignResponse
$creadsPrec :: Int -> ReadS DescribeCampaignResponse
Prelude.Read, Int -> DescribeCampaignResponse -> ShowS
[DescribeCampaignResponse] -> ShowS
DescribeCampaignResponse -> String
(Int -> DescribeCampaignResponse -> ShowS)
-> (DescribeCampaignResponse -> String)
-> ([DescribeCampaignResponse] -> ShowS)
-> Show DescribeCampaignResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCampaignResponse] -> ShowS
$cshowList :: [DescribeCampaignResponse] -> ShowS
show :: DescribeCampaignResponse -> String
$cshow :: DescribeCampaignResponse -> String
showsPrec :: Int -> DescribeCampaignResponse -> ShowS
$cshowsPrec :: Int -> DescribeCampaignResponse -> ShowS
Prelude.Show, (forall x.
DescribeCampaignResponse -> Rep DescribeCampaignResponse x)
-> (forall x.
Rep DescribeCampaignResponse x -> DescribeCampaignResponse)
-> Generic DescribeCampaignResponse
forall x.
Rep DescribeCampaignResponse x -> DescribeCampaignResponse
forall x.
DescribeCampaignResponse -> Rep DescribeCampaignResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeCampaignResponse x -> DescribeCampaignResponse
$cfrom :: forall x.
DescribeCampaignResponse -> Rep DescribeCampaignResponse x
Prelude.Generic)
newDescribeCampaignResponse ::
Prelude.Int ->
DescribeCampaignResponse
newDescribeCampaignResponse :: Int -> DescribeCampaignResponse
newDescribeCampaignResponse Int
pHttpStatus_ =
DescribeCampaignResponse' :: Maybe Campaign -> Int -> DescribeCampaignResponse
DescribeCampaignResponse'
{ $sel:campaign:DescribeCampaignResponse' :: Maybe Campaign
campaign =
Maybe Campaign
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DescribeCampaignResponse' :: Int
httpStatus = Int
pHttpStatus_
}
describeCampaignResponse_campaign :: Lens.Lens' DescribeCampaignResponse (Prelude.Maybe Campaign)
describeCampaignResponse_campaign :: (Maybe Campaign -> f (Maybe Campaign))
-> DescribeCampaignResponse -> f DescribeCampaignResponse
describeCampaignResponse_campaign = (DescribeCampaignResponse -> Maybe Campaign)
-> (DescribeCampaignResponse
-> Maybe Campaign -> DescribeCampaignResponse)
-> Lens
DescribeCampaignResponse
DescribeCampaignResponse
(Maybe Campaign)
(Maybe Campaign)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCampaignResponse' {Maybe Campaign
campaign :: Maybe Campaign
$sel:campaign:DescribeCampaignResponse' :: DescribeCampaignResponse -> Maybe Campaign
campaign} -> Maybe Campaign
campaign) (\s :: DescribeCampaignResponse
s@DescribeCampaignResponse' {} Maybe Campaign
a -> DescribeCampaignResponse
s {$sel:campaign:DescribeCampaignResponse' :: Maybe Campaign
campaign = Maybe Campaign
a} :: DescribeCampaignResponse)
describeCampaignResponse_httpStatus :: Lens.Lens' DescribeCampaignResponse Prelude.Int
describeCampaignResponse_httpStatus :: (Int -> f Int)
-> DescribeCampaignResponse -> f DescribeCampaignResponse
describeCampaignResponse_httpStatus = (DescribeCampaignResponse -> Int)
-> (DescribeCampaignResponse -> Int -> DescribeCampaignResponse)
-> Lens DescribeCampaignResponse DescribeCampaignResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCampaignResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeCampaignResponse' :: DescribeCampaignResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeCampaignResponse
s@DescribeCampaignResponse' {} Int
a -> DescribeCampaignResponse
s {$sel:httpStatus:DescribeCampaignResponse' :: Int
httpStatus = Int
a} :: DescribeCampaignResponse)
instance Prelude.NFData DescribeCampaignResponse