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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkMail.Types.EntityState
import Amazonka.WorkMail.Types.UserRole

-- | The representation of an Amazon WorkMail user.
--
-- /See:/ 'newUser' smart constructor.
data User = User'
  { -- | The email of the user.
    User -> Maybe Text
email :: Prelude.Maybe Prelude.Text,
    -- | The state of the user, which can be ENABLED, DISABLED, or DELETED.
    User -> Maybe EntityState
state :: Prelude.Maybe EntityState,
    -- | The date indicating when the user was disabled from Amazon WorkMail use.
    User -> Maybe POSIX
disabledDate :: Prelude.Maybe Core.POSIX,
    -- | The name of the user.
    User -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the user.
    User -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The display name of the user.
    User -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The role of the user.
    User -> Maybe UserRole
userRole :: Prelude.Maybe UserRole,
    -- | The date indicating when the user was enabled for Amazon WorkMail use.
    User -> Maybe POSIX
enabledDate :: Prelude.Maybe Core.POSIX
  }
  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, ReadPrec [User]
ReadPrec User
Int -> ReadS User
ReadS [User]
(Int -> ReadS User)
-> ReadS [User] -> ReadPrec User -> ReadPrec [User] -> Read User
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [User]
$creadListPrec :: ReadPrec [User]
readPrec :: ReadPrec User
$creadPrec :: ReadPrec User
readList :: ReadS [User]
$creadList :: ReadS [User]
readsPrec :: Int -> ReadS User
$creadsPrec :: Int -> ReadS User
Prelude.Read, 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:
--
-- 'email', 'user_email' - The email of the user.
--
-- 'state', 'user_state' - The state of the user, which can be ENABLED, DISABLED, or DELETED.
--
-- 'disabledDate', 'user_disabledDate' - The date indicating when the user was disabled from Amazon WorkMail use.
--
-- 'name', 'user_name' - The name of the user.
--
-- 'id', 'user_id' - The identifier of the user.
--
-- 'displayName', 'user_displayName' - The display name of the user.
--
-- 'userRole', 'user_userRole' - The role of the user.
--
-- 'enabledDate', 'user_enabledDate' - The date indicating when the user was enabled for Amazon WorkMail use.
newUser ::
  User
newUser :: User
newUser =
  User' :: Maybe Text
-> Maybe EntityState
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe UserRole
-> Maybe POSIX
-> User
User'
    { $sel:email:User' :: Maybe Text
email = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:state:User' :: Maybe EntityState
state = Maybe EntityState
forall a. Maybe a
Prelude.Nothing,
      $sel:disabledDate:User' :: Maybe POSIX
disabledDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:User' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:User' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:User' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userRole:User' :: Maybe UserRole
userRole = Maybe UserRole
forall a. Maybe a
Prelude.Nothing,
      $sel:enabledDate:User' :: Maybe POSIX
enabledDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The email of the user.
user_email :: Lens.Lens' User (Prelude.Maybe Prelude.Text)
user_email :: (Maybe Text -> f (Maybe Text)) -> User -> f User
user_email = (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
email :: Maybe Text
$sel:email:User' :: User -> Maybe Text
email} -> Maybe Text
email) (\s :: User
s@User' {} Maybe Text
a -> User
s {$sel:email:User' :: Maybe Text
email = Maybe Text
a} :: User)

-- | The state of the user, which can be ENABLED, DISABLED, or DELETED.
user_state :: Lens.Lens' User (Prelude.Maybe EntityState)
user_state :: (Maybe EntityState -> f (Maybe EntityState)) -> User -> f User
user_state = (User -> Maybe EntityState)
-> (User -> Maybe EntityState -> User)
-> Lens User User (Maybe EntityState) (Maybe EntityState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Maybe EntityState
state :: Maybe EntityState
$sel:state:User' :: User -> Maybe EntityState
state} -> Maybe EntityState
state) (\s :: User
s@User' {} Maybe EntityState
a -> User
s {$sel:state:User' :: Maybe EntityState
state = Maybe EntityState
a} :: User)

-- | The date indicating when the user was disabled from Amazon WorkMail use.
user_disabledDate :: Lens.Lens' User (Prelude.Maybe Prelude.UTCTime)
user_disabledDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> User -> f User
user_disabledDate = (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
disabledDate :: Maybe POSIX
$sel:disabledDate:User' :: User -> Maybe POSIX
disabledDate} -> Maybe POSIX
disabledDate) (\s :: User
s@User' {} Maybe POSIX
a -> User
s {$sel:disabledDate:User' :: Maybe POSIX
disabledDate = 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 name of the user.
user_name :: Lens.Lens' User (Prelude.Maybe Prelude.Text)
user_name :: (Maybe Text -> f (Maybe Text)) -> User -> f User
user_name = (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
name :: Maybe Text
$sel:name:User' :: User -> Maybe Text
name} -> Maybe Text
name) (\s :: User
s@User' {} Maybe Text
a -> User
s {$sel:name:User' :: Maybe Text
name = Maybe Text
a} :: User)

-- | The identifier of the user.
user_id :: Lens.Lens' User (Prelude.Maybe Prelude.Text)
user_id :: (Maybe Text -> f (Maybe Text)) -> User -> f User
user_id = (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
id :: Maybe Text
$sel:id:User' :: User -> Maybe Text
id} -> Maybe Text
id) (\s :: User
s@User' {} Maybe Text
a -> User
s {$sel:id:User' :: Maybe Text
id = Maybe Text
a} :: User)

-- | The display name of the user.
user_displayName :: Lens.Lens' User (Prelude.Maybe Prelude.Text)
user_displayName :: (Maybe Text -> f (Maybe Text)) -> User -> f User
user_displayName = (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
displayName :: Maybe Text
$sel:displayName:User' :: User -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: User
s@User' {} Maybe Text
a -> User
s {$sel:displayName:User' :: Maybe Text
displayName = Maybe Text
a} :: User)

-- | The role of the user.
user_userRole :: Lens.Lens' User (Prelude.Maybe UserRole)
user_userRole :: (Maybe UserRole -> f (Maybe UserRole)) -> User -> f User
user_userRole = (User -> Maybe UserRole)
-> (User -> Maybe UserRole -> User)
-> Lens User User (Maybe UserRole) (Maybe UserRole)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Maybe UserRole
userRole :: Maybe UserRole
$sel:userRole:User' :: User -> Maybe UserRole
userRole} -> Maybe UserRole
userRole) (\s :: User
s@User' {} Maybe UserRole
a -> User
s {$sel:userRole:User' :: Maybe UserRole
userRole = Maybe UserRole
a} :: User)

-- | The date indicating when the user was enabled for Amazon WorkMail use.
user_enabledDate :: Lens.Lens' User (Prelude.Maybe Prelude.UTCTime)
user_enabledDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> User -> f User
user_enabledDate = (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
enabledDate :: Maybe POSIX
$sel:enabledDate:User' :: User -> Maybe POSIX
enabledDate} -> Maybe POSIX
enabledDate) (\s :: User
s@User' {} Maybe POSIX
a -> User
s {$sel:enabledDate:User' :: Maybe POSIX
enabledDate = 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

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 EntityState
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe UserRole
-> Maybe POSIX
-> User
User'
            (Maybe Text
 -> Maybe EntityState
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe UserRole
 -> Maybe POSIX
 -> User)
-> Parser (Maybe Text)
-> Parser
     (Maybe EntityState
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe UserRole
      -> Maybe POSIX
      -> 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
"Email")
            Parser
  (Maybe EntityState
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe UserRole
   -> Maybe POSIX
   -> User)
-> Parser (Maybe EntityState)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe UserRole
      -> Maybe POSIX
      -> User)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EntityState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe UserRole
   -> Maybe POSIX
   -> User)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe UserRole
      -> Maybe POSIX
      -> 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
"DisabledDate")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe UserRole
   -> Maybe POSIX
   -> User)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe UserRole -> Maybe POSIX -> 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
"Name")
            Parser
  (Maybe Text -> Maybe Text -> Maybe UserRole -> Maybe POSIX -> User)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe UserRole -> Maybe POSIX -> 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
"Id")
            Parser (Maybe Text -> Maybe UserRole -> Maybe POSIX -> User)
-> Parser (Maybe Text)
-> Parser (Maybe UserRole -> Maybe POSIX -> 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
"DisplayName")
            Parser (Maybe UserRole -> Maybe POSIX -> User)
-> Parser (Maybe UserRole) -> Parser (Maybe POSIX -> User)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UserRole)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UserRole")
            Parser (Maybe POSIX -> User) -> Parser (Maybe POSIX) -> Parser 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
"EnabledDate")
      )

instance Prelude.Hashable User

instance Prelude.NFData User