{-# 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.PutUserPermissionsBoundary
-- 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 user\'s
-- permissions boundary. You can use an Amazon Web Services managed policy
-- or a customer managed policy to set the boundary for a user. Use the
-- boundary to control the maximum permissions that the user can have.
-- Setting a permissions boundary is an advanced feature that can affect
-- the permissions for the user.
--
-- Policies that are used as permissions boundaries do not provide
-- permissions. You must also attach a permissions policy to the user. To
-- learn how the effective permissions for a user 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.PutUserPermissionsBoundary
  ( -- * Creating a Request
    PutUserPermissionsBoundary (..),
    newPutUserPermissionsBoundary,

    -- * Request Lenses
    putUserPermissionsBoundary_userName,
    putUserPermissionsBoundary_permissionsBoundary,

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

-- |
-- Create a value of 'PutUserPermissionsBoundary' 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:
--
-- 'userName', 'putUserPermissionsBoundary_userName' - The name (friendly name, not ARN) of the IAM user for which you want to
-- set the permissions boundary.
--
-- 'permissionsBoundary', 'putUserPermissionsBoundary_permissionsBoundary' - The ARN of the policy that is used to set the permissions boundary for
-- the user.
newPutUserPermissionsBoundary ::
  -- | 'userName'
  Prelude.Text ->
  -- | 'permissionsBoundary'
  Prelude.Text ->
  PutUserPermissionsBoundary
newPutUserPermissionsBoundary :: Text -> Text -> PutUserPermissionsBoundary
newPutUserPermissionsBoundary
  Text
pUserName_
  Text
pPermissionsBoundary_ =
    PutUserPermissionsBoundary' :: Text -> Text -> PutUserPermissionsBoundary
PutUserPermissionsBoundary'
      { $sel:userName:PutUserPermissionsBoundary' :: Text
userName = Text
pUserName_,
        $sel:permissionsBoundary:PutUserPermissionsBoundary' :: Text
permissionsBoundary = Text
pPermissionsBoundary_
      }

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

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

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

instance Prelude.Hashable PutUserPermissionsBoundary

instance Prelude.NFData PutUserPermissionsBoundary

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

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

instance Core.ToQuery PutUserPermissionsBoundary where
  toQuery :: PutUserPermissionsBoundary -> QueryString
toQuery PutUserPermissionsBoundary' {Text
permissionsBoundary :: Text
userName :: Text
$sel:permissionsBoundary:PutUserPermissionsBoundary' :: PutUserPermissionsBoundary -> Text
$sel:userName:PutUserPermissionsBoundary' :: PutUserPermissionsBoundary -> 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
"PutUserPermissionsBoundary" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"UserName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
userName,
        ByteString
"PermissionsBoundary" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
permissionsBoundary
      ]

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

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

instance
  Prelude.NFData
    PutUserPermissionsBoundaryResponse