{-# 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-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)
module Amazonka.IAM.Types.LoginProfile where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 :: Core.ISO8601
  }
  deriving (LoginProfile -> LoginProfile -> Bool
(LoginProfile -> LoginProfile -> Bool)
-> (LoginProfile -> LoginProfile -> Bool) -> Eq LoginProfile
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]
(Int -> ReadS LoginProfile)
-> ReadS [LoginProfile]
-> ReadPrec LoginProfile
-> ReadPrec [LoginProfile]
-> Read 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
(Int -> LoginProfile -> ShowS)
-> (LoginProfile -> String)
-> ([LoginProfile] -> ShowS)
-> Show LoginProfile
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. LoginProfile -> Rep LoginProfile x)
-> (forall x. Rep LoginProfile x -> LoginProfile)
-> Generic LoginProfile
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' :: Maybe Bool -> Text -> ISO8601 -> LoginProfile
LoginProfile'
    { $sel:passwordResetRequired:LoginProfile' :: Maybe Bool
passwordResetRequired =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:LoginProfile' :: Text
userName = Text
pUserName_,
      $sel:createDate:LoginProfile' :: ISO8601
createDate = Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
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 :: (Maybe Bool -> f (Maybe Bool)) -> LoginProfile -> f LoginProfile
loginProfile_passwordResetRequired = (LoginProfile -> Maybe Bool)
-> (LoginProfile -> Maybe Bool -> LoginProfile)
-> Lens LoginProfile LoginProfile (Maybe Bool) (Maybe Bool)
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 :: (Text -> f Text) -> LoginProfile -> f LoginProfile
loginProfile_userName = (LoginProfile -> Text)
-> (LoginProfile -> Text -> LoginProfile)
-> Lens LoginProfile LoginProfile Text Text
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 :: (UTCTime -> f UTCTime) -> LoginProfile -> f LoginProfile
loginProfile_createDate = (LoginProfile -> ISO8601)
-> (LoginProfile -> ISO8601 -> LoginProfile)
-> Lens LoginProfile LoginProfile ISO8601 ISO8601
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) ((ISO8601 -> f ISO8601) -> LoginProfile -> f LoginProfile)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> LoginProfile
-> f LoginProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.Hashable LoginProfile

instance Prelude.NFData LoginProfile