{-# 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.AppStream.Types.User
-- 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.AppStream.Types.User where

import Amazonka.AppStream.Types.AuthenticationType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a user in the user pool.
--
-- /See:/ 'newUser' smart constructor.
data User = User'
  { -- | The status of the user in the user pool. The status can be one of the
    -- following:
    --
    -- -   UNCONFIRMED – The user is created but not confirmed.
    --
    -- -   CONFIRMED – The user is confirmed.
    --
    -- -   ARCHIVED – The user is no longer active.
    --
    -- -   COMPROMISED – The user is disabled because of a potential security
    --     threat.
    --
    -- -   UNKNOWN – The user status is not known.
    User -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether the user in the user pool is enabled.
    User -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The last name, or surname, of the user.
    User -> Maybe (Sensitive Text)
lastName :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The ARN of the user.
    User -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The date and time the user was created in the user pool.
    User -> Maybe POSIX
createdTime :: Prelude.Maybe Core.POSIX,
    -- | The email address of the user.
    --
    -- Users\' email addresses are case-sensitive.
    User -> Maybe (Sensitive Text)
userName :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The first name, or given name, of the user.
    User -> Maybe (Sensitive Text)
firstName :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The authentication type for the user.
    User -> AuthenticationType
authenticationType :: AuthenticationType
  }
  deriving (User -> User -> Bool
(User -> User -> Bool) -> (User -> User -> Bool) -> Eq User
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: User -> User -> Bool
$c/= :: User -> User -> Bool
== :: User -> User -> Bool
$c== :: User -> User -> Bool
Prelude.Eq, Int -> User -> ShowS
[User] -> ShowS
User -> String
(Int -> User -> ShowS)
-> (User -> String) -> ([User] -> ShowS) -> Show User
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [User] -> ShowS
$cshowList :: [User] -> ShowS
show :: User -> String
$cshow :: User -> String
showsPrec :: Int -> User -> ShowS
$cshowsPrec :: Int -> User -> ShowS
Prelude.Show, (forall x. User -> Rep User x)
-> (forall x. Rep User x -> User) -> Generic User
forall x. Rep User x -> User
forall x. User -> Rep User x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep User x -> User
$cfrom :: forall x. User -> Rep User x
Prelude.Generic)

-- |
-- Create a value of 'User' 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:
--
-- 'status', 'user_status' - The status of the user in the user pool. The status can be one of the
-- following:
--
-- -   UNCONFIRMED – The user is created but not confirmed.
--
-- -   CONFIRMED – The user is confirmed.
--
-- -   ARCHIVED – The user is no longer active.
--
-- -   COMPROMISED – The user is disabled because of a potential security
--     threat.
--
-- -   UNKNOWN – The user status is not known.
--
-- 'enabled', 'user_enabled' - Specifies whether the user in the user pool is enabled.
--
-- 'lastName', 'user_lastName' - The last name, or surname, of the user.
--
-- 'arn', 'user_arn' - The ARN of the user.
--
-- 'createdTime', 'user_createdTime' - The date and time the user was created in the user pool.
--
-- 'userName', 'user_userName' - The email address of the user.
--
-- Users\' email addresses are case-sensitive.
--
-- 'firstName', 'user_firstName' - The first name, or given name, of the user.
--
-- 'authenticationType', 'user_authenticationType' - The authentication type for the user.
newUser ::
  -- | 'authenticationType'
  AuthenticationType ->
  User
newUser :: AuthenticationType -> User
newUser AuthenticationType
pAuthenticationType_ =
  User' :: Maybe Text
-> Maybe Bool
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe POSIX
-> Maybe (Sensitive Text)
-> Maybe (Sensitive Text)
-> AuthenticationType
-> User
User'
    { $sel:status:User' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:User' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:lastName:User' :: Maybe (Sensitive Text)
lastName = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:User' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdTime:User' :: Maybe POSIX
createdTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:User' :: Maybe (Sensitive Text)
userName = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:firstName:User' :: Maybe (Sensitive Text)
firstName = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:authenticationType:User' :: AuthenticationType
authenticationType = AuthenticationType
pAuthenticationType_
    }

-- | The status of the user in the user pool. The status can be one of the
-- following:
--
-- -   UNCONFIRMED – The user is created but not confirmed.
--
-- -   CONFIRMED – The user is confirmed.
--
-- -   ARCHIVED – The user is no longer active.
--
-- -   COMPROMISED – The user is disabled because of a potential security
--     threat.
--
-- -   UNKNOWN – The user status is not known.
user_status :: Lens.Lens' User (Prelude.Maybe Prelude.Text)
user_status :: (Maybe Text -> f (Maybe Text)) -> User -> f User
user_status = (User -> Maybe Text)
-> (User -> Maybe Text -> User)
-> Lens User User (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Maybe Text
status :: Maybe Text
$sel:status:User' :: User -> Maybe Text
status} -> Maybe Text
status) (\s :: User
s@User' {} Maybe Text
a -> User
s {$sel:status:User' :: Maybe Text
status = Maybe Text
a} :: User)

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

-- | The last name, or surname, of the user.
user_lastName :: Lens.Lens' User (Prelude.Maybe Prelude.Text)
user_lastName :: (Maybe Text -> f (Maybe Text)) -> User -> f User
user_lastName = (User -> Maybe (Sensitive Text))
-> (User -> Maybe (Sensitive Text) -> User)
-> Lens User User (Maybe (Sensitive Text)) (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Maybe (Sensitive Text)
lastName :: Maybe (Sensitive Text)
$sel:lastName:User' :: User -> Maybe (Sensitive Text)
lastName} -> Maybe (Sensitive Text)
lastName) (\s :: User
s@User' {} Maybe (Sensitive Text)
a -> User
s {$sel:lastName:User' :: Maybe (Sensitive Text)
lastName = Maybe (Sensitive Text)
a} :: User) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> User -> f User)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> User
-> f User
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

-- | The ARN of the user.
user_arn :: Lens.Lens' User (Prelude.Maybe Prelude.Text)
user_arn :: (Maybe Text -> f (Maybe Text)) -> User -> f User
user_arn = (User -> Maybe Text)
-> (User -> Maybe Text -> User)
-> Lens User User (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Maybe Text
arn :: Maybe Text
$sel:arn:User' :: User -> Maybe Text
arn} -> Maybe Text
arn) (\s :: User
s@User' {} Maybe Text
a -> User
s {$sel:arn:User' :: Maybe Text
arn = Maybe Text
a} :: User)

-- | The date and time the user was created in the user pool.
user_createdTime :: Lens.Lens' User (Prelude.Maybe Prelude.UTCTime)
user_createdTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> User -> f User
user_createdTime = (User -> Maybe POSIX)
-> (User -> Maybe POSIX -> User)
-> Lens User User (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Maybe POSIX
createdTime :: Maybe POSIX
$sel:createdTime:User' :: User -> Maybe POSIX
createdTime} -> Maybe POSIX
createdTime) (\s :: User
s@User' {} Maybe POSIX
a -> User
s {$sel:createdTime:User' :: Maybe POSIX
createdTime = Maybe POSIX
a} :: User) ((Maybe POSIX -> f (Maybe POSIX)) -> User -> f User)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> User
-> f User
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The email address of the user.
--
-- Users\' email addresses are case-sensitive.
user_userName :: Lens.Lens' User (Prelude.Maybe Prelude.Text)
user_userName :: (Maybe Text -> f (Maybe Text)) -> User -> f User
user_userName = (User -> Maybe (Sensitive Text))
-> (User -> Maybe (Sensitive Text) -> User)
-> Lens User User (Maybe (Sensitive Text)) (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Maybe (Sensitive Text)
userName :: Maybe (Sensitive Text)
$sel:userName:User' :: User -> Maybe (Sensitive Text)
userName} -> Maybe (Sensitive Text)
userName) (\s :: User
s@User' {} Maybe (Sensitive Text)
a -> User
s {$sel:userName:User' :: Maybe (Sensitive Text)
userName = Maybe (Sensitive Text)
a} :: User) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> User -> f User)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> User
-> f User
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

-- | The first name, or given name, of the user.
user_firstName :: Lens.Lens' User (Prelude.Maybe Prelude.Text)
user_firstName :: (Maybe Text -> f (Maybe Text)) -> User -> f User
user_firstName = (User -> Maybe (Sensitive Text))
-> (User -> Maybe (Sensitive Text) -> User)
-> Lens User User (Maybe (Sensitive Text)) (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Maybe (Sensitive Text)
firstName :: Maybe (Sensitive Text)
$sel:firstName:User' :: User -> Maybe (Sensitive Text)
firstName} -> Maybe (Sensitive Text)
firstName) (\s :: User
s@User' {} Maybe (Sensitive Text)
a -> User
s {$sel:firstName:User' :: Maybe (Sensitive Text)
firstName = Maybe (Sensitive Text)
a} :: User) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> User -> f User)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> User
-> f User
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

-- | The authentication type for the user.
user_authenticationType :: Lens.Lens' User AuthenticationType
user_authenticationType :: (AuthenticationType -> f AuthenticationType) -> User -> f User
user_authenticationType = (User -> AuthenticationType)
-> (User -> AuthenticationType -> User)
-> Lens User User AuthenticationType AuthenticationType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {AuthenticationType
authenticationType :: AuthenticationType
$sel:authenticationType:User' :: User -> AuthenticationType
authenticationType} -> AuthenticationType
authenticationType) (\s :: User
s@User' {} AuthenticationType
a -> User
s {$sel:authenticationType:User' :: AuthenticationType
authenticationType = AuthenticationType
a} :: User)

instance Core.FromJSON User where
  parseJSON :: Value -> Parser User
parseJSON =
    String -> (Object -> Parser User) -> Value -> Parser User
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"User"
      ( \Object
x ->
          Maybe Text
-> Maybe Bool
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe POSIX
-> Maybe (Sensitive Text)
-> Maybe (Sensitive Text)
-> AuthenticationType
-> User
User'
            (Maybe Text
 -> Maybe Bool
 -> Maybe (Sensitive Text)
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe (Sensitive Text)
 -> Maybe (Sensitive Text)
 -> AuthenticationType
 -> User)
-> Parser (Maybe Text)
-> Parser
     (Maybe Bool
      -> Maybe (Sensitive Text)
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe (Sensitive Text)
      -> Maybe (Sensitive Text)
      -> AuthenticationType
      -> User)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Bool
   -> Maybe (Sensitive Text)
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe (Sensitive Text)
   -> Maybe (Sensitive Text)
   -> AuthenticationType
   -> User)
-> Parser (Maybe Bool)
-> Parser
     (Maybe (Sensitive Text)
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe (Sensitive Text)
      -> Maybe (Sensitive Text)
      -> AuthenticationType
      -> User)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Enabled")
            Parser
  (Maybe (Sensitive Text)
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe (Sensitive Text)
   -> Maybe (Sensitive Text)
   -> AuthenticationType
   -> User)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe (Sensitive Text)
      -> Maybe (Sensitive Text)
      -> AuthenticationType
      -> User)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastName")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe (Sensitive Text)
   -> Maybe (Sensitive Text)
   -> AuthenticationType
   -> User)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe (Sensitive Text)
      -> Maybe (Sensitive Text)
      -> AuthenticationType
      -> User)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Arn")
            Parser
  (Maybe POSIX
   -> Maybe (Sensitive Text)
   -> Maybe (Sensitive Text)
   -> AuthenticationType
   -> User)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe (Sensitive Text)
      -> Maybe (Sensitive Text) -> AuthenticationType -> User)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreatedTime")
            Parser
  (Maybe (Sensitive Text)
   -> Maybe (Sensitive Text) -> AuthenticationType -> User)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe (Sensitive Text) -> AuthenticationType -> User)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UserName")
            Parser (Maybe (Sensitive Text) -> AuthenticationType -> User)
-> Parser (Maybe (Sensitive Text))
-> Parser (AuthenticationType -> User)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FirstName")
            Parser (AuthenticationType -> User)
-> Parser AuthenticationType -> Parser User
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AuthenticationType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AuthenticationType")
      )

instance Prelude.Hashable User

instance Prelude.NFData User