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

import Amazonka.AppMesh.Types.VirtualGatewayFileAccessLog
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

-- | The access log configuration for a virtual gateway.
--
-- /See:/ 'newVirtualGatewayAccessLog' smart constructor.
data VirtualGatewayAccessLog = VirtualGatewayAccessLog'
  { -- | The file object to send virtual gateway access logs to.
    VirtualGatewayAccessLog -> Maybe VirtualGatewayFileAccessLog
file :: Prelude.Maybe VirtualGatewayFileAccessLog
  }
  deriving (VirtualGatewayAccessLog -> VirtualGatewayAccessLog -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualGatewayAccessLog -> VirtualGatewayAccessLog -> Bool
$c/= :: VirtualGatewayAccessLog -> VirtualGatewayAccessLog -> Bool
== :: VirtualGatewayAccessLog -> VirtualGatewayAccessLog -> Bool
$c== :: VirtualGatewayAccessLog -> VirtualGatewayAccessLog -> Bool
Prelude.Eq, ReadPrec [VirtualGatewayAccessLog]
ReadPrec VirtualGatewayAccessLog
Int -> ReadS VirtualGatewayAccessLog
ReadS [VirtualGatewayAccessLog]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualGatewayAccessLog]
$creadListPrec :: ReadPrec [VirtualGatewayAccessLog]
readPrec :: ReadPrec VirtualGatewayAccessLog
$creadPrec :: ReadPrec VirtualGatewayAccessLog
readList :: ReadS [VirtualGatewayAccessLog]
$creadList :: ReadS [VirtualGatewayAccessLog]
readsPrec :: Int -> ReadS VirtualGatewayAccessLog
$creadsPrec :: Int -> ReadS VirtualGatewayAccessLog
Prelude.Read, Int -> VirtualGatewayAccessLog -> ShowS
[VirtualGatewayAccessLog] -> ShowS
VirtualGatewayAccessLog -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualGatewayAccessLog] -> ShowS
$cshowList :: [VirtualGatewayAccessLog] -> ShowS
show :: VirtualGatewayAccessLog -> String
$cshow :: VirtualGatewayAccessLog -> String
showsPrec :: Int -> VirtualGatewayAccessLog -> ShowS
$cshowsPrec :: Int -> VirtualGatewayAccessLog -> ShowS
Prelude.Show, forall x. Rep VirtualGatewayAccessLog x -> VirtualGatewayAccessLog
forall x. VirtualGatewayAccessLog -> Rep VirtualGatewayAccessLog x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VirtualGatewayAccessLog x -> VirtualGatewayAccessLog
$cfrom :: forall x. VirtualGatewayAccessLog -> Rep VirtualGatewayAccessLog x
Prelude.Generic)

-- |
-- Create a value of 'VirtualGatewayAccessLog' 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', 'virtualGatewayAccessLog_file' - The file object to send virtual gateway access logs to.
newVirtualGatewayAccessLog ::
  VirtualGatewayAccessLog
newVirtualGatewayAccessLog :: VirtualGatewayAccessLog
newVirtualGatewayAccessLog =
  VirtualGatewayAccessLog' {$sel:file:VirtualGatewayAccessLog' :: Maybe VirtualGatewayFileAccessLog
file = forall a. Maybe a
Prelude.Nothing}

-- | The file object to send virtual gateway access logs to.
virtualGatewayAccessLog_file :: Lens.Lens' VirtualGatewayAccessLog (Prelude.Maybe VirtualGatewayFileAccessLog)
virtualGatewayAccessLog_file :: Lens' VirtualGatewayAccessLog (Maybe VirtualGatewayFileAccessLog)
virtualGatewayAccessLog_file = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayAccessLog' {Maybe VirtualGatewayFileAccessLog
file :: Maybe VirtualGatewayFileAccessLog
$sel:file:VirtualGatewayAccessLog' :: VirtualGatewayAccessLog -> Maybe VirtualGatewayFileAccessLog
file} -> Maybe VirtualGatewayFileAccessLog
file) (\s :: VirtualGatewayAccessLog
s@VirtualGatewayAccessLog' {} Maybe VirtualGatewayFileAccessLog
a -> VirtualGatewayAccessLog
s {$sel:file:VirtualGatewayAccessLog' :: Maybe VirtualGatewayFileAccessLog
file = Maybe VirtualGatewayFileAccessLog
a} :: VirtualGatewayAccessLog)

instance Data.FromJSON VirtualGatewayAccessLog where
  parseJSON :: Value -> Parser VirtualGatewayAccessLog
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VirtualGatewayAccessLog"
      ( \Object
x ->
          Maybe VirtualGatewayFileAccessLog -> VirtualGatewayAccessLog
VirtualGatewayAccessLog'
            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
"file")
      )

instance Prelude.Hashable VirtualGatewayAccessLog where
  hashWithSalt :: Int -> VirtualGatewayAccessLog -> Int
hashWithSalt Int
_salt VirtualGatewayAccessLog' {Maybe VirtualGatewayFileAccessLog
file :: Maybe VirtualGatewayFileAccessLog
$sel:file:VirtualGatewayAccessLog' :: VirtualGatewayAccessLog -> Maybe VirtualGatewayFileAccessLog
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VirtualGatewayFileAccessLog
file

instance Prelude.NFData VirtualGatewayAccessLog where
  rnf :: VirtualGatewayAccessLog -> ()
rnf VirtualGatewayAccessLog' {Maybe VirtualGatewayFileAccessLog
file :: Maybe VirtualGatewayFileAccessLog
$sel:file:VirtualGatewayAccessLog' :: VirtualGatewayAccessLog -> Maybe VirtualGatewayFileAccessLog
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe VirtualGatewayFileAccessLog
file

instance Data.ToJSON VirtualGatewayAccessLog where
  toJSON :: VirtualGatewayAccessLog -> Value
toJSON VirtualGatewayAccessLog' {Maybe VirtualGatewayFileAccessLog
file :: Maybe VirtualGatewayFileAccessLog
$sel:file:VirtualGatewayAccessLog' :: VirtualGatewayAccessLog -> Maybe VirtualGatewayFileAccessLog
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"file" 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 VirtualGatewayFileAccessLog
file]
      )