{-# 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.UpdateUser
-- 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 name and\/or the path of the specified IAM user.
--
-- You should understand the implications of changing an IAM user\'s path
-- or name. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_manage.html#id_users_renaming Renaming an IAM user>
-- and
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups_manage_rename.html Renaming an IAM group>
-- in the /IAM User Guide/.
--
-- To change a user name, the requester must have appropriate permissions
-- on both the source object and the target object. For example, to change
-- Bob to Robert, the entity making the request must have permission on Bob
-- and Robert, or must have permission on all (*). For more information
-- about permissions, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/PermissionsAndPolicies.html Permissions and policies>.
module Amazonka.IAM.UpdateUser
  ( -- * Creating a Request
    UpdateUser (..),
    newUpdateUser,

    -- * Request Lenses
    updateUser_newUserName,
    updateUser_newPath,
    updateUser_userName,

    -- * Destructuring the Response
    UpdateUserResponse (..),
    newUpdateUserResponse,
  )
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:/ 'newUpdateUser' smart constructor.
data UpdateUser = UpdateUser'
  { -- | New name for the user. Include this parameter only if you\'re changing
    -- the user\'s name.
    --
    -- 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\".
    UpdateUser -> Maybe Text
newUserName' :: Prelude.Maybe Prelude.Text,
    -- | New path for the IAM user. Include this parameter only if you\'re
    -- changing the user\'s path.
    --
    -- 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.
    UpdateUser -> Maybe Text
newPath' :: Prelude.Maybe Prelude.Text,
    -- | Name of the user to update. If you\'re changing the name of the user,
    -- this is the original user name.
    --
    -- 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: _+=,.\@-
    UpdateUser -> Text
userName :: Prelude.Text
  }
  deriving (UpdateUser -> UpdateUser -> Bool
(UpdateUser -> UpdateUser -> Bool)
-> (UpdateUser -> UpdateUser -> Bool) -> Eq UpdateUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateUser -> UpdateUser -> Bool
$c/= :: UpdateUser -> UpdateUser -> Bool
== :: UpdateUser -> UpdateUser -> Bool
$c== :: UpdateUser -> UpdateUser -> Bool
Prelude.Eq, ReadPrec [UpdateUser]
ReadPrec UpdateUser
Int -> ReadS UpdateUser
ReadS [UpdateUser]
(Int -> ReadS UpdateUser)
-> ReadS [UpdateUser]
-> ReadPrec UpdateUser
-> ReadPrec [UpdateUser]
-> Read UpdateUser
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateUser]
$creadListPrec :: ReadPrec [UpdateUser]
readPrec :: ReadPrec UpdateUser
$creadPrec :: ReadPrec UpdateUser
readList :: ReadS [UpdateUser]
$creadList :: ReadS [UpdateUser]
readsPrec :: Int -> ReadS UpdateUser
$creadsPrec :: Int -> ReadS UpdateUser
Prelude.Read, Int -> UpdateUser -> ShowS
[UpdateUser] -> ShowS
UpdateUser -> String
(Int -> UpdateUser -> ShowS)
-> (UpdateUser -> String)
-> ([UpdateUser] -> ShowS)
-> Show UpdateUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateUser] -> ShowS
$cshowList :: [UpdateUser] -> ShowS
show :: UpdateUser -> String
$cshow :: UpdateUser -> String
showsPrec :: Int -> UpdateUser -> ShowS
$cshowsPrec :: Int -> UpdateUser -> ShowS
Prelude.Show, (forall x. UpdateUser -> Rep UpdateUser x)
-> (forall x. Rep UpdateUser x -> UpdateUser) -> Generic UpdateUser
forall x. Rep UpdateUser x -> UpdateUser
forall x. UpdateUser -> Rep UpdateUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateUser x -> UpdateUser
$cfrom :: forall x. UpdateUser -> Rep UpdateUser x
Prelude.Generic)

-- |
-- Create a value of 'UpdateUser' 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:
--
-- 'newUserName'', 'updateUser_newUserName' - New name for the user. Include this parameter only if you\'re changing
-- the user\'s name.
--
-- 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\".
--
-- 'newPath'', 'updateUser_newPath' - New path for the IAM user. Include this parameter only if you\'re
-- changing the user\'s path.
--
-- 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.
--
-- 'userName', 'updateUser_userName' - Name of the user to update. If you\'re changing the name of the user,
-- this is the original user name.
--
-- 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: _+=,.\@-
newUpdateUser ::
  -- | 'userName'
  Prelude.Text ->
  UpdateUser
newUpdateUser :: Text -> UpdateUser
newUpdateUser Text
pUserName_ =
  UpdateUser' :: Maybe Text -> Maybe Text -> Text -> UpdateUser
UpdateUser'
    { $sel:newUserName':UpdateUser' :: Maybe Text
newUserName' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:newPath':UpdateUser' :: Maybe Text
newPath' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:UpdateUser' :: Text
userName = Text
pUserName_
    }

-- | New name for the user. Include this parameter only if you\'re changing
-- the user\'s name.
--
-- 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\".
updateUser_newUserName :: Lens.Lens' UpdateUser (Prelude.Maybe Prelude.Text)
updateUser_newUserName :: (Maybe Text -> f (Maybe Text)) -> UpdateUser -> f UpdateUser
updateUser_newUserName = (UpdateUser -> Maybe Text)
-> (UpdateUser -> Maybe Text -> UpdateUser)
-> Lens UpdateUser UpdateUser (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUser' {Maybe Text
newUserName' :: Maybe Text
$sel:newUserName':UpdateUser' :: UpdateUser -> Maybe Text
newUserName'} -> Maybe Text
newUserName') (\s :: UpdateUser
s@UpdateUser' {} Maybe Text
a -> UpdateUser
s {$sel:newUserName':UpdateUser' :: Maybe Text
newUserName' = Maybe Text
a} :: UpdateUser)

-- | New path for the IAM user. Include this parameter only if you\'re
-- changing the user\'s path.
--
-- 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.
updateUser_newPath :: Lens.Lens' UpdateUser (Prelude.Maybe Prelude.Text)
updateUser_newPath :: (Maybe Text -> f (Maybe Text)) -> UpdateUser -> f UpdateUser
updateUser_newPath = (UpdateUser -> Maybe Text)
-> (UpdateUser -> Maybe Text -> UpdateUser)
-> Lens UpdateUser UpdateUser (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUser' {Maybe Text
newPath' :: Maybe Text
$sel:newPath':UpdateUser' :: UpdateUser -> Maybe Text
newPath'} -> Maybe Text
newPath') (\s :: UpdateUser
s@UpdateUser' {} Maybe Text
a -> UpdateUser
s {$sel:newPath':UpdateUser' :: Maybe Text
newPath' = Maybe Text
a} :: UpdateUser)

-- | Name of the user to update. If you\'re changing the name of the user,
-- this is the original user name.
--
-- 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: _+=,.\@-
updateUser_userName :: Lens.Lens' UpdateUser Prelude.Text
updateUser_userName :: (Text -> f Text) -> UpdateUser -> f UpdateUser
updateUser_userName = (UpdateUser -> Text)
-> (UpdateUser -> Text -> UpdateUser)
-> Lens UpdateUser UpdateUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUser' {Text
userName :: Text
$sel:userName:UpdateUser' :: UpdateUser -> Text
userName} -> Text
userName) (\s :: UpdateUser
s@UpdateUser' {} Text
a -> UpdateUser
s {$sel:userName:UpdateUser' :: Text
userName = Text
a} :: UpdateUser)

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

instance Prelude.Hashable UpdateUser

instance Prelude.NFData UpdateUser

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

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

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

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

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

instance Prelude.NFData UpdateUserResponse