{-# 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.KafkaAction where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data KafkaAction = KafkaAction'
{
KafkaAction -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
KafkaAction -> Maybe Text
partition :: Prelude.Maybe Prelude.Text,
KafkaAction -> Text
destinationArn :: Prelude.Text,
KafkaAction -> Text
topic :: Prelude.Text,
KafkaAction -> HashMap Text Text
clientProperties :: Prelude.HashMap Prelude.Text Prelude.Text
}
deriving (KafkaAction -> KafkaAction -> Bool
(KafkaAction -> KafkaAction -> Bool)
-> (KafkaAction -> KafkaAction -> Bool) -> Eq KafkaAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KafkaAction -> KafkaAction -> Bool
$c/= :: KafkaAction -> KafkaAction -> Bool
== :: KafkaAction -> KafkaAction -> Bool
$c== :: KafkaAction -> KafkaAction -> Bool
Prelude.Eq, ReadPrec [KafkaAction]
ReadPrec KafkaAction
Int -> ReadS KafkaAction
ReadS [KafkaAction]
(Int -> ReadS KafkaAction)
-> ReadS [KafkaAction]
-> ReadPrec KafkaAction
-> ReadPrec [KafkaAction]
-> Read KafkaAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KafkaAction]
$creadListPrec :: ReadPrec [KafkaAction]
readPrec :: ReadPrec KafkaAction
$creadPrec :: ReadPrec KafkaAction
readList :: ReadS [KafkaAction]
$creadList :: ReadS [KafkaAction]
readsPrec :: Int -> ReadS KafkaAction
$creadsPrec :: Int -> ReadS KafkaAction
Prelude.Read, Int -> KafkaAction -> ShowS
[KafkaAction] -> ShowS
KafkaAction -> String
(Int -> KafkaAction -> ShowS)
-> (KafkaAction -> String)
-> ([KafkaAction] -> ShowS)
-> Show KafkaAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KafkaAction] -> ShowS
$cshowList :: [KafkaAction] -> ShowS
show :: KafkaAction -> String
$cshow :: KafkaAction -> String
showsPrec :: Int -> KafkaAction -> ShowS
$cshowsPrec :: Int -> KafkaAction -> ShowS
Prelude.Show, (forall x. KafkaAction -> Rep KafkaAction x)
-> (forall x. Rep KafkaAction x -> KafkaAction)
-> Generic KafkaAction
forall x. Rep KafkaAction x -> KafkaAction
forall x. KafkaAction -> Rep KafkaAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KafkaAction x -> KafkaAction
$cfrom :: forall x. KafkaAction -> Rep KafkaAction x
Prelude.Generic)
newKafkaAction ::
Prelude.Text ->
Prelude.Text ->
KafkaAction
newKafkaAction :: Text -> Text -> KafkaAction
newKafkaAction Text
pDestinationArn_ Text
pTopic_ =
KafkaAction' :: Maybe Text
-> Maybe Text -> Text -> Text -> HashMap Text Text -> KafkaAction
KafkaAction'
{ $sel:key:KafkaAction' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:partition:KafkaAction' :: Maybe Text
partition = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:destinationArn:KafkaAction' :: Text
destinationArn = Text
pDestinationArn_,
$sel:topic:KafkaAction' :: Text
topic = Text
pTopic_,
$sel:clientProperties:KafkaAction' :: HashMap Text Text
clientProperties = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
}
kafkaAction_key :: Lens.Lens' KafkaAction (Prelude.Maybe Prelude.Text)
kafkaAction_key :: (Maybe Text -> f (Maybe Text)) -> KafkaAction -> f KafkaAction
kafkaAction_key = (KafkaAction -> Maybe Text)
-> (KafkaAction -> Maybe Text -> KafkaAction)
-> Lens KafkaAction KafkaAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KafkaAction' {Maybe Text
key :: Maybe Text
$sel:key:KafkaAction' :: KafkaAction -> Maybe Text
key} -> Maybe Text
key) (\s :: KafkaAction
s@KafkaAction' {} Maybe Text
a -> KafkaAction
s {$sel:key:KafkaAction' :: Maybe Text
key = Maybe Text
a} :: KafkaAction)
kafkaAction_partition :: Lens.Lens' KafkaAction (Prelude.Maybe Prelude.Text)
kafkaAction_partition :: (Maybe Text -> f (Maybe Text)) -> KafkaAction -> f KafkaAction
kafkaAction_partition = (KafkaAction -> Maybe Text)
-> (KafkaAction -> Maybe Text -> KafkaAction)
-> Lens KafkaAction KafkaAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KafkaAction' {Maybe Text
partition :: Maybe Text
$sel:partition:KafkaAction' :: KafkaAction -> Maybe Text
partition} -> Maybe Text
partition) (\s :: KafkaAction
s@KafkaAction' {} Maybe Text
a -> KafkaAction
s {$sel:partition:KafkaAction' :: Maybe Text
partition = Maybe Text
a} :: KafkaAction)
kafkaAction_destinationArn :: Lens.Lens' KafkaAction Prelude.Text
kafkaAction_destinationArn :: (Text -> f Text) -> KafkaAction -> f KafkaAction
kafkaAction_destinationArn = (KafkaAction -> Text)
-> (KafkaAction -> Text -> KafkaAction)
-> Lens KafkaAction KafkaAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KafkaAction' {Text
destinationArn :: Text
$sel:destinationArn:KafkaAction' :: KafkaAction -> Text
destinationArn} -> Text
destinationArn) (\s :: KafkaAction
s@KafkaAction' {} Text
a -> KafkaAction
s {$sel:destinationArn:KafkaAction' :: Text
destinationArn = Text
a} :: KafkaAction)
kafkaAction_topic :: Lens.Lens' KafkaAction Prelude.Text
kafkaAction_topic :: (Text -> f Text) -> KafkaAction -> f KafkaAction
kafkaAction_topic = (KafkaAction -> Text)
-> (KafkaAction -> Text -> KafkaAction)
-> Lens KafkaAction KafkaAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KafkaAction' {Text
topic :: Text
$sel:topic:KafkaAction' :: KafkaAction -> Text
topic} -> Text
topic) (\s :: KafkaAction
s@KafkaAction' {} Text
a -> KafkaAction
s {$sel:topic:KafkaAction' :: Text
topic = Text
a} :: KafkaAction)
kafkaAction_clientProperties :: Lens.Lens' KafkaAction (Prelude.HashMap Prelude.Text Prelude.Text)
kafkaAction_clientProperties :: (HashMap Text Text -> f (HashMap Text Text))
-> KafkaAction -> f KafkaAction
kafkaAction_clientProperties = (KafkaAction -> HashMap Text Text)
-> (KafkaAction -> HashMap Text Text -> KafkaAction)
-> Lens
KafkaAction KafkaAction (HashMap Text Text) (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KafkaAction' {HashMap Text Text
clientProperties :: HashMap Text Text
$sel:clientProperties:KafkaAction' :: KafkaAction -> HashMap Text Text
clientProperties} -> HashMap Text Text
clientProperties) (\s :: KafkaAction
s@KafkaAction' {} HashMap Text Text
a -> KafkaAction
s {$sel:clientProperties:KafkaAction' :: HashMap Text Text
clientProperties = HashMap Text Text
a} :: KafkaAction) ((HashMap Text Text -> f (HashMap Text Text))
-> KafkaAction -> f KafkaAction)
-> ((HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> KafkaAction
-> f KafkaAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON KafkaAction where
parseJSON :: Value -> Parser KafkaAction
parseJSON =
String
-> (Object -> Parser KafkaAction) -> Value -> Parser KafkaAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"KafkaAction"
( \Object
x ->
Maybe Text
-> Maybe Text -> Text -> Text -> HashMap Text Text -> KafkaAction
KafkaAction'
(Maybe Text
-> Maybe Text -> Text -> Text -> HashMap Text Text -> KafkaAction)
-> Parser (Maybe Text)
-> Parser
(Maybe Text -> Text -> Text -> HashMap Text Text -> KafkaAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"key")
Parser
(Maybe Text -> Text -> Text -> HashMap Text Text -> KafkaAction)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> HashMap Text Text -> KafkaAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"partition")
Parser (Text -> Text -> HashMap Text Text -> KafkaAction)
-> Parser Text -> Parser (Text -> HashMap Text Text -> KafkaAction)
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
"destinationArn")
Parser (Text -> HashMap Text Text -> KafkaAction)
-> Parser Text -> Parser (HashMap Text Text -> KafkaAction)
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
"topic")
Parser (HashMap Text Text -> KafkaAction)
-> Parser (HashMap Text Text) -> Parser KafkaAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (HashMap Text Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"clientProperties"
Parser (Maybe (HashMap Text Text))
-> HashMap Text Text -> Parser (HashMap Text Text)
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
)
)
instance Prelude.Hashable KafkaAction
instance Prelude.NFData KafkaAction
instance Core.ToJSON KafkaAction where
toJSON :: KafkaAction -> Value
toJSON KafkaAction' {Maybe Text
Text
HashMap Text Text
clientProperties :: HashMap Text Text
topic :: Text
destinationArn :: Text
partition :: Maybe Text
key :: Maybe Text
$sel:clientProperties:KafkaAction' :: KafkaAction -> HashMap Text Text
$sel:topic:KafkaAction' :: KafkaAction -> Text
$sel:destinationArn:KafkaAction' :: KafkaAction -> Text
$sel:partition:KafkaAction' :: KafkaAction -> Maybe Text
$sel:key:KafkaAction' :: KafkaAction -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
key,
(Text
"partition" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
partition,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"destinationArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
destinationArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"topic" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
topic),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"clientProperties" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text Text
clientProperties)
]
)