{-# 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.UpdateAssumeRolePolicy
-- 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)
--
-- Updates the policy that grants an IAM entity permission to assume a
-- role. This is typically referred to as the \"role trust policy\". For
-- more information about roles, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/roles-toplevel.html Using roles to delegate permissions and federate identities>.
module Amazonka.IAM.UpdateAssumeRolePolicy
  ( -- * Creating a Request
    UpdateAssumeRolePolicy (..),
    newUpdateAssumeRolePolicy,

    -- * Request Lenses
    updateAssumeRolePolicy_roleName,
    updateAssumeRolePolicy_policyDocument,

    -- * Destructuring the Response
    UpdateAssumeRolePolicyResponse (..),
    newUpdateAssumeRolePolicyResponse,
  )
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:/ 'newUpdateAssumeRolePolicy' smart constructor.
data UpdateAssumeRolePolicy = UpdateAssumeRolePolicy'
  { -- | The name of the role to update with the new policy.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of upper and lowercase alphanumeric characters with no
    -- spaces. You can also include any of the following characters: _+=,.\@-
    UpdateAssumeRolePolicy -> Text
roleName :: Prelude.Text,
    -- | The policy that grants an entity permission to assume the role.
    --
    -- You must provide policies in JSON format in IAM. 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@)
    UpdateAssumeRolePolicy -> Text
policyDocument :: Prelude.Text
  }
  deriving (UpdateAssumeRolePolicy -> UpdateAssumeRolePolicy -> Bool
(UpdateAssumeRolePolicy -> UpdateAssumeRolePolicy -> Bool)
-> (UpdateAssumeRolePolicy -> UpdateAssumeRolePolicy -> Bool)
-> Eq UpdateAssumeRolePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAssumeRolePolicy -> UpdateAssumeRolePolicy -> Bool
$c/= :: UpdateAssumeRolePolicy -> UpdateAssumeRolePolicy -> Bool
== :: UpdateAssumeRolePolicy -> UpdateAssumeRolePolicy -> Bool
$c== :: UpdateAssumeRolePolicy -> UpdateAssumeRolePolicy -> Bool
Prelude.Eq, ReadPrec [UpdateAssumeRolePolicy]
ReadPrec UpdateAssumeRolePolicy
Int -> ReadS UpdateAssumeRolePolicy
ReadS [UpdateAssumeRolePolicy]
(Int -> ReadS UpdateAssumeRolePolicy)
-> ReadS [UpdateAssumeRolePolicy]
-> ReadPrec UpdateAssumeRolePolicy
-> ReadPrec [UpdateAssumeRolePolicy]
-> Read UpdateAssumeRolePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAssumeRolePolicy]
$creadListPrec :: ReadPrec [UpdateAssumeRolePolicy]
readPrec :: ReadPrec UpdateAssumeRolePolicy
$creadPrec :: ReadPrec UpdateAssumeRolePolicy
readList :: ReadS [UpdateAssumeRolePolicy]
$creadList :: ReadS [UpdateAssumeRolePolicy]
readsPrec :: Int -> ReadS UpdateAssumeRolePolicy
$creadsPrec :: Int -> ReadS UpdateAssumeRolePolicy
Prelude.Read, Int -> UpdateAssumeRolePolicy -> ShowS
[UpdateAssumeRolePolicy] -> ShowS
UpdateAssumeRolePolicy -> String
(Int -> UpdateAssumeRolePolicy -> ShowS)
-> (UpdateAssumeRolePolicy -> String)
-> ([UpdateAssumeRolePolicy] -> ShowS)
-> Show UpdateAssumeRolePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAssumeRolePolicy] -> ShowS
$cshowList :: [UpdateAssumeRolePolicy] -> ShowS
show :: UpdateAssumeRolePolicy -> String
$cshow :: UpdateAssumeRolePolicy -> String
showsPrec :: Int -> UpdateAssumeRolePolicy -> ShowS
$cshowsPrec :: Int -> UpdateAssumeRolePolicy -> ShowS
Prelude.Show, (forall x. UpdateAssumeRolePolicy -> Rep UpdateAssumeRolePolicy x)
-> (forall x.
    Rep UpdateAssumeRolePolicy x -> UpdateAssumeRolePolicy)
-> Generic UpdateAssumeRolePolicy
forall x. Rep UpdateAssumeRolePolicy x -> UpdateAssumeRolePolicy
forall x. UpdateAssumeRolePolicy -> Rep UpdateAssumeRolePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAssumeRolePolicy x -> UpdateAssumeRolePolicy
$cfrom :: forall x. UpdateAssumeRolePolicy -> Rep UpdateAssumeRolePolicy x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAssumeRolePolicy' 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:
--
-- 'roleName', 'updateAssumeRolePolicy_roleName' - The name of the role to update with the new policy.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
--
-- 'policyDocument', 'updateAssumeRolePolicy_policyDocument' - The policy that grants an entity permission to assume the role.
--
-- You must provide policies in JSON format in IAM. 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@)
newUpdateAssumeRolePolicy ::
  -- | 'roleName'
  Prelude.Text ->
  -- | 'policyDocument'
  Prelude.Text ->
  UpdateAssumeRolePolicy
newUpdateAssumeRolePolicy :: Text -> Text -> UpdateAssumeRolePolicy
newUpdateAssumeRolePolicy Text
pRoleName_ Text
pPolicyDocument_ =
  UpdateAssumeRolePolicy' :: Text -> Text -> UpdateAssumeRolePolicy
UpdateAssumeRolePolicy'
    { $sel:roleName:UpdateAssumeRolePolicy' :: Text
roleName = Text
pRoleName_,
      $sel:policyDocument:UpdateAssumeRolePolicy' :: Text
policyDocument = Text
pPolicyDocument_
    }

-- | The name of the role to update with the new policy.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
updateAssumeRolePolicy_roleName :: Lens.Lens' UpdateAssumeRolePolicy Prelude.Text
updateAssumeRolePolicy_roleName :: (Text -> f Text)
-> UpdateAssumeRolePolicy -> f UpdateAssumeRolePolicy
updateAssumeRolePolicy_roleName = (UpdateAssumeRolePolicy -> Text)
-> (UpdateAssumeRolePolicy -> Text -> UpdateAssumeRolePolicy)
-> Lens UpdateAssumeRolePolicy UpdateAssumeRolePolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssumeRolePolicy' {Text
roleName :: Text
$sel:roleName:UpdateAssumeRolePolicy' :: UpdateAssumeRolePolicy -> Text
roleName} -> Text
roleName) (\s :: UpdateAssumeRolePolicy
s@UpdateAssumeRolePolicy' {} Text
a -> UpdateAssumeRolePolicy
s {$sel:roleName:UpdateAssumeRolePolicy' :: Text
roleName = Text
a} :: UpdateAssumeRolePolicy)

-- | The policy that grants an entity permission to assume the role.
--
-- You must provide policies in JSON format in IAM. 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@)
updateAssumeRolePolicy_policyDocument :: Lens.Lens' UpdateAssumeRolePolicy Prelude.Text
updateAssumeRolePolicy_policyDocument :: (Text -> f Text)
-> UpdateAssumeRolePolicy -> f UpdateAssumeRolePolicy
updateAssumeRolePolicy_policyDocument = (UpdateAssumeRolePolicy -> Text)
-> (UpdateAssumeRolePolicy -> Text -> UpdateAssumeRolePolicy)
-> Lens UpdateAssumeRolePolicy UpdateAssumeRolePolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssumeRolePolicy' {Text
policyDocument :: Text
$sel:policyDocument:UpdateAssumeRolePolicy' :: UpdateAssumeRolePolicy -> Text
policyDocument} -> Text
policyDocument) (\s :: UpdateAssumeRolePolicy
s@UpdateAssumeRolePolicy' {} Text
a -> UpdateAssumeRolePolicy
s {$sel:policyDocument:UpdateAssumeRolePolicy' :: Text
policyDocument = Text
a} :: UpdateAssumeRolePolicy)

instance Core.AWSRequest UpdateAssumeRolePolicy where
  type
    AWSResponse UpdateAssumeRolePolicy =
      UpdateAssumeRolePolicyResponse
  request :: UpdateAssumeRolePolicy -> Request UpdateAssumeRolePolicy
request = Service -> UpdateAssumeRolePolicy -> Request UpdateAssumeRolePolicy
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateAssumeRolePolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateAssumeRolePolicy)))
response =
    AWSResponse UpdateAssumeRolePolicy
-> Logger
-> Service
-> Proxy UpdateAssumeRolePolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateAssumeRolePolicy)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse UpdateAssumeRolePolicy
UpdateAssumeRolePolicyResponse
UpdateAssumeRolePolicyResponse'

instance Prelude.Hashable UpdateAssumeRolePolicy

instance Prelude.NFData UpdateAssumeRolePolicy

instance Core.ToHeaders UpdateAssumeRolePolicy where
  toHeaders :: UpdateAssumeRolePolicy -> [Header]
toHeaders = [Header] -> UpdateAssumeRolePolicy -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath UpdateAssumeRolePolicy where
  toPath :: UpdateAssumeRolePolicy -> ByteString
toPath = ByteString -> UpdateAssumeRolePolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery UpdateAssumeRolePolicy where
  toQuery :: UpdateAssumeRolePolicy -> QueryString
toQuery UpdateAssumeRolePolicy' {Text
policyDocument :: Text
roleName :: Text
$sel:policyDocument:UpdateAssumeRolePolicy' :: UpdateAssumeRolePolicy -> Text
$sel:roleName:UpdateAssumeRolePolicy' :: UpdateAssumeRolePolicy -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"UpdateAssumeRolePolicy" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"RoleName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
roleName,
        ByteString
"PolicyDocument" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
policyDocument
      ]

-- | /See:/ 'newUpdateAssumeRolePolicyResponse' smart constructor.
data UpdateAssumeRolePolicyResponse = UpdateAssumeRolePolicyResponse'
  {
  }
  deriving (UpdateAssumeRolePolicyResponse
-> UpdateAssumeRolePolicyResponse -> Bool
(UpdateAssumeRolePolicyResponse
 -> UpdateAssumeRolePolicyResponse -> Bool)
-> (UpdateAssumeRolePolicyResponse
    -> UpdateAssumeRolePolicyResponse -> Bool)
-> Eq UpdateAssumeRolePolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAssumeRolePolicyResponse
-> UpdateAssumeRolePolicyResponse -> Bool
$c/= :: UpdateAssumeRolePolicyResponse
-> UpdateAssumeRolePolicyResponse -> Bool
== :: UpdateAssumeRolePolicyResponse
-> UpdateAssumeRolePolicyResponse -> Bool
$c== :: UpdateAssumeRolePolicyResponse
-> UpdateAssumeRolePolicyResponse -> Bool
Prelude.Eq, ReadPrec [UpdateAssumeRolePolicyResponse]
ReadPrec UpdateAssumeRolePolicyResponse
Int -> ReadS UpdateAssumeRolePolicyResponse
ReadS [UpdateAssumeRolePolicyResponse]
(Int -> ReadS UpdateAssumeRolePolicyResponse)
-> ReadS [UpdateAssumeRolePolicyResponse]
-> ReadPrec UpdateAssumeRolePolicyResponse
-> ReadPrec [UpdateAssumeRolePolicyResponse]
-> Read UpdateAssumeRolePolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAssumeRolePolicyResponse]
$creadListPrec :: ReadPrec [UpdateAssumeRolePolicyResponse]
readPrec :: ReadPrec UpdateAssumeRolePolicyResponse
$creadPrec :: ReadPrec UpdateAssumeRolePolicyResponse
readList :: ReadS [UpdateAssumeRolePolicyResponse]
$creadList :: ReadS [UpdateAssumeRolePolicyResponse]
readsPrec :: Int -> ReadS UpdateAssumeRolePolicyResponse
$creadsPrec :: Int -> ReadS UpdateAssumeRolePolicyResponse
Prelude.Read, Int -> UpdateAssumeRolePolicyResponse -> ShowS
[UpdateAssumeRolePolicyResponse] -> ShowS
UpdateAssumeRolePolicyResponse -> String
(Int -> UpdateAssumeRolePolicyResponse -> ShowS)
-> (UpdateAssumeRolePolicyResponse -> String)
-> ([UpdateAssumeRolePolicyResponse] -> ShowS)
-> Show UpdateAssumeRolePolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAssumeRolePolicyResponse] -> ShowS
$cshowList :: [UpdateAssumeRolePolicyResponse] -> ShowS
show :: UpdateAssumeRolePolicyResponse -> String
$cshow :: UpdateAssumeRolePolicyResponse -> String
showsPrec :: Int -> UpdateAssumeRolePolicyResponse -> ShowS
$cshowsPrec :: Int -> UpdateAssumeRolePolicyResponse -> ShowS
Prelude.Show, (forall x.
 UpdateAssumeRolePolicyResponse
 -> Rep UpdateAssumeRolePolicyResponse x)
-> (forall x.
    Rep UpdateAssumeRolePolicyResponse x
    -> UpdateAssumeRolePolicyResponse)
-> Generic UpdateAssumeRolePolicyResponse
forall x.
Rep UpdateAssumeRolePolicyResponse x
-> UpdateAssumeRolePolicyResponse
forall x.
UpdateAssumeRolePolicyResponse
-> Rep UpdateAssumeRolePolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateAssumeRolePolicyResponse x
-> UpdateAssumeRolePolicyResponse
$cfrom :: forall x.
UpdateAssumeRolePolicyResponse
-> Rep UpdateAssumeRolePolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAssumeRolePolicyResponse' 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.
newUpdateAssumeRolePolicyResponse ::
  UpdateAssumeRolePolicyResponse
newUpdateAssumeRolePolicyResponse :: UpdateAssumeRolePolicyResponse
newUpdateAssumeRolePolicyResponse =
  UpdateAssumeRolePolicyResponse
UpdateAssumeRolePolicyResponse'

instance
  Prelude.NFData
    UpdateAssumeRolePolicyResponse