{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.SESV2.Types.TopicPreference where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SESV2.Types.SubscriptionStatus
data TopicPreference = TopicPreference'
{
TopicPreference -> Text
topicName :: Prelude.Text,
TopicPreference -> SubscriptionStatus
subscriptionStatus :: SubscriptionStatus
}
deriving (TopicPreference -> TopicPreference -> Bool
(TopicPreference -> TopicPreference -> Bool)
-> (TopicPreference -> TopicPreference -> Bool)
-> Eq TopicPreference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TopicPreference -> TopicPreference -> Bool
$c/= :: TopicPreference -> TopicPreference -> Bool
== :: TopicPreference -> TopicPreference -> Bool
$c== :: TopicPreference -> TopicPreference -> Bool
Prelude.Eq, ReadPrec [TopicPreference]
ReadPrec TopicPreference
Int -> ReadS TopicPreference
ReadS [TopicPreference]
(Int -> ReadS TopicPreference)
-> ReadS [TopicPreference]
-> ReadPrec TopicPreference
-> ReadPrec [TopicPreference]
-> Read TopicPreference
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TopicPreference]
$creadListPrec :: ReadPrec [TopicPreference]
readPrec :: ReadPrec TopicPreference
$creadPrec :: ReadPrec TopicPreference
readList :: ReadS [TopicPreference]
$creadList :: ReadS [TopicPreference]
readsPrec :: Int -> ReadS TopicPreference
$creadsPrec :: Int -> ReadS TopicPreference
Prelude.Read, Int -> TopicPreference -> ShowS
[TopicPreference] -> ShowS
TopicPreference -> String
(Int -> TopicPreference -> ShowS)
-> (TopicPreference -> String)
-> ([TopicPreference] -> ShowS)
-> Show TopicPreference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TopicPreference] -> ShowS
$cshowList :: [TopicPreference] -> ShowS
show :: TopicPreference -> String
$cshow :: TopicPreference -> String
showsPrec :: Int -> TopicPreference -> ShowS
$cshowsPrec :: Int -> TopicPreference -> ShowS
Prelude.Show, (forall x. TopicPreference -> Rep TopicPreference x)
-> (forall x. Rep TopicPreference x -> TopicPreference)
-> Generic TopicPreference
forall x. Rep TopicPreference x -> TopicPreference
forall x. TopicPreference -> Rep TopicPreference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TopicPreference x -> TopicPreference
$cfrom :: forall x. TopicPreference -> Rep TopicPreference x
Prelude.Generic)
newTopicPreference ::
Prelude.Text ->
SubscriptionStatus ->
TopicPreference
newTopicPreference :: Text -> SubscriptionStatus -> TopicPreference
newTopicPreference Text
pTopicName_ SubscriptionStatus
pSubscriptionStatus_ =
TopicPreference' :: Text -> SubscriptionStatus -> TopicPreference
TopicPreference'
{ $sel:topicName:TopicPreference' :: Text
topicName = Text
pTopicName_,
$sel:subscriptionStatus:TopicPreference' :: SubscriptionStatus
subscriptionStatus = SubscriptionStatus
pSubscriptionStatus_
}
topicPreference_topicName :: Lens.Lens' TopicPreference Prelude.Text
topicPreference_topicName :: (Text -> f Text) -> TopicPreference -> f TopicPreference
topicPreference_topicName = (TopicPreference -> Text)
-> (TopicPreference -> Text -> TopicPreference)
-> Lens TopicPreference TopicPreference Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicPreference' {Text
topicName :: Text
$sel:topicName:TopicPreference' :: TopicPreference -> Text
topicName} -> Text
topicName) (\s :: TopicPreference
s@TopicPreference' {} Text
a -> TopicPreference
s {$sel:topicName:TopicPreference' :: Text
topicName = Text
a} :: TopicPreference)
topicPreference_subscriptionStatus :: Lens.Lens' TopicPreference SubscriptionStatus
topicPreference_subscriptionStatus :: (SubscriptionStatus -> f SubscriptionStatus)
-> TopicPreference -> f TopicPreference
topicPreference_subscriptionStatus = (TopicPreference -> SubscriptionStatus)
-> (TopicPreference -> SubscriptionStatus -> TopicPreference)
-> Lens
TopicPreference
TopicPreference
SubscriptionStatus
SubscriptionStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicPreference' {SubscriptionStatus
subscriptionStatus :: SubscriptionStatus
$sel:subscriptionStatus:TopicPreference' :: TopicPreference -> SubscriptionStatus
subscriptionStatus} -> SubscriptionStatus
subscriptionStatus) (\s :: TopicPreference
s@TopicPreference' {} SubscriptionStatus
a -> TopicPreference
s {$sel:subscriptionStatus:TopicPreference' :: SubscriptionStatus
subscriptionStatus = SubscriptionStatus
a} :: TopicPreference)
instance Core.FromJSON TopicPreference where
parseJSON :: Value -> Parser TopicPreference
parseJSON =
String
-> (Object -> Parser TopicPreference)
-> Value
-> Parser TopicPreference
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"TopicPreference"
( \Object
x ->
Text -> SubscriptionStatus -> TopicPreference
TopicPreference'
(Text -> SubscriptionStatus -> TopicPreference)
-> Parser Text -> Parser (SubscriptionStatus -> TopicPreference)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TopicName")
Parser (SubscriptionStatus -> TopicPreference)
-> Parser SubscriptionStatus -> Parser TopicPreference
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser SubscriptionStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SubscriptionStatus")
)
instance Prelude.Hashable TopicPreference
instance Prelude.NFData TopicPreference
instance Core.ToJSON TopicPreference where
toJSON :: TopicPreference -> Value
toJSON TopicPreference' {Text
SubscriptionStatus
subscriptionStatus :: SubscriptionStatus
topicName :: Text
$sel:subscriptionStatus:TopicPreference' :: TopicPreference -> SubscriptionStatus
$sel:topicName:TopicPreference' :: TopicPreference -> 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
"TopicName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
topicName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"SubscriptionStatus" Text -> SubscriptionStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SubscriptionStatus
subscriptionStatus)
]
)