{-# 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.CognitoIdentityProvider.Types.UserType
-- 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.CognitoIdentityProvider.Types.UserType where

import Amazonka.CognitoIdentityProvider.Types.AttributeType
import Amazonka.CognitoIdentityProvider.Types.MFAOptionType
import Amazonka.CognitoIdentityProvider.Types.UserStatusType
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

-- | A user profile in a Amazon Cognito user pool.
--
-- /See:/ 'newUserType' smart constructor.
data UserType = UserType'
  { -- | A container with information about the user type attributes.
    UserType -> Maybe [AttributeType]
attributes :: Prelude.Maybe [AttributeType],
    -- | Specifies whether the user is enabled.
    UserType -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The MFA options for the user.
    UserType -> Maybe [MFAOptionType]
mfaOptions :: Prelude.Maybe [MFAOptionType],
    -- | The creation date of the user.
    UserType -> Maybe POSIX
userCreateDate :: Prelude.Maybe Data.POSIX,
    -- | The last modified date of the user.
    UserType -> Maybe POSIX
userLastModifiedDate :: Prelude.Maybe Data.POSIX,
    -- | The user status. This can be one of the following:
    --
    -- -   UNCONFIRMED - User has been created but not confirmed.
    --
    -- -   CONFIRMED - User has been confirmed.
    --
    -- -   EXTERNAL_PROVIDER - User signed in with a third-party IdP.
    --
    -- -   ARCHIVED - User is no longer active.
    --
    -- -   UNKNOWN - User status isn\'t known.
    --
    -- -   RESET_REQUIRED - User is confirmed, but the user must request a code
    --     and reset their password before they can sign in.
    --
    -- -   FORCE_CHANGE_PASSWORD - The user is confirmed and the user can sign
    --     in using a temporary password, but on first sign-in, the user must
    --     change their password to a new value before doing anything else.
    UserType -> Maybe UserStatusType
userStatus :: Prelude.Maybe UserStatusType,
    -- | The user name of the user you want to describe.
    UserType -> Maybe (Sensitive Text)
username :: Prelude.Maybe (Data.Sensitive Prelude.Text)
  }
  deriving (UserType -> UserType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserType -> UserType -> Bool
$c/= :: UserType -> UserType -> Bool
== :: UserType -> UserType -> Bool
$c== :: UserType -> UserType -> Bool
Prelude.Eq, Int -> UserType -> ShowS
[UserType] -> ShowS
UserType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserType] -> ShowS
$cshowList :: [UserType] -> ShowS
show :: UserType -> String
$cshow :: UserType -> String
showsPrec :: Int -> UserType -> ShowS
$cshowsPrec :: Int -> UserType -> ShowS
Prelude.Show, forall x. Rep UserType x -> UserType
forall x. UserType -> Rep UserType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserType x -> UserType
$cfrom :: forall x. UserType -> Rep UserType x
Prelude.Generic)

-- |
-- Create a value of 'UserType' 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:
--
-- 'attributes', 'userType_attributes' - A container with information about the user type attributes.
--
-- 'enabled', 'userType_enabled' - Specifies whether the user is enabled.
--
-- 'mfaOptions', 'userType_mfaOptions' - The MFA options for the user.
--
-- 'userCreateDate', 'userType_userCreateDate' - The creation date of the user.
--
-- 'userLastModifiedDate', 'userType_userLastModifiedDate' - The last modified date of the user.
--
-- 'userStatus', 'userType_userStatus' - The user status. This can be one of the following:
--
-- -   UNCONFIRMED - User has been created but not confirmed.
--
-- -   CONFIRMED - User has been confirmed.
--
-- -   EXTERNAL_PROVIDER - User signed in with a third-party IdP.
--
-- -   ARCHIVED - User is no longer active.
--
-- -   UNKNOWN - User status isn\'t known.
--
-- -   RESET_REQUIRED - User is confirmed, but the user must request a code
--     and reset their password before they can sign in.
--
-- -   FORCE_CHANGE_PASSWORD - The user is confirmed and the user can sign
--     in using a temporary password, but on first sign-in, the user must
--     change their password to a new value before doing anything else.
--
-- 'username', 'userType_username' - The user name of the user you want to describe.
newUserType ::
  UserType
newUserType :: UserType
newUserType =
  UserType'
    { $sel:attributes:UserType' :: Maybe [AttributeType]
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:UserType' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:mfaOptions:UserType' :: Maybe [MFAOptionType]
mfaOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:userCreateDate:UserType' :: Maybe POSIX
userCreateDate = forall a. Maybe a
Prelude.Nothing,
      $sel:userLastModifiedDate:UserType' :: Maybe POSIX
userLastModifiedDate = forall a. Maybe a
Prelude.Nothing,
      $sel:userStatus:UserType' :: Maybe UserStatusType
userStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:username:UserType' :: Maybe (Sensitive Text)
username = forall a. Maybe a
Prelude.Nothing
    }

-- | A container with information about the user type attributes.
userType_attributes :: Lens.Lens' UserType (Prelude.Maybe [AttributeType])
userType_attributes :: Lens' UserType (Maybe [AttributeType])
userType_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserType' {Maybe [AttributeType]
attributes :: Maybe [AttributeType]
$sel:attributes:UserType' :: UserType -> Maybe [AttributeType]
attributes} -> Maybe [AttributeType]
attributes) (\s :: UserType
s@UserType' {} Maybe [AttributeType]
a -> UserType
s {$sel:attributes:UserType' :: Maybe [AttributeType]
attributes = Maybe [AttributeType]
a} :: UserType) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies whether the user is enabled.
userType_enabled :: Lens.Lens' UserType (Prelude.Maybe Prelude.Bool)
userType_enabled :: Lens' UserType (Maybe Bool)
userType_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserType' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:UserType' :: UserType -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: UserType
s@UserType' {} Maybe Bool
a -> UserType
s {$sel:enabled:UserType' :: Maybe Bool
enabled = Maybe Bool
a} :: UserType)

-- | The MFA options for the user.
userType_mfaOptions :: Lens.Lens' UserType (Prelude.Maybe [MFAOptionType])
userType_mfaOptions :: Lens' UserType (Maybe [MFAOptionType])
userType_mfaOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserType' {Maybe [MFAOptionType]
mfaOptions :: Maybe [MFAOptionType]
$sel:mfaOptions:UserType' :: UserType -> Maybe [MFAOptionType]
mfaOptions} -> Maybe [MFAOptionType]
mfaOptions) (\s :: UserType
s@UserType' {} Maybe [MFAOptionType]
a -> UserType
s {$sel:mfaOptions:UserType' :: Maybe [MFAOptionType]
mfaOptions = Maybe [MFAOptionType]
a} :: UserType) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The creation date of the user.
userType_userCreateDate :: Lens.Lens' UserType (Prelude.Maybe Prelude.UTCTime)
userType_userCreateDate :: Lens' UserType (Maybe UTCTime)
userType_userCreateDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserType' {Maybe POSIX
userCreateDate :: Maybe POSIX
$sel:userCreateDate:UserType' :: UserType -> Maybe POSIX
userCreateDate} -> Maybe POSIX
userCreateDate) (\s :: UserType
s@UserType' {} Maybe POSIX
a -> UserType
s {$sel:userCreateDate:UserType' :: Maybe POSIX
userCreateDate = Maybe POSIX
a} :: UserType) 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 :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The last modified date of the user.
userType_userLastModifiedDate :: Lens.Lens' UserType (Prelude.Maybe Prelude.UTCTime)
userType_userLastModifiedDate :: Lens' UserType (Maybe UTCTime)
userType_userLastModifiedDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserType' {Maybe POSIX
userLastModifiedDate :: Maybe POSIX
$sel:userLastModifiedDate:UserType' :: UserType -> Maybe POSIX
userLastModifiedDate} -> Maybe POSIX
userLastModifiedDate) (\s :: UserType
s@UserType' {} Maybe POSIX
a -> UserType
s {$sel:userLastModifiedDate:UserType' :: Maybe POSIX
userLastModifiedDate = Maybe POSIX
a} :: UserType) 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 :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The user status. This can be one of the following:
--
-- -   UNCONFIRMED - User has been created but not confirmed.
--
-- -   CONFIRMED - User has been confirmed.
--
-- -   EXTERNAL_PROVIDER - User signed in with a third-party IdP.
--
-- -   ARCHIVED - User is no longer active.
--
-- -   UNKNOWN - User status isn\'t known.
--
-- -   RESET_REQUIRED - User is confirmed, but the user must request a code
--     and reset their password before they can sign in.
--
-- -   FORCE_CHANGE_PASSWORD - The user is confirmed and the user can sign
--     in using a temporary password, but on first sign-in, the user must
--     change their password to a new value before doing anything else.
userType_userStatus :: Lens.Lens' UserType (Prelude.Maybe UserStatusType)
userType_userStatus :: Lens' UserType (Maybe UserStatusType)
userType_userStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserType' {Maybe UserStatusType
userStatus :: Maybe UserStatusType
$sel:userStatus:UserType' :: UserType -> Maybe UserStatusType
userStatus} -> Maybe UserStatusType
userStatus) (\s :: UserType
s@UserType' {} Maybe UserStatusType
a -> UserType
s {$sel:userStatus:UserType' :: Maybe UserStatusType
userStatus = Maybe UserStatusType
a} :: UserType)

-- | The user name of the user you want to describe.
userType_username :: Lens.Lens' UserType (Prelude.Maybe Prelude.Text)
userType_username :: Lens' UserType (Maybe Text)
userType_username = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserType' {Maybe (Sensitive Text)
username :: Maybe (Sensitive Text)
$sel:username:UserType' :: UserType -> Maybe (Sensitive Text)
username} -> Maybe (Sensitive Text)
username) (\s :: UserType
s@UserType' {} Maybe (Sensitive Text)
a -> UserType
s {$sel:username:UserType' :: Maybe (Sensitive Text)
username = Maybe (Sensitive Text)
a} :: UserType) 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

instance Data.FromJSON UserType where
  parseJSON :: Value -> Parser UserType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UserType"
      ( \Object
x ->
          Maybe [AttributeType]
-> Maybe Bool
-> Maybe [MFAOptionType]
-> Maybe POSIX
-> Maybe POSIX
-> Maybe UserStatusType
-> Maybe (Sensitive Text)
-> UserType
UserType'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Attributes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Enabled")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MFAOptions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UserCreateDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UserLastModifiedDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UserStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Username")
      )

instance Prelude.Hashable UserType where
  hashWithSalt :: Int -> UserType -> Int
hashWithSalt Int
_salt UserType' {Maybe Bool
Maybe [AttributeType]
Maybe [MFAOptionType]
Maybe (Sensitive Text)
Maybe POSIX
Maybe UserStatusType
username :: Maybe (Sensitive Text)
userStatus :: Maybe UserStatusType
userLastModifiedDate :: Maybe POSIX
userCreateDate :: Maybe POSIX
mfaOptions :: Maybe [MFAOptionType]
enabled :: Maybe Bool
attributes :: Maybe [AttributeType]
$sel:username:UserType' :: UserType -> Maybe (Sensitive Text)
$sel:userStatus:UserType' :: UserType -> Maybe UserStatusType
$sel:userLastModifiedDate:UserType' :: UserType -> Maybe POSIX
$sel:userCreateDate:UserType' :: UserType -> Maybe POSIX
$sel:mfaOptions:UserType' :: UserType -> Maybe [MFAOptionType]
$sel:enabled:UserType' :: UserType -> Maybe Bool
$sel:attributes:UserType' :: UserType -> Maybe [AttributeType]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AttributeType]
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [MFAOptionType]
mfaOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
userCreateDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
userLastModifiedDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UserStatusType
userStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
username

instance Prelude.NFData UserType where
  rnf :: UserType -> ()
rnf UserType' {Maybe Bool
Maybe [AttributeType]
Maybe [MFAOptionType]
Maybe (Sensitive Text)
Maybe POSIX
Maybe UserStatusType
username :: Maybe (Sensitive Text)
userStatus :: Maybe UserStatusType
userLastModifiedDate :: Maybe POSIX
userCreateDate :: Maybe POSIX
mfaOptions :: Maybe [MFAOptionType]
enabled :: Maybe Bool
attributes :: Maybe [AttributeType]
$sel:username:UserType' :: UserType -> Maybe (Sensitive Text)
$sel:userStatus:UserType' :: UserType -> Maybe UserStatusType
$sel:userLastModifiedDate:UserType' :: UserType -> Maybe POSIX
$sel:userCreateDate:UserType' :: UserType -> Maybe POSIX
$sel:mfaOptions:UserType' :: UserType -> Maybe [MFAOptionType]
$sel:enabled:UserType' :: UserType -> Maybe Bool
$sel:attributes:UserType' :: UserType -> Maybe [AttributeType]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AttributeType]
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [MFAOptionType]
mfaOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
userCreateDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
userLastModifiedDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UserStatusType
userStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
username