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

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

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

-- |
-- Create a value of 'VirtualGatewayLogging' 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', 'virtualGatewayLogging_accessLog' - The access log configuration.
newVirtualGatewayLogging ::
  VirtualGatewayLogging
newVirtualGatewayLogging :: VirtualGatewayLogging
newVirtualGatewayLogging =
  VirtualGatewayLogging' :: Maybe VirtualGatewayAccessLog -> VirtualGatewayLogging
VirtualGatewayLogging' {$sel:accessLog:VirtualGatewayLogging' :: Maybe VirtualGatewayAccessLog
accessLog = Maybe VirtualGatewayAccessLog
forall a. Maybe a
Prelude.Nothing}

-- | The access log configuration.
virtualGatewayLogging_accessLog :: Lens.Lens' VirtualGatewayLogging (Prelude.Maybe VirtualGatewayAccessLog)
virtualGatewayLogging_accessLog :: (Maybe VirtualGatewayAccessLog
 -> f (Maybe VirtualGatewayAccessLog))
-> VirtualGatewayLogging -> f VirtualGatewayLogging
virtualGatewayLogging_accessLog = (VirtualGatewayLogging -> Maybe VirtualGatewayAccessLog)
-> (VirtualGatewayLogging
    -> Maybe VirtualGatewayAccessLog -> VirtualGatewayLogging)
-> Lens
     VirtualGatewayLogging
     VirtualGatewayLogging
     (Maybe VirtualGatewayAccessLog)
     (Maybe VirtualGatewayAccessLog)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayLogging' {Maybe VirtualGatewayAccessLog
accessLog :: Maybe VirtualGatewayAccessLog
$sel:accessLog:VirtualGatewayLogging' :: VirtualGatewayLogging -> Maybe VirtualGatewayAccessLog
accessLog} -> Maybe VirtualGatewayAccessLog
accessLog) (\s :: VirtualGatewayLogging
s@VirtualGatewayLogging' {} Maybe VirtualGatewayAccessLog
a -> VirtualGatewayLogging
s {$sel:accessLog:VirtualGatewayLogging' :: Maybe VirtualGatewayAccessLog
accessLog = Maybe VirtualGatewayAccessLog
a} :: VirtualGatewayLogging)

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

instance Prelude.Hashable VirtualGatewayLogging

instance Prelude.NFData VirtualGatewayLogging

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