{-# 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.UpdateLoginProfile
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Changes the password for the specified IAM user. You can use the CLI,
-- the Amazon Web Services API, or the __Users__ page in the IAM console to
-- change the password for any IAM user. Use ChangePassword to change your
-- own password in the __My Security Credentials__ page in the Amazon Web
-- Services Management Console.
--
-- For more information about modifying passwords, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_ManagingLogins.html Managing passwords>
-- in the /IAM User Guide/.
module Amazonka.IAM.UpdateLoginProfile
  ( -- * Creating a Request
    UpdateLoginProfile (..),
    newUpdateLoginProfile,

    -- * Request Lenses
    updateLoginProfile_password,
    updateLoginProfile_passwordResetRequired,
    updateLoginProfile_userName,

    -- * Destructuring the Response
    UpdateLoginProfileResponse (..),
    newUpdateLoginProfileResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateLoginProfile' smart constructor.
data UpdateLoginProfile = UpdateLoginProfile'
  { -- | The new password for the specified IAM user.
    --
    -- 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@)
    --
    -- However, the format can be further restricted by the account
    -- administrator by setting a password policy on the Amazon Web Services
    -- account. For more information, see UpdateAccountPasswordPolicy.
    UpdateLoginProfile -> Maybe (Sensitive Text)
password :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | Allows this new password to be used only once by requiring the specified
    -- IAM user to set a new password on next sign-in.
    UpdateLoginProfile -> Maybe Bool
passwordResetRequired :: Prelude.Maybe Prelude.Bool,
    -- | The name of the user whose password you want to update.
    --
    -- 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: _+=,.\@-
    UpdateLoginProfile -> Text
userName :: Prelude.Text
  }
  deriving (UpdateLoginProfile -> UpdateLoginProfile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateLoginProfile -> UpdateLoginProfile -> Bool
$c/= :: UpdateLoginProfile -> UpdateLoginProfile -> Bool
== :: UpdateLoginProfile -> UpdateLoginProfile -> Bool
$c== :: UpdateLoginProfile -> UpdateLoginProfile -> Bool
Prelude.Eq, Int -> UpdateLoginProfile -> ShowS
[UpdateLoginProfile] -> ShowS
UpdateLoginProfile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateLoginProfile] -> ShowS
$cshowList :: [UpdateLoginProfile] -> ShowS
show :: UpdateLoginProfile -> String
$cshow :: UpdateLoginProfile -> String
showsPrec :: Int -> UpdateLoginProfile -> ShowS
$cshowsPrec :: Int -> UpdateLoginProfile -> ShowS
Prelude.Show, forall x. Rep UpdateLoginProfile x -> UpdateLoginProfile
forall x. UpdateLoginProfile -> Rep UpdateLoginProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateLoginProfile x -> UpdateLoginProfile
$cfrom :: forall x. UpdateLoginProfile -> Rep UpdateLoginProfile x
Prelude.Generic)

-- |
-- Create a value of 'UpdateLoginProfile' 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:
--
-- 'password', 'updateLoginProfile_password' - The new password for the specified IAM user.
--
-- 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@)
--
-- However, the format can be further restricted by the account
-- administrator by setting a password policy on the Amazon Web Services
-- account. For more information, see UpdateAccountPasswordPolicy.
--
-- 'passwordResetRequired', 'updateLoginProfile_passwordResetRequired' - Allows this new password to be used only once by requiring the specified
-- IAM user to set a new password on next sign-in.
--
-- 'userName', 'updateLoginProfile_userName' - The name of the user whose password you want to update.
--
-- 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: _+=,.\@-
newUpdateLoginProfile ::
  -- | 'userName'
  Prelude.Text ->
  UpdateLoginProfile
newUpdateLoginProfile :: Text -> UpdateLoginProfile
newUpdateLoginProfile Text
pUserName_ =
  UpdateLoginProfile'
    { $sel:password:UpdateLoginProfile' :: Maybe (Sensitive Text)
password = forall a. Maybe a
Prelude.Nothing,
      $sel:passwordResetRequired:UpdateLoginProfile' :: Maybe Bool
passwordResetRequired = forall a. Maybe a
Prelude.Nothing,
      $sel:userName:UpdateLoginProfile' :: Text
userName = Text
pUserName_
    }

-- | The new password for the specified IAM user.
--
-- 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@)
--
-- However, the format can be further restricted by the account
-- administrator by setting a password policy on the Amazon Web Services
-- account. For more information, see UpdateAccountPasswordPolicy.
updateLoginProfile_password :: Lens.Lens' UpdateLoginProfile (Prelude.Maybe Prelude.Text)
updateLoginProfile_password :: Lens' UpdateLoginProfile (Maybe Text)
updateLoginProfile_password = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLoginProfile' {Maybe (Sensitive Text)
password :: Maybe (Sensitive Text)
$sel:password:UpdateLoginProfile' :: UpdateLoginProfile -> Maybe (Sensitive Text)
password} -> Maybe (Sensitive Text)
password) (\s :: UpdateLoginProfile
s@UpdateLoginProfile' {} Maybe (Sensitive Text)
a -> UpdateLoginProfile
s {$sel:password:UpdateLoginProfile' :: Maybe (Sensitive Text)
password = Maybe (Sensitive Text)
a} :: UpdateLoginProfile) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | Allows this new password to be used only once by requiring the specified
-- IAM user to set a new password on next sign-in.
updateLoginProfile_passwordResetRequired :: Lens.Lens' UpdateLoginProfile (Prelude.Maybe Prelude.Bool)
updateLoginProfile_passwordResetRequired :: Lens' UpdateLoginProfile (Maybe Bool)
updateLoginProfile_passwordResetRequired = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLoginProfile' {Maybe Bool
passwordResetRequired :: Maybe Bool
$sel:passwordResetRequired:UpdateLoginProfile' :: UpdateLoginProfile -> Maybe Bool
passwordResetRequired} -> Maybe Bool
passwordResetRequired) (\s :: UpdateLoginProfile
s@UpdateLoginProfile' {} Maybe Bool
a -> UpdateLoginProfile
s {$sel:passwordResetRequired:UpdateLoginProfile' :: Maybe Bool
passwordResetRequired = Maybe Bool
a} :: UpdateLoginProfile)

-- | The name of the user whose password you want to update.
--
-- 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: _+=,.\@-
updateLoginProfile_userName :: Lens.Lens' UpdateLoginProfile Prelude.Text
updateLoginProfile_userName :: Lens' UpdateLoginProfile Text
updateLoginProfile_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLoginProfile' {Text
userName :: Text
$sel:userName:UpdateLoginProfile' :: UpdateLoginProfile -> Text
userName} -> Text
userName) (\s :: UpdateLoginProfile
s@UpdateLoginProfile' {} Text
a -> UpdateLoginProfile
s {$sel:userName:UpdateLoginProfile' :: Text
userName = Text
a} :: UpdateLoginProfile)

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

instance Prelude.Hashable UpdateLoginProfile where
  hashWithSalt :: Int -> UpdateLoginProfile -> Int
hashWithSalt Int
_salt UpdateLoginProfile' {Maybe Bool
Maybe (Sensitive Text)
Text
userName :: Text
passwordResetRequired :: Maybe Bool
password :: Maybe (Sensitive Text)
$sel:userName:UpdateLoginProfile' :: UpdateLoginProfile -> Text
$sel:passwordResetRequired:UpdateLoginProfile' :: UpdateLoginProfile -> Maybe Bool
$sel:password:UpdateLoginProfile' :: UpdateLoginProfile -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
password
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
passwordResetRequired
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userName

instance Prelude.NFData UpdateLoginProfile where
  rnf :: UpdateLoginProfile -> ()
rnf UpdateLoginProfile' {Maybe Bool
Maybe (Sensitive Text)
Text
userName :: Text
passwordResetRequired :: Maybe Bool
password :: Maybe (Sensitive Text)
$sel:userName:UpdateLoginProfile' :: UpdateLoginProfile -> Text
$sel:passwordResetRequired:UpdateLoginProfile' :: UpdateLoginProfile -> Maybe Bool
$sel:password:UpdateLoginProfile' :: UpdateLoginProfile -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
password
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
passwordResetRequired
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userName

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

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

instance Data.ToQuery UpdateLoginProfile where
  toQuery :: UpdateLoginProfile -> QueryString
toQuery UpdateLoginProfile' {Maybe Bool
Maybe (Sensitive Text)
Text
userName :: Text
passwordResetRequired :: Maybe Bool
password :: Maybe (Sensitive Text)
$sel:userName:UpdateLoginProfile' :: UpdateLoginProfile -> Text
$sel:passwordResetRequired:UpdateLoginProfile' :: UpdateLoginProfile -> Maybe Bool
$sel:password:UpdateLoginProfile' :: UpdateLoginProfile -> Maybe (Sensitive Text)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"UpdateLoginProfile" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"Password" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe (Sensitive Text)
password,
        ByteString
"PasswordResetRequired"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
passwordResetRequired,
        ByteString
"UserName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
userName
      ]

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

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

instance Prelude.NFData UpdateLoginProfileResponse where
  rnf :: UpdateLoginProfileResponse -> ()
rnf UpdateLoginProfileResponse
_ = ()