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

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.Types.GreengrassLogger
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about a logger definition version.
--
-- /See:/ 'newLoggerDefinitionVersion' smart constructor.
data LoggerDefinitionVersion = LoggerDefinitionVersion'
  { -- | A list of loggers.
    LoggerDefinitionVersion -> Maybe [GreengrassLogger]
loggers :: Prelude.Maybe [GreengrassLogger]
  }
  deriving (LoggerDefinitionVersion -> LoggerDefinitionVersion -> Bool
(LoggerDefinitionVersion -> LoggerDefinitionVersion -> Bool)
-> (LoggerDefinitionVersion -> LoggerDefinitionVersion -> Bool)
-> Eq LoggerDefinitionVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoggerDefinitionVersion -> LoggerDefinitionVersion -> Bool
$c/= :: LoggerDefinitionVersion -> LoggerDefinitionVersion -> Bool
== :: LoggerDefinitionVersion -> LoggerDefinitionVersion -> Bool
$c== :: LoggerDefinitionVersion -> LoggerDefinitionVersion -> Bool
Prelude.Eq, ReadPrec [LoggerDefinitionVersion]
ReadPrec LoggerDefinitionVersion
Int -> ReadS LoggerDefinitionVersion
ReadS [LoggerDefinitionVersion]
(Int -> ReadS LoggerDefinitionVersion)
-> ReadS [LoggerDefinitionVersion]
-> ReadPrec LoggerDefinitionVersion
-> ReadPrec [LoggerDefinitionVersion]
-> Read LoggerDefinitionVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoggerDefinitionVersion]
$creadListPrec :: ReadPrec [LoggerDefinitionVersion]
readPrec :: ReadPrec LoggerDefinitionVersion
$creadPrec :: ReadPrec LoggerDefinitionVersion
readList :: ReadS [LoggerDefinitionVersion]
$creadList :: ReadS [LoggerDefinitionVersion]
readsPrec :: Int -> ReadS LoggerDefinitionVersion
$creadsPrec :: Int -> ReadS LoggerDefinitionVersion
Prelude.Read, Int -> LoggerDefinitionVersion -> ShowS
[LoggerDefinitionVersion] -> ShowS
LoggerDefinitionVersion -> String
(Int -> LoggerDefinitionVersion -> ShowS)
-> (LoggerDefinitionVersion -> String)
-> ([LoggerDefinitionVersion] -> ShowS)
-> Show LoggerDefinitionVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoggerDefinitionVersion] -> ShowS
$cshowList :: [LoggerDefinitionVersion] -> ShowS
show :: LoggerDefinitionVersion -> String
$cshow :: LoggerDefinitionVersion -> String
showsPrec :: Int -> LoggerDefinitionVersion -> ShowS
$cshowsPrec :: Int -> LoggerDefinitionVersion -> ShowS
Prelude.Show, (forall x.
 LoggerDefinitionVersion -> Rep LoggerDefinitionVersion x)
-> (forall x.
    Rep LoggerDefinitionVersion x -> LoggerDefinitionVersion)
-> Generic LoggerDefinitionVersion
forall x. Rep LoggerDefinitionVersion x -> LoggerDefinitionVersion
forall x. LoggerDefinitionVersion -> Rep LoggerDefinitionVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoggerDefinitionVersion x -> LoggerDefinitionVersion
$cfrom :: forall x. LoggerDefinitionVersion -> Rep LoggerDefinitionVersion x
Prelude.Generic)

-- |
-- Create a value of 'LoggerDefinitionVersion' 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:
--
-- 'loggers', 'loggerDefinitionVersion_loggers' - A list of loggers.
newLoggerDefinitionVersion ::
  LoggerDefinitionVersion
newLoggerDefinitionVersion :: LoggerDefinitionVersion
newLoggerDefinitionVersion =
  LoggerDefinitionVersion' :: Maybe [GreengrassLogger] -> LoggerDefinitionVersion
LoggerDefinitionVersion' {$sel:loggers:LoggerDefinitionVersion' :: Maybe [GreengrassLogger]
loggers = Maybe [GreengrassLogger]
forall a. Maybe a
Prelude.Nothing}

-- | A list of loggers.
loggerDefinitionVersion_loggers :: Lens.Lens' LoggerDefinitionVersion (Prelude.Maybe [GreengrassLogger])
loggerDefinitionVersion_loggers :: (Maybe [GreengrassLogger] -> f (Maybe [GreengrassLogger]))
-> LoggerDefinitionVersion -> f LoggerDefinitionVersion
loggerDefinitionVersion_loggers = (LoggerDefinitionVersion -> Maybe [GreengrassLogger])
-> (LoggerDefinitionVersion
    -> Maybe [GreengrassLogger] -> LoggerDefinitionVersion)
-> Lens
     LoggerDefinitionVersion
     LoggerDefinitionVersion
     (Maybe [GreengrassLogger])
     (Maybe [GreengrassLogger])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggerDefinitionVersion' {Maybe [GreengrassLogger]
loggers :: Maybe [GreengrassLogger]
$sel:loggers:LoggerDefinitionVersion' :: LoggerDefinitionVersion -> Maybe [GreengrassLogger]
loggers} -> Maybe [GreengrassLogger]
loggers) (\s :: LoggerDefinitionVersion
s@LoggerDefinitionVersion' {} Maybe [GreengrassLogger]
a -> LoggerDefinitionVersion
s {$sel:loggers:LoggerDefinitionVersion' :: Maybe [GreengrassLogger]
loggers = Maybe [GreengrassLogger]
a} :: LoggerDefinitionVersion) ((Maybe [GreengrassLogger] -> f (Maybe [GreengrassLogger]))
 -> LoggerDefinitionVersion -> f LoggerDefinitionVersion)
-> ((Maybe [GreengrassLogger] -> f (Maybe [GreengrassLogger]))
    -> Maybe [GreengrassLogger] -> f (Maybe [GreengrassLogger]))
-> (Maybe [GreengrassLogger] -> f (Maybe [GreengrassLogger]))
-> LoggerDefinitionVersion
-> f LoggerDefinitionVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GreengrassLogger]
  [GreengrassLogger]
  [GreengrassLogger]
  [GreengrassLogger]
-> Iso
     (Maybe [GreengrassLogger])
     (Maybe [GreengrassLogger])
     (Maybe [GreengrassLogger])
     (Maybe [GreengrassLogger])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [GreengrassLogger]
  [GreengrassLogger]
  [GreengrassLogger]
  [GreengrassLogger]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON LoggerDefinitionVersion where
  parseJSON :: Value -> Parser LoggerDefinitionVersion
parseJSON =
    String
-> (Object -> Parser LoggerDefinitionVersion)
-> Value
-> Parser LoggerDefinitionVersion
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LoggerDefinitionVersion"
      ( \Object
x ->
          Maybe [GreengrassLogger] -> LoggerDefinitionVersion
LoggerDefinitionVersion'
            (Maybe [GreengrassLogger] -> LoggerDefinitionVersion)
-> Parser (Maybe [GreengrassLogger])
-> Parser LoggerDefinitionVersion
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [GreengrassLogger]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Loggers" Parser (Maybe (Maybe [GreengrassLogger]))
-> Maybe [GreengrassLogger] -> Parser (Maybe [GreengrassLogger])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [GreengrassLogger]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable LoggerDefinitionVersion

instance Prelude.NFData LoggerDefinitionVersion

instance Core.ToJSON LoggerDefinitionVersion where
  toJSON :: LoggerDefinitionVersion -> Value
toJSON LoggerDefinitionVersion' {Maybe [GreengrassLogger]
loggers :: Maybe [GreengrassLogger]
$sel:loggers:LoggerDefinitionVersion' :: LoggerDefinitionVersion -> Maybe [GreengrassLogger]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Loggers" Text -> [GreengrassLogger] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([GreengrassLogger] -> Pair)
-> Maybe [GreengrassLogger] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [GreengrassLogger]
loggers]
      )