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

import Amazonka.AppMesh.Types.LoggingFormat
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 an access log file.
--
-- /See:/ 'newVirtualGatewayFileAccessLog' smart constructor.
data VirtualGatewayFileAccessLog = VirtualGatewayFileAccessLog'
  { -- | The specified format for the virtual gateway access logs. It can be
    -- either @json_format@ or @text_format@.
    VirtualGatewayFileAccessLog -> Maybe LoggingFormat
format :: Prelude.Maybe LoggingFormat,
    -- | The file path to write access logs to. You can use @\/dev\/stdout@ to
    -- send access logs to standard out and configure your Envoy container to
    -- use a log driver, such as @awslogs@, to export the access logs to a log
    -- storage service such as Amazon CloudWatch Logs. You can also specify a
    -- path in the Envoy container\'s file system to write the files to disk.
    VirtualGatewayFileAccessLog -> Text
path :: Prelude.Text
  }
  deriving (VirtualGatewayFileAccessLog -> VirtualGatewayFileAccessLog -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualGatewayFileAccessLog -> VirtualGatewayFileAccessLog -> Bool
$c/= :: VirtualGatewayFileAccessLog -> VirtualGatewayFileAccessLog -> Bool
== :: VirtualGatewayFileAccessLog -> VirtualGatewayFileAccessLog -> Bool
$c== :: VirtualGatewayFileAccessLog -> VirtualGatewayFileAccessLog -> Bool
Prelude.Eq, ReadPrec [VirtualGatewayFileAccessLog]
ReadPrec VirtualGatewayFileAccessLog
Int -> ReadS VirtualGatewayFileAccessLog
ReadS [VirtualGatewayFileAccessLog]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualGatewayFileAccessLog]
$creadListPrec :: ReadPrec [VirtualGatewayFileAccessLog]
readPrec :: ReadPrec VirtualGatewayFileAccessLog
$creadPrec :: ReadPrec VirtualGatewayFileAccessLog
readList :: ReadS [VirtualGatewayFileAccessLog]
$creadList :: ReadS [VirtualGatewayFileAccessLog]
readsPrec :: Int -> ReadS VirtualGatewayFileAccessLog
$creadsPrec :: Int -> ReadS VirtualGatewayFileAccessLog
Prelude.Read, Int -> VirtualGatewayFileAccessLog -> ShowS
[VirtualGatewayFileAccessLog] -> ShowS
VirtualGatewayFileAccessLog -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualGatewayFileAccessLog] -> ShowS
$cshowList :: [VirtualGatewayFileAccessLog] -> ShowS
show :: VirtualGatewayFileAccessLog -> String
$cshow :: VirtualGatewayFileAccessLog -> String
showsPrec :: Int -> VirtualGatewayFileAccessLog -> ShowS
$cshowsPrec :: Int -> VirtualGatewayFileAccessLog -> ShowS
Prelude.Show, forall x.
Rep VirtualGatewayFileAccessLog x -> VirtualGatewayFileAccessLog
forall x.
VirtualGatewayFileAccessLog -> Rep VirtualGatewayFileAccessLog x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep VirtualGatewayFileAccessLog x -> VirtualGatewayFileAccessLog
$cfrom :: forall x.
VirtualGatewayFileAccessLog -> Rep VirtualGatewayFileAccessLog x
Prelude.Generic)

-- |
-- Create a value of 'VirtualGatewayFileAccessLog' 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:
--
-- 'format', 'virtualGatewayFileAccessLog_format' - The specified format for the virtual gateway access logs. It can be
-- either @json_format@ or @text_format@.
--
-- 'path', 'virtualGatewayFileAccessLog_path' - The file path to write access logs to. You can use @\/dev\/stdout@ to
-- send access logs to standard out and configure your Envoy container to
-- use a log driver, such as @awslogs@, to export the access logs to a log
-- storage service such as Amazon CloudWatch Logs. You can also specify a
-- path in the Envoy container\'s file system to write the files to disk.
newVirtualGatewayFileAccessLog ::
  -- | 'path'
  Prelude.Text ->
  VirtualGatewayFileAccessLog
newVirtualGatewayFileAccessLog :: Text -> VirtualGatewayFileAccessLog
newVirtualGatewayFileAccessLog Text
pPath_ =
  VirtualGatewayFileAccessLog'
    { $sel:format:VirtualGatewayFileAccessLog' :: Maybe LoggingFormat
format =
        forall a. Maybe a
Prelude.Nothing,
      $sel:path:VirtualGatewayFileAccessLog' :: Text
path = Text
pPath_
    }

-- | The specified format for the virtual gateway access logs. It can be
-- either @json_format@ or @text_format@.
virtualGatewayFileAccessLog_format :: Lens.Lens' VirtualGatewayFileAccessLog (Prelude.Maybe LoggingFormat)
virtualGatewayFileAccessLog_format :: Lens' VirtualGatewayFileAccessLog (Maybe LoggingFormat)
virtualGatewayFileAccessLog_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayFileAccessLog' {Maybe LoggingFormat
format :: Maybe LoggingFormat
$sel:format:VirtualGatewayFileAccessLog' :: VirtualGatewayFileAccessLog -> Maybe LoggingFormat
format} -> Maybe LoggingFormat
format) (\s :: VirtualGatewayFileAccessLog
s@VirtualGatewayFileAccessLog' {} Maybe LoggingFormat
a -> VirtualGatewayFileAccessLog
s {$sel:format:VirtualGatewayFileAccessLog' :: Maybe LoggingFormat
format = Maybe LoggingFormat
a} :: VirtualGatewayFileAccessLog)

-- | The file path to write access logs to. You can use @\/dev\/stdout@ to
-- send access logs to standard out and configure your Envoy container to
-- use a log driver, such as @awslogs@, to export the access logs to a log
-- storage service such as Amazon CloudWatch Logs. You can also specify a
-- path in the Envoy container\'s file system to write the files to disk.
virtualGatewayFileAccessLog_path :: Lens.Lens' VirtualGatewayFileAccessLog Prelude.Text
virtualGatewayFileAccessLog_path :: Lens' VirtualGatewayFileAccessLog Text
virtualGatewayFileAccessLog_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayFileAccessLog' {Text
path :: Text
$sel:path:VirtualGatewayFileAccessLog' :: VirtualGatewayFileAccessLog -> Text
path} -> Text
path) (\s :: VirtualGatewayFileAccessLog
s@VirtualGatewayFileAccessLog' {} Text
a -> VirtualGatewayFileAccessLog
s {$sel:path:VirtualGatewayFileAccessLog' :: Text
path = Text
a} :: VirtualGatewayFileAccessLog)

instance Data.FromJSON VirtualGatewayFileAccessLog where
  parseJSON :: Value -> Parser VirtualGatewayFileAccessLog
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VirtualGatewayFileAccessLog"
      ( \Object
x ->
          Maybe LoggingFormat -> Text -> VirtualGatewayFileAccessLog
VirtualGatewayFileAccessLog'
            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
"format")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"path")
      )

instance Prelude.Hashable VirtualGatewayFileAccessLog where
  hashWithSalt :: Int -> VirtualGatewayFileAccessLog -> Int
hashWithSalt Int
_salt VirtualGatewayFileAccessLog' {Maybe LoggingFormat
Text
path :: Text
format :: Maybe LoggingFormat
$sel:path:VirtualGatewayFileAccessLog' :: VirtualGatewayFileAccessLog -> Text
$sel:format:VirtualGatewayFileAccessLog' :: VirtualGatewayFileAccessLog -> Maybe LoggingFormat
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LoggingFormat
format
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
path

instance Prelude.NFData VirtualGatewayFileAccessLog where
  rnf :: VirtualGatewayFileAccessLog -> ()
rnf VirtualGatewayFileAccessLog' {Maybe LoggingFormat
Text
path :: Text
format :: Maybe LoggingFormat
$sel:path:VirtualGatewayFileAccessLog' :: VirtualGatewayFileAccessLog -> Text
$sel:format:VirtualGatewayFileAccessLog' :: VirtualGatewayFileAccessLog -> Maybe LoggingFormat
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe LoggingFormat
format seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
path

instance Data.ToJSON VirtualGatewayFileAccessLog where
  toJSON :: VirtualGatewayFileAccessLog -> Value
toJSON VirtualGatewayFileAccessLog' {Maybe LoggingFormat
Text
path :: Text
format :: Maybe LoggingFormat
$sel:path:VirtualGatewayFileAccessLog' :: VirtualGatewayFileAccessLog -> Text
$sel:format:VirtualGatewayFileAccessLog' :: VirtualGatewayFileAccessLog -> Maybe LoggingFormat
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"format" 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 LoggingFormat
format,
            forall a. a -> Maybe a
Prelude.Just (Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
path)
          ]
      )