{-# 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.RepublishAction where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.MqttHeaders
import qualified Amazonka.Prelude as Prelude
data RepublishAction = RepublishAction'
{
:: Prelude.Maybe MqttHeaders,
RepublishAction -> Maybe Natural
qos :: Prelude.Maybe Prelude.Natural,
RepublishAction -> Text
roleArn :: Prelude.Text,
RepublishAction -> Text
topic :: Prelude.Text
}
deriving (RepublishAction -> RepublishAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RepublishAction -> RepublishAction -> Bool
$c/= :: RepublishAction -> RepublishAction -> Bool
== :: RepublishAction -> RepublishAction -> Bool
$c== :: RepublishAction -> RepublishAction -> Bool
Prelude.Eq, ReadPrec [RepublishAction]
ReadPrec RepublishAction
Int -> ReadS RepublishAction
ReadS [RepublishAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RepublishAction]
$creadListPrec :: ReadPrec [RepublishAction]
readPrec :: ReadPrec RepublishAction
$creadPrec :: ReadPrec RepublishAction
readList :: ReadS [RepublishAction]
$creadList :: ReadS [RepublishAction]
readsPrec :: Int -> ReadS RepublishAction
$creadsPrec :: Int -> ReadS RepublishAction
Prelude.Read, Int -> RepublishAction -> ShowS
[RepublishAction] -> ShowS
RepublishAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RepublishAction] -> ShowS
$cshowList :: [RepublishAction] -> ShowS
show :: RepublishAction -> String
$cshow :: RepublishAction -> String
showsPrec :: Int -> RepublishAction -> ShowS
$cshowsPrec :: Int -> RepublishAction -> ShowS
Prelude.Show, forall x. Rep RepublishAction x -> RepublishAction
forall x. RepublishAction -> Rep RepublishAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RepublishAction x -> RepublishAction
$cfrom :: forall x. RepublishAction -> Rep RepublishAction x
Prelude.Generic)
newRepublishAction ::
Prelude.Text ->
Prelude.Text ->
RepublishAction
newRepublishAction :: Text -> Text -> RepublishAction
newRepublishAction Text
pRoleArn_ Text
pTopic_ =
RepublishAction'
{ $sel:headers:RepublishAction' :: Maybe MqttHeaders
headers = forall a. Maybe a
Prelude.Nothing,
$sel:qos:RepublishAction' :: Maybe Natural
qos = forall a. Maybe a
Prelude.Nothing,
$sel:roleArn:RepublishAction' :: Text
roleArn = Text
pRoleArn_,
$sel:topic:RepublishAction' :: Text
topic = Text
pTopic_
}
republishAction_headers :: Lens.Lens' RepublishAction (Prelude.Maybe MqttHeaders)
= forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepublishAction' {Maybe MqttHeaders
headers :: Maybe MqttHeaders
$sel:headers:RepublishAction' :: RepublishAction -> Maybe MqttHeaders
headers} -> Maybe MqttHeaders
headers) (\s :: RepublishAction
s@RepublishAction' {} Maybe MqttHeaders
a -> RepublishAction
s {$sel:headers:RepublishAction' :: Maybe MqttHeaders
headers = Maybe MqttHeaders
a} :: RepublishAction)
republishAction_qos :: Lens.Lens' RepublishAction (Prelude.Maybe Prelude.Natural)
republishAction_qos :: Lens' RepublishAction (Maybe Natural)
republishAction_qos = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepublishAction' {Maybe Natural
qos :: Maybe Natural
$sel:qos:RepublishAction' :: RepublishAction -> Maybe Natural
qos} -> Maybe Natural
qos) (\s :: RepublishAction
s@RepublishAction' {} Maybe Natural
a -> RepublishAction
s {$sel:qos:RepublishAction' :: Maybe Natural
qos = Maybe Natural
a} :: RepublishAction)
republishAction_roleArn :: Lens.Lens' RepublishAction Prelude.Text
republishAction_roleArn :: Lens' RepublishAction Text
republishAction_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepublishAction' {Text
roleArn :: Text
$sel:roleArn:RepublishAction' :: RepublishAction -> Text
roleArn} -> Text
roleArn) (\s :: RepublishAction
s@RepublishAction' {} Text
a -> RepublishAction
s {$sel:roleArn:RepublishAction' :: Text
roleArn = Text
a} :: RepublishAction)
republishAction_topic :: Lens.Lens' RepublishAction Prelude.Text
republishAction_topic :: Lens' RepublishAction Text
republishAction_topic = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepublishAction' {Text
topic :: Text
$sel:topic:RepublishAction' :: RepublishAction -> Text
topic} -> Text
topic) (\s :: RepublishAction
s@RepublishAction' {} Text
a -> RepublishAction
s {$sel:topic:RepublishAction' :: Text
topic = Text
a} :: RepublishAction)
instance Data.FromJSON RepublishAction where
parseJSON :: Value -> Parser RepublishAction
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"RepublishAction"
( \Object
x ->
Maybe MqttHeaders
-> Maybe Natural -> Text -> Text -> RepublishAction
RepublishAction'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"headers")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"qos")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"roleArn")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"topic")
)
instance Prelude.Hashable RepublishAction where
hashWithSalt :: Int -> RepublishAction -> Int
hashWithSalt Int
_salt RepublishAction' {Maybe Natural
Maybe MqttHeaders
Text
topic :: Text
roleArn :: Text
qos :: Maybe Natural
headers :: Maybe MqttHeaders
$sel:topic:RepublishAction' :: RepublishAction -> Text
$sel:roleArn:RepublishAction' :: RepublishAction -> Text
$sel:qos:RepublishAction' :: RepublishAction -> Maybe Natural
$sel:headers:RepublishAction' :: RepublishAction -> Maybe MqttHeaders
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MqttHeaders
headers
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
qos
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
topic
instance Prelude.NFData RepublishAction where
rnf :: RepublishAction -> ()
rnf RepublishAction' {Maybe Natural
Maybe MqttHeaders
Text
topic :: Text
roleArn :: Text
qos :: Maybe Natural
headers :: Maybe MqttHeaders
$sel:topic:RepublishAction' :: RepublishAction -> Text
$sel:roleArn:RepublishAction' :: RepublishAction -> Text
$sel:qos:RepublishAction' :: RepublishAction -> Maybe Natural
$sel:headers:RepublishAction' :: RepublishAction -> Maybe MqttHeaders
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe MqttHeaders
headers
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
qos
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
topic
instance Data.ToJSON RepublishAction where
toJSON :: RepublishAction -> Value
toJSON RepublishAction' {Maybe Natural
Maybe MqttHeaders
Text
topic :: Text
roleArn :: Text
qos :: Maybe Natural
headers :: Maybe MqttHeaders
$sel:topic:RepublishAction' :: RepublishAction -> Text
$sel:roleArn:RepublishAction' :: RepublishAction -> Text
$sel:qos:RepublishAction' :: RepublishAction -> Maybe Natural
$sel:headers:RepublishAction' :: RepublishAction -> Maybe MqttHeaders
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"headers" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MqttHeaders
headers,
(Key
"qos" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
qos,
forall a. a -> Maybe a
Prelude.Just (Key
"roleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleArn),
forall a. a -> Maybe a
Prelude.Just (Key
"topic" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
topic)
]
)