{-# 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.IoT.Types.EnableIoTLoggingParams
-- 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.IoT.Types.EnableIoTLoggingParams where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.LogLevel
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Parameters used when defining a mitigation action that enable Amazon Web
-- Services IoT Core logging.
--
-- /See:/ 'newEnableIoTLoggingParams' smart constructor.
data EnableIoTLoggingParams = EnableIoTLoggingParams'
  { -- | The Amazon Resource Name (ARN) of the IAM role used for logging.
    EnableIoTLoggingParams -> Text
roleArnForLogging :: Prelude.Text,
    -- | Specifies the type of information to be logged.
    EnableIoTLoggingParams -> LogLevel
logLevel :: LogLevel
  }
  deriving (EnableIoTLoggingParams -> EnableIoTLoggingParams -> Bool
(EnableIoTLoggingParams -> EnableIoTLoggingParams -> Bool)
-> (EnableIoTLoggingParams -> EnableIoTLoggingParams -> Bool)
-> Eq EnableIoTLoggingParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableIoTLoggingParams -> EnableIoTLoggingParams -> Bool
$c/= :: EnableIoTLoggingParams -> EnableIoTLoggingParams -> Bool
== :: EnableIoTLoggingParams -> EnableIoTLoggingParams -> Bool
$c== :: EnableIoTLoggingParams -> EnableIoTLoggingParams -> Bool
Prelude.Eq, ReadPrec [EnableIoTLoggingParams]
ReadPrec EnableIoTLoggingParams
Int -> ReadS EnableIoTLoggingParams
ReadS [EnableIoTLoggingParams]
(Int -> ReadS EnableIoTLoggingParams)
-> ReadS [EnableIoTLoggingParams]
-> ReadPrec EnableIoTLoggingParams
-> ReadPrec [EnableIoTLoggingParams]
-> Read EnableIoTLoggingParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableIoTLoggingParams]
$creadListPrec :: ReadPrec [EnableIoTLoggingParams]
readPrec :: ReadPrec EnableIoTLoggingParams
$creadPrec :: ReadPrec EnableIoTLoggingParams
readList :: ReadS [EnableIoTLoggingParams]
$creadList :: ReadS [EnableIoTLoggingParams]
readsPrec :: Int -> ReadS EnableIoTLoggingParams
$creadsPrec :: Int -> ReadS EnableIoTLoggingParams
Prelude.Read, Int -> EnableIoTLoggingParams -> ShowS
[EnableIoTLoggingParams] -> ShowS
EnableIoTLoggingParams -> String
(Int -> EnableIoTLoggingParams -> ShowS)
-> (EnableIoTLoggingParams -> String)
-> ([EnableIoTLoggingParams] -> ShowS)
-> Show EnableIoTLoggingParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableIoTLoggingParams] -> ShowS
$cshowList :: [EnableIoTLoggingParams] -> ShowS
show :: EnableIoTLoggingParams -> String
$cshow :: EnableIoTLoggingParams -> String
showsPrec :: Int -> EnableIoTLoggingParams -> ShowS
$cshowsPrec :: Int -> EnableIoTLoggingParams -> ShowS
Prelude.Show, (forall x. EnableIoTLoggingParams -> Rep EnableIoTLoggingParams x)
-> (forall x.
    Rep EnableIoTLoggingParams x -> EnableIoTLoggingParams)
-> Generic EnableIoTLoggingParams
forall x. Rep EnableIoTLoggingParams x -> EnableIoTLoggingParams
forall x. EnableIoTLoggingParams -> Rep EnableIoTLoggingParams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnableIoTLoggingParams x -> EnableIoTLoggingParams
$cfrom :: forall x. EnableIoTLoggingParams -> Rep EnableIoTLoggingParams x
Prelude.Generic)

-- |
-- Create a value of 'EnableIoTLoggingParams' 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:
--
-- 'roleArnForLogging', 'enableIoTLoggingParams_roleArnForLogging' - The Amazon Resource Name (ARN) of the IAM role used for logging.
--
-- 'logLevel', 'enableIoTLoggingParams_logLevel' - Specifies the type of information to be logged.
newEnableIoTLoggingParams ::
  -- | 'roleArnForLogging'
  Prelude.Text ->
  -- | 'logLevel'
  LogLevel ->
  EnableIoTLoggingParams
newEnableIoTLoggingParams :: Text -> LogLevel -> EnableIoTLoggingParams
newEnableIoTLoggingParams
  Text
pRoleArnForLogging_
  LogLevel
pLogLevel_ =
    EnableIoTLoggingParams' :: Text -> LogLevel -> EnableIoTLoggingParams
EnableIoTLoggingParams'
      { $sel:roleArnForLogging:EnableIoTLoggingParams' :: Text
roleArnForLogging =
          Text
pRoleArnForLogging_,
        $sel:logLevel:EnableIoTLoggingParams' :: LogLevel
logLevel = LogLevel
pLogLevel_
      }

-- | The Amazon Resource Name (ARN) of the IAM role used for logging.
enableIoTLoggingParams_roleArnForLogging :: Lens.Lens' EnableIoTLoggingParams Prelude.Text
enableIoTLoggingParams_roleArnForLogging :: (Text -> f Text)
-> EnableIoTLoggingParams -> f EnableIoTLoggingParams
enableIoTLoggingParams_roleArnForLogging = (EnableIoTLoggingParams -> Text)
-> (EnableIoTLoggingParams -> Text -> EnableIoTLoggingParams)
-> Lens EnableIoTLoggingParams EnableIoTLoggingParams Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableIoTLoggingParams' {Text
roleArnForLogging :: Text
$sel:roleArnForLogging:EnableIoTLoggingParams' :: EnableIoTLoggingParams -> Text
roleArnForLogging} -> Text
roleArnForLogging) (\s :: EnableIoTLoggingParams
s@EnableIoTLoggingParams' {} Text
a -> EnableIoTLoggingParams
s {$sel:roleArnForLogging:EnableIoTLoggingParams' :: Text
roleArnForLogging = Text
a} :: EnableIoTLoggingParams)

-- | Specifies the type of information to be logged.
enableIoTLoggingParams_logLevel :: Lens.Lens' EnableIoTLoggingParams LogLevel
enableIoTLoggingParams_logLevel :: (LogLevel -> f LogLevel)
-> EnableIoTLoggingParams -> f EnableIoTLoggingParams
enableIoTLoggingParams_logLevel = (EnableIoTLoggingParams -> LogLevel)
-> (EnableIoTLoggingParams -> LogLevel -> EnableIoTLoggingParams)
-> Lens
     EnableIoTLoggingParams EnableIoTLoggingParams LogLevel LogLevel
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableIoTLoggingParams' {LogLevel
logLevel :: LogLevel
$sel:logLevel:EnableIoTLoggingParams' :: EnableIoTLoggingParams -> LogLevel
logLevel} -> LogLevel
logLevel) (\s :: EnableIoTLoggingParams
s@EnableIoTLoggingParams' {} LogLevel
a -> EnableIoTLoggingParams
s {$sel:logLevel:EnableIoTLoggingParams' :: LogLevel
logLevel = LogLevel
a} :: EnableIoTLoggingParams)

instance Core.FromJSON EnableIoTLoggingParams where
  parseJSON :: Value -> Parser EnableIoTLoggingParams
parseJSON =
    String
-> (Object -> Parser EnableIoTLoggingParams)
-> Value
-> Parser EnableIoTLoggingParams
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EnableIoTLoggingParams"
      ( \Object
x ->
          Text -> LogLevel -> EnableIoTLoggingParams
EnableIoTLoggingParams'
            (Text -> LogLevel -> EnableIoTLoggingParams)
-> Parser Text -> Parser (LogLevel -> EnableIoTLoggingParams)
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
"roleArnForLogging")
            Parser (LogLevel -> EnableIoTLoggingParams)
-> Parser LogLevel -> Parser EnableIoTLoggingParams
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser LogLevel
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"logLevel")
      )

instance Prelude.Hashable EnableIoTLoggingParams

instance Prelude.NFData EnableIoTLoggingParams

instance Core.ToJSON EnableIoTLoggingParams where
  toJSON :: EnableIoTLoggingParams -> Value
toJSON EnableIoTLoggingParams' {Text
LogLevel
logLevel :: LogLevel
roleArnForLogging :: Text
$sel:logLevel:EnableIoTLoggingParams' :: EnableIoTLoggingParams -> LogLevel
$sel:roleArnForLogging:EnableIoTLoggingParams' :: EnableIoTLoggingParams -> 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
"roleArnForLogging" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArnForLogging),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"logLevel" Text -> LogLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LogLevel
logLevel)
          ]
      )