{-# 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.Group
-- 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.Group where

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

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

-- |
-- Create a value of 'Group' 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', 'group_email' - The email of the group.
--
-- 'state', 'group_state' - The state of the group, which can be ENABLED, DISABLED, or DELETED.
--
-- 'disabledDate', 'group_disabledDate' - The date indicating when the group was disabled from Amazon WorkMail
-- use.
--
-- 'name', 'group_name' - The name of the group.
--
-- 'id', 'group_id' - The identifier of the group.
--
-- 'enabledDate', 'group_enabledDate' - The date indicating when the group was enabled for Amazon WorkMail use.
newGroup ::
  Group
newGroup :: Group
newGroup =
  Group' :: Maybe Text
-> Maybe EntityState
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Group
Group'
    { $sel:email:Group' :: Maybe Text
email = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:state:Group' :: Maybe EntityState
state = Maybe EntityState
forall a. Maybe a
Prelude.Nothing,
      $sel:disabledDate:Group' :: Maybe POSIX
disabledDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Group' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Group' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:enabledDate:Group' :: Maybe POSIX
enabledDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The email of the group.
group_email :: Lens.Lens' Group (Prelude.Maybe Prelude.Text)
group_email :: (Maybe Text -> f (Maybe Text)) -> Group -> f Group
group_email = (Group -> Maybe Text)
-> (Group -> Maybe Text -> Group)
-> Lens Group Group (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Group' {Maybe Text
email :: Maybe Text
$sel:email:Group' :: Group -> Maybe Text
email} -> Maybe Text
email) (\s :: Group
s@Group' {} Maybe Text
a -> Group
s {$sel:email:Group' :: Maybe Text
email = Maybe Text
a} :: Group)

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

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

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

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

instance Prelude.NFData Group