{-# 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.LogTargetType
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
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]
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
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. 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'
{ $sel:targetName:LogTarget' :: Maybe Text
targetName = forall a. Maybe a
Prelude.Nothing,
$sel:targetType:LogTarget' :: LogTargetType
targetType = LogTargetType
pTargetType_
}
logTarget_targetName :: Lens.Lens' LogTarget (Prelude.Maybe Prelude.Text)
logTarget_targetName :: Lens' LogTarget (Maybe Text)
logTarget_targetName = 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 :: Lens' LogTarget LogTargetType
logTarget_targetType = 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 Data.FromJSON LogTarget where
parseJSON :: Value -> Parser LogTarget
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"LogTarget"
( \Object
x ->
Maybe Text -> LogTargetType -> LogTarget
LogTarget'
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
"targetName")
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
"targetType")
)
instance Prelude.Hashable LogTarget where
hashWithSalt :: Int -> LogTarget -> Int
hashWithSalt Int
_salt LogTarget' {Maybe Text
LogTargetType
targetType :: LogTargetType
targetName :: Maybe Text
$sel:targetType:LogTarget' :: LogTarget -> LogTargetType
$sel:targetName:LogTarget' :: LogTarget -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetName
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LogTargetType
targetType
instance Prelude.NFData LogTarget where
rnf :: LogTarget -> ()
rnf LogTarget' {Maybe Text
LogTargetType
targetType :: LogTargetType
targetName :: Maybe Text
$sel:targetType:LogTarget' :: LogTarget -> LogTargetType
$sel:targetName:LogTarget' :: LogTarget -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetName
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf LogTargetType
targetType
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"targetName" 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 Text
targetName,
forall a. a -> Maybe a
Prelude.Just (Key
"targetType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= LogTargetType
targetType)
]
)