{-# 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.IAM.Types.Role where
import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.AttachedPermissionsBoundary
import Amazonka.IAM.Types.RoleLastUsed
import Amazonka.IAM.Types.Tag
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Role = Role'
{
Role -> Maybe Natural
maxSessionDuration :: Prelude.Maybe Prelude.Natural,
Role -> Maybe Text
assumeRolePolicyDocument :: Prelude.Maybe Prelude.Text,
Role -> Maybe RoleLastUsed
roleLastUsed :: Prelude.Maybe RoleLastUsed,
Role -> Maybe AttachedPermissionsBoundary
permissionsBoundary :: Prelude.Maybe AttachedPermissionsBoundary,
Role -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
Role -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
Role -> Text
path :: Prelude.Text,
Role -> Text
roleName :: Prelude.Text,
Role -> Text
roleId :: Prelude.Text,
Role -> Text
arn :: Prelude.Text,
Role -> ISO8601
createDate :: Core.ISO8601
}
deriving (Role -> Role -> Bool
(Role -> Role -> Bool) -> (Role -> Role -> Bool) -> Eq Role
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Role -> Role -> Bool
$c/= :: Role -> Role -> Bool
== :: Role -> Role -> Bool
$c== :: Role -> Role -> Bool
Prelude.Eq, ReadPrec [Role]
ReadPrec Role
Int -> ReadS Role
ReadS [Role]
(Int -> ReadS Role)
-> ReadS [Role] -> ReadPrec Role -> ReadPrec [Role] -> Read Role
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Role]
$creadListPrec :: ReadPrec [Role]
readPrec :: ReadPrec Role
$creadPrec :: ReadPrec Role
readList :: ReadS [Role]
$creadList :: ReadS [Role]
readsPrec :: Int -> ReadS Role
$creadsPrec :: Int -> ReadS Role
Prelude.Read, Int -> Role -> ShowS
[Role] -> ShowS
Role -> String
(Int -> Role -> ShowS)
-> (Role -> String) -> ([Role] -> ShowS) -> Show Role
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Role] -> ShowS
$cshowList :: [Role] -> ShowS
show :: Role -> String
$cshow :: Role -> String
showsPrec :: Int -> Role -> ShowS
$cshowsPrec :: Int -> Role -> ShowS
Prelude.Show, (forall x. Role -> Rep Role x)
-> (forall x. Rep Role x -> Role) -> Generic Role
forall x. Rep Role x -> Role
forall x. Role -> Rep Role x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Role x -> Role
$cfrom :: forall x. Role -> Rep Role x
Prelude.Generic)
newRole ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
Prelude.UTCTime ->
Role
newRole :: Text -> Text -> Text -> Text -> UTCTime -> Role
newRole Text
pPath_ Text
pRoleName_ Text
pRoleId_ Text
pArn_ UTCTime
pCreateDate_ =
Role' :: Maybe Natural
-> Maybe Text
-> Maybe RoleLastUsed
-> Maybe AttachedPermissionsBoundary
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> Role
Role'
{ $sel:maxSessionDuration:Role' :: Maybe Natural
maxSessionDuration = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:assumeRolePolicyDocument:Role' :: Maybe Text
assumeRolePolicyDocument = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:roleLastUsed:Role' :: Maybe RoleLastUsed
roleLastUsed = Maybe RoleLastUsed
forall a. Maybe a
Prelude.Nothing,
$sel:permissionsBoundary:Role' :: Maybe AttachedPermissionsBoundary
permissionsBoundary = Maybe AttachedPermissionsBoundary
forall a. Maybe a
Prelude.Nothing,
$sel:description:Role' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:Role' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:path:Role' :: Text
path = Text
pPath_,
$sel:roleName:Role' :: Text
roleName = Text
pRoleName_,
$sel:roleId:Role' :: Text
roleId = Text
pRoleId_,
$sel:arn:Role' :: Text
arn = Text
pArn_,
$sel:createDate:Role' :: ISO8601
createDate = Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreateDate_
}
role_maxSessionDuration :: Lens.Lens' Role (Prelude.Maybe Prelude.Natural)
role_maxSessionDuration :: (Maybe Natural -> f (Maybe Natural)) -> Role -> f Role
role_maxSessionDuration = (Role -> Maybe Natural)
-> (Role -> Maybe Natural -> Role)
-> Lens Role Role (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {Maybe Natural
maxSessionDuration :: Maybe Natural
$sel:maxSessionDuration:Role' :: Role -> Maybe Natural
maxSessionDuration} -> Maybe Natural
maxSessionDuration) (\s :: Role
s@Role' {} Maybe Natural
a -> Role
s {$sel:maxSessionDuration:Role' :: Maybe Natural
maxSessionDuration = Maybe Natural
a} :: Role)
role_assumeRolePolicyDocument :: Lens.Lens' Role (Prelude.Maybe Prelude.Text)
role_assumeRolePolicyDocument :: (Maybe Text -> f (Maybe Text)) -> Role -> f Role
role_assumeRolePolicyDocument = (Role -> Maybe Text)
-> (Role -> Maybe Text -> Role)
-> Lens Role Role (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {Maybe Text
assumeRolePolicyDocument :: Maybe Text
$sel:assumeRolePolicyDocument:Role' :: Role -> Maybe Text
assumeRolePolicyDocument} -> Maybe Text
assumeRolePolicyDocument) (\s :: Role
s@Role' {} Maybe Text
a -> Role
s {$sel:assumeRolePolicyDocument:Role' :: Maybe Text
assumeRolePolicyDocument = Maybe Text
a} :: Role)
role_roleLastUsed :: Lens.Lens' Role (Prelude.Maybe RoleLastUsed)
role_roleLastUsed :: (Maybe RoleLastUsed -> f (Maybe RoleLastUsed)) -> Role -> f Role
role_roleLastUsed = (Role -> Maybe RoleLastUsed)
-> (Role -> Maybe RoleLastUsed -> Role)
-> Lens Role Role (Maybe RoleLastUsed) (Maybe RoleLastUsed)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {Maybe RoleLastUsed
roleLastUsed :: Maybe RoleLastUsed
$sel:roleLastUsed:Role' :: Role -> Maybe RoleLastUsed
roleLastUsed} -> Maybe RoleLastUsed
roleLastUsed) (\s :: Role
s@Role' {} Maybe RoleLastUsed
a -> Role
s {$sel:roleLastUsed:Role' :: Maybe RoleLastUsed
roleLastUsed = Maybe RoleLastUsed
a} :: Role)
role_permissionsBoundary :: Lens.Lens' Role (Prelude.Maybe AttachedPermissionsBoundary)
role_permissionsBoundary :: (Maybe AttachedPermissionsBoundary
-> f (Maybe AttachedPermissionsBoundary))
-> Role -> f Role
role_permissionsBoundary = (Role -> Maybe AttachedPermissionsBoundary)
-> (Role -> Maybe AttachedPermissionsBoundary -> Role)
-> Lens
Role
Role
(Maybe AttachedPermissionsBoundary)
(Maybe AttachedPermissionsBoundary)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {Maybe AttachedPermissionsBoundary
permissionsBoundary :: Maybe AttachedPermissionsBoundary
$sel:permissionsBoundary:Role' :: Role -> Maybe AttachedPermissionsBoundary
permissionsBoundary} -> Maybe AttachedPermissionsBoundary
permissionsBoundary) (\s :: Role
s@Role' {} Maybe AttachedPermissionsBoundary
a -> Role
s {$sel:permissionsBoundary:Role' :: Maybe AttachedPermissionsBoundary
permissionsBoundary = Maybe AttachedPermissionsBoundary
a} :: Role)
role_description :: Lens.Lens' Role (Prelude.Maybe Prelude.Text)
role_description :: (Maybe Text -> f (Maybe Text)) -> Role -> f Role
role_description = (Role -> Maybe Text)
-> (Role -> Maybe Text -> Role)
-> Lens Role Role (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {Maybe Text
description :: Maybe Text
$sel:description:Role' :: Role -> Maybe Text
description} -> Maybe Text
description) (\s :: Role
s@Role' {} Maybe Text
a -> Role
s {$sel:description:Role' :: Maybe Text
description = Maybe Text
a} :: Role)
role_tags :: Lens.Lens' Role (Prelude.Maybe [Tag])
role_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> Role -> f Role
role_tags = (Role -> Maybe [Tag])
-> (Role -> Maybe [Tag] -> Role)
-> Lens Role Role (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:Role' :: Role -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: Role
s@Role' {} Maybe [Tag]
a -> Role
s {$sel:tags:Role' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: Role) ((Maybe [Tag] -> f (Maybe [Tag])) -> Role -> f Role)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> Role
-> f Role
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
role_path :: Lens.Lens' Role Prelude.Text
role_path :: (Text -> f Text) -> Role -> f Role
role_path = (Role -> Text)
-> (Role -> Text -> Role) -> Lens Role Role Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {Text
path :: Text
$sel:path:Role' :: Role -> Text
path} -> Text
path) (\s :: Role
s@Role' {} Text
a -> Role
s {$sel:path:Role' :: Text
path = Text
a} :: Role)
role_roleName :: Lens.Lens' Role Prelude.Text
role_roleName :: (Text -> f Text) -> Role -> f Role
role_roleName = (Role -> Text)
-> (Role -> Text -> Role) -> Lens Role Role Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {Text
roleName :: Text
$sel:roleName:Role' :: Role -> Text
roleName} -> Text
roleName) (\s :: Role
s@Role' {} Text
a -> Role
s {$sel:roleName:Role' :: Text
roleName = Text
a} :: Role)
role_roleId :: Lens.Lens' Role Prelude.Text
role_roleId :: (Text -> f Text) -> Role -> f Role
role_roleId = (Role -> Text)
-> (Role -> Text -> Role) -> Lens Role Role Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {Text
roleId :: Text
$sel:roleId:Role' :: Role -> Text
roleId} -> Text
roleId) (\s :: Role
s@Role' {} Text
a -> Role
s {$sel:roleId:Role' :: Text
roleId = Text
a} :: Role)
role_arn :: Lens.Lens' Role Prelude.Text
role_arn :: (Text -> f Text) -> Role -> f Role
role_arn = (Role -> Text)
-> (Role -> Text -> Role) -> Lens Role Role Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {Text
arn :: Text
$sel:arn:Role' :: Role -> Text
arn} -> Text
arn) (\s :: Role
s@Role' {} Text
a -> Role
s {$sel:arn:Role' :: Text
arn = Text
a} :: Role)
role_createDate :: Lens.Lens' Role Prelude.UTCTime
role_createDate :: (UTCTime -> f UTCTime) -> Role -> f Role
role_createDate = (Role -> ISO8601)
-> (Role -> ISO8601 -> Role) -> Lens Role Role ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Role' {ISO8601
createDate :: ISO8601
$sel:createDate:Role' :: Role -> ISO8601
createDate} -> ISO8601
createDate) (\s :: Role
s@Role' {} ISO8601
a -> Role
s {$sel:createDate:Role' :: ISO8601
createDate = ISO8601
a} :: Role) ((ISO8601 -> f ISO8601) -> Role -> f Role)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> Role
-> f Role
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time
instance Core.FromXML Role where
parseXML :: [Node] -> Either String Role
parseXML [Node]
x =
Maybe Natural
-> Maybe Text
-> Maybe RoleLastUsed
-> Maybe AttachedPermissionsBoundary
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> Role
Role'
(Maybe Natural
-> Maybe Text
-> Maybe RoleLastUsed
-> Maybe AttachedPermissionsBoundary
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> Role)
-> Either String (Maybe Natural)
-> Either
String
(Maybe Text
-> Maybe RoleLastUsed
-> Maybe AttachedPermissionsBoundary
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> Role)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Natural)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MaxSessionDuration")
Either
String
(Maybe Text
-> Maybe RoleLastUsed
-> Maybe AttachedPermissionsBoundary
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> Role)
-> Either String (Maybe Text)
-> Either
String
(Maybe RoleLastUsed
-> Maybe AttachedPermissionsBoundary
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> Role)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AssumeRolePolicyDocument")
Either
String
(Maybe RoleLastUsed
-> Maybe AttachedPermissionsBoundary
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> Role)
-> Either String (Maybe RoleLastUsed)
-> Either
String
(Maybe AttachedPermissionsBoundary
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> Role)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe RoleLastUsed)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"RoleLastUsed")
Either
String
(Maybe AttachedPermissionsBoundary
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> Text
-> Text
-> ISO8601
-> Role)
-> Either String (Maybe AttachedPermissionsBoundary)
-> Either
String
(Maybe Text
-> Maybe [Tag] -> Text -> Text -> Text -> Text -> ISO8601 -> Role)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe AttachedPermissionsBoundary)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PermissionsBoundary")
Either
String
(Maybe Text
-> Maybe [Tag] -> Text -> Text -> Text -> Text -> ISO8601 -> Role)
-> Either String (Maybe Text)
-> Either
String
(Maybe [Tag] -> Text -> Text -> Text -> Text -> ISO8601 -> Role)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Description")
Either
String
(Maybe [Tag] -> Text -> Text -> Text -> Text -> ISO8601 -> Role)
-> Either String (Maybe [Tag])
-> Either String (Text -> Text -> Text -> Text -> ISO8601 -> Role)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Tags" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
Either String [Node]
-> ([Node] -> Either String (Maybe [Tag]))
-> Either String (Maybe [Tag])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Tag])
-> [Node] -> Either String (Maybe [Tag])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Tag]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
)
Either String (Text -> Text -> Text -> Text -> ISO8601 -> Role)
-> Either String Text
-> Either String (Text -> Text -> Text -> ISO8601 -> Role)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Path")
Either String (Text -> Text -> Text -> ISO8601 -> Role)
-> Either String Text
-> Either String (Text -> Text -> ISO8601 -> Role)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"RoleName")
Either String (Text -> Text -> ISO8601 -> Role)
-> Either String Text -> Either String (Text -> ISO8601 -> Role)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"RoleId")
Either String (Text -> ISO8601 -> Role)
-> Either String Text -> Either String (ISO8601 -> Role)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Arn")
Either String (ISO8601 -> Role)
-> Either String ISO8601 -> Either String Role
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ISO8601
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"CreateDate")
instance Prelude.Hashable Role
instance Prelude.NFData Role