{-# 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.PrincipalResourcePermissions
-- 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.PrincipalResourcePermissions where

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

-- | The permissions granted or revoked on a resource.
--
-- /See:/ 'newPrincipalResourcePermissions' smart constructor.
data PrincipalResourcePermissions = PrincipalResourcePermissions'
  { -- | This attribute can be used to return any additional details of
    -- @PrincipalResourcePermissions@. Currently returns only as a RAM resource
    -- share ARN.
    PrincipalResourcePermissions -> Maybe DetailsMap
additionalDetails :: Prelude.Maybe DetailsMap,
    -- | Indicates whether to grant the ability to grant permissions (as a subset
    -- of permissions granted).
    PrincipalResourcePermissions -> Maybe [Permission]
permissionsWithGrantOption :: Prelude.Maybe [Permission],
    -- | The Data Lake principal to be granted or revoked permissions.
    PrincipalResourcePermissions -> Maybe DataLakePrincipal
principal :: Prelude.Maybe DataLakePrincipal,
    -- | The resource where permissions are to be granted or revoked.
    PrincipalResourcePermissions -> Maybe Resource
resource :: Prelude.Maybe Resource,
    -- | The permissions to be granted or revoked on the resource.
    PrincipalResourcePermissions -> Maybe [Permission]
permissions :: Prelude.Maybe [Permission]
  }
  deriving (PrincipalResourcePermissions
-> PrincipalResourcePermissions -> Bool
(PrincipalResourcePermissions
 -> PrincipalResourcePermissions -> Bool)
-> (PrincipalResourcePermissions
    -> PrincipalResourcePermissions -> Bool)
-> Eq PrincipalResourcePermissions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrincipalResourcePermissions
-> PrincipalResourcePermissions -> Bool
$c/= :: PrincipalResourcePermissions
-> PrincipalResourcePermissions -> Bool
== :: PrincipalResourcePermissions
-> PrincipalResourcePermissions -> Bool
$c== :: PrincipalResourcePermissions
-> PrincipalResourcePermissions -> Bool
Prelude.Eq, ReadPrec [PrincipalResourcePermissions]
ReadPrec PrincipalResourcePermissions
Int -> ReadS PrincipalResourcePermissions
ReadS [PrincipalResourcePermissions]
(Int -> ReadS PrincipalResourcePermissions)
-> ReadS [PrincipalResourcePermissions]
-> ReadPrec PrincipalResourcePermissions
-> ReadPrec [PrincipalResourcePermissions]
-> Read PrincipalResourcePermissions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PrincipalResourcePermissions]
$creadListPrec :: ReadPrec [PrincipalResourcePermissions]
readPrec :: ReadPrec PrincipalResourcePermissions
$creadPrec :: ReadPrec PrincipalResourcePermissions
readList :: ReadS [PrincipalResourcePermissions]
$creadList :: ReadS [PrincipalResourcePermissions]
readsPrec :: Int -> ReadS PrincipalResourcePermissions
$creadsPrec :: Int -> ReadS PrincipalResourcePermissions
Prelude.Read, Int -> PrincipalResourcePermissions -> ShowS
[PrincipalResourcePermissions] -> ShowS
PrincipalResourcePermissions -> String
(Int -> PrincipalResourcePermissions -> ShowS)
-> (PrincipalResourcePermissions -> String)
-> ([PrincipalResourcePermissions] -> ShowS)
-> Show PrincipalResourcePermissions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PrincipalResourcePermissions] -> ShowS
$cshowList :: [PrincipalResourcePermissions] -> ShowS
show :: PrincipalResourcePermissions -> String
$cshow :: PrincipalResourcePermissions -> String
showsPrec :: Int -> PrincipalResourcePermissions -> ShowS
$cshowsPrec :: Int -> PrincipalResourcePermissions -> ShowS
Prelude.Show, (forall x.
 PrincipalResourcePermissions -> Rep PrincipalResourcePermissions x)
-> (forall x.
    Rep PrincipalResourcePermissions x -> PrincipalResourcePermissions)
-> Generic PrincipalResourcePermissions
forall x.
Rep PrincipalResourcePermissions x -> PrincipalResourcePermissions
forall x.
PrincipalResourcePermissions -> Rep PrincipalResourcePermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PrincipalResourcePermissions x -> PrincipalResourcePermissions
$cfrom :: forall x.
PrincipalResourcePermissions -> Rep PrincipalResourcePermissions x
Prelude.Generic)

-- |
-- Create a value of 'PrincipalResourcePermissions' 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:
--
-- 'additionalDetails', 'principalResourcePermissions_additionalDetails' - This attribute can be used to return any additional details of
-- @PrincipalResourcePermissions@. Currently returns only as a RAM resource
-- share ARN.
--
-- 'permissionsWithGrantOption', 'principalResourcePermissions_permissionsWithGrantOption' - Indicates whether to grant the ability to grant permissions (as a subset
-- of permissions granted).
--
-- 'principal', 'principalResourcePermissions_principal' - The Data Lake principal to be granted or revoked permissions.
--
-- 'resource', 'principalResourcePermissions_resource' - The resource where permissions are to be granted or revoked.
--
-- 'permissions', 'principalResourcePermissions_permissions' - The permissions to be granted or revoked on the resource.
newPrincipalResourcePermissions ::
  PrincipalResourcePermissions
newPrincipalResourcePermissions :: PrincipalResourcePermissions
newPrincipalResourcePermissions =
  PrincipalResourcePermissions' :: Maybe DetailsMap
-> Maybe [Permission]
-> Maybe DataLakePrincipal
-> Maybe Resource
-> Maybe [Permission]
-> PrincipalResourcePermissions
PrincipalResourcePermissions'
    { $sel:additionalDetails:PrincipalResourcePermissions' :: Maybe DetailsMap
additionalDetails =
        Maybe DetailsMap
forall a. Maybe a
Prelude.Nothing,
      $sel:permissionsWithGrantOption:PrincipalResourcePermissions' :: Maybe [Permission]
permissionsWithGrantOption = Maybe [Permission]
forall a. Maybe a
Prelude.Nothing,
      $sel:principal:PrincipalResourcePermissions' :: Maybe DataLakePrincipal
principal = Maybe DataLakePrincipal
forall a. Maybe a
Prelude.Nothing,
      $sel:resource:PrincipalResourcePermissions' :: Maybe Resource
resource = Maybe Resource
forall a. Maybe a
Prelude.Nothing,
      $sel:permissions:PrincipalResourcePermissions' :: Maybe [Permission]
permissions = Maybe [Permission]
forall a. Maybe a
Prelude.Nothing
    }

-- | This attribute can be used to return any additional details of
-- @PrincipalResourcePermissions@. Currently returns only as a RAM resource
-- share ARN.
principalResourcePermissions_additionalDetails :: Lens.Lens' PrincipalResourcePermissions (Prelude.Maybe DetailsMap)
principalResourcePermissions_additionalDetails :: (Maybe DetailsMap -> f (Maybe DetailsMap))
-> PrincipalResourcePermissions -> f PrincipalResourcePermissions
principalResourcePermissions_additionalDetails = (PrincipalResourcePermissions -> Maybe DetailsMap)
-> (PrincipalResourcePermissions
    -> Maybe DetailsMap -> PrincipalResourcePermissions)
-> Lens
     PrincipalResourcePermissions
     PrincipalResourcePermissions
     (Maybe DetailsMap)
     (Maybe DetailsMap)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrincipalResourcePermissions' {Maybe DetailsMap
additionalDetails :: Maybe DetailsMap
$sel:additionalDetails:PrincipalResourcePermissions' :: PrincipalResourcePermissions -> Maybe DetailsMap
additionalDetails} -> Maybe DetailsMap
additionalDetails) (\s :: PrincipalResourcePermissions
s@PrincipalResourcePermissions' {} Maybe DetailsMap
a -> PrincipalResourcePermissions
s {$sel:additionalDetails:PrincipalResourcePermissions' :: Maybe DetailsMap
additionalDetails = Maybe DetailsMap
a} :: PrincipalResourcePermissions)

-- | Indicates whether to grant the ability to grant permissions (as a subset
-- of permissions granted).
principalResourcePermissions_permissionsWithGrantOption :: Lens.Lens' PrincipalResourcePermissions (Prelude.Maybe [Permission])
principalResourcePermissions_permissionsWithGrantOption :: (Maybe [Permission] -> f (Maybe [Permission]))
-> PrincipalResourcePermissions -> f PrincipalResourcePermissions
principalResourcePermissions_permissionsWithGrantOption = (PrincipalResourcePermissions -> Maybe [Permission])
-> (PrincipalResourcePermissions
    -> Maybe [Permission] -> PrincipalResourcePermissions)
-> Lens
     PrincipalResourcePermissions
     PrincipalResourcePermissions
     (Maybe [Permission])
     (Maybe [Permission])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrincipalResourcePermissions' {Maybe [Permission]
permissionsWithGrantOption :: Maybe [Permission]
$sel:permissionsWithGrantOption:PrincipalResourcePermissions' :: PrincipalResourcePermissions -> Maybe [Permission]
permissionsWithGrantOption} -> Maybe [Permission]
permissionsWithGrantOption) (\s :: PrincipalResourcePermissions
s@PrincipalResourcePermissions' {} Maybe [Permission]
a -> PrincipalResourcePermissions
s {$sel:permissionsWithGrantOption:PrincipalResourcePermissions' :: Maybe [Permission]
permissionsWithGrantOption = Maybe [Permission]
a} :: PrincipalResourcePermissions) ((Maybe [Permission] -> f (Maybe [Permission]))
 -> PrincipalResourcePermissions -> f PrincipalResourcePermissions)
-> ((Maybe [Permission] -> f (Maybe [Permission]))
    -> Maybe [Permission] -> f (Maybe [Permission]))
-> (Maybe [Permission] -> f (Maybe [Permission]))
-> PrincipalResourcePermissions
-> f PrincipalResourcePermissions
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 Data Lake principal to be granted or revoked permissions.
principalResourcePermissions_principal :: Lens.Lens' PrincipalResourcePermissions (Prelude.Maybe DataLakePrincipal)
principalResourcePermissions_principal :: (Maybe DataLakePrincipal -> f (Maybe DataLakePrincipal))
-> PrincipalResourcePermissions -> f PrincipalResourcePermissions
principalResourcePermissions_principal = (PrincipalResourcePermissions -> Maybe DataLakePrincipal)
-> (PrincipalResourcePermissions
    -> Maybe DataLakePrincipal -> PrincipalResourcePermissions)
-> Lens
     PrincipalResourcePermissions
     PrincipalResourcePermissions
     (Maybe DataLakePrincipal)
     (Maybe DataLakePrincipal)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrincipalResourcePermissions' {Maybe DataLakePrincipal
principal :: Maybe DataLakePrincipal
$sel:principal:PrincipalResourcePermissions' :: PrincipalResourcePermissions -> Maybe DataLakePrincipal
principal} -> Maybe DataLakePrincipal
principal) (\s :: PrincipalResourcePermissions
s@PrincipalResourcePermissions' {} Maybe DataLakePrincipal
a -> PrincipalResourcePermissions
s {$sel:principal:PrincipalResourcePermissions' :: Maybe DataLakePrincipal
principal = Maybe DataLakePrincipal
a} :: PrincipalResourcePermissions)

-- | The resource where permissions are to be granted or revoked.
principalResourcePermissions_resource :: Lens.Lens' PrincipalResourcePermissions (Prelude.Maybe Resource)
principalResourcePermissions_resource :: (Maybe Resource -> f (Maybe Resource))
-> PrincipalResourcePermissions -> f PrincipalResourcePermissions
principalResourcePermissions_resource = (PrincipalResourcePermissions -> Maybe Resource)
-> (PrincipalResourcePermissions
    -> Maybe Resource -> PrincipalResourcePermissions)
-> Lens
     PrincipalResourcePermissions
     PrincipalResourcePermissions
     (Maybe Resource)
     (Maybe Resource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrincipalResourcePermissions' {Maybe Resource
resource :: Maybe Resource
$sel:resource:PrincipalResourcePermissions' :: PrincipalResourcePermissions -> Maybe Resource
resource} -> Maybe Resource
resource) (\s :: PrincipalResourcePermissions
s@PrincipalResourcePermissions' {} Maybe Resource
a -> PrincipalResourcePermissions
s {$sel:resource:PrincipalResourcePermissions' :: Maybe Resource
resource = Maybe Resource
a} :: PrincipalResourcePermissions)

-- | The permissions to be granted or revoked on the resource.
principalResourcePermissions_permissions :: Lens.Lens' PrincipalResourcePermissions (Prelude.Maybe [Permission])
principalResourcePermissions_permissions :: (Maybe [Permission] -> f (Maybe [Permission]))
-> PrincipalResourcePermissions -> f PrincipalResourcePermissions
principalResourcePermissions_permissions = (PrincipalResourcePermissions -> Maybe [Permission])
-> (PrincipalResourcePermissions
    -> Maybe [Permission] -> PrincipalResourcePermissions)
-> Lens
     PrincipalResourcePermissions
     PrincipalResourcePermissions
     (Maybe [Permission])
     (Maybe [Permission])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrincipalResourcePermissions' {Maybe [Permission]
permissions :: Maybe [Permission]
$sel:permissions:PrincipalResourcePermissions' :: PrincipalResourcePermissions -> Maybe [Permission]
permissions} -> Maybe [Permission]
permissions) (\s :: PrincipalResourcePermissions
s@PrincipalResourcePermissions' {} Maybe [Permission]
a -> PrincipalResourcePermissions
s {$sel:permissions:PrincipalResourcePermissions' :: Maybe [Permission]
permissions = Maybe [Permission]
a} :: PrincipalResourcePermissions) ((Maybe [Permission] -> f (Maybe [Permission]))
 -> PrincipalResourcePermissions -> f PrincipalResourcePermissions)
-> ((Maybe [Permission] -> f (Maybe [Permission]))
    -> Maybe [Permission] -> f (Maybe [Permission]))
-> (Maybe [Permission] -> f (Maybe [Permission]))
-> PrincipalResourcePermissions
-> f PrincipalResourcePermissions
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

instance Core.FromJSON PrincipalResourcePermissions where
  parseJSON :: Value -> Parser PrincipalResourcePermissions
parseJSON =
    String
-> (Object -> Parser PrincipalResourcePermissions)
-> Value
-> Parser PrincipalResourcePermissions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PrincipalResourcePermissions"
      ( \Object
x ->
          Maybe DetailsMap
-> Maybe [Permission]
-> Maybe DataLakePrincipal
-> Maybe Resource
-> Maybe [Permission]
-> PrincipalResourcePermissions
PrincipalResourcePermissions'
            (Maybe DetailsMap
 -> Maybe [Permission]
 -> Maybe DataLakePrincipal
 -> Maybe Resource
 -> Maybe [Permission]
 -> PrincipalResourcePermissions)
-> Parser (Maybe DetailsMap)
-> Parser
     (Maybe [Permission]
      -> Maybe DataLakePrincipal
      -> Maybe Resource
      -> Maybe [Permission]
      -> PrincipalResourcePermissions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DetailsMap)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AdditionalDetails")
            Parser
  (Maybe [Permission]
   -> Maybe DataLakePrincipal
   -> Maybe Resource
   -> Maybe [Permission]
   -> PrincipalResourcePermissions)
-> Parser (Maybe [Permission])
-> Parser
     (Maybe DataLakePrincipal
      -> Maybe Resource
      -> Maybe [Permission]
      -> PrincipalResourcePermissions)
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
"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]
   -> PrincipalResourcePermissions)
-> Parser (Maybe DataLakePrincipal)
-> Parser
     (Maybe Resource
      -> Maybe [Permission] -> PrincipalResourcePermissions)
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] -> PrincipalResourcePermissions)
-> Parser (Maybe Resource)
-> Parser (Maybe [Permission] -> PrincipalResourcePermissions)
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] -> PrincipalResourcePermissions)
-> Parser (Maybe [Permission])
-> Parser PrincipalResourcePermissions
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)
      )

instance
  Prelude.Hashable
    PrincipalResourcePermissions

instance Prelude.NFData PrincipalResourcePermissions