{-# 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.PutRolePermissionsBoundary
-- 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)
--
-- Adds or updates the policy that is specified as the IAM role\'s
-- permissions boundary. You can use an Amazon Web Services managed policy
-- or a customer managed policy to set the boundary for a role. Use the
-- boundary to control the maximum permissions that the role can have.
-- Setting a permissions boundary is an advanced feature that can affect
-- the permissions for the role.
--
-- You cannot set the boundary for a service-linked role.
--
-- Policies used as permissions boundaries do not provide permissions. You
-- must also attach a permissions policy to the role. To learn how the
-- effective permissions for a role are evaluated, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html IAM JSON policy evaluation logic>
-- in the IAM User Guide.
module Amazonka.IAM.PutRolePermissionsBoundary
  ( -- * Creating a Request
    PutRolePermissionsBoundary (..),
    newPutRolePermissionsBoundary,

    -- * Request Lenses
    putRolePermissionsBoundary_roleName,
    putRolePermissionsBoundary_permissionsBoundary,

    -- * Destructuring the Response
    PutRolePermissionsBoundaryResponse (..),
    newPutRolePermissionsBoundaryResponse,
  )
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:/ 'newPutRolePermissionsBoundary' smart constructor.
data PutRolePermissionsBoundary = PutRolePermissionsBoundary'
  { -- | The name (friendly name, not ARN) of the IAM role for which you want to
    -- set the permissions boundary.
    PutRolePermissionsBoundary -> Text
roleName :: Prelude.Text,
    -- | The ARN of the policy that is used to set the permissions boundary for
    -- the role.
    PutRolePermissionsBoundary -> Text
permissionsBoundary :: Prelude.Text
  }
  deriving (PutRolePermissionsBoundary -> PutRolePermissionsBoundary -> Bool
(PutRolePermissionsBoundary -> PutRolePermissionsBoundary -> Bool)
-> (PutRolePermissionsBoundary
    -> PutRolePermissionsBoundary -> Bool)
-> Eq PutRolePermissionsBoundary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRolePermissionsBoundary -> PutRolePermissionsBoundary -> Bool
$c/= :: PutRolePermissionsBoundary -> PutRolePermissionsBoundary -> Bool
== :: PutRolePermissionsBoundary -> PutRolePermissionsBoundary -> Bool
$c== :: PutRolePermissionsBoundary -> PutRolePermissionsBoundary -> Bool
Prelude.Eq, ReadPrec [PutRolePermissionsBoundary]
ReadPrec PutRolePermissionsBoundary
Int -> ReadS PutRolePermissionsBoundary
ReadS [PutRolePermissionsBoundary]
(Int -> ReadS PutRolePermissionsBoundary)
-> ReadS [PutRolePermissionsBoundary]
-> ReadPrec PutRolePermissionsBoundary
-> ReadPrec [PutRolePermissionsBoundary]
-> Read PutRolePermissionsBoundary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRolePermissionsBoundary]
$creadListPrec :: ReadPrec [PutRolePermissionsBoundary]
readPrec :: ReadPrec PutRolePermissionsBoundary
$creadPrec :: ReadPrec PutRolePermissionsBoundary
readList :: ReadS [PutRolePermissionsBoundary]
$creadList :: ReadS [PutRolePermissionsBoundary]
readsPrec :: Int -> ReadS PutRolePermissionsBoundary
$creadsPrec :: Int -> ReadS PutRolePermissionsBoundary
Prelude.Read, Int -> PutRolePermissionsBoundary -> ShowS
[PutRolePermissionsBoundary] -> ShowS
PutRolePermissionsBoundary -> String
(Int -> PutRolePermissionsBoundary -> ShowS)
-> (PutRolePermissionsBoundary -> String)
-> ([PutRolePermissionsBoundary] -> ShowS)
-> Show PutRolePermissionsBoundary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRolePermissionsBoundary] -> ShowS
$cshowList :: [PutRolePermissionsBoundary] -> ShowS
show :: PutRolePermissionsBoundary -> String
$cshow :: PutRolePermissionsBoundary -> String
showsPrec :: Int -> PutRolePermissionsBoundary -> ShowS
$cshowsPrec :: Int -> PutRolePermissionsBoundary -> ShowS
Prelude.Show, (forall x.
 PutRolePermissionsBoundary -> Rep PutRolePermissionsBoundary x)
-> (forall x.
    Rep PutRolePermissionsBoundary x -> PutRolePermissionsBoundary)
-> Generic PutRolePermissionsBoundary
forall x.
Rep PutRolePermissionsBoundary x -> PutRolePermissionsBoundary
forall x.
PutRolePermissionsBoundary -> Rep PutRolePermissionsBoundary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutRolePermissionsBoundary x -> PutRolePermissionsBoundary
$cfrom :: forall x.
PutRolePermissionsBoundary -> Rep PutRolePermissionsBoundary x
Prelude.Generic)

-- |
-- Create a value of 'PutRolePermissionsBoundary' 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', 'putRolePermissionsBoundary_roleName' - The name (friendly name, not ARN) of the IAM role for which you want to
-- set the permissions boundary.
--
-- 'permissionsBoundary', 'putRolePermissionsBoundary_permissionsBoundary' - The ARN of the policy that is used to set the permissions boundary for
-- the role.
newPutRolePermissionsBoundary ::
  -- | 'roleName'
  Prelude.Text ->
  -- | 'permissionsBoundary'
  Prelude.Text ->
  PutRolePermissionsBoundary
newPutRolePermissionsBoundary :: Text -> Text -> PutRolePermissionsBoundary
newPutRolePermissionsBoundary
  Text
pRoleName_
  Text
pPermissionsBoundary_ =
    PutRolePermissionsBoundary' :: Text -> Text -> PutRolePermissionsBoundary
PutRolePermissionsBoundary'
      { $sel:roleName:PutRolePermissionsBoundary' :: Text
roleName = Text
pRoleName_,
        $sel:permissionsBoundary:PutRolePermissionsBoundary' :: Text
permissionsBoundary = Text
pPermissionsBoundary_
      }

-- | The name (friendly name, not ARN) of the IAM role for which you want to
-- set the permissions boundary.
putRolePermissionsBoundary_roleName :: Lens.Lens' PutRolePermissionsBoundary Prelude.Text
putRolePermissionsBoundary_roleName :: (Text -> f Text)
-> PutRolePermissionsBoundary -> f PutRolePermissionsBoundary
putRolePermissionsBoundary_roleName = (PutRolePermissionsBoundary -> Text)
-> (PutRolePermissionsBoundary
    -> Text -> PutRolePermissionsBoundary)
-> Lens
     PutRolePermissionsBoundary PutRolePermissionsBoundary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRolePermissionsBoundary' {Text
roleName :: Text
$sel:roleName:PutRolePermissionsBoundary' :: PutRolePermissionsBoundary -> Text
roleName} -> Text
roleName) (\s :: PutRolePermissionsBoundary
s@PutRolePermissionsBoundary' {} Text
a -> PutRolePermissionsBoundary
s {$sel:roleName:PutRolePermissionsBoundary' :: Text
roleName = Text
a} :: PutRolePermissionsBoundary)

-- | The ARN of the policy that is used to set the permissions boundary for
-- the role.
putRolePermissionsBoundary_permissionsBoundary :: Lens.Lens' PutRolePermissionsBoundary Prelude.Text
putRolePermissionsBoundary_permissionsBoundary :: (Text -> f Text)
-> PutRolePermissionsBoundary -> f PutRolePermissionsBoundary
putRolePermissionsBoundary_permissionsBoundary = (PutRolePermissionsBoundary -> Text)
-> (PutRolePermissionsBoundary
    -> Text -> PutRolePermissionsBoundary)
-> Lens
     PutRolePermissionsBoundary PutRolePermissionsBoundary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRolePermissionsBoundary' {Text
permissionsBoundary :: Text
$sel:permissionsBoundary:PutRolePermissionsBoundary' :: PutRolePermissionsBoundary -> Text
permissionsBoundary} -> Text
permissionsBoundary) (\s :: PutRolePermissionsBoundary
s@PutRolePermissionsBoundary' {} Text
a -> PutRolePermissionsBoundary
s {$sel:permissionsBoundary:PutRolePermissionsBoundary' :: Text
permissionsBoundary = Text
a} :: PutRolePermissionsBoundary)

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

instance Prelude.Hashable PutRolePermissionsBoundary

instance Prelude.NFData PutRolePermissionsBoundary

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

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

instance Core.ToQuery PutRolePermissionsBoundary where
  toQuery :: PutRolePermissionsBoundary -> QueryString
toQuery PutRolePermissionsBoundary' {Text
permissionsBoundary :: Text
roleName :: Text
$sel:permissionsBoundary:PutRolePermissionsBoundary' :: PutRolePermissionsBoundary -> Text
$sel:roleName:PutRolePermissionsBoundary' :: PutRolePermissionsBoundary -> 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
"PutRolePermissionsBoundary" :: 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
"PermissionsBoundary" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
permissionsBoundary
      ]

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

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

instance
  Prelude.NFData
    PutRolePermissionsBoundaryResponse