{-# 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.AccessLog
-- 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.AppMesh.Types.AccessLog where

import Amazonka.AppMesh.Types.FileAccessLog
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'AccessLog' 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:
--
-- 'file', 'accessLog_file' - The file object to send virtual node access logs to.
newAccessLog ::
  AccessLog
newAccessLog :: AccessLog
newAccessLog = AccessLog' :: Maybe FileAccessLog -> AccessLog
AccessLog' {$sel:file:AccessLog' :: Maybe FileAccessLog
file = Maybe FileAccessLog
forall a. Maybe a
Prelude.Nothing}

-- | The file object to send virtual node access logs to.
accessLog_file :: Lens.Lens' AccessLog (Prelude.Maybe FileAccessLog)
accessLog_file :: (Maybe FileAccessLog -> f (Maybe FileAccessLog))
-> AccessLog -> f AccessLog
accessLog_file = (AccessLog -> Maybe FileAccessLog)
-> (AccessLog -> Maybe FileAccessLog -> AccessLog)
-> Lens
     AccessLog AccessLog (Maybe FileAccessLog) (Maybe FileAccessLog)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessLog' {Maybe FileAccessLog
file :: Maybe FileAccessLog
$sel:file:AccessLog' :: AccessLog -> Maybe FileAccessLog
file} -> Maybe FileAccessLog
file) (\s :: AccessLog
s@AccessLog' {} Maybe FileAccessLog
a -> AccessLog
s {$sel:file:AccessLog' :: Maybe FileAccessLog
file = Maybe FileAccessLog
a} :: AccessLog)

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

instance Prelude.Hashable AccessLog

instance Prelude.NFData AccessLog

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