{-# 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.ChimeSDKMessaging.Types.ChannelMembership
-- 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.ChimeSDKMessaging.Types.ChannelMembership where

import Amazonka.ChimeSDKMessaging.Types.ChannelMembershipType
import Amazonka.ChimeSDKMessaging.Types.Identity
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details of a channel member.
--
-- /See:/ 'newChannelMembership' smart constructor.
data ChannelMembership = ChannelMembership'
  { -- | The ARN of the member\'s channel.
    ChannelMembership -> Maybe Text
channelArn :: Prelude.Maybe Prelude.Text,
    -- | The data of the channel member.
    ChannelMembership -> Maybe Identity
member :: Prelude.Maybe Identity,
    -- | The membership type set for the channel member.
    ChannelMembership -> Maybe ChannelMembershipType
type' :: Prelude.Maybe ChannelMembershipType,
    -- | The identifier of the member who invited another member.
    ChannelMembership -> Maybe Identity
invitedBy :: Prelude.Maybe Identity,
    -- | The time at which the channel membership was created.
    ChannelMembership -> Maybe POSIX
createdTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The time at which a channel membership was last updated.
    ChannelMembership -> Maybe POSIX
lastUpdatedTimestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (ChannelMembership -> ChannelMembership -> Bool
(ChannelMembership -> ChannelMembership -> Bool)
-> (ChannelMembership -> ChannelMembership -> Bool)
-> Eq ChannelMembership
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelMembership -> ChannelMembership -> Bool
$c/= :: ChannelMembership -> ChannelMembership -> Bool
== :: ChannelMembership -> ChannelMembership -> Bool
$c== :: ChannelMembership -> ChannelMembership -> Bool
Prelude.Eq, Int -> ChannelMembership -> ShowS
[ChannelMembership] -> ShowS
ChannelMembership -> String
(Int -> ChannelMembership -> ShowS)
-> (ChannelMembership -> String)
-> ([ChannelMembership] -> ShowS)
-> Show ChannelMembership
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelMembership] -> ShowS
$cshowList :: [ChannelMembership] -> ShowS
show :: ChannelMembership -> String
$cshow :: ChannelMembership -> String
showsPrec :: Int -> ChannelMembership -> ShowS
$cshowsPrec :: Int -> ChannelMembership -> ShowS
Prelude.Show, (forall x. ChannelMembership -> Rep ChannelMembership x)
-> (forall x. Rep ChannelMembership x -> ChannelMembership)
-> Generic ChannelMembership
forall x. Rep ChannelMembership x -> ChannelMembership
forall x. ChannelMembership -> Rep ChannelMembership x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChannelMembership x -> ChannelMembership
$cfrom :: forall x. ChannelMembership -> Rep ChannelMembership x
Prelude.Generic)

-- |
-- Create a value of 'ChannelMembership' 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:
--
-- 'channelArn', 'channelMembership_channelArn' - The ARN of the member\'s channel.
--
-- 'member', 'channelMembership_member' - The data of the channel member.
--
-- 'type'', 'channelMembership_type' - The membership type set for the channel member.
--
-- 'invitedBy', 'channelMembership_invitedBy' - The identifier of the member who invited another member.
--
-- 'createdTimestamp', 'channelMembership_createdTimestamp' - The time at which the channel membership was created.
--
-- 'lastUpdatedTimestamp', 'channelMembership_lastUpdatedTimestamp' - The time at which a channel membership was last updated.
newChannelMembership ::
  ChannelMembership
newChannelMembership :: ChannelMembership
newChannelMembership =
  ChannelMembership' :: Maybe Text
-> Maybe Identity
-> Maybe ChannelMembershipType
-> Maybe Identity
-> Maybe POSIX
-> Maybe POSIX
-> ChannelMembership
ChannelMembership'
    { $sel:channelArn:ChannelMembership' :: Maybe Text
channelArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:member:ChannelMembership' :: Maybe Identity
member = Maybe Identity
forall a. Maybe a
Prelude.Nothing,
      $sel:type':ChannelMembership' :: Maybe ChannelMembershipType
type' = Maybe ChannelMembershipType
forall a. Maybe a
Prelude.Nothing,
      $sel:invitedBy:ChannelMembership' :: Maybe Identity
invitedBy = Maybe Identity
forall a. Maybe a
Prelude.Nothing,
      $sel:createdTimestamp:ChannelMembership' :: Maybe POSIX
createdTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedTimestamp:ChannelMembership' :: Maybe POSIX
lastUpdatedTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the member\'s channel.
channelMembership_channelArn :: Lens.Lens' ChannelMembership (Prelude.Maybe Prelude.Text)
channelMembership_channelArn :: (Maybe Text -> f (Maybe Text))
-> ChannelMembership -> f ChannelMembership
channelMembership_channelArn = (ChannelMembership -> Maybe Text)
-> (ChannelMembership -> Maybe Text -> ChannelMembership)
-> Lens
     ChannelMembership ChannelMembership (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelMembership' {Maybe Text
channelArn :: Maybe Text
$sel:channelArn:ChannelMembership' :: ChannelMembership -> Maybe Text
channelArn} -> Maybe Text
channelArn) (\s :: ChannelMembership
s@ChannelMembership' {} Maybe Text
a -> ChannelMembership
s {$sel:channelArn:ChannelMembership' :: Maybe Text
channelArn = Maybe Text
a} :: ChannelMembership)

-- | The data of the channel member.
channelMembership_member :: Lens.Lens' ChannelMembership (Prelude.Maybe Identity)
channelMembership_member :: (Maybe Identity -> f (Maybe Identity))
-> ChannelMembership -> f ChannelMembership
channelMembership_member = (ChannelMembership -> Maybe Identity)
-> (ChannelMembership -> Maybe Identity -> ChannelMembership)
-> Lens
     ChannelMembership
     ChannelMembership
     (Maybe Identity)
     (Maybe Identity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelMembership' {Maybe Identity
member :: Maybe Identity
$sel:member:ChannelMembership' :: ChannelMembership -> Maybe Identity
member} -> Maybe Identity
member) (\s :: ChannelMembership
s@ChannelMembership' {} Maybe Identity
a -> ChannelMembership
s {$sel:member:ChannelMembership' :: Maybe Identity
member = Maybe Identity
a} :: ChannelMembership)

-- | The membership type set for the channel member.
channelMembership_type :: Lens.Lens' ChannelMembership (Prelude.Maybe ChannelMembershipType)
channelMembership_type :: (Maybe ChannelMembershipType -> f (Maybe ChannelMembershipType))
-> ChannelMembership -> f ChannelMembership
channelMembership_type = (ChannelMembership -> Maybe ChannelMembershipType)
-> (ChannelMembership
    -> Maybe ChannelMembershipType -> ChannelMembership)
-> Lens
     ChannelMembership
     ChannelMembership
     (Maybe ChannelMembershipType)
     (Maybe ChannelMembershipType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelMembership' {Maybe ChannelMembershipType
type' :: Maybe ChannelMembershipType
$sel:type':ChannelMembership' :: ChannelMembership -> Maybe ChannelMembershipType
type'} -> Maybe ChannelMembershipType
type') (\s :: ChannelMembership
s@ChannelMembership' {} Maybe ChannelMembershipType
a -> ChannelMembership
s {$sel:type':ChannelMembership' :: Maybe ChannelMembershipType
type' = Maybe ChannelMembershipType
a} :: ChannelMembership)

-- | The identifier of the member who invited another member.
channelMembership_invitedBy :: Lens.Lens' ChannelMembership (Prelude.Maybe Identity)
channelMembership_invitedBy :: (Maybe Identity -> f (Maybe Identity))
-> ChannelMembership -> f ChannelMembership
channelMembership_invitedBy = (ChannelMembership -> Maybe Identity)
-> (ChannelMembership -> Maybe Identity -> ChannelMembership)
-> Lens
     ChannelMembership
     ChannelMembership
     (Maybe Identity)
     (Maybe Identity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelMembership' {Maybe Identity
invitedBy :: Maybe Identity
$sel:invitedBy:ChannelMembership' :: ChannelMembership -> Maybe Identity
invitedBy} -> Maybe Identity
invitedBy) (\s :: ChannelMembership
s@ChannelMembership' {} Maybe Identity
a -> ChannelMembership
s {$sel:invitedBy:ChannelMembership' :: Maybe Identity
invitedBy = Maybe Identity
a} :: ChannelMembership)

-- | The time at which the channel membership was created.
channelMembership_createdTimestamp :: Lens.Lens' ChannelMembership (Prelude.Maybe Prelude.UTCTime)
channelMembership_createdTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ChannelMembership -> f ChannelMembership
channelMembership_createdTimestamp = (ChannelMembership -> Maybe POSIX)
-> (ChannelMembership -> Maybe POSIX -> ChannelMembership)
-> Lens
     ChannelMembership ChannelMembership (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelMembership' {Maybe POSIX
createdTimestamp :: Maybe POSIX
$sel:createdTimestamp:ChannelMembership' :: ChannelMembership -> Maybe POSIX
createdTimestamp} -> Maybe POSIX
createdTimestamp) (\s :: ChannelMembership
s@ChannelMembership' {} Maybe POSIX
a -> ChannelMembership
s {$sel:createdTimestamp:ChannelMembership' :: Maybe POSIX
createdTimestamp = Maybe POSIX
a} :: ChannelMembership) ((Maybe POSIX -> f (Maybe POSIX))
 -> ChannelMembership -> f ChannelMembership)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ChannelMembership
-> f ChannelMembership
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 time at which a channel membership was last updated.
channelMembership_lastUpdatedTimestamp :: Lens.Lens' ChannelMembership (Prelude.Maybe Prelude.UTCTime)
channelMembership_lastUpdatedTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ChannelMembership -> f ChannelMembership
channelMembership_lastUpdatedTimestamp = (ChannelMembership -> Maybe POSIX)
-> (ChannelMembership -> Maybe POSIX -> ChannelMembership)
-> Lens
     ChannelMembership ChannelMembership (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelMembership' {Maybe POSIX
lastUpdatedTimestamp :: Maybe POSIX
$sel:lastUpdatedTimestamp:ChannelMembership' :: ChannelMembership -> Maybe POSIX
lastUpdatedTimestamp} -> Maybe POSIX
lastUpdatedTimestamp) (\s :: ChannelMembership
s@ChannelMembership' {} Maybe POSIX
a -> ChannelMembership
s {$sel:lastUpdatedTimestamp:ChannelMembership' :: Maybe POSIX
lastUpdatedTimestamp = Maybe POSIX
a} :: ChannelMembership) ((Maybe POSIX -> f (Maybe POSIX))
 -> ChannelMembership -> f ChannelMembership)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ChannelMembership
-> f ChannelMembership
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 ChannelMembership where
  parseJSON :: Value -> Parser ChannelMembership
parseJSON =
    String
-> (Object -> Parser ChannelMembership)
-> Value
-> Parser ChannelMembership
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ChannelMembership"
      ( \Object
x ->
          Maybe Text
-> Maybe Identity
-> Maybe ChannelMembershipType
-> Maybe Identity
-> Maybe POSIX
-> Maybe POSIX
-> ChannelMembership
ChannelMembership'
            (Maybe Text
 -> Maybe Identity
 -> Maybe ChannelMembershipType
 -> Maybe Identity
 -> Maybe POSIX
 -> Maybe POSIX
 -> ChannelMembership)
-> Parser (Maybe Text)
-> Parser
     (Maybe Identity
      -> Maybe ChannelMembershipType
      -> Maybe Identity
      -> Maybe POSIX
      -> Maybe POSIX
      -> ChannelMembership)
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
"ChannelArn")
            Parser
  (Maybe Identity
   -> Maybe ChannelMembershipType
   -> Maybe Identity
   -> Maybe POSIX
   -> Maybe POSIX
   -> ChannelMembership)
-> Parser (Maybe Identity)
-> Parser
     (Maybe ChannelMembershipType
      -> Maybe Identity
      -> Maybe POSIX
      -> Maybe POSIX
      -> ChannelMembership)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Identity)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Member")
            Parser
  (Maybe ChannelMembershipType
   -> Maybe Identity
   -> Maybe POSIX
   -> Maybe POSIX
   -> ChannelMembership)
-> Parser (Maybe ChannelMembershipType)
-> Parser
     (Maybe Identity -> Maybe POSIX -> Maybe POSIX -> ChannelMembership)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ChannelMembershipType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser
  (Maybe Identity -> Maybe POSIX -> Maybe POSIX -> ChannelMembership)
-> Parser (Maybe Identity)
-> Parser (Maybe POSIX -> Maybe POSIX -> ChannelMembership)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Identity)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InvitedBy")
            Parser (Maybe POSIX -> Maybe POSIX -> ChannelMembership)
-> Parser (Maybe POSIX)
-> Parser (Maybe POSIX -> ChannelMembership)
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
"CreatedTimestamp")
            Parser (Maybe POSIX -> ChannelMembership)
-> Parser (Maybe POSIX) -> Parser ChannelMembership
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
"LastUpdatedTimestamp")
      )

instance Prelude.Hashable ChannelMembership

instance Prelude.NFData ChannelMembership