{-# 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.LoggingOptionsPayload
-- 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.LoggingOptionsPayload where

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

-- | Describes the logging options payload.
--
-- /See:/ 'newLoggingOptionsPayload' smart constructor.
data LoggingOptionsPayload = LoggingOptionsPayload'
  { -- | The log level.
    LoggingOptionsPayload -> Maybe LogLevel
logLevel :: Prelude.Maybe LogLevel,
    -- | The ARN of the IAM role that grants access.
    LoggingOptionsPayload -> Text
roleArn :: Prelude.Text
  }
  deriving (LoggingOptionsPayload -> LoggingOptionsPayload -> Bool
(LoggingOptionsPayload -> LoggingOptionsPayload -> Bool)
-> (LoggingOptionsPayload -> LoggingOptionsPayload -> Bool)
-> Eq LoggingOptionsPayload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoggingOptionsPayload -> LoggingOptionsPayload -> Bool
$c/= :: LoggingOptionsPayload -> LoggingOptionsPayload -> Bool
== :: LoggingOptionsPayload -> LoggingOptionsPayload -> Bool
$c== :: LoggingOptionsPayload -> LoggingOptionsPayload -> Bool
Prelude.Eq, ReadPrec [LoggingOptionsPayload]
ReadPrec LoggingOptionsPayload
Int -> ReadS LoggingOptionsPayload
ReadS [LoggingOptionsPayload]
(Int -> ReadS LoggingOptionsPayload)
-> ReadS [LoggingOptionsPayload]
-> ReadPrec LoggingOptionsPayload
-> ReadPrec [LoggingOptionsPayload]
-> Read LoggingOptionsPayload
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoggingOptionsPayload]
$creadListPrec :: ReadPrec [LoggingOptionsPayload]
readPrec :: ReadPrec LoggingOptionsPayload
$creadPrec :: ReadPrec LoggingOptionsPayload
readList :: ReadS [LoggingOptionsPayload]
$creadList :: ReadS [LoggingOptionsPayload]
readsPrec :: Int -> ReadS LoggingOptionsPayload
$creadsPrec :: Int -> ReadS LoggingOptionsPayload
Prelude.Read, Int -> LoggingOptionsPayload -> ShowS
[LoggingOptionsPayload] -> ShowS
LoggingOptionsPayload -> String
(Int -> LoggingOptionsPayload -> ShowS)
-> (LoggingOptionsPayload -> String)
-> ([LoggingOptionsPayload] -> ShowS)
-> Show LoggingOptionsPayload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoggingOptionsPayload] -> ShowS
$cshowList :: [LoggingOptionsPayload] -> ShowS
show :: LoggingOptionsPayload -> String
$cshow :: LoggingOptionsPayload -> String
showsPrec :: Int -> LoggingOptionsPayload -> ShowS
$cshowsPrec :: Int -> LoggingOptionsPayload -> ShowS
Prelude.Show, (forall x. LoggingOptionsPayload -> Rep LoggingOptionsPayload x)
-> (forall x. Rep LoggingOptionsPayload x -> LoggingOptionsPayload)
-> Generic LoggingOptionsPayload
forall x. Rep LoggingOptionsPayload x -> LoggingOptionsPayload
forall x. LoggingOptionsPayload -> Rep LoggingOptionsPayload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoggingOptionsPayload x -> LoggingOptionsPayload
$cfrom :: forall x. LoggingOptionsPayload -> Rep LoggingOptionsPayload x
Prelude.Generic)

-- |
-- Create a value of 'LoggingOptionsPayload' 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:
--
-- 'logLevel', 'loggingOptionsPayload_logLevel' - The log level.
--
-- 'roleArn', 'loggingOptionsPayload_roleArn' - The ARN of the IAM role that grants access.
newLoggingOptionsPayload ::
  -- | 'roleArn'
  Prelude.Text ->
  LoggingOptionsPayload
newLoggingOptionsPayload :: Text -> LoggingOptionsPayload
newLoggingOptionsPayload Text
pRoleArn_ =
  LoggingOptionsPayload' :: Maybe LogLevel -> Text -> LoggingOptionsPayload
LoggingOptionsPayload'
    { $sel:logLevel:LoggingOptionsPayload' :: Maybe LogLevel
logLevel = Maybe LogLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:LoggingOptionsPayload' :: Text
roleArn = Text
pRoleArn_
    }

-- | The log level.
loggingOptionsPayload_logLevel :: Lens.Lens' LoggingOptionsPayload (Prelude.Maybe LogLevel)
loggingOptionsPayload_logLevel :: (Maybe LogLevel -> f (Maybe LogLevel))
-> LoggingOptionsPayload -> f LoggingOptionsPayload
loggingOptionsPayload_logLevel = (LoggingOptionsPayload -> Maybe LogLevel)
-> (LoggingOptionsPayload
    -> Maybe LogLevel -> LoggingOptionsPayload)
-> Lens
     LoggingOptionsPayload
     LoggingOptionsPayload
     (Maybe LogLevel)
     (Maybe LogLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingOptionsPayload' {Maybe LogLevel
logLevel :: Maybe LogLevel
$sel:logLevel:LoggingOptionsPayload' :: LoggingOptionsPayload -> Maybe LogLevel
logLevel} -> Maybe LogLevel
logLevel) (\s :: LoggingOptionsPayload
s@LoggingOptionsPayload' {} Maybe LogLevel
a -> LoggingOptionsPayload
s {$sel:logLevel:LoggingOptionsPayload' :: Maybe LogLevel
logLevel = Maybe LogLevel
a} :: LoggingOptionsPayload)

-- | The ARN of the IAM role that grants access.
loggingOptionsPayload_roleArn :: Lens.Lens' LoggingOptionsPayload Prelude.Text
loggingOptionsPayload_roleArn :: (Text -> f Text)
-> LoggingOptionsPayload -> f LoggingOptionsPayload
loggingOptionsPayload_roleArn = (LoggingOptionsPayload -> Text)
-> (LoggingOptionsPayload -> Text -> LoggingOptionsPayload)
-> Lens LoggingOptionsPayload LoggingOptionsPayload Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingOptionsPayload' {Text
roleArn :: Text
$sel:roleArn:LoggingOptionsPayload' :: LoggingOptionsPayload -> Text
roleArn} -> Text
roleArn) (\s :: LoggingOptionsPayload
s@LoggingOptionsPayload' {} Text
a -> LoggingOptionsPayload
s {$sel:roleArn:LoggingOptionsPayload' :: Text
roleArn = Text
a} :: LoggingOptionsPayload)

instance Prelude.Hashable LoggingOptionsPayload

instance Prelude.NFData LoggingOptionsPayload

instance Core.ToJSON LoggingOptionsPayload where
  toJSON :: LoggingOptionsPayload -> Value
toJSON LoggingOptionsPayload' {Maybe LogLevel
Text
roleArn :: Text
logLevel :: Maybe LogLevel
$sel:roleArn:LoggingOptionsPayload' :: LoggingOptionsPayload -> Text
$sel:logLevel:LoggingOptionsPayload' :: LoggingOptionsPayload -> Maybe LogLevel
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"logLevel" Text -> LogLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LogLevel -> Pair) -> Maybe LogLevel -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LogLevel
logLevel,
            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)
          ]
      )