{-# 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.AppMesh.Types.Logging
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppMesh.Types.Logging where

import Amazonka.AppMesh.Types.AccessLog
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the logging information for a virtual node.
--
-- /See:/ 'newLogging' smart constructor.
data Logging = Logging'
  { -- | The access log configuration for a virtual node.
    Logging -> Maybe AccessLog
accessLog :: Prelude.Maybe AccessLog
  }
  deriving (Logging -> Logging -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Logging -> Logging -> Bool
$c/= :: Logging -> Logging -> Bool
== :: Logging -> Logging -> Bool
$c== :: Logging -> Logging -> Bool
Prelude.Eq, ReadPrec [Logging]
ReadPrec Logging
Int -> ReadS Logging
ReadS [Logging]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Logging]
$creadListPrec :: ReadPrec [Logging]
readPrec :: ReadPrec Logging
$creadPrec :: ReadPrec Logging
readList :: ReadS [Logging]
$creadList :: ReadS [Logging]
readsPrec :: Int -> ReadS Logging
$creadsPrec :: Int -> ReadS Logging
Prelude.Read, Int -> Logging -> ShowS
[Logging] -> ShowS
Logging -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Logging] -> ShowS
$cshowList :: [Logging] -> ShowS
show :: Logging -> String
$cshow :: Logging -> String
showsPrec :: Int -> Logging -> ShowS
$cshowsPrec :: Int -> Logging -> ShowS
Prelude.Show, forall x. Rep Logging x -> Logging
forall x. Logging -> Rep Logging x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Logging x -> Logging
$cfrom :: forall x. Logging -> Rep Logging x
Prelude.Generic)

-- |
-- Create a value of 'Logging' 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:
--
-- 'accessLog', 'logging_accessLog' - The access log configuration for a virtual node.
newLogging ::
  Logging
newLogging :: Logging
newLogging = Logging' {$sel:accessLog:Logging' :: Maybe AccessLog
accessLog = forall a. Maybe a
Prelude.Nothing}

-- | The access log configuration for a virtual node.
logging_accessLog :: Lens.Lens' Logging (Prelude.Maybe AccessLog)
logging_accessLog :: Lens' Logging (Maybe AccessLog)
logging_accessLog = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Logging' {Maybe AccessLog
accessLog :: Maybe AccessLog
$sel:accessLog:Logging' :: Logging -> Maybe AccessLog
accessLog} -> Maybe AccessLog
accessLog) (\s :: Logging
s@Logging' {} Maybe AccessLog
a -> Logging
s {$sel:accessLog:Logging' :: Maybe AccessLog
accessLog = Maybe AccessLog
a} :: Logging)

instance Data.FromJSON Logging where
  parseJSON :: Value -> Parser Logging
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Logging"
      ( \Object
x ->
          Maybe AccessLog -> Logging
Logging' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"accessLog")
      )

instance Prelude.Hashable Logging where
  hashWithSalt :: Int -> Logging -> Int
hashWithSalt Int
_salt Logging' {Maybe AccessLog
accessLog :: Maybe AccessLog
$sel:accessLog:Logging' :: Logging -> Maybe AccessLog
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AccessLog
accessLog

instance Prelude.NFData Logging where
  rnf :: Logging -> ()
rnf Logging' {Maybe AccessLog
accessLog :: Maybe AccessLog
$sel:accessLog:Logging' :: Logging -> Maybe AccessLog
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe AccessLog
accessLog

instance Data.ToJSON Logging where
  toJSON :: Logging -> Value
toJSON Logging' {Maybe AccessLog
accessLog :: Maybe AccessLog
$sel:accessLog:Logging' :: Logging -> Maybe AccessLog
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"accessLog" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AccessLog
accessLog]
      )