{-# 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.Greengrass.Types.GreengrassLogger
-- 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.Greengrass.Types.GreengrassLogger where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.Types.LoggerComponent
import Amazonka.Greengrass.Types.LoggerLevel
import Amazonka.Greengrass.Types.LoggerType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about a logger
--
-- /See:/ 'newGreengrassLogger' smart constructor.
data GreengrassLogger = GreengrassLogger'
  { -- | The amount of file space, in KB, to use if the local file system is used
    -- for logging purposes.
    GreengrassLogger -> Maybe Int
space :: Prelude.Maybe Prelude.Int,
    -- | The type of log output which will be used.
    GreengrassLogger -> LoggerType
type' :: LoggerType,
    -- | The level of the logs.
    GreengrassLogger -> LoggerLevel
level :: LoggerLevel,
    -- | A descriptive or arbitrary ID for the logger. This value must be unique
    -- within the logger definition version. Max length is 128 characters with
    -- pattern \'\'[a-zA-Z0-9:_-]+\'\'.
    GreengrassLogger -> Text
id :: Prelude.Text,
    -- | The component that will be subject to logging.
    GreengrassLogger -> LoggerComponent
component :: LoggerComponent
  }
  deriving (GreengrassLogger -> GreengrassLogger -> Bool
(GreengrassLogger -> GreengrassLogger -> Bool)
-> (GreengrassLogger -> GreengrassLogger -> Bool)
-> Eq GreengrassLogger
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GreengrassLogger -> GreengrassLogger -> Bool
$c/= :: GreengrassLogger -> GreengrassLogger -> Bool
== :: GreengrassLogger -> GreengrassLogger -> Bool
$c== :: GreengrassLogger -> GreengrassLogger -> Bool
Prelude.Eq, ReadPrec [GreengrassLogger]
ReadPrec GreengrassLogger
Int -> ReadS GreengrassLogger
ReadS [GreengrassLogger]
(Int -> ReadS GreengrassLogger)
-> ReadS [GreengrassLogger]
-> ReadPrec GreengrassLogger
-> ReadPrec [GreengrassLogger]
-> Read GreengrassLogger
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GreengrassLogger]
$creadListPrec :: ReadPrec [GreengrassLogger]
readPrec :: ReadPrec GreengrassLogger
$creadPrec :: ReadPrec GreengrassLogger
readList :: ReadS [GreengrassLogger]
$creadList :: ReadS [GreengrassLogger]
readsPrec :: Int -> ReadS GreengrassLogger
$creadsPrec :: Int -> ReadS GreengrassLogger
Prelude.Read, Int -> GreengrassLogger -> ShowS
[GreengrassLogger] -> ShowS
GreengrassLogger -> String
(Int -> GreengrassLogger -> ShowS)
-> (GreengrassLogger -> String)
-> ([GreengrassLogger] -> ShowS)
-> Show GreengrassLogger
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GreengrassLogger] -> ShowS
$cshowList :: [GreengrassLogger] -> ShowS
show :: GreengrassLogger -> String
$cshow :: GreengrassLogger -> String
showsPrec :: Int -> GreengrassLogger -> ShowS
$cshowsPrec :: Int -> GreengrassLogger -> ShowS
Prelude.Show, (forall x. GreengrassLogger -> Rep GreengrassLogger x)
-> (forall x. Rep GreengrassLogger x -> GreengrassLogger)
-> Generic GreengrassLogger
forall x. Rep GreengrassLogger x -> GreengrassLogger
forall x. GreengrassLogger -> Rep GreengrassLogger x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GreengrassLogger x -> GreengrassLogger
$cfrom :: forall x. GreengrassLogger -> Rep GreengrassLogger x
Prelude.Generic)

-- |
-- Create a value of 'GreengrassLogger' 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:
--
-- 'space', 'greengrassLogger_space' - The amount of file space, in KB, to use if the local file system is used
-- for logging purposes.
--
-- 'type'', 'greengrassLogger_type' - The type of log output which will be used.
--
-- 'level', 'greengrassLogger_level' - The level of the logs.
--
-- 'id', 'greengrassLogger_id' - A descriptive or arbitrary ID for the logger. This value must be unique
-- within the logger definition version. Max length is 128 characters with
-- pattern \'\'[a-zA-Z0-9:_-]+\'\'.
--
-- 'component', 'greengrassLogger_component' - The component that will be subject to logging.
newGreengrassLogger ::
  -- | 'type''
  LoggerType ->
  -- | 'level'
  LoggerLevel ->
  -- | 'id'
  Prelude.Text ->
  -- | 'component'
  LoggerComponent ->
  GreengrassLogger
newGreengrassLogger :: LoggerType
-> LoggerLevel -> Text -> LoggerComponent -> GreengrassLogger
newGreengrassLogger LoggerType
pType_ LoggerLevel
pLevel_ Text
pId_ LoggerComponent
pComponent_ =
  GreengrassLogger' :: Maybe Int
-> LoggerType
-> LoggerLevel
-> Text
-> LoggerComponent
-> GreengrassLogger
GreengrassLogger'
    { $sel:space:GreengrassLogger' :: Maybe Int
space = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:type':GreengrassLogger' :: LoggerType
type' = LoggerType
pType_,
      $sel:level:GreengrassLogger' :: LoggerLevel
level = LoggerLevel
pLevel_,
      $sel:id:GreengrassLogger' :: Text
id = Text
pId_,
      $sel:component:GreengrassLogger' :: LoggerComponent
component = LoggerComponent
pComponent_
    }

-- | The amount of file space, in KB, to use if the local file system is used
-- for logging purposes.
greengrassLogger_space :: Lens.Lens' GreengrassLogger (Prelude.Maybe Prelude.Int)
greengrassLogger_space :: (Maybe Int -> f (Maybe Int))
-> GreengrassLogger -> f GreengrassLogger
greengrassLogger_space = (GreengrassLogger -> Maybe Int)
-> (GreengrassLogger -> Maybe Int -> GreengrassLogger)
-> Lens GreengrassLogger GreengrassLogger (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GreengrassLogger' {Maybe Int
space :: Maybe Int
$sel:space:GreengrassLogger' :: GreengrassLogger -> Maybe Int
space} -> Maybe Int
space) (\s :: GreengrassLogger
s@GreengrassLogger' {} Maybe Int
a -> GreengrassLogger
s {$sel:space:GreengrassLogger' :: Maybe Int
space = Maybe Int
a} :: GreengrassLogger)

-- | The type of log output which will be used.
greengrassLogger_type :: Lens.Lens' GreengrassLogger LoggerType
greengrassLogger_type :: (LoggerType -> f LoggerType)
-> GreengrassLogger -> f GreengrassLogger
greengrassLogger_type = (GreengrassLogger -> LoggerType)
-> (GreengrassLogger -> LoggerType -> GreengrassLogger)
-> Lens GreengrassLogger GreengrassLogger LoggerType LoggerType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GreengrassLogger' {LoggerType
type' :: LoggerType
$sel:type':GreengrassLogger' :: GreengrassLogger -> LoggerType
type'} -> LoggerType
type') (\s :: GreengrassLogger
s@GreengrassLogger' {} LoggerType
a -> GreengrassLogger
s {$sel:type':GreengrassLogger' :: LoggerType
type' = LoggerType
a} :: GreengrassLogger)

-- | The level of the logs.
greengrassLogger_level :: Lens.Lens' GreengrassLogger LoggerLevel
greengrassLogger_level :: (LoggerLevel -> f LoggerLevel)
-> GreengrassLogger -> f GreengrassLogger
greengrassLogger_level = (GreengrassLogger -> LoggerLevel)
-> (GreengrassLogger -> LoggerLevel -> GreengrassLogger)
-> Lens GreengrassLogger GreengrassLogger LoggerLevel LoggerLevel
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GreengrassLogger' {LoggerLevel
level :: LoggerLevel
$sel:level:GreengrassLogger' :: GreengrassLogger -> LoggerLevel
level} -> LoggerLevel
level) (\s :: GreengrassLogger
s@GreengrassLogger' {} LoggerLevel
a -> GreengrassLogger
s {$sel:level:GreengrassLogger' :: LoggerLevel
level = LoggerLevel
a} :: GreengrassLogger)

-- | A descriptive or arbitrary ID for the logger. This value must be unique
-- within the logger definition version. Max length is 128 characters with
-- pattern \'\'[a-zA-Z0-9:_-]+\'\'.
greengrassLogger_id :: Lens.Lens' GreengrassLogger Prelude.Text
greengrassLogger_id :: (Text -> f Text) -> GreengrassLogger -> f GreengrassLogger
greengrassLogger_id = (GreengrassLogger -> Text)
-> (GreengrassLogger -> Text -> GreengrassLogger)
-> Lens GreengrassLogger GreengrassLogger Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GreengrassLogger' {Text
id :: Text
$sel:id:GreengrassLogger' :: GreengrassLogger -> Text
id} -> Text
id) (\s :: GreengrassLogger
s@GreengrassLogger' {} Text
a -> GreengrassLogger
s {$sel:id:GreengrassLogger' :: Text
id = Text
a} :: GreengrassLogger)

-- | The component that will be subject to logging.
greengrassLogger_component :: Lens.Lens' GreengrassLogger LoggerComponent
greengrassLogger_component :: (LoggerComponent -> f LoggerComponent)
-> GreengrassLogger -> f GreengrassLogger
greengrassLogger_component = (GreengrassLogger -> LoggerComponent)
-> (GreengrassLogger -> LoggerComponent -> GreengrassLogger)
-> Lens
     GreengrassLogger GreengrassLogger LoggerComponent LoggerComponent
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GreengrassLogger' {LoggerComponent
component :: LoggerComponent
$sel:component:GreengrassLogger' :: GreengrassLogger -> LoggerComponent
component} -> LoggerComponent
component) (\s :: GreengrassLogger
s@GreengrassLogger' {} LoggerComponent
a -> GreengrassLogger
s {$sel:component:GreengrassLogger' :: LoggerComponent
component = LoggerComponent
a} :: GreengrassLogger)

instance Core.FromJSON GreengrassLogger where
  parseJSON :: Value -> Parser GreengrassLogger
parseJSON =
    String
-> (Object -> Parser GreengrassLogger)
-> Value
-> Parser GreengrassLogger
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GreengrassLogger"
      ( \Object
x ->
          Maybe Int
-> LoggerType
-> LoggerLevel
-> Text
-> LoggerComponent
-> GreengrassLogger
GreengrassLogger'
            (Maybe Int
 -> LoggerType
 -> LoggerLevel
 -> Text
 -> LoggerComponent
 -> GreengrassLogger)
-> Parser (Maybe Int)
-> Parser
     (LoggerType
      -> LoggerLevel -> Text -> LoggerComponent -> GreengrassLogger)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Space")
            Parser
  (LoggerType
   -> LoggerLevel -> Text -> LoggerComponent -> GreengrassLogger)
-> Parser LoggerType
-> Parser
     (LoggerLevel -> Text -> LoggerComponent -> GreengrassLogger)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser LoggerType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
            Parser (LoggerLevel -> Text -> LoggerComponent -> GreengrassLogger)
-> Parser LoggerLevel
-> Parser (Text -> LoggerComponent -> GreengrassLogger)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser LoggerLevel
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Level")
            Parser (Text -> LoggerComponent -> GreengrassLogger)
-> Parser Text -> Parser (LoggerComponent -> GreengrassLogger)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
            Parser (LoggerComponent -> GreengrassLogger)
-> Parser LoggerComponent -> Parser GreengrassLogger
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser LoggerComponent
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Component")
      )

instance Prelude.Hashable GreengrassLogger

instance Prelude.NFData GreengrassLogger

instance Core.ToJSON GreengrassLogger where
  toJSON :: GreengrassLogger -> Value
toJSON GreengrassLogger' {Maybe Int
Text
LoggerComponent
LoggerLevel
LoggerType
component :: LoggerComponent
id :: Text
level :: LoggerLevel
type' :: LoggerType
space :: Maybe Int
$sel:component:GreengrassLogger' :: GreengrassLogger -> LoggerComponent
$sel:id:GreengrassLogger' :: GreengrassLogger -> Text
$sel:level:GreengrassLogger' :: GreengrassLogger -> LoggerLevel
$sel:type':GreengrassLogger' :: GreengrassLogger -> LoggerType
$sel:space:GreengrassLogger' :: GreengrassLogger -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Space" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
space,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> LoggerType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LoggerType
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Level" Text -> LoggerLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LoggerLevel
level),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Component" Text -> LoggerComponent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LoggerComponent
component)
          ]
      )