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

import qualified Amazonka.Core as Core
import Amazonka.ECS.Types.EFSAuthorizationConfigIAM
import qualified Amazonka.Lens as Lens
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,
    -- | Whether or not 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
(EFSAuthorizationConfig -> EFSAuthorizationConfig -> Bool)
-> (EFSAuthorizationConfig -> EFSAuthorizationConfig -> Bool)
-> Eq EFSAuthorizationConfig
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]
(Int -> ReadS EFSAuthorizationConfig)
-> ReadS [EFSAuthorizationConfig]
-> ReadPrec EFSAuthorizationConfig
-> ReadPrec [EFSAuthorizationConfig]
-> Read 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
(Int -> EFSAuthorizationConfig -> ShowS)
-> (EFSAuthorizationConfig -> String)
-> ([EFSAuthorizationConfig] -> ShowS)
-> Show EFSAuthorizationConfig
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. EFSAuthorizationConfig -> Rep EFSAuthorizationConfig x)
-> (forall x.
    Rep EFSAuthorizationConfig x -> EFSAuthorizationConfig)
-> Generic EFSAuthorizationConfig
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' - Whether or not 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' :: Maybe Text
-> Maybe EFSAuthorizationConfigIAM -> EFSAuthorizationConfig
EFSAuthorizationConfig'
    { $sel:accessPointId:EFSAuthorizationConfig' :: Maybe Text
accessPointId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iam:EFSAuthorizationConfig' :: Maybe EFSAuthorizationConfigIAM
iam = Maybe EFSAuthorizationConfigIAM
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 :: (Maybe Text -> f (Maybe Text))
-> EFSAuthorizationConfig -> f EFSAuthorizationConfig
eFSAuthorizationConfig_accessPointId = (EFSAuthorizationConfig -> Maybe Text)
-> (EFSAuthorizationConfig -> Maybe Text -> EFSAuthorizationConfig)
-> Lens
     EFSAuthorizationConfig
     EFSAuthorizationConfig
     (Maybe Text)
     (Maybe Text)
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)

-- | Whether or not 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 :: (Maybe EFSAuthorizationConfigIAM
 -> f (Maybe EFSAuthorizationConfigIAM))
-> EFSAuthorizationConfig -> f EFSAuthorizationConfig
eFSAuthorizationConfig_iam = (EFSAuthorizationConfig -> Maybe EFSAuthorizationConfigIAM)
-> (EFSAuthorizationConfig
    -> Maybe EFSAuthorizationConfigIAM -> EFSAuthorizationConfig)
-> Lens
     EFSAuthorizationConfig
     EFSAuthorizationConfig
     (Maybe EFSAuthorizationConfigIAM)
     (Maybe EFSAuthorizationConfigIAM)
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 Core.FromJSON EFSAuthorizationConfig where
  parseJSON :: Value -> Parser EFSAuthorizationConfig
parseJSON =
    String
-> (Object -> Parser EFSAuthorizationConfig)
-> Value
-> Parser EFSAuthorizationConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EFSAuthorizationConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe EFSAuthorizationConfigIAM -> EFSAuthorizationConfig
EFSAuthorizationConfig'
            (Maybe Text
 -> Maybe EFSAuthorizationConfigIAM -> EFSAuthorizationConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe EFSAuthorizationConfigIAM -> EFSAuthorizationConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"accessPointId")
            Parser (Maybe EFSAuthorizationConfigIAM -> EFSAuthorizationConfig)
-> Parser (Maybe EFSAuthorizationConfigIAM)
-> Parser EFSAuthorizationConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EFSAuthorizationConfigIAM)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"iam")
      )

instance Prelude.Hashable EFSAuthorizationConfig

instance Prelude.NFData EFSAuthorizationConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"accessPointId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
accessPointId,
            (Text
"iam" Text -> EFSAuthorizationConfigIAM -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (EFSAuthorizationConfigIAM -> Pair)
-> Maybe EFSAuthorizationConfigIAM -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EFSAuthorizationConfigIAM
iam
          ]
      )