{-# 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.Member
-- 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.Member 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.MemberType

-- | The representation of a user or group.
--
-- /See:/ 'newMember' smart constructor.
data Member = Member'
  { -- | The state of the member, which can be ENABLED, DISABLED, or DELETED.
    Member -> Maybe EntityState
state :: Prelude.Maybe EntityState,
    -- | The date indicating when the member was disabled from Amazon WorkMail
    -- use.
    Member -> Maybe POSIX
disabledDate :: Prelude.Maybe Core.POSIX,
    -- | The name of the member.
    Member -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the member.
    Member -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | A member can be a user or group.
    Member -> Maybe MemberType
type' :: Prelude.Maybe MemberType,
    -- | The date indicating when the member was enabled for Amazon WorkMail use.
    Member -> Maybe POSIX
enabledDate :: Prelude.Maybe Core.POSIX
  }
  deriving (Member -> Member -> Bool
(Member -> Member -> Bool)
-> (Member -> Member -> Bool) -> Eq Member
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Member -> Member -> Bool
$c/= :: Member -> Member -> Bool
== :: Member -> Member -> Bool
$c== :: Member -> Member -> Bool
Prelude.Eq, ReadPrec [Member]
ReadPrec Member
Int -> ReadS Member
ReadS [Member]
(Int -> ReadS Member)
-> ReadS [Member]
-> ReadPrec Member
-> ReadPrec [Member]
-> Read Member
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Member]
$creadListPrec :: ReadPrec [Member]
readPrec :: ReadPrec Member
$creadPrec :: ReadPrec Member
readList :: ReadS [Member]
$creadList :: ReadS [Member]
readsPrec :: Int -> ReadS Member
$creadsPrec :: Int -> ReadS Member
Prelude.Read, Int -> Member -> ShowS
[Member] -> ShowS
Member -> String
(Int -> Member -> ShowS)
-> (Member -> String) -> ([Member] -> ShowS) -> Show Member
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Member] -> ShowS
$cshowList :: [Member] -> ShowS
show :: Member -> String
$cshow :: Member -> String
showsPrec :: Int -> Member -> ShowS
$cshowsPrec :: Int -> Member -> ShowS
Prelude.Show, (forall x. Member -> Rep Member x)
-> (forall x. Rep Member x -> Member) -> Generic Member
forall x. Rep Member x -> Member
forall x. Member -> Rep Member x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Member x -> Member
$cfrom :: forall x. Member -> Rep Member x
Prelude.Generic)

-- |
-- Create a value of 'Member' 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:
--
-- 'state', 'member_state' - The state of the member, which can be ENABLED, DISABLED, or DELETED.
--
-- 'disabledDate', 'member_disabledDate' - The date indicating when the member was disabled from Amazon WorkMail
-- use.
--
-- 'name', 'member_name' - The name of the member.
--
-- 'id', 'member_id' - The identifier of the member.
--
-- 'type'', 'member_type' - A member can be a user or group.
--
-- 'enabledDate', 'member_enabledDate' - The date indicating when the member was enabled for Amazon WorkMail use.
newMember ::
  Member
newMember :: Member
newMember =
  Member' :: Maybe EntityState
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe MemberType
-> Maybe POSIX
-> Member
Member'
    { $sel:state:Member' :: Maybe EntityState
state = Maybe EntityState
forall a. Maybe a
Prelude.Nothing,
      $sel:disabledDate:Member' :: Maybe POSIX
disabledDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Member' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Member' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Member' :: Maybe MemberType
type' = Maybe MemberType
forall a. Maybe a
Prelude.Nothing,
      $sel:enabledDate:Member' :: Maybe POSIX
enabledDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The date indicating when the member was disabled from Amazon WorkMail
-- use.
member_disabledDate :: Lens.Lens' Member (Prelude.Maybe Prelude.UTCTime)
member_disabledDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Member -> f Member
member_disabledDate = (Member -> Maybe POSIX)
-> (Member -> Maybe POSIX -> Member)
-> Lens Member Member (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Member' {Maybe POSIX
disabledDate :: Maybe POSIX
$sel:disabledDate:Member' :: Member -> Maybe POSIX
disabledDate} -> Maybe POSIX
disabledDate) (\s :: Member
s@Member' {} Maybe POSIX
a -> Member
s {$sel:disabledDate:Member' :: Maybe POSIX
disabledDate = Maybe POSIX
a} :: Member) ((Maybe POSIX -> f (Maybe POSIX)) -> Member -> f Member)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Member
-> f Member
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 member.
member_name :: Lens.Lens' Member (Prelude.Maybe Prelude.Text)
member_name :: (Maybe Text -> f (Maybe Text)) -> Member -> f Member
member_name = (Member -> Maybe Text)
-> (Member -> Maybe Text -> Member)
-> Lens Member Member (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Member' {Maybe Text
name :: Maybe Text
$sel:name:Member' :: Member -> Maybe Text
name} -> Maybe Text
name) (\s :: Member
s@Member' {} Maybe Text
a -> Member
s {$sel:name:Member' :: Maybe Text
name = Maybe Text
a} :: Member)

-- | The identifier of the member.
member_id :: Lens.Lens' Member (Prelude.Maybe Prelude.Text)
member_id :: (Maybe Text -> f (Maybe Text)) -> Member -> f Member
member_id = (Member -> Maybe Text)
-> (Member -> Maybe Text -> Member)
-> Lens Member Member (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Member' {Maybe Text
id :: Maybe Text
$sel:id:Member' :: Member -> Maybe Text
id} -> Maybe Text
id) (\s :: Member
s@Member' {} Maybe Text
a -> Member
s {$sel:id:Member' :: Maybe Text
id = Maybe Text
a} :: Member)

-- | A member can be a user or group.
member_type :: Lens.Lens' Member (Prelude.Maybe MemberType)
member_type :: (Maybe MemberType -> f (Maybe MemberType)) -> Member -> f Member
member_type = (Member -> Maybe MemberType)
-> (Member -> Maybe MemberType -> Member)
-> Lens Member Member (Maybe MemberType) (Maybe MemberType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Member' {Maybe MemberType
type' :: Maybe MemberType
$sel:type':Member' :: Member -> Maybe MemberType
type'} -> Maybe MemberType
type') (\s :: Member
s@Member' {} Maybe MemberType
a -> Member
s {$sel:type':Member' :: Maybe MemberType
type' = Maybe MemberType
a} :: Member)

-- | The date indicating when the member was enabled for Amazon WorkMail use.
member_enabledDate :: Lens.Lens' Member (Prelude.Maybe Prelude.UTCTime)
member_enabledDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Member -> f Member
member_enabledDate = (Member -> Maybe POSIX)
-> (Member -> Maybe POSIX -> Member)
-> Lens Member Member (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Member' {Maybe POSIX
enabledDate :: Maybe POSIX
$sel:enabledDate:Member' :: Member -> Maybe POSIX
enabledDate} -> Maybe POSIX
enabledDate) (\s :: Member
s@Member' {} Maybe POSIX
a -> Member
s {$sel:enabledDate:Member' :: Maybe POSIX
enabledDate = Maybe POSIX
a} :: Member) ((Maybe POSIX -> f (Maybe POSIX)) -> Member -> f Member)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Member
-> f Member
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 Member where
  parseJSON :: Value -> Parser Member
parseJSON =
    String -> (Object -> Parser Member) -> Value -> Parser Member
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Member"
      ( \Object
x ->
          Maybe EntityState
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe MemberType
-> Maybe POSIX
-> Member
Member'
            (Maybe EntityState
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe MemberType
 -> Maybe POSIX
 -> Member)
-> Parser (Maybe EntityState)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe MemberType
      -> Maybe POSIX
      -> Member)
forall (f :: * -> *) a b. Functor 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 MemberType
   -> Maybe POSIX
   -> Member)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe MemberType -> Maybe POSIX -> Member)
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 MemberType -> Maybe POSIX -> Member)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe MemberType -> Maybe POSIX -> Member)
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 MemberType -> Maybe POSIX -> Member)
-> Parser (Maybe Text)
-> Parser (Maybe MemberType -> Maybe POSIX -> Member)
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 MemberType -> Maybe POSIX -> Member)
-> Parser (Maybe MemberType) -> Parser (Maybe POSIX -> Member)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MemberType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe POSIX -> Member)
-> Parser (Maybe POSIX) -> Parser Member
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 Member

instance Prelude.NFData Member