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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents an access log file.
--
-- /See:/ 'newFileAccessLog' smart constructor.
data FileAccessLog = FileAccessLog'
  { -- | 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.
    --
    -- The Envoy process must have write permissions to the path that you
    -- specify here. Otherwise, Envoy fails to bootstrap properly.
    FileAccessLog -> Text
path :: Prelude.Text
  }
  deriving (FileAccessLog -> FileAccessLog -> Bool
(FileAccessLog -> FileAccessLog -> Bool)
-> (FileAccessLog -> FileAccessLog -> Bool) -> Eq FileAccessLog
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileAccessLog -> FileAccessLog -> Bool
$c/= :: FileAccessLog -> FileAccessLog -> Bool
== :: FileAccessLog -> FileAccessLog -> Bool
$c== :: FileAccessLog -> FileAccessLog -> Bool
Prelude.Eq, ReadPrec [FileAccessLog]
ReadPrec FileAccessLog
Int -> ReadS FileAccessLog
ReadS [FileAccessLog]
(Int -> ReadS FileAccessLog)
-> ReadS [FileAccessLog]
-> ReadPrec FileAccessLog
-> ReadPrec [FileAccessLog]
-> Read FileAccessLog
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileAccessLog]
$creadListPrec :: ReadPrec [FileAccessLog]
readPrec :: ReadPrec FileAccessLog
$creadPrec :: ReadPrec FileAccessLog
readList :: ReadS [FileAccessLog]
$creadList :: ReadS [FileAccessLog]
readsPrec :: Int -> ReadS FileAccessLog
$creadsPrec :: Int -> ReadS FileAccessLog
Prelude.Read, Int -> FileAccessLog -> ShowS
[FileAccessLog] -> ShowS
FileAccessLog -> String
(Int -> FileAccessLog -> ShowS)
-> (FileAccessLog -> String)
-> ([FileAccessLog] -> ShowS)
-> Show FileAccessLog
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileAccessLog] -> ShowS
$cshowList :: [FileAccessLog] -> ShowS
show :: FileAccessLog -> String
$cshow :: FileAccessLog -> String
showsPrec :: Int -> FileAccessLog -> ShowS
$cshowsPrec :: Int -> FileAccessLog -> ShowS
Prelude.Show, (forall x. FileAccessLog -> Rep FileAccessLog x)
-> (forall x. Rep FileAccessLog x -> FileAccessLog)
-> Generic FileAccessLog
forall x. Rep FileAccessLog x -> FileAccessLog
forall x. FileAccessLog -> Rep FileAccessLog x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FileAccessLog x -> FileAccessLog
$cfrom :: forall x. FileAccessLog -> Rep FileAccessLog x
Prelude.Generic)

-- |
-- Create a value of 'FileAccessLog' 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:
--
-- 'path', 'fileAccessLog_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.
--
-- The Envoy process must have write permissions to the path that you
-- specify here. Otherwise, Envoy fails to bootstrap properly.
newFileAccessLog ::
  -- | 'path'
  Prelude.Text ->
  FileAccessLog
newFileAccessLog :: Text -> FileAccessLog
newFileAccessLog Text
pPath_ =
  FileAccessLog' :: Text -> FileAccessLog
FileAccessLog' {$sel:path:FileAccessLog' :: Text
path = Text
pPath_}

-- | 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.
--
-- The Envoy process must have write permissions to the path that you
-- specify here. Otherwise, Envoy fails to bootstrap properly.
fileAccessLog_path :: Lens.Lens' FileAccessLog Prelude.Text
fileAccessLog_path :: (Text -> f Text) -> FileAccessLog -> f FileAccessLog
fileAccessLog_path = (FileAccessLog -> Text)
-> (FileAccessLog -> Text -> FileAccessLog)
-> Lens FileAccessLog FileAccessLog Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileAccessLog' {Text
path :: Text
$sel:path:FileAccessLog' :: FileAccessLog -> Text
path} -> Text
path) (\s :: FileAccessLog
s@FileAccessLog' {} Text
a -> FileAccessLog
s {$sel:path:FileAccessLog' :: Text
path = Text
a} :: FileAccessLog)

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

instance Prelude.Hashable FileAccessLog

instance Prelude.NFData FileAccessLog

instance Core.ToJSON FileAccessLog where
  toJSON :: FileAccessLog -> Value
toJSON FileAccessLog' {Text
path :: Text
$sel:path:FileAccessLog' :: FileAccessLog -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"path" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
path)]
      )