{-# 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.EFSAuthorizationConfig
-- 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.EFSAuthorizationConfig 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.EFSAuthorizationConfigIAM
import qualified Amazonka.Prelude as Prelude

-- | The authorization configuration details for the Amazon EFS file system.
--
-- /See:/ 'newEFSAuthorizationConfig' smart constructor.
data EFSAuthorizationConfig = EFSAuthorizationConfig'
  { -- | The Amazon EFS access point ID to use. If an access point is specified,
    -- the root directory value specified in the @EFSVolumeConfiguration@ must
    -- either be omitted or set to @\/@ which will enforce the path set on the
    -- EFS access point. If an access point is used, transit encryption must be
    -- enabled in the @EFSVolumeConfiguration@. For more information, see
    -- <https://docs.aws.amazon.com/efs/latest/ug/efs-access-points.html Working with Amazon EFS access points>
    -- in the /Amazon Elastic File System User Guide/.
    EFSAuthorizationConfig -> Maybe Text
accessPointId :: Prelude.Maybe Prelude.Text,
    -- | Determines whether to use the Amazon ECS task IAM role defined in a task
    -- definition when mounting the Amazon EFS file system. If enabled, transit
    -- encryption must be enabled in the @EFSVolumeConfiguration@. If this
    -- parameter is omitted, the default value of @DISABLED@ is used. For more
    -- information, see
    -- <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-volumes.html#efs-volume-accesspoints Using Amazon EFS access points>
    -- in the /Amazon Elastic Container Service Developer Guide/.
    EFSAuthorizationConfig -> Maybe EFSAuthorizationConfigIAM
iam :: Prelude.Maybe EFSAuthorizationConfigIAM
  }
  deriving (EFSAuthorizationConfig -> EFSAuthorizationConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EFSAuthorizationConfig -> EFSAuthorizationConfig -> Bool
$c/= :: EFSAuthorizationConfig -> EFSAuthorizationConfig -> Bool
== :: EFSAuthorizationConfig -> EFSAuthorizationConfig -> Bool
$c== :: EFSAuthorizationConfig -> EFSAuthorizationConfig -> Bool
Prelude.Eq, ReadPrec [EFSAuthorizationConfig]
ReadPrec EFSAuthorizationConfig
Int -> ReadS EFSAuthorizationConfig
ReadS [EFSAuthorizationConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EFSAuthorizationConfig]
$creadListPrec :: ReadPrec [EFSAuthorizationConfig]
readPrec :: ReadPrec EFSAuthorizationConfig
$creadPrec :: ReadPrec EFSAuthorizationConfig
readList :: ReadS [EFSAuthorizationConfig]
$creadList :: ReadS [EFSAuthorizationConfig]
readsPrec :: Int -> ReadS EFSAuthorizationConfig
$creadsPrec :: Int -> ReadS EFSAuthorizationConfig
Prelude.Read, Int -> EFSAuthorizationConfig -> ShowS
[EFSAuthorizationConfig] -> ShowS
EFSAuthorizationConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EFSAuthorizationConfig] -> ShowS
$cshowList :: [EFSAuthorizationConfig] -> ShowS
show :: EFSAuthorizationConfig -> String
$cshow :: EFSAuthorizationConfig -> String
showsPrec :: Int -> EFSAuthorizationConfig -> ShowS
$cshowsPrec :: Int -> EFSAuthorizationConfig -> ShowS
Prelude.Show, forall x. Rep EFSAuthorizationConfig x -> EFSAuthorizationConfig
forall x. EFSAuthorizationConfig -> Rep EFSAuthorizationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EFSAuthorizationConfig x -> EFSAuthorizationConfig
$cfrom :: forall x. EFSAuthorizationConfig -> Rep EFSAuthorizationConfig x
Prelude.Generic)

-- |
-- Create a value of 'EFSAuthorizationConfig' 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:
--
-- 'accessPointId', 'eFSAuthorizationConfig_accessPointId' - The Amazon EFS access point ID to use. If an access point is specified,
-- the root directory value specified in the @EFSVolumeConfiguration@ must
-- either be omitted or set to @\/@ which will enforce the path set on the
-- EFS access point. If an access point is used, transit encryption must be
-- enabled in the @EFSVolumeConfiguration@. For more information, see
-- <https://docs.aws.amazon.com/efs/latest/ug/efs-access-points.html Working with Amazon EFS access points>
-- in the /Amazon Elastic File System User Guide/.
--
-- 'iam', 'eFSAuthorizationConfig_iam' - Determines whether to use the Amazon ECS task IAM role defined in a task
-- definition when mounting the Amazon EFS file system. If enabled, transit
-- encryption must be enabled in the @EFSVolumeConfiguration@. If this
-- parameter is omitted, the default value of @DISABLED@ is used. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-volumes.html#efs-volume-accesspoints Using Amazon EFS access points>
-- in the /Amazon Elastic Container Service Developer Guide/.
newEFSAuthorizationConfig ::
  EFSAuthorizationConfig
newEFSAuthorizationConfig :: EFSAuthorizationConfig
newEFSAuthorizationConfig =
  EFSAuthorizationConfig'
    { $sel:accessPointId:EFSAuthorizationConfig' :: Maybe Text
accessPointId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:iam:EFSAuthorizationConfig' :: Maybe EFSAuthorizationConfigIAM
iam = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon EFS access point ID to use. If an access point is specified,
-- the root directory value specified in the @EFSVolumeConfiguration@ must
-- either be omitted or set to @\/@ which will enforce the path set on the
-- EFS access point. If an access point is used, transit encryption must be
-- enabled in the @EFSVolumeConfiguration@. For more information, see
-- <https://docs.aws.amazon.com/efs/latest/ug/efs-access-points.html Working with Amazon EFS access points>
-- in the /Amazon Elastic File System User Guide/.
eFSAuthorizationConfig_accessPointId :: Lens.Lens' EFSAuthorizationConfig (Prelude.Maybe Prelude.Text)
eFSAuthorizationConfig_accessPointId :: Lens' EFSAuthorizationConfig (Maybe Text)
eFSAuthorizationConfig_accessPointId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EFSAuthorizationConfig' {Maybe Text
accessPointId :: Maybe Text
$sel:accessPointId:EFSAuthorizationConfig' :: EFSAuthorizationConfig -> Maybe Text
accessPointId} -> Maybe Text
accessPointId) (\s :: EFSAuthorizationConfig
s@EFSAuthorizationConfig' {} Maybe Text
a -> EFSAuthorizationConfig
s {$sel:accessPointId:EFSAuthorizationConfig' :: Maybe Text
accessPointId = Maybe Text
a} :: EFSAuthorizationConfig)

-- | Determines whether to use the Amazon ECS task IAM role defined in a task
-- definition when mounting the Amazon EFS file system. If enabled, transit
-- encryption must be enabled in the @EFSVolumeConfiguration@. If this
-- parameter is omitted, the default value of @DISABLED@ is used. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-volumes.html#efs-volume-accesspoints Using Amazon EFS access points>
-- in the /Amazon Elastic Container Service Developer Guide/.
eFSAuthorizationConfig_iam :: Lens.Lens' EFSAuthorizationConfig (Prelude.Maybe EFSAuthorizationConfigIAM)
eFSAuthorizationConfig_iam :: Lens' EFSAuthorizationConfig (Maybe EFSAuthorizationConfigIAM)
eFSAuthorizationConfig_iam = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EFSAuthorizationConfig' {Maybe EFSAuthorizationConfigIAM
iam :: Maybe EFSAuthorizationConfigIAM
$sel:iam:EFSAuthorizationConfig' :: EFSAuthorizationConfig -> Maybe EFSAuthorizationConfigIAM
iam} -> Maybe EFSAuthorizationConfigIAM
iam) (\s :: EFSAuthorizationConfig
s@EFSAuthorizationConfig' {} Maybe EFSAuthorizationConfigIAM
a -> EFSAuthorizationConfig
s {$sel:iam:EFSAuthorizationConfig' :: Maybe EFSAuthorizationConfigIAM
iam = Maybe EFSAuthorizationConfigIAM
a} :: EFSAuthorizationConfig)

instance Data.FromJSON EFSAuthorizationConfig where
  parseJSON :: Value -> Parser EFSAuthorizationConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EFSAuthorizationConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe EFSAuthorizationConfigIAM -> EFSAuthorizationConfig
EFSAuthorizationConfig'
            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
"accessPointId")
            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
"iam")
      )

instance Prelude.Hashable EFSAuthorizationConfig where
  hashWithSalt :: Int -> EFSAuthorizationConfig -> Int
hashWithSalt Int
_salt EFSAuthorizationConfig' {Maybe Text
Maybe EFSAuthorizationConfigIAM
iam :: Maybe EFSAuthorizationConfigIAM
accessPointId :: Maybe Text
$sel:iam:EFSAuthorizationConfig' :: EFSAuthorizationConfig -> Maybe EFSAuthorizationConfigIAM
$sel:accessPointId:EFSAuthorizationConfig' :: EFSAuthorizationConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accessPointId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EFSAuthorizationConfigIAM
iam

instance Prelude.NFData EFSAuthorizationConfig where
  rnf :: EFSAuthorizationConfig -> ()
rnf EFSAuthorizationConfig' {Maybe Text
Maybe EFSAuthorizationConfigIAM
iam :: Maybe EFSAuthorizationConfigIAM
accessPointId :: Maybe Text
$sel:iam:EFSAuthorizationConfig' :: EFSAuthorizationConfig -> Maybe EFSAuthorizationConfigIAM
$sel:accessPointId:EFSAuthorizationConfig' :: EFSAuthorizationConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accessPointId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EFSAuthorizationConfigIAM
iam

instance Data.ToJSON EFSAuthorizationConfig where
  toJSON :: EFSAuthorizationConfig -> Value
toJSON EFSAuthorizationConfig' {Maybe Text
Maybe EFSAuthorizationConfigIAM
iam :: Maybe EFSAuthorizationConfigIAM
accessPointId :: Maybe Text
$sel:iam:EFSAuthorizationConfig' :: EFSAuthorizationConfig -> Maybe EFSAuthorizationConfigIAM
$sel:accessPointId:EFSAuthorizationConfig' :: EFSAuthorizationConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"accessPointId" 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
accessPointId,
            (Key
"iam" 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 EFSAuthorizationConfigIAM
iam
          ]
      )