{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoTAnalytics.Types.LoggingOptions
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTAnalytics.Types.LoggingOptions where

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.LoggingLevel
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about logging options.
--
-- /See:/ 'newLoggingOptions' smart constructor.
data LoggingOptions = LoggingOptions'
  { -- | The ARN of the role that grants permission to IoT Analytics to perform
    -- logging.
    LoggingOptions -> Text
roleArn :: Prelude.Text,
    -- | The logging level. Currently, only ERROR is supported.
    LoggingOptions -> LoggingLevel
level :: LoggingLevel,
    -- | If true, logging is enabled for IoT Analytics.
    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)

-- |
-- Create a value of 'LoggingOptions' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'roleArn', 'loggingOptions_roleArn' - The ARN of the role that grants permission to IoT Analytics to perform
-- logging.
--
-- 'level', 'loggingOptions_level' - The logging level. Currently, only ERROR is supported.
--
-- 'enabled', 'loggingOptions_enabled' - If true, logging is enabled for IoT Analytics.
newLoggingOptions ::
  -- | 'roleArn'
  Prelude.Text ->
  -- | 'level'
  LoggingLevel ->
  -- | 'enabled'
  Prelude.Bool ->
  LoggingOptions
newLoggingOptions :: Text -> LoggingLevel -> Bool -> LoggingOptions
newLoggingOptions Text
pRoleArn_ LoggingLevel
pLevel_ Bool
pEnabled_ =
  LoggingOptions' :: Text -> LoggingLevel -> Bool -> LoggingOptions
LoggingOptions'
    { $sel:roleArn:LoggingOptions' :: Text
roleArn = Text
pRoleArn_,
      $sel:level:LoggingOptions' :: LoggingLevel
level = LoggingLevel
pLevel_,
      $sel:enabled:LoggingOptions' :: Bool
enabled = Bool
pEnabled_
    }

-- | The ARN of the role that grants permission to IoT Analytics to perform
-- logging.
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)

-- | The logging level. Currently, only ERROR is supported.
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)

-- | If true, logging is enabled for IoT Analytics.
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 ->
          Text -> LoggingLevel -> Bool -> LoggingOptions
LoggingOptions'
            (Text -> LoggingLevel -> Bool -> LoggingOptions)
-> Parser Text -> Parser (LoggingLevel -> Bool -> LoggingOptions)
forall (f :: * -> *) a b. Functor 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
Text
LoggingLevel
enabled :: Bool
level :: LoggingLevel
roleArn :: Text
$sel:enabled:LoggingOptions' :: LoggingOptions -> Bool
$sel:level:LoggingOptions' :: LoggingOptions -> LoggingLevel
$sel:roleArn:LoggingOptions' :: LoggingOptions -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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)
          ]
      )