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

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

-- | The target configuration.
--
-- /See:/ 'newLogTargetConfiguration' smart constructor.
data LogTargetConfiguration = LogTargetConfiguration'
  { -- | The logging level.
    LogTargetConfiguration -> Maybe LogLevel
logLevel :: Prelude.Maybe LogLevel,
    -- | A log target
    LogTargetConfiguration -> Maybe LogTarget
logTarget :: Prelude.Maybe LogTarget
  }
  deriving (LogTargetConfiguration -> LogTargetConfiguration -> Bool
(LogTargetConfiguration -> LogTargetConfiguration -> Bool)
-> (LogTargetConfiguration -> LogTargetConfiguration -> Bool)
-> Eq LogTargetConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogTargetConfiguration -> LogTargetConfiguration -> Bool
$c/= :: LogTargetConfiguration -> LogTargetConfiguration -> Bool
== :: LogTargetConfiguration -> LogTargetConfiguration -> Bool
$c== :: LogTargetConfiguration -> LogTargetConfiguration -> Bool
Prelude.Eq, ReadPrec [LogTargetConfiguration]
ReadPrec LogTargetConfiguration
Int -> ReadS LogTargetConfiguration
ReadS [LogTargetConfiguration]
(Int -> ReadS LogTargetConfiguration)
-> ReadS [LogTargetConfiguration]
-> ReadPrec LogTargetConfiguration
-> ReadPrec [LogTargetConfiguration]
-> Read LogTargetConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogTargetConfiguration]
$creadListPrec :: ReadPrec [LogTargetConfiguration]
readPrec :: ReadPrec LogTargetConfiguration
$creadPrec :: ReadPrec LogTargetConfiguration
readList :: ReadS [LogTargetConfiguration]
$creadList :: ReadS [LogTargetConfiguration]
readsPrec :: Int -> ReadS LogTargetConfiguration
$creadsPrec :: Int -> ReadS LogTargetConfiguration
Prelude.Read, Int -> LogTargetConfiguration -> ShowS
[LogTargetConfiguration] -> ShowS
LogTargetConfiguration -> String
(Int -> LogTargetConfiguration -> ShowS)
-> (LogTargetConfiguration -> String)
-> ([LogTargetConfiguration] -> ShowS)
-> Show LogTargetConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogTargetConfiguration] -> ShowS
$cshowList :: [LogTargetConfiguration] -> ShowS
show :: LogTargetConfiguration -> String
$cshow :: LogTargetConfiguration -> String
showsPrec :: Int -> LogTargetConfiguration -> ShowS
$cshowsPrec :: Int -> LogTargetConfiguration -> ShowS
Prelude.Show, (forall x. LogTargetConfiguration -> Rep LogTargetConfiguration x)
-> (forall x.
    Rep LogTargetConfiguration x -> LogTargetConfiguration)
-> Generic LogTargetConfiguration
forall x. Rep LogTargetConfiguration x -> LogTargetConfiguration
forall x. LogTargetConfiguration -> Rep LogTargetConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogTargetConfiguration x -> LogTargetConfiguration
$cfrom :: forall x. LogTargetConfiguration -> Rep LogTargetConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LogTargetConfiguration' 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', 'logTargetConfiguration_logLevel' - The logging level.
--
-- 'logTarget', 'logTargetConfiguration_logTarget' - A log target
newLogTargetConfiguration ::
  LogTargetConfiguration
newLogTargetConfiguration :: LogTargetConfiguration
newLogTargetConfiguration =
  LogTargetConfiguration' :: Maybe LogLevel -> Maybe LogTarget -> LogTargetConfiguration
LogTargetConfiguration'
    { $sel:logLevel:LogTargetConfiguration' :: Maybe LogLevel
logLevel = Maybe LogLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:logTarget:LogTargetConfiguration' :: Maybe LogTarget
logTarget = Maybe LogTarget
forall a. Maybe a
Prelude.Nothing
    }

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

-- | A log target
logTargetConfiguration_logTarget :: Lens.Lens' LogTargetConfiguration (Prelude.Maybe LogTarget)
logTargetConfiguration_logTarget :: (Maybe LogTarget -> f (Maybe LogTarget))
-> LogTargetConfiguration -> f LogTargetConfiguration
logTargetConfiguration_logTarget = (LogTargetConfiguration -> Maybe LogTarget)
-> (LogTargetConfiguration
    -> Maybe LogTarget -> LogTargetConfiguration)
-> Lens
     LogTargetConfiguration
     LogTargetConfiguration
     (Maybe LogTarget)
     (Maybe LogTarget)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogTargetConfiguration' {Maybe LogTarget
logTarget :: Maybe LogTarget
$sel:logTarget:LogTargetConfiguration' :: LogTargetConfiguration -> Maybe LogTarget
logTarget} -> Maybe LogTarget
logTarget) (\s :: LogTargetConfiguration
s@LogTargetConfiguration' {} Maybe LogTarget
a -> LogTargetConfiguration
s {$sel:logTarget:LogTargetConfiguration' :: Maybe LogTarget
logTarget = Maybe LogTarget
a} :: LogTargetConfiguration)

instance Core.FromJSON LogTargetConfiguration where
  parseJSON :: Value -> Parser LogTargetConfiguration
parseJSON =
    String
-> (Object -> Parser LogTargetConfiguration)
-> Value
-> Parser LogTargetConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LogTargetConfiguration"
      ( \Object
x ->
          Maybe LogLevel -> Maybe LogTarget -> LogTargetConfiguration
LogTargetConfiguration'
            (Maybe LogLevel -> Maybe LogTarget -> LogTargetConfiguration)
-> Parser (Maybe LogLevel)
-> Parser (Maybe LogTarget -> LogTargetConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe LogLevel)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"logLevel")
            Parser (Maybe LogTarget -> LogTargetConfiguration)
-> Parser (Maybe LogTarget) -> Parser LogTargetConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LogTarget)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"logTarget")
      )

instance Prelude.Hashable LogTargetConfiguration

instance Prelude.NFData LogTargetConfiguration