{-# 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.IoTSiteWise.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.IoTSiteWise.Types.LoggingOptions where

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

-- | Contains logging options.
--
-- /See:/ 'newLoggingOptions' smart constructor.
data LoggingOptions = LoggingOptions'
  { -- | The IoT SiteWise logging verbosity level.
    LoggingOptions -> LoggingLevel
level :: LoggingLevel
  }
  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:
--
-- 'level', 'loggingOptions_level' - The IoT SiteWise logging verbosity level.
newLoggingOptions ::
  -- | 'level'
  LoggingLevel ->
  LoggingOptions
newLoggingOptions :: LoggingLevel -> LoggingOptions
newLoggingOptions LoggingLevel
pLevel_ =
  LoggingOptions' :: LoggingLevel -> LoggingOptions
LoggingOptions' {$sel:level:LoggingOptions' :: LoggingLevel
level = LoggingLevel
pLevel_}

-- | The IoT SiteWise logging verbosity level.
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)

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 ->
          LoggingLevel -> LoggingOptions
LoggingOptions' (LoggingLevel -> LoggingOptions)
-> Parser LoggingLevel -> Parser LoggingOptions
forall (f :: * -> *) a b. Functor 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")
      )

instance Prelude.Hashable LoggingOptions

instance Prelude.NFData LoggingOptions

instance Core.ToJSON LoggingOptions where
  toJSON :: LoggingOptions -> Value
toJSON LoggingOptions' {LoggingLevel
level :: LoggingLevel
$sel:level:LoggingOptions' :: LoggingOptions -> LoggingLevel
..} =
    [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
"level" Text -> LoggingLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LoggingLevel
level)]
      )