{-# 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.BatchChannelMemberships
-- 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.BatchChannelMemberships 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 membership information, including member ARNs, the channel ARN, and
-- membership types.
--
-- /See:/ 'newBatchChannelMemberships' smart constructor.
data BatchChannelMemberships = BatchChannelMemberships'
  { -- | The users successfully added to the request.
    BatchChannelMemberships -> Maybe [Identity]
members :: Prelude.Maybe [Identity],
    -- | The ARN of the channel to which you\'re adding users.
    BatchChannelMemberships -> Maybe Text
channelArn :: Prelude.Maybe Prelude.Text,
    -- | The membership types set for the channel users.
    BatchChannelMemberships -> Maybe ChannelMembershipType
type' :: Prelude.Maybe ChannelMembershipType,
    -- | The identifier of the member who invited another member.
    BatchChannelMemberships -> Maybe Identity
invitedBy :: Prelude.Maybe Identity
  }
  deriving (BatchChannelMemberships -> BatchChannelMemberships -> Bool
(BatchChannelMemberships -> BatchChannelMemberships -> Bool)
-> (BatchChannelMemberships -> BatchChannelMemberships -> Bool)
-> Eq BatchChannelMemberships
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchChannelMemberships -> BatchChannelMemberships -> Bool
$c/= :: BatchChannelMemberships -> BatchChannelMemberships -> Bool
== :: BatchChannelMemberships -> BatchChannelMemberships -> Bool
$c== :: BatchChannelMemberships -> BatchChannelMemberships -> Bool
Prelude.Eq, Int -> BatchChannelMemberships -> ShowS
[BatchChannelMemberships] -> ShowS
BatchChannelMemberships -> String
(Int -> BatchChannelMemberships -> ShowS)
-> (BatchChannelMemberships -> String)
-> ([BatchChannelMemberships] -> ShowS)
-> Show BatchChannelMemberships
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchChannelMemberships] -> ShowS
$cshowList :: [BatchChannelMemberships] -> ShowS
show :: BatchChannelMemberships -> String
$cshow :: BatchChannelMemberships -> String
showsPrec :: Int -> BatchChannelMemberships -> ShowS
$cshowsPrec :: Int -> BatchChannelMemberships -> ShowS
Prelude.Show, (forall x.
 BatchChannelMemberships -> Rep BatchChannelMemberships x)
-> (forall x.
    Rep BatchChannelMemberships x -> BatchChannelMemberships)
-> Generic BatchChannelMemberships
forall x. Rep BatchChannelMemberships x -> BatchChannelMemberships
forall x. BatchChannelMemberships -> Rep BatchChannelMemberships x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchChannelMemberships x -> BatchChannelMemberships
$cfrom :: forall x. BatchChannelMemberships -> Rep BatchChannelMemberships x
Prelude.Generic)

-- |
-- Create a value of 'BatchChannelMemberships' 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:
--
-- 'members', 'batchChannelMemberships_members' - The users successfully added to the request.
--
-- 'channelArn', 'batchChannelMemberships_channelArn' - The ARN of the channel to which you\'re adding users.
--
-- 'type'', 'batchChannelMemberships_type' - The membership types set for the channel users.
--
-- 'invitedBy', 'batchChannelMemberships_invitedBy' - The identifier of the member who invited another member.
newBatchChannelMemberships ::
  BatchChannelMemberships
newBatchChannelMemberships :: BatchChannelMemberships
newBatchChannelMemberships =
  BatchChannelMemberships' :: Maybe [Identity]
-> Maybe Text
-> Maybe ChannelMembershipType
-> Maybe Identity
-> BatchChannelMemberships
BatchChannelMemberships'
    { $sel:members:BatchChannelMemberships' :: Maybe [Identity]
members = Maybe [Identity]
forall a. Maybe a
Prelude.Nothing,
      $sel:channelArn:BatchChannelMemberships' :: Maybe Text
channelArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':BatchChannelMemberships' :: Maybe ChannelMembershipType
type' = Maybe ChannelMembershipType
forall a. Maybe a
Prelude.Nothing,
      $sel:invitedBy:BatchChannelMemberships' :: Maybe Identity
invitedBy = Maybe Identity
forall a. Maybe a
Prelude.Nothing
    }

-- | The users successfully added to the request.
batchChannelMemberships_members :: Lens.Lens' BatchChannelMemberships (Prelude.Maybe [Identity])
batchChannelMemberships_members :: (Maybe [Identity] -> f (Maybe [Identity]))
-> BatchChannelMemberships -> f BatchChannelMemberships
batchChannelMemberships_members = (BatchChannelMemberships -> Maybe [Identity])
-> (BatchChannelMemberships
    -> Maybe [Identity] -> BatchChannelMemberships)
-> Lens
     BatchChannelMemberships
     BatchChannelMemberships
     (Maybe [Identity])
     (Maybe [Identity])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchChannelMemberships' {Maybe [Identity]
members :: Maybe [Identity]
$sel:members:BatchChannelMemberships' :: BatchChannelMemberships -> Maybe [Identity]
members} -> Maybe [Identity]
members) (\s :: BatchChannelMemberships
s@BatchChannelMemberships' {} Maybe [Identity]
a -> BatchChannelMemberships
s {$sel:members:BatchChannelMemberships' :: Maybe [Identity]
members = Maybe [Identity]
a} :: BatchChannelMemberships) ((Maybe [Identity] -> f (Maybe [Identity]))
 -> BatchChannelMemberships -> f BatchChannelMemberships)
-> ((Maybe [Identity] -> f (Maybe [Identity]))
    -> Maybe [Identity] -> f (Maybe [Identity]))
-> (Maybe [Identity] -> f (Maybe [Identity]))
-> BatchChannelMemberships
-> f BatchChannelMemberships
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Identity] [Identity] [Identity] [Identity]
-> Iso
     (Maybe [Identity])
     (Maybe [Identity])
     (Maybe [Identity])
     (Maybe [Identity])
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 [Identity] [Identity] [Identity] [Identity]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the channel to which you\'re adding users.
batchChannelMemberships_channelArn :: Lens.Lens' BatchChannelMemberships (Prelude.Maybe Prelude.Text)
batchChannelMemberships_channelArn :: (Maybe Text -> f (Maybe Text))
-> BatchChannelMemberships -> f BatchChannelMemberships
batchChannelMemberships_channelArn = (BatchChannelMemberships -> Maybe Text)
-> (BatchChannelMemberships
    -> Maybe Text -> BatchChannelMemberships)
-> Lens
     BatchChannelMemberships
     BatchChannelMemberships
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchChannelMemberships' {Maybe Text
channelArn :: Maybe Text
$sel:channelArn:BatchChannelMemberships' :: BatchChannelMemberships -> Maybe Text
channelArn} -> Maybe Text
channelArn) (\s :: BatchChannelMemberships
s@BatchChannelMemberships' {} Maybe Text
a -> BatchChannelMemberships
s {$sel:channelArn:BatchChannelMemberships' :: Maybe Text
channelArn = Maybe Text
a} :: BatchChannelMemberships)

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

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

instance Core.FromJSON BatchChannelMemberships where
  parseJSON :: Value -> Parser BatchChannelMemberships
parseJSON =
    String
-> (Object -> Parser BatchChannelMemberships)
-> Value
-> Parser BatchChannelMemberships
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchChannelMemberships"
      ( \Object
x ->
          Maybe [Identity]
-> Maybe Text
-> Maybe ChannelMembershipType
-> Maybe Identity
-> BatchChannelMemberships
BatchChannelMemberships'
            (Maybe [Identity]
 -> Maybe Text
 -> Maybe ChannelMembershipType
 -> Maybe Identity
 -> BatchChannelMemberships)
-> Parser (Maybe [Identity])
-> Parser
     (Maybe Text
      -> Maybe ChannelMembershipType
      -> Maybe Identity
      -> BatchChannelMemberships)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Identity]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Members" Parser (Maybe (Maybe [Identity]))
-> Maybe [Identity] -> Parser (Maybe [Identity])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Identity]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe ChannelMembershipType
   -> Maybe Identity
   -> BatchChannelMemberships)
-> Parser (Maybe Text)
-> Parser
     (Maybe ChannelMembershipType
      -> Maybe Identity -> BatchChannelMemberships)
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
"ChannelArn")
            Parser
  (Maybe ChannelMembershipType
   -> Maybe Identity -> BatchChannelMemberships)
-> Parser (Maybe ChannelMembershipType)
-> Parser (Maybe Identity -> BatchChannelMemberships)
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 -> BatchChannelMemberships)
-> Parser (Maybe Identity) -> Parser BatchChannelMemberships
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")
      )

instance Prelude.Hashable BatchChannelMemberships

instance Prelude.NFData BatchChannelMemberships