{-# 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.ECS.Types.EFSVolumeConfiguration
-- 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.ECS.Types.EFSVolumeConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECS.Types.EFSAuthorizationConfig
import Amazonka.ECS.Types.EFSTransitEncryption
import qualified Amazonka.Prelude as Prelude

-- | This parameter is specified when you\'re using an Amazon Elastic File
-- System file system for task storage. For more information, see
-- <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-volumes.html Amazon EFS volumes>
-- in the /Amazon Elastic Container Service Developer Guide/.
--
-- /See:/ 'newEFSVolumeConfiguration' smart constructor.
data EFSVolumeConfiguration = EFSVolumeConfiguration'
  { -- | The authorization configuration details for the Amazon EFS file system.
    EFSVolumeConfiguration -> Maybe EFSAuthorizationConfig
authorizationConfig :: Prelude.Maybe EFSAuthorizationConfig,
    -- | The directory within the Amazon EFS file system to mount as the root
    -- directory inside the host. If this parameter is omitted, the root of the
    -- Amazon EFS volume will be used. Specifying @\/@ will have the same
    -- effect as omitting this parameter.
    --
    -- If an EFS access point is specified in the @authorizationConfig@, the
    -- root directory parameter must either be omitted or set to @\/@ which
    -- will enforce the path set on the EFS access point.
    EFSVolumeConfiguration -> Maybe Text
rootDirectory :: Prelude.Maybe Prelude.Text,
    -- | Determines whether to use encryption for Amazon EFS data in transit
    -- between the Amazon ECS host and the Amazon EFS server. Transit
    -- encryption must be enabled if Amazon EFS IAM authorization is used. If
    -- this parameter is omitted, the default value of @DISABLED@ is used. For
    -- more information, see
    -- <https://docs.aws.amazon.com/efs/latest/ug/encryption-in-transit.html Encrypting data in transit>
    -- in the /Amazon Elastic File System User Guide/.
    EFSVolumeConfiguration -> Maybe EFSTransitEncryption
transitEncryption :: Prelude.Maybe EFSTransitEncryption,
    -- | The port to use when sending encrypted data between the Amazon ECS host
    -- and the Amazon EFS server. If you do not specify a transit encryption
    -- port, it will use the port selection strategy that the Amazon EFS mount
    -- helper uses. For more information, see
    -- <https://docs.aws.amazon.com/efs/latest/ug/efs-mount-helper.html EFS mount helper>
    -- in the /Amazon Elastic File System User Guide/.
    EFSVolumeConfiguration -> Maybe Int
transitEncryptionPort :: Prelude.Maybe Prelude.Int,
    -- | The Amazon EFS file system ID to use.
    EFSVolumeConfiguration -> Text
fileSystemId :: Prelude.Text
  }
  deriving (EFSVolumeConfiguration -> EFSVolumeConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EFSVolumeConfiguration -> EFSVolumeConfiguration -> Bool
$c/= :: EFSVolumeConfiguration -> EFSVolumeConfiguration -> Bool
== :: EFSVolumeConfiguration -> EFSVolumeConfiguration -> Bool
$c== :: EFSVolumeConfiguration -> EFSVolumeConfiguration -> Bool
Prelude.Eq, ReadPrec [EFSVolumeConfiguration]
ReadPrec EFSVolumeConfiguration
Int -> ReadS EFSVolumeConfiguration
ReadS [EFSVolumeConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EFSVolumeConfiguration]
$creadListPrec :: ReadPrec [EFSVolumeConfiguration]
readPrec :: ReadPrec EFSVolumeConfiguration
$creadPrec :: ReadPrec EFSVolumeConfiguration
readList :: ReadS [EFSVolumeConfiguration]
$creadList :: ReadS [EFSVolumeConfiguration]
readsPrec :: Int -> ReadS EFSVolumeConfiguration
$creadsPrec :: Int -> ReadS EFSVolumeConfiguration
Prelude.Read, Int -> EFSVolumeConfiguration -> ShowS
[EFSVolumeConfiguration] -> ShowS
EFSVolumeConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EFSVolumeConfiguration] -> ShowS
$cshowList :: [EFSVolumeConfiguration] -> ShowS
show :: EFSVolumeConfiguration -> String
$cshow :: EFSVolumeConfiguration -> String
showsPrec :: Int -> EFSVolumeConfiguration -> ShowS
$cshowsPrec :: Int -> EFSVolumeConfiguration -> ShowS
Prelude.Show, forall x. Rep EFSVolumeConfiguration x -> EFSVolumeConfiguration
forall x. EFSVolumeConfiguration -> Rep EFSVolumeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EFSVolumeConfiguration x -> EFSVolumeConfiguration
$cfrom :: forall x. EFSVolumeConfiguration -> Rep EFSVolumeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EFSVolumeConfiguration' 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:
--
-- 'authorizationConfig', 'eFSVolumeConfiguration_authorizationConfig' - The authorization configuration details for the Amazon EFS file system.
--
-- 'rootDirectory', 'eFSVolumeConfiguration_rootDirectory' - The directory within the Amazon EFS file system to mount as the root
-- directory inside the host. If this parameter is omitted, the root of the
-- Amazon EFS volume will be used. Specifying @\/@ will have the same
-- effect as omitting this parameter.
--
-- If an EFS access point is specified in the @authorizationConfig@, the
-- root directory parameter must either be omitted or set to @\/@ which
-- will enforce the path set on the EFS access point.
--
-- 'transitEncryption', 'eFSVolumeConfiguration_transitEncryption' - Determines whether to use encryption for Amazon EFS data in transit
-- between the Amazon ECS host and the Amazon EFS server. Transit
-- encryption must be enabled if Amazon EFS IAM authorization is used. If
-- this parameter is omitted, the default value of @DISABLED@ is used. For
-- more information, see
-- <https://docs.aws.amazon.com/efs/latest/ug/encryption-in-transit.html Encrypting data in transit>
-- in the /Amazon Elastic File System User Guide/.
--
-- 'transitEncryptionPort', 'eFSVolumeConfiguration_transitEncryptionPort' - The port to use when sending encrypted data between the Amazon ECS host
-- and the Amazon EFS server. If you do not specify a transit encryption
-- port, it will use the port selection strategy that the Amazon EFS mount
-- helper uses. For more information, see
-- <https://docs.aws.amazon.com/efs/latest/ug/efs-mount-helper.html EFS mount helper>
-- in the /Amazon Elastic File System User Guide/.
--
-- 'fileSystemId', 'eFSVolumeConfiguration_fileSystemId' - The Amazon EFS file system ID to use.
newEFSVolumeConfiguration ::
  -- | 'fileSystemId'
  Prelude.Text ->
  EFSVolumeConfiguration
newEFSVolumeConfiguration :: Text -> EFSVolumeConfiguration
newEFSVolumeConfiguration Text
pFileSystemId_ =
  EFSVolumeConfiguration'
    { $sel:authorizationConfig:EFSVolumeConfiguration' :: Maybe EFSAuthorizationConfig
authorizationConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:rootDirectory:EFSVolumeConfiguration' :: Maybe Text
rootDirectory = forall a. Maybe a
Prelude.Nothing,
      $sel:transitEncryption:EFSVolumeConfiguration' :: Maybe EFSTransitEncryption
transitEncryption = forall a. Maybe a
Prelude.Nothing,
      $sel:transitEncryptionPort:EFSVolumeConfiguration' :: Maybe Int
transitEncryptionPort = forall a. Maybe a
Prelude.Nothing,
      $sel:fileSystemId:EFSVolumeConfiguration' :: Text
fileSystemId = Text
pFileSystemId_
    }

-- | The authorization configuration details for the Amazon EFS file system.
eFSVolumeConfiguration_authorizationConfig :: Lens.Lens' EFSVolumeConfiguration (Prelude.Maybe EFSAuthorizationConfig)
eFSVolumeConfiguration_authorizationConfig :: Lens' EFSVolumeConfiguration (Maybe EFSAuthorizationConfig)
eFSVolumeConfiguration_authorizationConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EFSVolumeConfiguration' {Maybe EFSAuthorizationConfig
authorizationConfig :: Maybe EFSAuthorizationConfig
$sel:authorizationConfig:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe EFSAuthorizationConfig
authorizationConfig} -> Maybe EFSAuthorizationConfig
authorizationConfig) (\s :: EFSVolumeConfiguration
s@EFSVolumeConfiguration' {} Maybe EFSAuthorizationConfig
a -> EFSVolumeConfiguration
s {$sel:authorizationConfig:EFSVolumeConfiguration' :: Maybe EFSAuthorizationConfig
authorizationConfig = Maybe EFSAuthorizationConfig
a} :: EFSVolumeConfiguration)

-- | The directory within the Amazon EFS file system to mount as the root
-- directory inside the host. If this parameter is omitted, the root of the
-- Amazon EFS volume will be used. Specifying @\/@ will have the same
-- effect as omitting this parameter.
--
-- If an EFS access point is specified in the @authorizationConfig@, the
-- root directory parameter must either be omitted or set to @\/@ which
-- will enforce the path set on the EFS access point.
eFSVolumeConfiguration_rootDirectory :: Lens.Lens' EFSVolumeConfiguration (Prelude.Maybe Prelude.Text)
eFSVolumeConfiguration_rootDirectory :: Lens' EFSVolumeConfiguration (Maybe Text)
eFSVolumeConfiguration_rootDirectory = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EFSVolumeConfiguration' {Maybe Text
rootDirectory :: Maybe Text
$sel:rootDirectory:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe Text
rootDirectory} -> Maybe Text
rootDirectory) (\s :: EFSVolumeConfiguration
s@EFSVolumeConfiguration' {} Maybe Text
a -> EFSVolumeConfiguration
s {$sel:rootDirectory:EFSVolumeConfiguration' :: Maybe Text
rootDirectory = Maybe Text
a} :: EFSVolumeConfiguration)

-- | Determines whether to use encryption for Amazon EFS data in transit
-- between the Amazon ECS host and the Amazon EFS server. Transit
-- encryption must be enabled if Amazon EFS IAM authorization is used. If
-- this parameter is omitted, the default value of @DISABLED@ is used. For
-- more information, see
-- <https://docs.aws.amazon.com/efs/latest/ug/encryption-in-transit.html Encrypting data in transit>
-- in the /Amazon Elastic File System User Guide/.
eFSVolumeConfiguration_transitEncryption :: Lens.Lens' EFSVolumeConfiguration (Prelude.Maybe EFSTransitEncryption)
eFSVolumeConfiguration_transitEncryption :: Lens' EFSVolumeConfiguration (Maybe EFSTransitEncryption)
eFSVolumeConfiguration_transitEncryption = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EFSVolumeConfiguration' {Maybe EFSTransitEncryption
transitEncryption :: Maybe EFSTransitEncryption
$sel:transitEncryption:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe EFSTransitEncryption
transitEncryption} -> Maybe EFSTransitEncryption
transitEncryption) (\s :: EFSVolumeConfiguration
s@EFSVolumeConfiguration' {} Maybe EFSTransitEncryption
a -> EFSVolumeConfiguration
s {$sel:transitEncryption:EFSVolumeConfiguration' :: Maybe EFSTransitEncryption
transitEncryption = Maybe EFSTransitEncryption
a} :: EFSVolumeConfiguration)

-- | The port to use when sending encrypted data between the Amazon ECS host
-- and the Amazon EFS server. If you do not specify a transit encryption
-- port, it will use the port selection strategy that the Amazon EFS mount
-- helper uses. For more information, see
-- <https://docs.aws.amazon.com/efs/latest/ug/efs-mount-helper.html EFS mount helper>
-- in the /Amazon Elastic File System User Guide/.
eFSVolumeConfiguration_transitEncryptionPort :: Lens.Lens' EFSVolumeConfiguration (Prelude.Maybe Prelude.Int)
eFSVolumeConfiguration_transitEncryptionPort :: Lens' EFSVolumeConfiguration (Maybe Int)
eFSVolumeConfiguration_transitEncryptionPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EFSVolumeConfiguration' {Maybe Int
transitEncryptionPort :: Maybe Int
$sel:transitEncryptionPort:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe Int
transitEncryptionPort} -> Maybe Int
transitEncryptionPort) (\s :: EFSVolumeConfiguration
s@EFSVolumeConfiguration' {} Maybe Int
a -> EFSVolumeConfiguration
s {$sel:transitEncryptionPort:EFSVolumeConfiguration' :: Maybe Int
transitEncryptionPort = Maybe Int
a} :: EFSVolumeConfiguration)

-- | The Amazon EFS file system ID to use.
eFSVolumeConfiguration_fileSystemId :: Lens.Lens' EFSVolumeConfiguration Prelude.Text
eFSVolumeConfiguration_fileSystemId :: Lens' EFSVolumeConfiguration Text
eFSVolumeConfiguration_fileSystemId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EFSVolumeConfiguration' {Text
fileSystemId :: Text
$sel:fileSystemId:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Text
fileSystemId} -> Text
fileSystemId) (\s :: EFSVolumeConfiguration
s@EFSVolumeConfiguration' {} Text
a -> EFSVolumeConfiguration
s {$sel:fileSystemId:EFSVolumeConfiguration' :: Text
fileSystemId = Text
a} :: EFSVolumeConfiguration)

instance Data.FromJSON EFSVolumeConfiguration where
  parseJSON :: Value -> Parser EFSVolumeConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EFSVolumeConfiguration"
      ( \Object
x ->
          Maybe EFSAuthorizationConfig
-> Maybe Text
-> Maybe EFSTransitEncryption
-> Maybe Int
-> Text
-> EFSVolumeConfiguration
EFSVolumeConfiguration'
            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
"authorizationConfig")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"rootDirectory")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"transitEncryption")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"transitEncryptionPort")
            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
"fileSystemId")
      )

instance Prelude.Hashable EFSVolumeConfiguration where
  hashWithSalt :: Int -> EFSVolumeConfiguration -> Int
hashWithSalt Int
_salt EFSVolumeConfiguration' {Maybe Int
Maybe Text
Maybe EFSAuthorizationConfig
Maybe EFSTransitEncryption
Text
fileSystemId :: Text
transitEncryptionPort :: Maybe Int
transitEncryption :: Maybe EFSTransitEncryption
rootDirectory :: Maybe Text
authorizationConfig :: Maybe EFSAuthorizationConfig
$sel:fileSystemId:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Text
$sel:transitEncryptionPort:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe Int
$sel:transitEncryption:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe EFSTransitEncryption
$sel:rootDirectory:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe Text
$sel:authorizationConfig:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe EFSAuthorizationConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EFSAuthorizationConfig
authorizationConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
rootDirectory
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EFSTransitEncryption
transitEncryption
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
transitEncryptionPort
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fileSystemId

instance Prelude.NFData EFSVolumeConfiguration where
  rnf :: EFSVolumeConfiguration -> ()
rnf EFSVolumeConfiguration' {Maybe Int
Maybe Text
Maybe EFSAuthorizationConfig
Maybe EFSTransitEncryption
Text
fileSystemId :: Text
transitEncryptionPort :: Maybe Int
transitEncryption :: Maybe EFSTransitEncryption
rootDirectory :: Maybe Text
authorizationConfig :: Maybe EFSAuthorizationConfig
$sel:fileSystemId:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Text
$sel:transitEncryptionPort:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe Int
$sel:transitEncryption:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe EFSTransitEncryption
$sel:rootDirectory:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe Text
$sel:authorizationConfig:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe EFSAuthorizationConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EFSAuthorizationConfig
authorizationConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
rootDirectory
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EFSTransitEncryption
transitEncryption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
transitEncryptionPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
fileSystemId

instance Data.ToJSON EFSVolumeConfiguration where
  toJSON :: EFSVolumeConfiguration -> Value
toJSON EFSVolumeConfiguration' {Maybe Int
Maybe Text
Maybe EFSAuthorizationConfig
Maybe EFSTransitEncryption
Text
fileSystemId :: Text
transitEncryptionPort :: Maybe Int
transitEncryption :: Maybe EFSTransitEncryption
rootDirectory :: Maybe Text
authorizationConfig :: Maybe EFSAuthorizationConfig
$sel:fileSystemId:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Text
$sel:transitEncryptionPort:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe Int
$sel:transitEncryption:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe EFSTransitEncryption
$sel:rootDirectory:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe Text
$sel:authorizationConfig:EFSVolumeConfiguration' :: EFSVolumeConfiguration -> Maybe EFSAuthorizationConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"authorizationConfig" 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 EFSAuthorizationConfig
authorizationConfig,
            (Key
"rootDirectory" 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 Text
rootDirectory,
            (Key
"transitEncryption" 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 EFSTransitEncryption
transitEncryption,
            (Key
"transitEncryptionPort" 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 Int
transitEncryptionPort,
            forall a. a -> Maybe a
Prelude.Just (Key
"fileSystemId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
fileSystemId)
          ]
      )