{-# 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.Greengrass.Types.Subscription where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Subscription = Subscription'
{
Subscription -> Text
target :: Prelude.Text,
Subscription -> Text
id :: Prelude.Text,
Subscription -> Text
subject :: Prelude.Text,
Subscription -> Text
source :: Prelude.Text
}
deriving (Subscription -> Subscription -> Bool
(Subscription -> Subscription -> Bool)
-> (Subscription -> Subscription -> Bool) -> Eq Subscription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Subscription -> Subscription -> Bool
$c/= :: Subscription -> Subscription -> Bool
== :: Subscription -> Subscription -> Bool
$c== :: Subscription -> Subscription -> Bool
Prelude.Eq, ReadPrec [Subscription]
ReadPrec Subscription
Int -> ReadS Subscription
ReadS [Subscription]
(Int -> ReadS Subscription)
-> ReadS [Subscription]
-> ReadPrec Subscription
-> ReadPrec [Subscription]
-> Read Subscription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Subscription]
$creadListPrec :: ReadPrec [Subscription]
readPrec :: ReadPrec Subscription
$creadPrec :: ReadPrec Subscription
readList :: ReadS [Subscription]
$creadList :: ReadS [Subscription]
readsPrec :: Int -> ReadS Subscription
$creadsPrec :: Int -> ReadS Subscription
Prelude.Read, Int -> Subscription -> ShowS
[Subscription] -> ShowS
Subscription -> String
(Int -> Subscription -> ShowS)
-> (Subscription -> String)
-> ([Subscription] -> ShowS)
-> Show Subscription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Subscription] -> ShowS
$cshowList :: [Subscription] -> ShowS
show :: Subscription -> String
$cshow :: Subscription -> String
showsPrec :: Int -> Subscription -> ShowS
$cshowsPrec :: Int -> Subscription -> ShowS
Prelude.Show, (forall x. Subscription -> Rep Subscription x)
-> (forall x. Rep Subscription x -> Subscription)
-> Generic Subscription
forall x. Rep Subscription x -> Subscription
forall x. Subscription -> Rep Subscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Subscription x -> Subscription
$cfrom :: forall x. Subscription -> Rep Subscription x
Prelude.Generic)
newSubscription ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
Subscription
newSubscription :: Text -> Text -> Text -> Text -> Subscription
newSubscription Text
pTarget_ Text
pId_ Text
pSubject_ Text
pSource_ =
Subscription' :: Text -> Text -> Text -> Text -> Subscription
Subscription'
{ $sel:target:Subscription' :: Text
target = Text
pTarget_,
$sel:id:Subscription' :: Text
id = Text
pId_,
$sel:subject:Subscription' :: Text
subject = Text
pSubject_,
$sel:source:Subscription' :: Text
source = Text
pSource_
}
subscription_target :: Lens.Lens' Subscription Prelude.Text
subscription_target :: (Text -> f Text) -> Subscription -> f Subscription
subscription_target = (Subscription -> Text)
-> (Subscription -> Text -> Subscription)
-> Lens Subscription Subscription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Text
target :: Text
$sel:target:Subscription' :: Subscription -> Text
target} -> Text
target) (\s :: Subscription
s@Subscription' {} Text
a -> Subscription
s {$sel:target:Subscription' :: Text
target = Text
a} :: Subscription)
subscription_id :: Lens.Lens' Subscription Prelude.Text
subscription_id :: (Text -> f Text) -> Subscription -> f Subscription
subscription_id = (Subscription -> Text)
-> (Subscription -> Text -> Subscription)
-> Lens Subscription Subscription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Text
id :: Text
$sel:id:Subscription' :: Subscription -> Text
id} -> Text
id) (\s :: Subscription
s@Subscription' {} Text
a -> Subscription
s {$sel:id:Subscription' :: Text
id = Text
a} :: Subscription)
subscription_subject :: Lens.Lens' Subscription Prelude.Text
subscription_subject :: (Text -> f Text) -> Subscription -> f Subscription
subscription_subject = (Subscription -> Text)
-> (Subscription -> Text -> Subscription)
-> Lens Subscription Subscription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Text
subject :: Text
$sel:subject:Subscription' :: Subscription -> Text
subject} -> Text
subject) (\s :: Subscription
s@Subscription' {} Text
a -> Subscription
s {$sel:subject:Subscription' :: Text
subject = Text
a} :: Subscription)
subscription_source :: Lens.Lens' Subscription Prelude.Text
subscription_source :: (Text -> f Text) -> Subscription -> f Subscription
subscription_source = (Subscription -> Text)
-> (Subscription -> Text -> Subscription)
-> Lens Subscription Subscription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Text
source :: Text
$sel:source:Subscription' :: Subscription -> Text
source} -> Text
source) (\s :: Subscription
s@Subscription' {} Text
a -> Subscription
s {$sel:source:Subscription' :: Text
source = Text
a} :: Subscription)
instance Core.FromJSON Subscription where
parseJSON :: Value -> Parser Subscription
parseJSON =
String
-> (Object -> Parser Subscription) -> Value -> Parser Subscription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Subscription"
( \Object
x ->
Text -> Text -> Text -> Text -> Subscription
Subscription'
(Text -> Text -> Text -> Text -> Subscription)
-> Parser Text -> Parser (Text -> Text -> Text -> Subscription)
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
"Target")
Parser (Text -> Text -> Text -> Subscription)
-> Parser Text -> Parser (Text -> Text -> Subscription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
Parser (Text -> Text -> Subscription)
-> Parser Text -> Parser (Text -> Subscription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Subject")
Parser (Text -> Subscription) -> Parser Text -> Parser Subscription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Source")
)
instance Prelude.Hashable Subscription
instance Prelude.NFData Subscription
instance Core.ToJSON Subscription where
toJSON :: Subscription -> Value
toJSON Subscription' {Text
source :: Text
subject :: Text
id :: Text
target :: Text
$sel:source:Subscription' :: Subscription -> Text
$sel:subject:Subscription' :: Subscription -> Text
$sel:id:Subscription' :: Subscription -> Text
$sel:target:Subscription' :: Subscription -> 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
"Target" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
target),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Subject" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
subject),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Source" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
source)
]
)