{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.LoginProfile
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IAM.Types.LoginProfile where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Contains the user name and password create date for a user.
--
-- This data type is used as a response element in the CreateLoginProfile
-- and GetLoginProfile operations.
--
-- /See:/ 'newLoginProfile' smart constructor.
data LoginProfile = LoginProfile'
  { -- | Specifies whether the user is required to set a new password on next
    -- sign-in.
    LoginProfile -> Maybe Bool
passwordResetRequired :: Prelude.Maybe Prelude.Bool,
    -- | The name of the user, which can be used for signing in to the Amazon Web
    -- Services Management Console.
    LoginProfile -> Text
userName :: Prelude.Text,
    -- | The date when the password for the user was created.
    LoginProfile -> ISO8601
createDate :: Data.ISO8601
  }
  deriving (LoginProfile -> LoginProfile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoginProfile -> LoginProfile -> Bool
$c/= :: LoginProfile -> LoginProfile -> Bool
== :: LoginProfile -> LoginProfile -> Bool
$c== :: LoginProfile -> LoginProfile -> Bool
Prelude.Eq, ReadPrec [LoginProfile]
ReadPrec LoginProfile
Int -> ReadS LoginProfile
ReadS [LoginProfile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoginProfile]
$creadListPrec :: ReadPrec [LoginProfile]
readPrec :: ReadPrec LoginProfile
$creadPrec :: ReadPrec LoginProfile
readList :: ReadS [LoginProfile]
$creadList :: ReadS [LoginProfile]
readsPrec :: Int -> ReadS LoginProfile
$creadsPrec :: Int -> ReadS LoginProfile
Prelude.Read, Int -> LoginProfile -> ShowS
[LoginProfile] -> ShowS
LoginProfile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoginProfile] -> ShowS
$cshowList :: [LoginProfile] -> ShowS
show :: LoginProfile -> String
$cshow :: LoginProfile -> String
showsPrec :: Int -> LoginProfile -> ShowS
$cshowsPrec :: Int -> LoginProfile -> ShowS
Prelude.Show, forall x. Rep LoginProfile x -> LoginProfile
forall x. LoginProfile -> Rep LoginProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoginProfile x -> LoginProfile
$cfrom :: forall x. LoginProfile -> Rep LoginProfile x
Prelude.Generic)

-- |
-- Create a value of 'LoginProfile' 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:
--
-- 'passwordResetRequired', 'loginProfile_passwordResetRequired' - Specifies whether the user is required to set a new password on next
-- sign-in.
--
-- 'userName', 'loginProfile_userName' - The name of the user, which can be used for signing in to the Amazon Web
-- Services Management Console.
--
-- 'createDate', 'loginProfile_createDate' - The date when the password for the user was created.
newLoginProfile ::
  -- | 'userName'
  Prelude.Text ->
  -- | 'createDate'
  Prelude.UTCTime ->
  LoginProfile
newLoginProfile :: Text -> UTCTime -> LoginProfile
newLoginProfile Text
pUserName_ UTCTime
pCreateDate_ =
  LoginProfile'
    { $sel:passwordResetRequired:LoginProfile' :: Maybe Bool
passwordResetRequired =
        forall a. Maybe a
Prelude.Nothing,
      $sel:userName:LoginProfile' :: Text
userName = Text
pUserName_,
      $sel:createDate:LoginProfile' :: ISO8601
createDate = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreateDate_
    }

-- | Specifies whether the user is required to set a new password on next
-- sign-in.
loginProfile_passwordResetRequired :: Lens.Lens' LoginProfile (Prelude.Maybe Prelude.Bool)
loginProfile_passwordResetRequired :: Lens' LoginProfile (Maybe Bool)
loginProfile_passwordResetRequired = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoginProfile' {Maybe Bool
passwordResetRequired :: Maybe Bool
$sel:passwordResetRequired:LoginProfile' :: LoginProfile -> Maybe Bool
passwordResetRequired} -> Maybe Bool
passwordResetRequired) (\s :: LoginProfile
s@LoginProfile' {} Maybe Bool
a -> LoginProfile
s {$sel:passwordResetRequired:LoginProfile' :: Maybe Bool
passwordResetRequired = Maybe Bool
a} :: LoginProfile)

-- | The name of the user, which can be used for signing in to the Amazon Web
-- Services Management Console.
loginProfile_userName :: Lens.Lens' LoginProfile Prelude.Text
loginProfile_userName :: Lens' LoginProfile Text
loginProfile_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoginProfile' {Text
userName :: Text
$sel:userName:LoginProfile' :: LoginProfile -> Text
userName} -> Text
userName) (\s :: LoginProfile
s@LoginProfile' {} Text
a -> LoginProfile
s {$sel:userName:LoginProfile' :: Text
userName = Text
a} :: LoginProfile)

-- | The date when the password for the user was created.
loginProfile_createDate :: Lens.Lens' LoginProfile Prelude.UTCTime
loginProfile_createDate :: Lens' LoginProfile UTCTime
loginProfile_createDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoginProfile' {ISO8601
createDate :: ISO8601
$sel:createDate:LoginProfile' :: LoginProfile -> ISO8601
createDate} -> ISO8601
createDate) (\s :: LoginProfile
s@LoginProfile' {} ISO8601
a -> LoginProfile
s {$sel:createDate:LoginProfile' :: ISO8601
createDate = ISO8601
a} :: LoginProfile) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromXML LoginProfile where
  parseXML :: [Node] -> Either String LoginProfile
parseXML [Node]
x =
    Maybe Bool -> Text -> ISO8601 -> LoginProfile
LoginProfile'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"PasswordResetRequired")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"UserName")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"CreateDate")

instance Prelude.Hashable LoginProfile where
  hashWithSalt :: Int -> LoginProfile -> Int
hashWithSalt Int
_salt LoginProfile' {Maybe Bool
Text
ISO8601
createDate :: ISO8601
userName :: Text
passwordResetRequired :: Maybe Bool
$sel:createDate:LoginProfile' :: LoginProfile -> ISO8601
$sel:userName:LoginProfile' :: LoginProfile -> Text
$sel:passwordResetRequired:LoginProfile' :: LoginProfile -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
passwordResetRequired
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
createDate

instance Prelude.NFData LoginProfile where
  rnf :: LoginProfile -> ()
rnf LoginProfile' {Maybe Bool
Text
ISO8601
createDate :: ISO8601
userName :: Text
passwordResetRequired :: Maybe Bool
$sel:createDate:LoginProfile' :: LoginProfile -> ISO8601
$sel:userName:LoginProfile' :: LoginProfile -> Text
$sel:passwordResetRequired:LoginProfile' :: LoginProfile -> Maybe Bool
..} =
    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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
createDate