{-# 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.LakeFormation.Types.BatchPermissionsRequestEntry
-- 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.LakeFormation.Types.BatchPermissionsRequestEntry where

import qualified Amazonka.Core as Core
import Amazonka.LakeFormation.Types.DataLakePrincipal
import Amazonka.LakeFormation.Types.Permission
import Amazonka.LakeFormation.Types.Resource
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A permission to a resource granted by batch operation to the principal.
--
-- /See:/ 'newBatchPermissionsRequestEntry' smart constructor.
data BatchPermissionsRequestEntry = BatchPermissionsRequestEntry'
  { -- | Indicates if the option to pass permissions is granted.
    BatchPermissionsRequestEntry -> Maybe [Permission]
permissionsWithGrantOption :: Prelude.Maybe [Permission],
    -- | The principal to be granted a permission.
    BatchPermissionsRequestEntry -> Maybe DataLakePrincipal
principal :: Prelude.Maybe DataLakePrincipal,
    -- | The resource to which the principal is to be granted a permission.
    BatchPermissionsRequestEntry -> Maybe Resource
resource :: Prelude.Maybe Resource,
    -- | The permissions to be granted.
    BatchPermissionsRequestEntry -> Maybe [Permission]
permissions :: Prelude.Maybe [Permission],
    -- | A unique identifier for the batch permissions request entry.
    BatchPermissionsRequestEntry -> Text
id :: Prelude.Text
  }
  deriving (BatchPermissionsRequestEntry
-> BatchPermissionsRequestEntry -> Bool
(BatchPermissionsRequestEntry
 -> BatchPermissionsRequestEntry -> Bool)
-> (BatchPermissionsRequestEntry
    -> BatchPermissionsRequestEntry -> Bool)
-> Eq BatchPermissionsRequestEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchPermissionsRequestEntry
-> BatchPermissionsRequestEntry -> Bool
$c/= :: BatchPermissionsRequestEntry
-> BatchPermissionsRequestEntry -> Bool
== :: BatchPermissionsRequestEntry
-> BatchPermissionsRequestEntry -> Bool
$c== :: BatchPermissionsRequestEntry
-> BatchPermissionsRequestEntry -> Bool
Prelude.Eq, ReadPrec [BatchPermissionsRequestEntry]
ReadPrec BatchPermissionsRequestEntry
Int -> ReadS BatchPermissionsRequestEntry
ReadS [BatchPermissionsRequestEntry]
(Int -> ReadS BatchPermissionsRequestEntry)
-> ReadS [BatchPermissionsRequestEntry]
-> ReadPrec BatchPermissionsRequestEntry
-> ReadPrec [BatchPermissionsRequestEntry]
-> Read BatchPermissionsRequestEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchPermissionsRequestEntry]
$creadListPrec :: ReadPrec [BatchPermissionsRequestEntry]
readPrec :: ReadPrec BatchPermissionsRequestEntry
$creadPrec :: ReadPrec BatchPermissionsRequestEntry
readList :: ReadS [BatchPermissionsRequestEntry]
$creadList :: ReadS [BatchPermissionsRequestEntry]
readsPrec :: Int -> ReadS BatchPermissionsRequestEntry
$creadsPrec :: Int -> ReadS BatchPermissionsRequestEntry
Prelude.Read, Int -> BatchPermissionsRequestEntry -> ShowS
[BatchPermissionsRequestEntry] -> ShowS
BatchPermissionsRequestEntry -> String
(Int -> BatchPermissionsRequestEntry -> ShowS)
-> (BatchPermissionsRequestEntry -> String)
-> ([BatchPermissionsRequestEntry] -> ShowS)
-> Show BatchPermissionsRequestEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchPermissionsRequestEntry] -> ShowS
$cshowList :: [BatchPermissionsRequestEntry] -> ShowS
show :: BatchPermissionsRequestEntry -> String
$cshow :: BatchPermissionsRequestEntry -> String
showsPrec :: Int -> BatchPermissionsRequestEntry -> ShowS
$cshowsPrec :: Int -> BatchPermissionsRequestEntry -> ShowS
Prelude.Show, (forall x.
 BatchPermissionsRequestEntry -> Rep BatchPermissionsRequestEntry x)
-> (forall x.
    Rep BatchPermissionsRequestEntry x -> BatchPermissionsRequestEntry)
-> Generic BatchPermissionsRequestEntry
forall x.
Rep BatchPermissionsRequestEntry x -> BatchPermissionsRequestEntry
forall x.
BatchPermissionsRequestEntry -> Rep BatchPermissionsRequestEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchPermissionsRequestEntry x -> BatchPermissionsRequestEntry
$cfrom :: forall x.
BatchPermissionsRequestEntry -> Rep BatchPermissionsRequestEntry x
Prelude.Generic)

-- |
-- Create a value of 'BatchPermissionsRequestEntry' 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:
--
-- 'permissionsWithGrantOption', 'batchPermissionsRequestEntry_permissionsWithGrantOption' - Indicates if the option to pass permissions is granted.
--
-- 'principal', 'batchPermissionsRequestEntry_principal' - The principal to be granted a permission.
--
-- 'resource', 'batchPermissionsRequestEntry_resource' - The resource to which the principal is to be granted a permission.
--
-- 'permissions', 'batchPermissionsRequestEntry_permissions' - The permissions to be granted.
--
-- 'id', 'batchPermissionsRequestEntry_id' - A unique identifier for the batch permissions request entry.
newBatchPermissionsRequestEntry ::
  -- | 'id'
  Prelude.Text ->
  BatchPermissionsRequestEntry
newBatchPermissionsRequestEntry :: Text -> BatchPermissionsRequestEntry
newBatchPermissionsRequestEntry Text
pId_ =
  BatchPermissionsRequestEntry' :: Maybe [Permission]
-> Maybe DataLakePrincipal
-> Maybe Resource
-> Maybe [Permission]
-> Text
-> BatchPermissionsRequestEntry
BatchPermissionsRequestEntry'
    { $sel:permissionsWithGrantOption:BatchPermissionsRequestEntry' :: Maybe [Permission]
permissionsWithGrantOption =
        Maybe [Permission]
forall a. Maybe a
Prelude.Nothing,
      $sel:principal:BatchPermissionsRequestEntry' :: Maybe DataLakePrincipal
principal = Maybe DataLakePrincipal
forall a. Maybe a
Prelude.Nothing,
      $sel:resource:BatchPermissionsRequestEntry' :: Maybe Resource
resource = Maybe Resource
forall a. Maybe a
Prelude.Nothing,
      $sel:permissions:BatchPermissionsRequestEntry' :: Maybe [Permission]
permissions = Maybe [Permission]
forall a. Maybe a
Prelude.Nothing,
      $sel:id:BatchPermissionsRequestEntry' :: Text
id = Text
pId_
    }

-- | Indicates if the option to pass permissions is granted.
batchPermissionsRequestEntry_permissionsWithGrantOption :: Lens.Lens' BatchPermissionsRequestEntry (Prelude.Maybe [Permission])
batchPermissionsRequestEntry_permissionsWithGrantOption :: (Maybe [Permission] -> f (Maybe [Permission]))
-> BatchPermissionsRequestEntry -> f BatchPermissionsRequestEntry
batchPermissionsRequestEntry_permissionsWithGrantOption = (BatchPermissionsRequestEntry -> Maybe [Permission])
-> (BatchPermissionsRequestEntry
    -> Maybe [Permission] -> BatchPermissionsRequestEntry)
-> Lens
     BatchPermissionsRequestEntry
     BatchPermissionsRequestEntry
     (Maybe [Permission])
     (Maybe [Permission])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPermissionsRequestEntry' {Maybe [Permission]
permissionsWithGrantOption :: Maybe [Permission]
$sel:permissionsWithGrantOption:BatchPermissionsRequestEntry' :: BatchPermissionsRequestEntry -> Maybe [Permission]
permissionsWithGrantOption} -> Maybe [Permission]
permissionsWithGrantOption) (\s :: BatchPermissionsRequestEntry
s@BatchPermissionsRequestEntry' {} Maybe [Permission]
a -> BatchPermissionsRequestEntry
s {$sel:permissionsWithGrantOption:BatchPermissionsRequestEntry' :: Maybe [Permission]
permissionsWithGrantOption = Maybe [Permission]
a} :: BatchPermissionsRequestEntry) ((Maybe [Permission] -> f (Maybe [Permission]))
 -> BatchPermissionsRequestEntry -> f BatchPermissionsRequestEntry)
-> ((Maybe [Permission] -> f (Maybe [Permission]))
    -> Maybe [Permission] -> f (Maybe [Permission]))
-> (Maybe [Permission] -> f (Maybe [Permission]))
-> BatchPermissionsRequestEntry
-> f BatchPermissionsRequestEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Permission] [Permission] [Permission] [Permission]
-> Iso
     (Maybe [Permission])
     (Maybe [Permission])
     (Maybe [Permission])
     (Maybe [Permission])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Permission] [Permission] [Permission] [Permission]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The principal to be granted a permission.
batchPermissionsRequestEntry_principal :: Lens.Lens' BatchPermissionsRequestEntry (Prelude.Maybe DataLakePrincipal)
batchPermissionsRequestEntry_principal :: (Maybe DataLakePrincipal -> f (Maybe DataLakePrincipal))
-> BatchPermissionsRequestEntry -> f BatchPermissionsRequestEntry
batchPermissionsRequestEntry_principal = (BatchPermissionsRequestEntry -> Maybe DataLakePrincipal)
-> (BatchPermissionsRequestEntry
    -> Maybe DataLakePrincipal -> BatchPermissionsRequestEntry)
-> Lens
     BatchPermissionsRequestEntry
     BatchPermissionsRequestEntry
     (Maybe DataLakePrincipal)
     (Maybe DataLakePrincipal)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPermissionsRequestEntry' {Maybe DataLakePrincipal
principal :: Maybe DataLakePrincipal
$sel:principal:BatchPermissionsRequestEntry' :: BatchPermissionsRequestEntry -> Maybe DataLakePrincipal
principal} -> Maybe DataLakePrincipal
principal) (\s :: BatchPermissionsRequestEntry
s@BatchPermissionsRequestEntry' {} Maybe DataLakePrincipal
a -> BatchPermissionsRequestEntry
s {$sel:principal:BatchPermissionsRequestEntry' :: Maybe DataLakePrincipal
principal = Maybe DataLakePrincipal
a} :: BatchPermissionsRequestEntry)

-- | The resource to which the principal is to be granted a permission.
batchPermissionsRequestEntry_resource :: Lens.Lens' BatchPermissionsRequestEntry (Prelude.Maybe Resource)
batchPermissionsRequestEntry_resource :: (Maybe Resource -> f (Maybe Resource))
-> BatchPermissionsRequestEntry -> f BatchPermissionsRequestEntry
batchPermissionsRequestEntry_resource = (BatchPermissionsRequestEntry -> Maybe Resource)
-> (BatchPermissionsRequestEntry
    -> Maybe Resource -> BatchPermissionsRequestEntry)
-> Lens
     BatchPermissionsRequestEntry
     BatchPermissionsRequestEntry
     (Maybe Resource)
     (Maybe Resource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPermissionsRequestEntry' {Maybe Resource
resource :: Maybe Resource
$sel:resource:BatchPermissionsRequestEntry' :: BatchPermissionsRequestEntry -> Maybe Resource
resource} -> Maybe Resource
resource) (\s :: BatchPermissionsRequestEntry
s@BatchPermissionsRequestEntry' {} Maybe Resource
a -> BatchPermissionsRequestEntry
s {$sel:resource:BatchPermissionsRequestEntry' :: Maybe Resource
resource = Maybe Resource
a} :: BatchPermissionsRequestEntry)

-- | The permissions to be granted.
batchPermissionsRequestEntry_permissions :: Lens.Lens' BatchPermissionsRequestEntry (Prelude.Maybe [Permission])
batchPermissionsRequestEntry_permissions :: (Maybe [Permission] -> f (Maybe [Permission]))
-> BatchPermissionsRequestEntry -> f BatchPermissionsRequestEntry
batchPermissionsRequestEntry_permissions = (BatchPermissionsRequestEntry -> Maybe [Permission])
-> (BatchPermissionsRequestEntry
    -> Maybe [Permission] -> BatchPermissionsRequestEntry)
-> Lens
     BatchPermissionsRequestEntry
     BatchPermissionsRequestEntry
     (Maybe [Permission])
     (Maybe [Permission])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPermissionsRequestEntry' {Maybe [Permission]
permissions :: Maybe [Permission]
$sel:permissions:BatchPermissionsRequestEntry' :: BatchPermissionsRequestEntry -> Maybe [Permission]
permissions} -> Maybe [Permission]
permissions) (\s :: BatchPermissionsRequestEntry
s@BatchPermissionsRequestEntry' {} Maybe [Permission]
a -> BatchPermissionsRequestEntry
s {$sel:permissions:BatchPermissionsRequestEntry' :: Maybe [Permission]
permissions = Maybe [Permission]
a} :: BatchPermissionsRequestEntry) ((Maybe [Permission] -> f (Maybe [Permission]))
 -> BatchPermissionsRequestEntry -> f BatchPermissionsRequestEntry)
-> ((Maybe [Permission] -> f (Maybe [Permission]))
    -> Maybe [Permission] -> f (Maybe [Permission]))
-> (Maybe [Permission] -> f (Maybe [Permission]))
-> BatchPermissionsRequestEntry
-> f BatchPermissionsRequestEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Permission] [Permission] [Permission] [Permission]
-> Iso
     (Maybe [Permission])
     (Maybe [Permission])
     (Maybe [Permission])
     (Maybe [Permission])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Permission] [Permission] [Permission] [Permission]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A unique identifier for the batch permissions request entry.
batchPermissionsRequestEntry_id :: Lens.Lens' BatchPermissionsRequestEntry Prelude.Text
batchPermissionsRequestEntry_id :: (Text -> f Text)
-> BatchPermissionsRequestEntry -> f BatchPermissionsRequestEntry
batchPermissionsRequestEntry_id = (BatchPermissionsRequestEntry -> Text)
-> (BatchPermissionsRequestEntry
    -> Text -> BatchPermissionsRequestEntry)
-> Lens
     BatchPermissionsRequestEntry BatchPermissionsRequestEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPermissionsRequestEntry' {Text
id :: Text
$sel:id:BatchPermissionsRequestEntry' :: BatchPermissionsRequestEntry -> Text
id} -> Text
id) (\s :: BatchPermissionsRequestEntry
s@BatchPermissionsRequestEntry' {} Text
a -> BatchPermissionsRequestEntry
s {$sel:id:BatchPermissionsRequestEntry' :: Text
id = Text
a} :: BatchPermissionsRequestEntry)

instance Core.FromJSON BatchPermissionsRequestEntry where
  parseJSON :: Value -> Parser BatchPermissionsRequestEntry
parseJSON =
    String
-> (Object -> Parser BatchPermissionsRequestEntry)
-> Value
-> Parser BatchPermissionsRequestEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchPermissionsRequestEntry"
      ( \Object
x ->
          Maybe [Permission]
-> Maybe DataLakePrincipal
-> Maybe Resource
-> Maybe [Permission]
-> Text
-> BatchPermissionsRequestEntry
BatchPermissionsRequestEntry'
            (Maybe [Permission]
 -> Maybe DataLakePrincipal
 -> Maybe Resource
 -> Maybe [Permission]
 -> Text
 -> BatchPermissionsRequestEntry)
-> Parser (Maybe [Permission])
-> Parser
     (Maybe DataLakePrincipal
      -> Maybe Resource
      -> Maybe [Permission]
      -> Text
      -> BatchPermissionsRequestEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Permission]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PermissionsWithGrantOption"
                            Parser (Maybe (Maybe [Permission]))
-> Maybe [Permission] -> Parser (Maybe [Permission])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Permission]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe DataLakePrincipal
   -> Maybe Resource
   -> Maybe [Permission]
   -> Text
   -> BatchPermissionsRequestEntry)
-> Parser (Maybe DataLakePrincipal)
-> Parser
     (Maybe Resource
      -> Maybe [Permission] -> Text -> BatchPermissionsRequestEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DataLakePrincipal)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Principal")
            Parser
  (Maybe Resource
   -> Maybe [Permission] -> Text -> BatchPermissionsRequestEntry)
-> Parser (Maybe Resource)
-> Parser
     (Maybe [Permission] -> Text -> BatchPermissionsRequestEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Resource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Resource")
            Parser (Maybe [Permission] -> Text -> BatchPermissionsRequestEntry)
-> Parser (Maybe [Permission])
-> Parser (Text -> BatchPermissionsRequestEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Permission]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Permissions" Parser (Maybe (Maybe [Permission]))
-> Maybe [Permission] -> Parser (Maybe [Permission])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Permission]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> BatchPermissionsRequestEntry)
-> Parser Text -> Parser BatchPermissionsRequestEntry
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
"Id")
      )

instance
  Prelude.Hashable
    BatchPermissionsRequestEntry

instance Prelude.NFData BatchPermissionsRequestEntry

instance Core.ToJSON BatchPermissionsRequestEntry where
  toJSON :: BatchPermissionsRequestEntry -> Value
toJSON BatchPermissionsRequestEntry' {Maybe [Permission]
Maybe DataLakePrincipal
Maybe Resource
Text
id :: Text
permissions :: Maybe [Permission]
resource :: Maybe Resource
principal :: Maybe DataLakePrincipal
permissionsWithGrantOption :: Maybe [Permission]
$sel:id:BatchPermissionsRequestEntry' :: BatchPermissionsRequestEntry -> Text
$sel:permissions:BatchPermissionsRequestEntry' :: BatchPermissionsRequestEntry -> Maybe [Permission]
$sel:resource:BatchPermissionsRequestEntry' :: BatchPermissionsRequestEntry -> Maybe Resource
$sel:principal:BatchPermissionsRequestEntry' :: BatchPermissionsRequestEntry -> Maybe DataLakePrincipal
$sel:permissionsWithGrantOption:BatchPermissionsRequestEntry' :: BatchPermissionsRequestEntry -> Maybe [Permission]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PermissionsWithGrantOption" Text -> [Permission] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Permission] -> Pair) -> Maybe [Permission] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Permission]
permissionsWithGrantOption,
            (Text
"Principal" Text -> DataLakePrincipal -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DataLakePrincipal -> Pair)
-> Maybe DataLakePrincipal -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DataLakePrincipal
principal,
            (Text
"Resource" Text -> Resource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Resource -> Pair) -> Maybe Resource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Resource
resource,
            (Text
"Permissions" Text -> [Permission] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Permission] -> Pair) -> Maybe [Permission] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Permission]
permissions,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
          ]
      )