{-# 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.IoT.Types.SnsAction where
import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.MessageFormat
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data SnsAction = SnsAction'
{
SnsAction -> Maybe MessageFormat
messageFormat :: Prelude.Maybe MessageFormat,
SnsAction -> Text
targetArn :: Prelude.Text,
SnsAction -> Text
roleArn :: Prelude.Text
}
deriving (SnsAction -> SnsAction -> Bool
(SnsAction -> SnsAction -> Bool)
-> (SnsAction -> SnsAction -> Bool) -> Eq SnsAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnsAction -> SnsAction -> Bool
$c/= :: SnsAction -> SnsAction -> Bool
== :: SnsAction -> SnsAction -> Bool
$c== :: SnsAction -> SnsAction -> Bool
Prelude.Eq, ReadPrec [SnsAction]
ReadPrec SnsAction
Int -> ReadS SnsAction
ReadS [SnsAction]
(Int -> ReadS SnsAction)
-> ReadS [SnsAction]
-> ReadPrec SnsAction
-> ReadPrec [SnsAction]
-> Read SnsAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnsAction]
$creadListPrec :: ReadPrec [SnsAction]
readPrec :: ReadPrec SnsAction
$creadPrec :: ReadPrec SnsAction
readList :: ReadS [SnsAction]
$creadList :: ReadS [SnsAction]
readsPrec :: Int -> ReadS SnsAction
$creadsPrec :: Int -> ReadS SnsAction
Prelude.Read, Int -> SnsAction -> ShowS
[SnsAction] -> ShowS
SnsAction -> String
(Int -> SnsAction -> ShowS)
-> (SnsAction -> String)
-> ([SnsAction] -> ShowS)
-> Show SnsAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnsAction] -> ShowS
$cshowList :: [SnsAction] -> ShowS
show :: SnsAction -> String
$cshow :: SnsAction -> String
showsPrec :: Int -> SnsAction -> ShowS
$cshowsPrec :: Int -> SnsAction -> ShowS
Prelude.Show, (forall x. SnsAction -> Rep SnsAction x)
-> (forall x. Rep SnsAction x -> SnsAction) -> Generic SnsAction
forall x. Rep SnsAction x -> SnsAction
forall x. SnsAction -> Rep SnsAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnsAction x -> SnsAction
$cfrom :: forall x. SnsAction -> Rep SnsAction x
Prelude.Generic)
newSnsAction ::
Prelude.Text ->
Prelude.Text ->
SnsAction
newSnsAction :: Text -> Text -> SnsAction
newSnsAction Text
pTargetArn_ Text
pRoleArn_ =
SnsAction' :: Maybe MessageFormat -> Text -> Text -> SnsAction
SnsAction'
{ $sel:messageFormat:SnsAction' :: Maybe MessageFormat
messageFormat = Maybe MessageFormat
forall a. Maybe a
Prelude.Nothing,
$sel:targetArn:SnsAction' :: Text
targetArn = Text
pTargetArn_,
$sel:roleArn:SnsAction' :: Text
roleArn = Text
pRoleArn_
}
snsAction_messageFormat :: Lens.Lens' SnsAction (Prelude.Maybe MessageFormat)
snsAction_messageFormat :: (Maybe MessageFormat -> f (Maybe MessageFormat))
-> SnsAction -> f SnsAction
snsAction_messageFormat = (SnsAction -> Maybe MessageFormat)
-> (SnsAction -> Maybe MessageFormat -> SnsAction)
-> Lens
SnsAction SnsAction (Maybe MessageFormat) (Maybe MessageFormat)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnsAction' {Maybe MessageFormat
messageFormat :: Maybe MessageFormat
$sel:messageFormat:SnsAction' :: SnsAction -> Maybe MessageFormat
messageFormat} -> Maybe MessageFormat
messageFormat) (\s :: SnsAction
s@SnsAction' {} Maybe MessageFormat
a -> SnsAction
s {$sel:messageFormat:SnsAction' :: Maybe MessageFormat
messageFormat = Maybe MessageFormat
a} :: SnsAction)
snsAction_targetArn :: Lens.Lens' SnsAction Prelude.Text
snsAction_targetArn :: (Text -> f Text) -> SnsAction -> f SnsAction
snsAction_targetArn = (SnsAction -> Text)
-> (SnsAction -> Text -> SnsAction)
-> Lens SnsAction SnsAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnsAction' {Text
targetArn :: Text
$sel:targetArn:SnsAction' :: SnsAction -> Text
targetArn} -> Text
targetArn) (\s :: SnsAction
s@SnsAction' {} Text
a -> SnsAction
s {$sel:targetArn:SnsAction' :: Text
targetArn = Text
a} :: SnsAction)
snsAction_roleArn :: Lens.Lens' SnsAction Prelude.Text
snsAction_roleArn :: (Text -> f Text) -> SnsAction -> f SnsAction
snsAction_roleArn = (SnsAction -> Text)
-> (SnsAction -> Text -> SnsAction)
-> Lens SnsAction SnsAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnsAction' {Text
roleArn :: Text
$sel:roleArn:SnsAction' :: SnsAction -> Text
roleArn} -> Text
roleArn) (\s :: SnsAction
s@SnsAction' {} Text
a -> SnsAction
s {$sel:roleArn:SnsAction' :: Text
roleArn = Text
a} :: SnsAction)
instance Core.FromJSON SnsAction where
parseJSON :: Value -> Parser SnsAction
parseJSON =
String -> (Object -> Parser SnsAction) -> Value -> Parser SnsAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"SnsAction"
( \Object
x ->
Maybe MessageFormat -> Text -> Text -> SnsAction
SnsAction'
(Maybe MessageFormat -> Text -> Text -> SnsAction)
-> Parser (Maybe MessageFormat)
-> Parser (Text -> Text -> SnsAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MessageFormat)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"messageFormat")
Parser (Text -> Text -> SnsAction)
-> Parser Text -> Parser (Text -> SnsAction)
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
"targetArn")
Parser (Text -> SnsAction) -> Parser Text -> Parser SnsAction
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
"roleArn")
)
instance Prelude.Hashable SnsAction
instance Prelude.NFData SnsAction
instance Core.ToJSON SnsAction where
toJSON :: SnsAction -> Value
toJSON SnsAction' {Maybe MessageFormat
Text
roleArn :: Text
targetArn :: Text
messageFormat :: Maybe MessageFormat
$sel:roleArn:SnsAction' :: SnsAction -> Text
$sel:targetArn:SnsAction' :: SnsAction -> Text
$sel:messageFormat:SnsAction' :: SnsAction -> Maybe MessageFormat
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"messageFormat" Text -> MessageFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MessageFormat -> Pair) -> Maybe MessageFormat -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MessageFormat
messageFormat,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"targetArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
targetArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn)
]
)