{-# 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.Lambda.Types.FileSystemConfig
-- 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.Lambda.Types.FileSystemConfig where

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

-- | Details about the connection between a Lambda function and an
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-filesystem.html Amazon EFS file system>.
--
-- /See:/ 'newFileSystemConfig' smart constructor.
data FileSystemConfig = FileSystemConfig'
  { -- | The Amazon Resource Name (ARN) of the Amazon EFS access point that
    -- provides access to the file system.
    FileSystemConfig -> Text
arn :: Prelude.Text,
    -- | The path where the function can access the file system, starting with
    -- @\/mnt\/@.
    FileSystemConfig -> Text
localMountPath :: Prelude.Text
  }
  deriving (FileSystemConfig -> FileSystemConfig -> Bool
(FileSystemConfig -> FileSystemConfig -> Bool)
-> (FileSystemConfig -> FileSystemConfig -> Bool)
-> Eq FileSystemConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileSystemConfig -> FileSystemConfig -> Bool
$c/= :: FileSystemConfig -> FileSystemConfig -> Bool
== :: FileSystemConfig -> FileSystemConfig -> Bool
$c== :: FileSystemConfig -> FileSystemConfig -> Bool
Prelude.Eq, ReadPrec [FileSystemConfig]
ReadPrec FileSystemConfig
Int -> ReadS FileSystemConfig
ReadS [FileSystemConfig]
(Int -> ReadS FileSystemConfig)
-> ReadS [FileSystemConfig]
-> ReadPrec FileSystemConfig
-> ReadPrec [FileSystemConfig]
-> Read FileSystemConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileSystemConfig]
$creadListPrec :: ReadPrec [FileSystemConfig]
readPrec :: ReadPrec FileSystemConfig
$creadPrec :: ReadPrec FileSystemConfig
readList :: ReadS [FileSystemConfig]
$creadList :: ReadS [FileSystemConfig]
readsPrec :: Int -> ReadS FileSystemConfig
$creadsPrec :: Int -> ReadS FileSystemConfig
Prelude.Read, Int -> FileSystemConfig -> ShowS
[FileSystemConfig] -> ShowS
FileSystemConfig -> String
(Int -> FileSystemConfig -> ShowS)
-> (FileSystemConfig -> String)
-> ([FileSystemConfig] -> ShowS)
-> Show FileSystemConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileSystemConfig] -> ShowS
$cshowList :: [FileSystemConfig] -> ShowS
show :: FileSystemConfig -> String
$cshow :: FileSystemConfig -> String
showsPrec :: Int -> FileSystemConfig -> ShowS
$cshowsPrec :: Int -> FileSystemConfig -> ShowS
Prelude.Show, (forall x. FileSystemConfig -> Rep FileSystemConfig x)
-> (forall x. Rep FileSystemConfig x -> FileSystemConfig)
-> Generic FileSystemConfig
forall x. Rep FileSystemConfig x -> FileSystemConfig
forall x. FileSystemConfig -> Rep FileSystemConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FileSystemConfig x -> FileSystemConfig
$cfrom :: forall x. FileSystemConfig -> Rep FileSystemConfig x
Prelude.Generic)

-- |
-- Create a value of 'FileSystemConfig' 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:
--
-- 'arn', 'fileSystemConfig_arn' - The Amazon Resource Name (ARN) of the Amazon EFS access point that
-- provides access to the file system.
--
-- 'localMountPath', 'fileSystemConfig_localMountPath' - The path where the function can access the file system, starting with
-- @\/mnt\/@.
newFileSystemConfig ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'localMountPath'
  Prelude.Text ->
  FileSystemConfig
newFileSystemConfig :: Text -> Text -> FileSystemConfig
newFileSystemConfig Text
pArn_ Text
pLocalMountPath_ =
  FileSystemConfig' :: Text -> Text -> FileSystemConfig
FileSystemConfig'
    { $sel:arn:FileSystemConfig' :: Text
arn = Text
pArn_,
      $sel:localMountPath:FileSystemConfig' :: Text
localMountPath = Text
pLocalMountPath_
    }

-- | The Amazon Resource Name (ARN) of the Amazon EFS access point that
-- provides access to the file system.
fileSystemConfig_arn :: Lens.Lens' FileSystemConfig Prelude.Text
fileSystemConfig_arn :: (Text -> f Text) -> FileSystemConfig -> f FileSystemConfig
fileSystemConfig_arn = (FileSystemConfig -> Text)
-> (FileSystemConfig -> Text -> FileSystemConfig)
-> Lens FileSystemConfig FileSystemConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileSystemConfig' {Text
arn :: Text
$sel:arn:FileSystemConfig' :: FileSystemConfig -> Text
arn} -> Text
arn) (\s :: FileSystemConfig
s@FileSystemConfig' {} Text
a -> FileSystemConfig
s {$sel:arn:FileSystemConfig' :: Text
arn = Text
a} :: FileSystemConfig)

-- | The path where the function can access the file system, starting with
-- @\/mnt\/@.
fileSystemConfig_localMountPath :: Lens.Lens' FileSystemConfig Prelude.Text
fileSystemConfig_localMountPath :: (Text -> f Text) -> FileSystemConfig -> f FileSystemConfig
fileSystemConfig_localMountPath = (FileSystemConfig -> Text)
-> (FileSystemConfig -> Text -> FileSystemConfig)
-> Lens FileSystemConfig FileSystemConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileSystemConfig' {Text
localMountPath :: Text
$sel:localMountPath:FileSystemConfig' :: FileSystemConfig -> Text
localMountPath} -> Text
localMountPath) (\s :: FileSystemConfig
s@FileSystemConfig' {} Text
a -> FileSystemConfig
s {$sel:localMountPath:FileSystemConfig' :: Text
localMountPath = Text
a} :: FileSystemConfig)

instance Core.FromJSON FileSystemConfig where
  parseJSON :: Value -> Parser FileSystemConfig
parseJSON =
    String
-> (Object -> Parser FileSystemConfig)
-> Value
-> Parser FileSystemConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FileSystemConfig"
      ( \Object
x ->
          Text -> Text -> FileSystemConfig
FileSystemConfig'
            (Text -> Text -> FileSystemConfig)
-> Parser Text -> Parser (Text -> FileSystemConfig)
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
"Arn")
            Parser (Text -> FileSystemConfig)
-> Parser Text -> Parser FileSystemConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"LocalMountPath")
      )

instance Prelude.Hashable FileSystemConfig

instance Prelude.NFData FileSystemConfig

instance Core.ToJSON FileSystemConfig where
  toJSON :: FileSystemConfig -> Value
toJSON FileSystemConfig' {Text
localMountPath :: Text
arn :: Text
$sel:localMountPath:FileSystemConfig' :: FileSystemConfig -> Text
$sel:arn:FileSystemConfig' :: FileSystemConfig -> 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
"Arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"LocalMountPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
localMountPath)
          ]
      )