{-# 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.WorkDocs.Types.Principal where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkDocs.Types.PermissionInfo
import Amazonka.WorkDocs.Types.PrincipalType
data Principal = Principal'
{
Principal -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
Principal -> Maybe [PermissionInfo]
roles :: Prelude.Maybe [PermissionInfo],
Principal -> Maybe PrincipalType
type' :: Prelude.Maybe PrincipalType
}
deriving (Principal -> Principal -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Principal -> Principal -> Bool
$c/= :: Principal -> Principal -> Bool
== :: Principal -> Principal -> Bool
$c== :: Principal -> Principal -> Bool
Prelude.Eq, ReadPrec [Principal]
ReadPrec Principal
Int -> ReadS Principal
ReadS [Principal]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Principal]
$creadListPrec :: ReadPrec [Principal]
readPrec :: ReadPrec Principal
$creadPrec :: ReadPrec Principal
readList :: ReadS [Principal]
$creadList :: ReadS [Principal]
readsPrec :: Int -> ReadS Principal
$creadsPrec :: Int -> ReadS Principal
Prelude.Read, Int -> Principal -> ShowS
[Principal] -> ShowS
Principal -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Principal] -> ShowS
$cshowList :: [Principal] -> ShowS
show :: Principal -> String
$cshow :: Principal -> String
showsPrec :: Int -> Principal -> ShowS
$cshowsPrec :: Int -> Principal -> ShowS
Prelude.Show, forall x. Rep Principal x -> Principal
forall x. Principal -> Rep Principal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Principal x -> Principal
$cfrom :: forall x. Principal -> Rep Principal x
Prelude.Generic)
newPrincipal ::
Principal
newPrincipal :: Principal
newPrincipal =
Principal'
{ $sel:id:Principal' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
$sel:roles:Principal' :: Maybe [PermissionInfo]
roles = forall a. Maybe a
Prelude.Nothing,
$sel:type':Principal' :: Maybe PrincipalType
type' = forall a. Maybe a
Prelude.Nothing
}
principal_id :: Lens.Lens' Principal (Prelude.Maybe Prelude.Text)
principal_id :: Lens' Principal (Maybe Text)
principal_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Principal' {Maybe Text
id :: Maybe Text
$sel:id:Principal' :: Principal -> Maybe Text
id} -> Maybe Text
id) (\s :: Principal
s@Principal' {} Maybe Text
a -> Principal
s {$sel:id:Principal' :: Maybe Text
id = Maybe Text
a} :: Principal)
principal_roles :: Lens.Lens' Principal (Prelude.Maybe [PermissionInfo])
principal_roles :: Lens' Principal (Maybe [PermissionInfo])
principal_roles = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Principal' {Maybe [PermissionInfo]
roles :: Maybe [PermissionInfo]
$sel:roles:Principal' :: Principal -> Maybe [PermissionInfo]
roles} -> Maybe [PermissionInfo]
roles) (\s :: Principal
s@Principal' {} Maybe [PermissionInfo]
a -> Principal
s {$sel:roles:Principal' :: Maybe [PermissionInfo]
roles = Maybe [PermissionInfo]
a} :: Principal) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
principal_type :: Lens.Lens' Principal (Prelude.Maybe PrincipalType)
principal_type :: Lens' Principal (Maybe PrincipalType)
principal_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Principal' {Maybe PrincipalType
type' :: Maybe PrincipalType
$sel:type':Principal' :: Principal -> Maybe PrincipalType
type'} -> Maybe PrincipalType
type') (\s :: Principal
s@Principal' {} Maybe PrincipalType
a -> Principal
s {$sel:type':Principal' :: Maybe PrincipalType
type' = Maybe PrincipalType
a} :: Principal)
instance Data.FromJSON Principal where
parseJSON :: Value -> Parser Principal
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Principal"
( \Object
x ->
Maybe Text
-> Maybe [PermissionInfo] -> Maybe PrincipalType -> Principal
Principal'
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
"Id")
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
"Roles" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
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
"Type")
)
instance Prelude.Hashable Principal where
hashWithSalt :: Int -> Principal -> Int
hashWithSalt Int
_salt Principal' {Maybe [PermissionInfo]
Maybe Text
Maybe PrincipalType
type' :: Maybe PrincipalType
roles :: Maybe [PermissionInfo]
id :: Maybe Text
$sel:type':Principal' :: Principal -> Maybe PrincipalType
$sel:roles:Principal' :: Principal -> Maybe [PermissionInfo]
$sel:id:Principal' :: Principal -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PermissionInfo]
roles
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PrincipalType
type'
instance Prelude.NFData Principal where
rnf :: Principal -> ()
rnf Principal' {Maybe [PermissionInfo]
Maybe Text
Maybe PrincipalType
type' :: Maybe PrincipalType
roles :: Maybe [PermissionInfo]
id :: Maybe Text
$sel:type':Principal' :: Principal -> Maybe PrincipalType
$sel:roles:Principal' :: Principal -> Maybe [PermissionInfo]
$sel:id:Principal' :: Principal -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [PermissionInfo]
roles
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PrincipalType
type'