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