{-# 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-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)
--
-- 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 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:/ '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 (Core.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
(UpdateLoginProfile -> UpdateLoginProfile -> Bool)
-> (UpdateLoginProfile -> UpdateLoginProfile -> Bool)
-> Eq UpdateLoginProfile
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
(Int -> UpdateLoginProfile -> ShowS)
-> (UpdateLoginProfile -> String)
-> ([UpdateLoginProfile] -> ShowS)
-> Show UpdateLoginProfile
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. UpdateLoginProfile -> Rep UpdateLoginProfile x)
-> (forall x. Rep UpdateLoginProfile x -> UpdateLoginProfile)
-> Generic UpdateLoginProfile
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' :: Maybe (Sensitive Text) -> Maybe Bool -> Text -> UpdateLoginProfile
UpdateLoginProfile'
    { $sel:password:UpdateLoginProfile' :: Maybe (Sensitive Text)
password = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:passwordResetRequired:UpdateLoginProfile' :: Maybe Bool
passwordResetRequired = Maybe Bool
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 :: (Maybe Text -> f (Maybe Text))
-> UpdateLoginProfile -> f UpdateLoginProfile
updateLoginProfile_password = (UpdateLoginProfile -> Maybe (Sensitive Text))
-> (UpdateLoginProfile
    -> Maybe (Sensitive Text) -> UpdateLoginProfile)
-> Lens
     UpdateLoginProfile
     UpdateLoginProfile
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
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) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> UpdateLoginProfile -> f UpdateLoginProfile)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> UpdateLoginProfile
-> f UpdateLoginProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._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 :: (Maybe Bool -> f (Maybe Bool))
-> UpdateLoginProfile -> f UpdateLoginProfile
updateLoginProfile_passwordResetRequired = (UpdateLoginProfile -> Maybe Bool)
-> (UpdateLoginProfile -> Maybe Bool -> UpdateLoginProfile)
-> Lens
     UpdateLoginProfile UpdateLoginProfile (Maybe Bool) (Maybe Bool)
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 :: (Text -> f Text) -> UpdateLoginProfile -> f UpdateLoginProfile
updateLoginProfile_userName = (UpdateLoginProfile -> Text)
-> (UpdateLoginProfile -> Text -> UpdateLoginProfile)
-> Lens UpdateLoginProfile UpdateLoginProfile Text Text
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 :: UpdateLoginProfile -> Request UpdateLoginProfile
request = Service -> UpdateLoginProfile -> Request UpdateLoginProfile
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateLoginProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateLoginProfile)))
response =
    AWSResponse UpdateLoginProfile
-> Logger
-> Service
-> Proxy UpdateLoginProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateLoginProfile)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateLoginProfile
UpdateLoginProfileResponse
UpdateLoginProfileResponse'

instance Prelude.Hashable UpdateLoginProfile

instance Prelude.NFData UpdateLoginProfile

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

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

instance Core.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)
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"UpdateLoginProfile" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"Password" ByteString -> Maybe (Sensitive Text) -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe (Sensitive Text)
password,
        ByteString
"PasswordResetRequired"
          ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
passwordResetRequired,
        ByteString
"UserName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
userName
      ]

-- | /See:/ 'newUpdateLoginProfileResponse' smart constructor.
data UpdateLoginProfileResponse = UpdateLoginProfileResponse'
  {
  }
  deriving (UpdateLoginProfileResponse -> UpdateLoginProfileResponse -> Bool
(UpdateLoginProfileResponse -> UpdateLoginProfileResponse -> Bool)
-> (UpdateLoginProfileResponse
    -> UpdateLoginProfileResponse -> Bool)
-> Eq UpdateLoginProfileResponse
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]
(Int -> ReadS UpdateLoginProfileResponse)
-> ReadS [UpdateLoginProfileResponse]
-> ReadPrec UpdateLoginProfileResponse
-> ReadPrec [UpdateLoginProfileResponse]
-> Read 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
(Int -> UpdateLoginProfileResponse -> ShowS)
-> (UpdateLoginProfileResponse -> String)
-> ([UpdateLoginProfileResponse] -> ShowS)
-> Show UpdateLoginProfileResponse
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.
 UpdateLoginProfileResponse -> Rep UpdateLoginProfileResponse x)
-> (forall x.
    Rep UpdateLoginProfileResponse x -> UpdateLoginProfileResponse)
-> Generic UpdateLoginProfileResponse
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