{-# 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.IoTEvents.Types.LoggingOptions where
import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.Types.DetectorDebugOption
import Amazonka.IoTEvents.Types.LoggingLevel
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data LoggingOptions = LoggingOptions'
{
LoggingOptions -> Maybe (NonEmpty DetectorDebugOption)
detectorDebugOptions :: Prelude.Maybe (Prelude.NonEmpty DetectorDebugOption),
LoggingOptions -> Text
roleArn :: Prelude.Text,
LoggingOptions -> LoggingLevel
level :: LoggingLevel,
LoggingOptions -> Bool
enabled :: Prelude.Bool
}
deriving (LoggingOptions -> LoggingOptions -> Bool
(LoggingOptions -> LoggingOptions -> Bool)
-> (LoggingOptions -> LoggingOptions -> Bool) -> Eq LoggingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoggingOptions -> LoggingOptions -> Bool
$c/= :: LoggingOptions -> LoggingOptions -> Bool
== :: LoggingOptions -> LoggingOptions -> Bool
$c== :: LoggingOptions -> LoggingOptions -> Bool
Prelude.Eq, ReadPrec [LoggingOptions]
ReadPrec LoggingOptions
Int -> ReadS LoggingOptions
ReadS [LoggingOptions]
(Int -> ReadS LoggingOptions)
-> ReadS [LoggingOptions]
-> ReadPrec LoggingOptions
-> ReadPrec [LoggingOptions]
-> Read LoggingOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoggingOptions]
$creadListPrec :: ReadPrec [LoggingOptions]
readPrec :: ReadPrec LoggingOptions
$creadPrec :: ReadPrec LoggingOptions
readList :: ReadS [LoggingOptions]
$creadList :: ReadS [LoggingOptions]
readsPrec :: Int -> ReadS LoggingOptions
$creadsPrec :: Int -> ReadS LoggingOptions
Prelude.Read, Int -> LoggingOptions -> ShowS
[LoggingOptions] -> ShowS
LoggingOptions -> String
(Int -> LoggingOptions -> ShowS)
-> (LoggingOptions -> String)
-> ([LoggingOptions] -> ShowS)
-> Show LoggingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoggingOptions] -> ShowS
$cshowList :: [LoggingOptions] -> ShowS
show :: LoggingOptions -> String
$cshow :: LoggingOptions -> String
showsPrec :: Int -> LoggingOptions -> ShowS
$cshowsPrec :: Int -> LoggingOptions -> ShowS
Prelude.Show, (forall x. LoggingOptions -> Rep LoggingOptions x)
-> (forall x. Rep LoggingOptions x -> LoggingOptions)
-> Generic LoggingOptions
forall x. Rep LoggingOptions x -> LoggingOptions
forall x. LoggingOptions -> Rep LoggingOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoggingOptions x -> LoggingOptions
$cfrom :: forall x. LoggingOptions -> Rep LoggingOptions x
Prelude.Generic)
newLoggingOptions ::
Prelude.Text ->
LoggingLevel ->
Prelude.Bool ->
LoggingOptions
newLoggingOptions :: Text -> LoggingLevel -> Bool -> LoggingOptions
newLoggingOptions Text
pRoleArn_ LoggingLevel
pLevel_ Bool
pEnabled_ =
LoggingOptions' :: Maybe (NonEmpty DetectorDebugOption)
-> Text -> LoggingLevel -> Bool -> LoggingOptions
LoggingOptions'
{ $sel:detectorDebugOptions:LoggingOptions' :: Maybe (NonEmpty DetectorDebugOption)
detectorDebugOptions =
Maybe (NonEmpty DetectorDebugOption)
forall a. Maybe a
Prelude.Nothing,
$sel:roleArn:LoggingOptions' :: Text
roleArn = Text
pRoleArn_,
$sel:level:LoggingOptions' :: LoggingLevel
level = LoggingLevel
pLevel_,
$sel:enabled:LoggingOptions' :: Bool
enabled = Bool
pEnabled_
}
loggingOptions_detectorDebugOptions :: Lens.Lens' LoggingOptions (Prelude.Maybe (Prelude.NonEmpty DetectorDebugOption))
loggingOptions_detectorDebugOptions :: (Maybe (NonEmpty DetectorDebugOption)
-> f (Maybe (NonEmpty DetectorDebugOption)))
-> LoggingOptions -> f LoggingOptions
loggingOptions_detectorDebugOptions = (LoggingOptions -> Maybe (NonEmpty DetectorDebugOption))
-> (LoggingOptions
-> Maybe (NonEmpty DetectorDebugOption) -> LoggingOptions)
-> Lens
LoggingOptions
LoggingOptions
(Maybe (NonEmpty DetectorDebugOption))
(Maybe (NonEmpty DetectorDebugOption))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingOptions' {Maybe (NonEmpty DetectorDebugOption)
detectorDebugOptions :: Maybe (NonEmpty DetectorDebugOption)
$sel:detectorDebugOptions:LoggingOptions' :: LoggingOptions -> Maybe (NonEmpty DetectorDebugOption)
detectorDebugOptions} -> Maybe (NonEmpty DetectorDebugOption)
detectorDebugOptions) (\s :: LoggingOptions
s@LoggingOptions' {} Maybe (NonEmpty DetectorDebugOption)
a -> LoggingOptions
s {$sel:detectorDebugOptions:LoggingOptions' :: Maybe (NonEmpty DetectorDebugOption)
detectorDebugOptions = Maybe (NonEmpty DetectorDebugOption)
a} :: LoggingOptions) ((Maybe (NonEmpty DetectorDebugOption)
-> f (Maybe (NonEmpty DetectorDebugOption)))
-> LoggingOptions -> f LoggingOptions)
-> ((Maybe (NonEmpty DetectorDebugOption)
-> f (Maybe (NonEmpty DetectorDebugOption)))
-> Maybe (NonEmpty DetectorDebugOption)
-> f (Maybe (NonEmpty DetectorDebugOption)))
-> (Maybe (NonEmpty DetectorDebugOption)
-> f (Maybe (NonEmpty DetectorDebugOption)))
-> LoggingOptions
-> f LoggingOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty DetectorDebugOption)
(NonEmpty DetectorDebugOption)
(NonEmpty DetectorDebugOption)
(NonEmpty DetectorDebugOption)
-> Iso
(Maybe (NonEmpty DetectorDebugOption))
(Maybe (NonEmpty DetectorDebugOption))
(Maybe (NonEmpty DetectorDebugOption))
(Maybe (NonEmpty DetectorDebugOption))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(NonEmpty DetectorDebugOption)
(NonEmpty DetectorDebugOption)
(NonEmpty DetectorDebugOption)
(NonEmpty DetectorDebugOption)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
loggingOptions_roleArn :: Lens.Lens' LoggingOptions Prelude.Text
loggingOptions_roleArn :: (Text -> f Text) -> LoggingOptions -> f LoggingOptions
loggingOptions_roleArn = (LoggingOptions -> Text)
-> (LoggingOptions -> Text -> LoggingOptions)
-> Lens LoggingOptions LoggingOptions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingOptions' {Text
roleArn :: Text
$sel:roleArn:LoggingOptions' :: LoggingOptions -> Text
roleArn} -> Text
roleArn) (\s :: LoggingOptions
s@LoggingOptions' {} Text
a -> LoggingOptions
s {$sel:roleArn:LoggingOptions' :: Text
roleArn = Text
a} :: LoggingOptions)
loggingOptions_level :: Lens.Lens' LoggingOptions LoggingLevel
loggingOptions_level :: (LoggingLevel -> f LoggingLevel)
-> LoggingOptions -> f LoggingOptions
loggingOptions_level = (LoggingOptions -> LoggingLevel)
-> (LoggingOptions -> LoggingLevel -> LoggingOptions)
-> Lens LoggingOptions LoggingOptions LoggingLevel LoggingLevel
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingOptions' {LoggingLevel
level :: LoggingLevel
$sel:level:LoggingOptions' :: LoggingOptions -> LoggingLevel
level} -> LoggingLevel
level) (\s :: LoggingOptions
s@LoggingOptions' {} LoggingLevel
a -> LoggingOptions
s {$sel:level:LoggingOptions' :: LoggingLevel
level = LoggingLevel
a} :: LoggingOptions)
loggingOptions_enabled :: Lens.Lens' LoggingOptions Prelude.Bool
loggingOptions_enabled :: (Bool -> f Bool) -> LoggingOptions -> f LoggingOptions
loggingOptions_enabled = (LoggingOptions -> Bool)
-> (LoggingOptions -> Bool -> LoggingOptions)
-> Lens LoggingOptions LoggingOptions Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingOptions' {Bool
enabled :: Bool
$sel:enabled:LoggingOptions' :: LoggingOptions -> Bool
enabled} -> Bool
enabled) (\s :: LoggingOptions
s@LoggingOptions' {} Bool
a -> LoggingOptions
s {$sel:enabled:LoggingOptions' :: Bool
enabled = Bool
a} :: LoggingOptions)
instance Core.FromJSON LoggingOptions where
parseJSON :: Value -> Parser LoggingOptions
parseJSON =
String
-> (Object -> Parser LoggingOptions)
-> Value
-> Parser LoggingOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"LoggingOptions"
( \Object
x ->
Maybe (NonEmpty DetectorDebugOption)
-> Text -> LoggingLevel -> Bool -> LoggingOptions
LoggingOptions'
(Maybe (NonEmpty DetectorDebugOption)
-> Text -> LoggingLevel -> Bool -> LoggingOptions)
-> Parser (Maybe (NonEmpty DetectorDebugOption))
-> Parser (Text -> LoggingLevel -> Bool -> LoggingOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty DetectorDebugOption))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"detectorDebugOptions")
Parser (Text -> LoggingLevel -> Bool -> LoggingOptions)
-> Parser Text -> Parser (LoggingLevel -> Bool -> LoggingOptions)
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")
Parser (LoggingLevel -> Bool -> LoggingOptions)
-> Parser LoggingLevel -> Parser (Bool -> LoggingOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser LoggingLevel
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"level")
Parser (Bool -> LoggingOptions)
-> Parser Bool -> Parser LoggingOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"enabled")
)
instance Prelude.Hashable LoggingOptions
instance Prelude.NFData LoggingOptions
instance Core.ToJSON LoggingOptions where
toJSON :: LoggingOptions -> Value
toJSON LoggingOptions' {Bool
Maybe (NonEmpty DetectorDebugOption)
Text
LoggingLevel
enabled :: Bool
level :: LoggingLevel
roleArn :: Text
detectorDebugOptions :: Maybe (NonEmpty DetectorDebugOption)
$sel:enabled:LoggingOptions' :: LoggingOptions -> Bool
$sel:level:LoggingOptions' :: LoggingOptions -> LoggingLevel
$sel:roleArn:LoggingOptions' :: LoggingOptions -> Text
$sel:detectorDebugOptions:LoggingOptions' :: LoggingOptions -> Maybe (NonEmpty DetectorDebugOption)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"detectorDebugOptions" Text -> NonEmpty DetectorDebugOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(NonEmpty DetectorDebugOption -> Pair)
-> Maybe (NonEmpty DetectorDebugOption) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty DetectorDebugOption)
detectorDebugOptions,
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),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"level" Text -> LoggingLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LoggingLevel
level),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
enabled)
]
)