{-# 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 #-}
module Amazonka.Glue.Types.PrincipalPermissions where
import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.DataLakePrincipal
import Amazonka.Glue.Types.Permission
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data PrincipalPermissions = PrincipalPermissions'
{
PrincipalPermissions -> Maybe DataLakePrincipal
principal :: Prelude.Maybe DataLakePrincipal,
PrincipalPermissions -> Maybe [Permission]
permissions :: Prelude.Maybe [Permission]
}
deriving (PrincipalPermissions -> PrincipalPermissions -> Bool
(PrincipalPermissions -> PrincipalPermissions -> Bool)
-> (PrincipalPermissions -> PrincipalPermissions -> Bool)
-> Eq PrincipalPermissions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrincipalPermissions -> PrincipalPermissions -> Bool
$c/= :: PrincipalPermissions -> PrincipalPermissions -> Bool
== :: PrincipalPermissions -> PrincipalPermissions -> Bool
$c== :: PrincipalPermissions -> PrincipalPermissions -> Bool
Prelude.Eq, ReadPrec [PrincipalPermissions]
ReadPrec PrincipalPermissions
Int -> ReadS PrincipalPermissions
ReadS [PrincipalPermissions]
(Int -> ReadS PrincipalPermissions)
-> ReadS [PrincipalPermissions]
-> ReadPrec PrincipalPermissions
-> ReadPrec [PrincipalPermissions]
-> Read PrincipalPermissions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PrincipalPermissions]
$creadListPrec :: ReadPrec [PrincipalPermissions]
readPrec :: ReadPrec PrincipalPermissions
$creadPrec :: ReadPrec PrincipalPermissions
readList :: ReadS [PrincipalPermissions]
$creadList :: ReadS [PrincipalPermissions]
readsPrec :: Int -> ReadS PrincipalPermissions
$creadsPrec :: Int -> ReadS PrincipalPermissions
Prelude.Read, Int -> PrincipalPermissions -> ShowS
[PrincipalPermissions] -> ShowS
PrincipalPermissions -> String
(Int -> PrincipalPermissions -> ShowS)
-> (PrincipalPermissions -> String)
-> ([PrincipalPermissions] -> ShowS)
-> Show PrincipalPermissions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PrincipalPermissions] -> ShowS
$cshowList :: [PrincipalPermissions] -> ShowS
show :: PrincipalPermissions -> String
$cshow :: PrincipalPermissions -> String
showsPrec :: Int -> PrincipalPermissions -> ShowS
$cshowsPrec :: Int -> PrincipalPermissions -> ShowS
Prelude.Show, (forall x. PrincipalPermissions -> Rep PrincipalPermissions x)
-> (forall x. Rep PrincipalPermissions x -> PrincipalPermissions)
-> Generic PrincipalPermissions
forall x. Rep PrincipalPermissions x -> PrincipalPermissions
forall x. PrincipalPermissions -> Rep PrincipalPermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PrincipalPermissions x -> PrincipalPermissions
$cfrom :: forall x. PrincipalPermissions -> Rep PrincipalPermissions x
Prelude.Generic)
newPrincipalPermissions ::
PrincipalPermissions
newPrincipalPermissions :: PrincipalPermissions
newPrincipalPermissions =
PrincipalPermissions' :: Maybe DataLakePrincipal
-> Maybe [Permission] -> PrincipalPermissions
PrincipalPermissions'
{ $sel:principal:PrincipalPermissions' :: Maybe DataLakePrincipal
principal = Maybe DataLakePrincipal
forall a. Maybe a
Prelude.Nothing,
$sel:permissions:PrincipalPermissions' :: Maybe [Permission]
permissions = Maybe [Permission]
forall a. Maybe a
Prelude.Nothing
}
principalPermissions_principal :: Lens.Lens' PrincipalPermissions (Prelude.Maybe DataLakePrincipal)
principalPermissions_principal :: (Maybe DataLakePrincipal -> f (Maybe DataLakePrincipal))
-> PrincipalPermissions -> f PrincipalPermissions
principalPermissions_principal = (PrincipalPermissions -> Maybe DataLakePrincipal)
-> (PrincipalPermissions
-> Maybe DataLakePrincipal -> PrincipalPermissions)
-> Lens
PrincipalPermissions
PrincipalPermissions
(Maybe DataLakePrincipal)
(Maybe DataLakePrincipal)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrincipalPermissions' {Maybe DataLakePrincipal
principal :: Maybe DataLakePrincipal
$sel:principal:PrincipalPermissions' :: PrincipalPermissions -> Maybe DataLakePrincipal
principal} -> Maybe DataLakePrincipal
principal) (\s :: PrincipalPermissions
s@PrincipalPermissions' {} Maybe DataLakePrincipal
a -> PrincipalPermissions
s {$sel:principal:PrincipalPermissions' :: Maybe DataLakePrincipal
principal = Maybe DataLakePrincipal
a} :: PrincipalPermissions)
principalPermissions_permissions :: Lens.Lens' PrincipalPermissions (Prelude.Maybe [Permission])
principalPermissions_permissions :: (Maybe [Permission] -> f (Maybe [Permission]))
-> PrincipalPermissions -> f PrincipalPermissions
principalPermissions_permissions = (PrincipalPermissions -> Maybe [Permission])
-> (PrincipalPermissions
-> Maybe [Permission] -> PrincipalPermissions)
-> Lens
PrincipalPermissions
PrincipalPermissions
(Maybe [Permission])
(Maybe [Permission])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrincipalPermissions' {Maybe [Permission]
permissions :: Maybe [Permission]
$sel:permissions:PrincipalPermissions' :: PrincipalPermissions -> Maybe [Permission]
permissions} -> Maybe [Permission]
permissions) (\s :: PrincipalPermissions
s@PrincipalPermissions' {} Maybe [Permission]
a -> PrincipalPermissions
s {$sel:permissions:PrincipalPermissions' :: Maybe [Permission]
permissions = Maybe [Permission]
a} :: PrincipalPermissions) ((Maybe [Permission] -> f (Maybe [Permission]))
-> PrincipalPermissions -> f PrincipalPermissions)
-> ((Maybe [Permission] -> f (Maybe [Permission]))
-> Maybe [Permission] -> f (Maybe [Permission]))
-> (Maybe [Permission] -> f (Maybe [Permission]))
-> PrincipalPermissions
-> f PrincipalPermissions
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 PrincipalPermissions where
parseJSON :: Value -> Parser PrincipalPermissions
parseJSON =
String
-> (Object -> Parser PrincipalPermissions)
-> Value
-> Parser PrincipalPermissions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"PrincipalPermissions"
( \Object
x ->
Maybe DataLakePrincipal
-> Maybe [Permission] -> PrincipalPermissions
PrincipalPermissions'
(Maybe DataLakePrincipal
-> Maybe [Permission] -> PrincipalPermissions)
-> Parser (Maybe DataLakePrincipal)
-> Parser (Maybe [Permission] -> PrincipalPermissions)
forall (f :: * -> *) a b. Functor 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 [Permission] -> PrincipalPermissions)
-> Parser (Maybe [Permission]) -> Parser PrincipalPermissions
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 PrincipalPermissions
instance Prelude.NFData PrincipalPermissions
instance Core.ToJSON PrincipalPermissions where
toJSON :: PrincipalPermissions -> Value
toJSON PrincipalPermissions' {Maybe [Permission]
Maybe DataLakePrincipal
permissions :: Maybe [Permission]
principal :: Maybe DataLakePrincipal
$sel:permissions:PrincipalPermissions' :: PrincipalPermissions -> Maybe [Permission]
$sel:principal:PrincipalPermissions' :: PrincipalPermissions -> Maybe DataLakePrincipal
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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
"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
]
)