{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IAM.CreateRole
-- 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)
--
-- Creates a new role for your Amazon Web Services account. For more
-- information about roles, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/WorkingWithRoles.html IAM roles>.
-- For information about quotas for role names and the number of roles you
-- can create, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html IAM and STS quotas>
-- in the /IAM User Guide/.
module Amazonka.IAM.CreateRole
  ( -- * Creating a Request
    CreateRole (..),
    newCreateRole,

    -- * Request Lenses
    createRole_maxSessionDuration,
    createRole_path,
    createRole_permissionsBoundary,
    createRole_description,
    createRole_tags,
    createRole_roleName,
    createRole_assumeRolePolicyDocument,

    -- * Destructuring the Response
    CreateRoleResponse (..),
    newCreateRoleResponse,

    -- * Response Lenses
    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

-- | /See:/ 'newCreateRole' smart constructor.
data CreateRole = CreateRole'
  { -- | The maximum session duration (in seconds) that you want to set for the
    -- specified role. If you do not specify a value for this setting, the
    -- default maximum of one hour is applied. This setting can have a value
    -- from 1 hour to 12 hours.
    --
    -- Anyone who assumes the role from the or API can use the
    -- @DurationSeconds@ API parameter or the @duration-seconds@ CLI parameter
    -- to request a longer session. The @MaxSessionDuration@ setting determines
    -- the maximum duration that can be requested using the @DurationSeconds@
    -- parameter. If users don\'t specify a value for the @DurationSeconds@
    -- parameter, their security credentials are valid for one hour by default.
    -- This applies when you use the @AssumeRole*@ API operations or the
    -- @assume-role*@ CLI operations but does not apply when you use those
    -- operations to create a console URL. For more information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html Using IAM roles>
    -- in the /IAM User Guide/.
    CreateRole -> Maybe Natural
maxSessionDuration :: Prelude.Maybe Prelude.Natural,
    -- | The path to the role. For more information about paths, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM Identifiers>
    -- in the /IAM User Guide/.
    --
    -- This parameter is optional. If it is not included, it defaults to a
    -- slash (\/).
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of either a forward slash (\/) by itself or a string that
    -- must begin and end with forward slashes. In addition, it can contain any
    -- ASCII character from the ! (@\\u0021@) through the DEL character
    -- (@\\u007F@), including most punctuation characters, digits, and upper
    -- and lowercased letters.
    CreateRole -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the policy that is used to set the permissions boundary for
    -- the role.
    CreateRole -> Maybe Text
permissionsBoundary :: Prelude.Maybe Prelude.Text,
    -- | A description of the role.
    CreateRole -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A list of tags that you want to attach to the new role. Each tag
    -- consists of a key name and an associated value. For more information
    -- about tagging, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
    -- in the /IAM User Guide/.
    --
    -- If any one of the tags is invalid or if you exceed the allowed maximum
    -- number of tags, then the entire request fails and the resource is not
    -- created.
    CreateRole -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the role to create.
    --
    -- IAM user, group, role, and policy names must be unique within the
    -- account. Names are not distinguished by case. For example, you cannot
    -- create resources named both \"MyResource\" and \"myresource\".
    CreateRole -> Text
roleName :: Prelude.Text,
    -- | The trust relationship policy document that grants an entity permission
    -- to assume the role.
    --
    -- In IAM, you must provide a JSON policy that has been converted to a
    -- string. However, for CloudFormation templates formatted in YAML, you can
    -- provide the policy in JSON or YAML format. CloudFormation always
    -- converts a YAML policy to JSON format before submitting it to IAM.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
    -- this parameter is a string of characters consisting of the following:
    --
    -- -   Any printable ASCII character ranging from the space character
    --     (@\\u0020@) through the end of the ASCII character range
    --
    -- -   The printable characters in the Basic Latin and Latin-1 Supplement
    --     character set (through @\\u00FF@)
    --
    -- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
    --     carriage return (@\\u000D@)
    --
    -- Upon success, the response includes the same trust policy in JSON
    -- format.
    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)

-- |
-- Create a value of 'CreateRole' 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:
--
-- 'maxSessionDuration', 'createRole_maxSessionDuration' - The maximum session duration (in seconds) that you want to set for the
-- specified role. If you do not specify a value for this setting, the
-- default maximum of one hour is applied. This setting can have a value
-- from 1 hour to 12 hours.
--
-- Anyone who assumes the role from the or API can use the
-- @DurationSeconds@ API parameter or the @duration-seconds@ CLI parameter
-- to request a longer session. The @MaxSessionDuration@ setting determines
-- the maximum duration that can be requested using the @DurationSeconds@
-- parameter. If users don\'t specify a value for the @DurationSeconds@
-- parameter, their security credentials are valid for one hour by default.
-- This applies when you use the @AssumeRole*@ API operations or the
-- @assume-role*@ CLI operations but does not apply when you use those
-- operations to create a console URL. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html Using IAM roles>
-- in the /IAM User Guide/.
--
-- 'path', 'createRole_path' - The path to the role. For more information about paths, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM Identifiers>
-- in the /IAM User Guide/.
--
-- This parameter is optional. If it is not included, it defaults to a
-- slash (\/).
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of either a forward slash (\/) by itself or a string that
-- must begin and end with forward slashes. In addition, it can contain any
-- ASCII character from the ! (@\\u0021@) through the DEL character
-- (@\\u007F@), including most punctuation characters, digits, and upper
-- and lowercased letters.
--
-- 'permissionsBoundary', 'createRole_permissionsBoundary' - The ARN of the policy that is used to set the permissions boundary for
-- the role.
--
-- 'description', 'createRole_description' - A description of the role.
--
-- 'tags', 'createRole_tags' - A list of tags that you want to attach to the new role. Each tag
-- consists of a key name and an associated value. For more information
-- about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
--
-- If any one of the tags is invalid or if you exceed the allowed maximum
-- number of tags, then the entire request fails and the resource is not
-- created.
--
-- 'roleName', 'createRole_roleName' - The name of the role to create.
--
-- IAM user, group, role, and policy names must be unique within the
-- account. Names are not distinguished by case. For example, you cannot
-- create resources named both \"MyResource\" and \"myresource\".
--
-- 'assumeRolePolicyDocument', 'createRole_assumeRolePolicyDocument' - The trust relationship policy document that grants an entity permission
-- to assume the role.
--
-- In IAM, you must provide a JSON policy that has been converted to a
-- string. However, for CloudFormation templates formatted in YAML, you can
-- provide the policy in JSON or YAML format. CloudFormation always
-- converts a YAML policy to JSON format before submitting it to IAM.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
-- this parameter is a string of characters consisting of the following:
--
-- -   Any printable ASCII character ranging from the space character
--     (@\\u0020@) through the end of the ASCII character range
--
-- -   The printable characters in the Basic Latin and Latin-1 Supplement
--     character set (through @\\u00FF@)
--
-- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
--     carriage return (@\\u000D@)
--
-- Upon success, the response includes the same trust policy in JSON
-- format.
newCreateRole ::
  -- | 'roleName'
  Prelude.Text ->
  -- | 'assumeRolePolicyDocument'
  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_
    }

-- | The maximum session duration (in seconds) that you want to set for the
-- specified role. If you do not specify a value for this setting, the
-- default maximum of one hour is applied. This setting can have a value
-- from 1 hour to 12 hours.
--
-- Anyone who assumes the role from the or API can use the
-- @DurationSeconds@ API parameter or the @duration-seconds@ CLI parameter
-- to request a longer session. The @MaxSessionDuration@ setting determines
-- the maximum duration that can be requested using the @DurationSeconds@
-- parameter. If users don\'t specify a value for the @DurationSeconds@
-- parameter, their security credentials are valid for one hour by default.
-- This applies when you use the @AssumeRole*@ API operations or the
-- @assume-role*@ CLI operations but does not apply when you use those
-- operations to create a console URL. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html Using IAM roles>
-- in the /IAM User Guide/.
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)

-- | The path to the role. For more information about paths, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM Identifiers>
-- in the /IAM User Guide/.
--
-- This parameter is optional. If it is not included, it defaults to a
-- slash (\/).
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of either a forward slash (\/) by itself or a string that
-- must begin and end with forward slashes. In addition, it can contain any
-- ASCII character from the ! (@\\u0021@) through the DEL character
-- (@\\u007F@), including most punctuation characters, digits, and upper
-- and lowercased letters.
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)

-- | The ARN of the policy that is used to set the permissions boundary for
-- the role.
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)

-- | A description of the role.
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)

-- | A list of tags that you want to attach to the new role. Each tag
-- consists of a key name and an associated value. For more information
-- about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
--
-- If any one of the tags is invalid or if you exceed the allowed maximum
-- number of tags, then the entire request fails and the resource is not
-- created.
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

-- | The name of the role to create.
--
-- IAM user, group, role, and policy names must be unique within the
-- account. Names are not distinguished by case. For example, you cannot
-- create resources named both \"MyResource\" and \"myresource\".
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)

-- | The trust relationship policy document that grants an entity permission
-- to assume the role.
--
-- In IAM, you must provide a JSON policy that has been converted to a
-- string. However, for CloudFormation templates formatted in YAML, you can
-- provide the policy in JSON or YAML format. CloudFormation always
-- converts a YAML policy to JSON format before submitting it to IAM.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
-- this parameter is a string of characters consisting of the following:
--
-- -   Any printable ASCII character ranging from the space character
--     (@\\u0020@) through the end of the ASCII character range
--
-- -   The printable characters in the Basic Latin and Latin-1 Supplement
--     character set (through @\\u00FF@)
--
-- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
--     carriage return (@\\u000D@)
--
-- Upon success, the response includes the same trust policy in JSON
-- format.
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
      ]

-- | Contains the response to a successful CreateRole request.
--
-- /See:/ 'newCreateRoleResponse' smart constructor.
data CreateRoleResponse = CreateRoleResponse'
  { -- | The response's http status code.
    CreateRoleResponse -> Int
httpStatus :: Prelude.Int,
    -- | A structure containing details about the new role.
    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)

-- |
-- Create a value of 'CreateRoleResponse' 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:
--
-- 'httpStatus', 'createRoleResponse_httpStatus' - The response's http status code.
--
-- 'role'', 'createRoleResponse_role' - A structure containing details about the new role.
newCreateRoleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'role''
  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_
    }

-- | The response's http status code.
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)

-- | A structure containing details about the new role.
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