{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.IAM.CreateRole
(
CreateRole (..),
newCreateRole,
createRole_maxSessionDuration,
createRole_path,
createRole_permissionsBoundary,
createRole_description,
createRole_tags,
createRole_roleName,
createRole_assumeRolePolicyDocument,
CreateRoleResponse (..),
newCreateRoleResponse,
createRoleResponse_httpStatus,
createRoleResponse_role,
)
where
import qualified Amazonka.Core as Core
import Amazonka.IAM.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateRole = CreateRole'
{
CreateRole -> Maybe Natural
maxSessionDuration :: Prelude.Maybe Prelude.Natural,
CreateRole -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
CreateRole -> Maybe Text
permissionsBoundary :: Prelude.Maybe Prelude.Text,
CreateRole -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateRole -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateRole -> Text
roleName :: Prelude.Text,
CreateRole -> Text
assumeRolePolicyDocument :: Prelude.Text
}
deriving (CreateRole -> CreateRole -> Bool
(CreateRole -> CreateRole -> Bool)
-> (CreateRole -> CreateRole -> Bool) -> Eq CreateRole
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRole -> CreateRole -> Bool
$c/= :: CreateRole -> CreateRole -> Bool
== :: CreateRole -> CreateRole -> Bool
$c== :: CreateRole -> CreateRole -> Bool
Prelude.Eq, ReadPrec [CreateRole]
ReadPrec CreateRole
Int -> ReadS CreateRole
ReadS [CreateRole]
(Int -> ReadS CreateRole)
-> ReadS [CreateRole]
-> ReadPrec CreateRole
-> ReadPrec [CreateRole]
-> Read CreateRole
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRole]
$creadListPrec :: ReadPrec [CreateRole]
readPrec :: ReadPrec CreateRole
$creadPrec :: ReadPrec CreateRole
readList :: ReadS [CreateRole]
$creadList :: ReadS [CreateRole]
readsPrec :: Int -> ReadS CreateRole
$creadsPrec :: Int -> ReadS CreateRole
Prelude.Read, Int -> CreateRole -> ShowS
[CreateRole] -> ShowS
CreateRole -> String
(Int -> CreateRole -> ShowS)
-> (CreateRole -> String)
-> ([CreateRole] -> ShowS)
-> Show CreateRole
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRole] -> ShowS
$cshowList :: [CreateRole] -> ShowS
show :: CreateRole -> String
$cshow :: CreateRole -> String
showsPrec :: Int -> CreateRole -> ShowS
$cshowsPrec :: Int -> CreateRole -> ShowS
Prelude.Show, (forall x. CreateRole -> Rep CreateRole x)
-> (forall x. Rep CreateRole x -> CreateRole) -> Generic CreateRole
forall x. Rep CreateRole x -> CreateRole
forall x. CreateRole -> Rep CreateRole x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRole x -> CreateRole
$cfrom :: forall x. CreateRole -> Rep CreateRole x
Prelude.Generic)
newCreateRole ::
Prelude.Text ->
Prelude.Text ->
CreateRole
newCreateRole :: Text -> Text -> CreateRole
newCreateRole Text
pRoleName_ Text
pAssumeRolePolicyDocument_ =
CreateRole' :: Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> CreateRole
CreateRole'
{ $sel:maxSessionDuration:CreateRole' :: Maybe Natural
maxSessionDuration = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:path:CreateRole' :: Maybe Text
path = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:permissionsBoundary:CreateRole' :: Maybe Text
permissionsBoundary = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:description:CreateRole' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateRole' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:roleName:CreateRole' :: Text
roleName = Text
pRoleName_,
$sel:assumeRolePolicyDocument:CreateRole' :: Text
assumeRolePolicyDocument =
Text
pAssumeRolePolicyDocument_
}
createRole_maxSessionDuration :: Lens.Lens' CreateRole (Prelude.Maybe Prelude.Natural)
createRole_maxSessionDuration :: (Maybe Natural -> f (Maybe Natural)) -> CreateRole -> f CreateRole
createRole_maxSessionDuration = (CreateRole -> Maybe Natural)
-> (CreateRole -> Maybe Natural -> CreateRole)
-> Lens CreateRole CreateRole (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRole' {Maybe Natural
maxSessionDuration :: Maybe Natural
$sel:maxSessionDuration:CreateRole' :: CreateRole -> Maybe Natural
maxSessionDuration} -> Maybe Natural
maxSessionDuration) (\s :: CreateRole
s@CreateRole' {} Maybe Natural
a -> CreateRole
s {$sel:maxSessionDuration:CreateRole' :: Maybe Natural
maxSessionDuration = Maybe Natural
a} :: CreateRole)
createRole_path :: Lens.Lens' CreateRole (Prelude.Maybe Prelude.Text)
createRole_path :: (Maybe Text -> f (Maybe Text)) -> CreateRole -> f CreateRole
createRole_path = (CreateRole -> Maybe Text)
-> (CreateRole -> Maybe Text -> CreateRole)
-> Lens CreateRole CreateRole (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRole' {Maybe Text
path :: Maybe Text
$sel:path:CreateRole' :: CreateRole -> Maybe Text
path} -> Maybe Text
path) (\s :: CreateRole
s@CreateRole' {} Maybe Text
a -> CreateRole
s {$sel:path:CreateRole' :: Maybe Text
path = Maybe Text
a} :: CreateRole)
createRole_permissionsBoundary :: Lens.Lens' CreateRole (Prelude.Maybe Prelude.Text)
createRole_permissionsBoundary :: (Maybe Text -> f (Maybe Text)) -> CreateRole -> f CreateRole
createRole_permissionsBoundary = (CreateRole -> Maybe Text)
-> (CreateRole -> Maybe Text -> CreateRole)
-> Lens CreateRole CreateRole (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRole' {Maybe Text
permissionsBoundary :: Maybe Text
$sel:permissionsBoundary:CreateRole' :: CreateRole -> Maybe Text
permissionsBoundary} -> Maybe Text
permissionsBoundary) (\s :: CreateRole
s@CreateRole' {} Maybe Text
a -> CreateRole
s {$sel:permissionsBoundary:CreateRole' :: Maybe Text
permissionsBoundary = Maybe Text
a} :: CreateRole)
createRole_description :: Lens.Lens' CreateRole (Prelude.Maybe Prelude.Text)
createRole_description :: (Maybe Text -> f (Maybe Text)) -> CreateRole -> f CreateRole
createRole_description = (CreateRole -> Maybe Text)
-> (CreateRole -> Maybe Text -> CreateRole)
-> Lens CreateRole CreateRole (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRole' {Maybe Text
description :: Maybe Text
$sel:description:CreateRole' :: CreateRole -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateRole
s@CreateRole' {} Maybe Text
a -> CreateRole
s {$sel:description:CreateRole' :: Maybe Text
description = Maybe Text
a} :: CreateRole)
createRole_tags :: Lens.Lens' CreateRole (Prelude.Maybe [Tag])
createRole_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> CreateRole -> f CreateRole
createRole_tags = (CreateRole -> Maybe [Tag])
-> (CreateRole -> Maybe [Tag] -> CreateRole)
-> Lens CreateRole CreateRole (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRole' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateRole' :: CreateRole -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateRole
s@CreateRole' {} Maybe [Tag]
a -> CreateRole
s {$sel:tags:CreateRole' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateRole) ((Maybe [Tag] -> f (Maybe [Tag])) -> CreateRole -> f CreateRole)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateRole
-> f CreateRole
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
createRole_roleName :: Lens.Lens' CreateRole Prelude.Text
createRole_roleName :: (Text -> f Text) -> CreateRole -> f CreateRole
createRole_roleName = (CreateRole -> Text)
-> (CreateRole -> Text -> CreateRole)
-> Lens CreateRole CreateRole Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRole' {Text
roleName :: Text
$sel:roleName:CreateRole' :: CreateRole -> Text
roleName} -> Text
roleName) (\s :: CreateRole
s@CreateRole' {} Text
a -> CreateRole
s {$sel:roleName:CreateRole' :: Text
roleName = Text
a} :: CreateRole)
createRole_assumeRolePolicyDocument :: Lens.Lens' CreateRole Prelude.Text
createRole_assumeRolePolicyDocument :: (Text -> f Text) -> CreateRole -> f CreateRole
createRole_assumeRolePolicyDocument = (CreateRole -> Text)
-> (CreateRole -> Text -> CreateRole)
-> Lens CreateRole CreateRole Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRole' {Text
assumeRolePolicyDocument :: Text
$sel:assumeRolePolicyDocument:CreateRole' :: CreateRole -> Text
assumeRolePolicyDocument} -> Text
assumeRolePolicyDocument) (\s :: CreateRole
s@CreateRole' {} Text
a -> CreateRole
s {$sel:assumeRolePolicyDocument:CreateRole' :: Text
assumeRolePolicyDocument = Text
a} :: CreateRole)
instance Core.AWSRequest CreateRole where
type AWSResponse CreateRole = CreateRoleResponse
request :: CreateRole -> Request CreateRole
request = Service -> CreateRole -> Request CreateRole
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
response :: Logger
-> Service
-> Proxy CreateRole
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRole)))
response =
Text
-> (Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse CreateRole))
-> Logger
-> Service
-> Proxy CreateRole
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRole)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
Text
"CreateRoleResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Int -> Role -> CreateRoleResponse
CreateRoleResponse'
(Int -> Role -> CreateRoleResponse)
-> Either String Int -> Either String (Role -> CreateRoleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
Either String (Role -> CreateRoleResponse)
-> Either String Role -> Either String CreateRoleResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Role
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Role")
)
instance Prelude.Hashable CreateRole
instance Prelude.NFData CreateRole
instance Core.ToHeaders CreateRole where
toHeaders :: CreateRole -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateRole -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath CreateRole where
toPath :: CreateRole -> ByteString
toPath = ByteString -> CreateRole -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateRole where
toQuery :: CreateRole -> QueryString
toQuery CreateRole' {Maybe Natural
Maybe [Tag]
Maybe Text
Text
assumeRolePolicyDocument :: Text
roleName :: Text
tags :: Maybe [Tag]
description :: Maybe Text
permissionsBoundary :: Maybe Text
path :: Maybe Text
maxSessionDuration :: Maybe Natural
$sel:assumeRolePolicyDocument:CreateRole' :: CreateRole -> Text
$sel:roleName:CreateRole' :: CreateRole -> Text
$sel:tags:CreateRole' :: CreateRole -> Maybe [Tag]
$sel:description:CreateRole' :: CreateRole -> Maybe Text
$sel:permissionsBoundary:CreateRole' :: CreateRole -> Maybe Text
$sel:path:CreateRole' :: CreateRole -> Maybe Text
$sel:maxSessionDuration:CreateRole' :: CreateRole -> Maybe Natural
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Action"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"CreateRole" :: Prelude.ByteString),
ByteString
"Version"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
ByteString
"MaxSessionDuration" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxSessionDuration,
ByteString
"Path" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
path,
ByteString
"PermissionsBoundary" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
permissionsBoundary,
ByteString
"Description" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
description,
ByteString
"Tags"
ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
(ByteString -> [Tag] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Tag] -> QueryString) -> Maybe [Tag] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags),
ByteString
"RoleName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
roleName,
ByteString
"AssumeRolePolicyDocument"
ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
assumeRolePolicyDocument
]
data CreateRoleResponse = CreateRoleResponse'
{
CreateRoleResponse -> Int
httpStatus :: Prelude.Int,
CreateRoleResponse -> Role
role' :: Role
}
deriving (CreateRoleResponse -> CreateRoleResponse -> Bool
(CreateRoleResponse -> CreateRoleResponse -> Bool)
-> (CreateRoleResponse -> CreateRoleResponse -> Bool)
-> Eq CreateRoleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRoleResponse -> CreateRoleResponse -> Bool
$c/= :: CreateRoleResponse -> CreateRoleResponse -> Bool
== :: CreateRoleResponse -> CreateRoleResponse -> Bool
$c== :: CreateRoleResponse -> CreateRoleResponse -> Bool
Prelude.Eq, ReadPrec [CreateRoleResponse]
ReadPrec CreateRoleResponse
Int -> ReadS CreateRoleResponse
ReadS [CreateRoleResponse]
(Int -> ReadS CreateRoleResponse)
-> ReadS [CreateRoleResponse]
-> ReadPrec CreateRoleResponse
-> ReadPrec [CreateRoleResponse]
-> Read CreateRoleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRoleResponse]
$creadListPrec :: ReadPrec [CreateRoleResponse]
readPrec :: ReadPrec CreateRoleResponse
$creadPrec :: ReadPrec CreateRoleResponse
readList :: ReadS [CreateRoleResponse]
$creadList :: ReadS [CreateRoleResponse]
readsPrec :: Int -> ReadS CreateRoleResponse
$creadsPrec :: Int -> ReadS CreateRoleResponse
Prelude.Read, Int -> CreateRoleResponse -> ShowS
[CreateRoleResponse] -> ShowS
CreateRoleResponse -> String
(Int -> CreateRoleResponse -> ShowS)
-> (CreateRoleResponse -> String)
-> ([CreateRoleResponse] -> ShowS)
-> Show CreateRoleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRoleResponse] -> ShowS
$cshowList :: [CreateRoleResponse] -> ShowS
show :: CreateRoleResponse -> String
$cshow :: CreateRoleResponse -> String
showsPrec :: Int -> CreateRoleResponse -> ShowS
$cshowsPrec :: Int -> CreateRoleResponse -> ShowS
Prelude.Show, (forall x. CreateRoleResponse -> Rep CreateRoleResponse x)
-> (forall x. Rep CreateRoleResponse x -> CreateRoleResponse)
-> Generic CreateRoleResponse
forall x. Rep CreateRoleResponse x -> CreateRoleResponse
forall x. CreateRoleResponse -> Rep CreateRoleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRoleResponse x -> CreateRoleResponse
$cfrom :: forall x. CreateRoleResponse -> Rep CreateRoleResponse x
Prelude.Generic)
newCreateRoleResponse ::
Prelude.Int ->
Role ->
CreateRoleResponse
newCreateRoleResponse :: Int -> Role -> CreateRoleResponse
newCreateRoleResponse Int
pHttpStatus_ Role
pRole_ =
CreateRoleResponse' :: Int -> Role -> CreateRoleResponse
CreateRoleResponse'
{ $sel:httpStatus:CreateRoleResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:role':CreateRoleResponse' :: Role
role' = Role
pRole_
}
createRoleResponse_httpStatus :: Lens.Lens' CreateRoleResponse Prelude.Int
createRoleResponse_httpStatus :: (Int -> f Int) -> CreateRoleResponse -> f CreateRoleResponse
createRoleResponse_httpStatus = (CreateRoleResponse -> Int)
-> (CreateRoleResponse -> Int -> CreateRoleResponse)
-> Lens CreateRoleResponse CreateRoleResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRoleResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateRoleResponse' :: CreateRoleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateRoleResponse
s@CreateRoleResponse' {} Int
a -> CreateRoleResponse
s {$sel:httpStatus:CreateRoleResponse' :: Int
httpStatus = Int
a} :: CreateRoleResponse)
createRoleResponse_role :: Lens.Lens' CreateRoleResponse Role
createRoleResponse_role :: (Role -> f Role) -> CreateRoleResponse -> f CreateRoleResponse
createRoleResponse_role = (CreateRoleResponse -> Role)
-> (CreateRoleResponse -> Role -> CreateRoleResponse)
-> Lens CreateRoleResponse CreateRoleResponse Role Role
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRoleResponse' {Role
role' :: Role
$sel:role':CreateRoleResponse' :: CreateRoleResponse -> Role
role'} -> Role
role') (\s :: CreateRoleResponse
s@CreateRoleResponse' {} Role
a -> CreateRoleResponse
s {$sel:role':CreateRoleResponse' :: Role
role' = Role
a} :: CreateRoleResponse)
instance Prelude.NFData CreateRoleResponse