{-# 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.WorkDocs.Types.Participants
-- 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.WorkDocs.Types.Participants where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkDocs.Types.GroupMetadata
import Amazonka.WorkDocs.Types.UserMetadata

-- | Describes the users or user groups.
--
-- /See:/ 'newParticipants' smart constructor.
data Participants = Participants'
  { -- | The list of user groups.
    Participants -> Maybe [GroupMetadata]
groups :: Prelude.Maybe [GroupMetadata],
    -- | The list of users.
    Participants -> Maybe [UserMetadata]
users :: Prelude.Maybe [UserMetadata]
  }
  deriving (Participants -> Participants -> Bool
(Participants -> Participants -> Bool)
-> (Participants -> Participants -> Bool) -> Eq Participants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Participants -> Participants -> Bool
$c/= :: Participants -> Participants -> Bool
== :: Participants -> Participants -> Bool
$c== :: Participants -> Participants -> Bool
Prelude.Eq, ReadPrec [Participants]
ReadPrec Participants
Int -> ReadS Participants
ReadS [Participants]
(Int -> ReadS Participants)
-> ReadS [Participants]
-> ReadPrec Participants
-> ReadPrec [Participants]
-> Read Participants
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Participants]
$creadListPrec :: ReadPrec [Participants]
readPrec :: ReadPrec Participants
$creadPrec :: ReadPrec Participants
readList :: ReadS [Participants]
$creadList :: ReadS [Participants]
readsPrec :: Int -> ReadS Participants
$creadsPrec :: Int -> ReadS Participants
Prelude.Read, Int -> Participants -> ShowS
[Participants] -> ShowS
Participants -> String
(Int -> Participants -> ShowS)
-> (Participants -> String)
-> ([Participants] -> ShowS)
-> Show Participants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Participants] -> ShowS
$cshowList :: [Participants] -> ShowS
show :: Participants -> String
$cshow :: Participants -> String
showsPrec :: Int -> Participants -> ShowS
$cshowsPrec :: Int -> Participants -> ShowS
Prelude.Show, (forall x. Participants -> Rep Participants x)
-> (forall x. Rep Participants x -> Participants)
-> Generic Participants
forall x. Rep Participants x -> Participants
forall x. Participants -> Rep Participants x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Participants x -> Participants
$cfrom :: forall x. Participants -> Rep Participants x
Prelude.Generic)

-- |
-- Create a value of 'Participants' 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:
--
-- 'groups', 'participants_groups' - The list of user groups.
--
-- 'users', 'participants_users' - The list of users.
newParticipants ::
  Participants
newParticipants :: Participants
newParticipants =
  Participants' :: Maybe [GroupMetadata] -> Maybe [UserMetadata] -> Participants
Participants'
    { $sel:groups:Participants' :: Maybe [GroupMetadata]
groups = Maybe [GroupMetadata]
forall a. Maybe a
Prelude.Nothing,
      $sel:users:Participants' :: Maybe [UserMetadata]
users = Maybe [UserMetadata]
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of user groups.
participants_groups :: Lens.Lens' Participants (Prelude.Maybe [GroupMetadata])
participants_groups :: (Maybe [GroupMetadata] -> f (Maybe [GroupMetadata]))
-> Participants -> f Participants
participants_groups = (Participants -> Maybe [GroupMetadata])
-> (Participants -> Maybe [GroupMetadata] -> Participants)
-> Lens
     Participants
     Participants
     (Maybe [GroupMetadata])
     (Maybe [GroupMetadata])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Participants' {Maybe [GroupMetadata]
groups :: Maybe [GroupMetadata]
$sel:groups:Participants' :: Participants -> Maybe [GroupMetadata]
groups} -> Maybe [GroupMetadata]
groups) (\s :: Participants
s@Participants' {} Maybe [GroupMetadata]
a -> Participants
s {$sel:groups:Participants' :: Maybe [GroupMetadata]
groups = Maybe [GroupMetadata]
a} :: Participants) ((Maybe [GroupMetadata] -> f (Maybe [GroupMetadata]))
 -> Participants -> f Participants)
-> ((Maybe [GroupMetadata] -> f (Maybe [GroupMetadata]))
    -> Maybe [GroupMetadata] -> f (Maybe [GroupMetadata]))
-> (Maybe [GroupMetadata] -> f (Maybe [GroupMetadata]))
-> Participants
-> f Participants
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GroupMetadata] [GroupMetadata] [GroupMetadata] [GroupMetadata]
-> Iso
     (Maybe [GroupMetadata])
     (Maybe [GroupMetadata])
     (Maybe [GroupMetadata])
     (Maybe [GroupMetadata])
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
  [GroupMetadata] [GroupMetadata] [GroupMetadata] [GroupMetadata]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The list of users.
participants_users :: Lens.Lens' Participants (Prelude.Maybe [UserMetadata])
participants_users :: (Maybe [UserMetadata] -> f (Maybe [UserMetadata]))
-> Participants -> f Participants
participants_users = (Participants -> Maybe [UserMetadata])
-> (Participants -> Maybe [UserMetadata] -> Participants)
-> Lens
     Participants
     Participants
     (Maybe [UserMetadata])
     (Maybe [UserMetadata])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Participants' {Maybe [UserMetadata]
users :: Maybe [UserMetadata]
$sel:users:Participants' :: Participants -> Maybe [UserMetadata]
users} -> Maybe [UserMetadata]
users) (\s :: Participants
s@Participants' {} Maybe [UserMetadata]
a -> Participants
s {$sel:users:Participants' :: Maybe [UserMetadata]
users = Maybe [UserMetadata]
a} :: Participants) ((Maybe [UserMetadata] -> f (Maybe [UserMetadata]))
 -> Participants -> f Participants)
-> ((Maybe [UserMetadata] -> f (Maybe [UserMetadata]))
    -> Maybe [UserMetadata] -> f (Maybe [UserMetadata]))
-> (Maybe [UserMetadata] -> f (Maybe [UserMetadata]))
-> Participants
-> f Participants
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [UserMetadata] [UserMetadata] [UserMetadata] [UserMetadata]
-> Iso
     (Maybe [UserMetadata])
     (Maybe [UserMetadata])
     (Maybe [UserMetadata])
     (Maybe [UserMetadata])
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 [UserMetadata] [UserMetadata] [UserMetadata] [UserMetadata]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Participants where
  parseJSON :: Value -> Parser Participants
parseJSON =
    String
-> (Object -> Parser Participants) -> Value -> Parser Participants
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Participants"
      ( \Object
x ->
          Maybe [GroupMetadata] -> Maybe [UserMetadata] -> Participants
Participants'
            (Maybe [GroupMetadata] -> Maybe [UserMetadata] -> Participants)
-> Parser (Maybe [GroupMetadata])
-> Parser (Maybe [UserMetadata] -> Participants)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [GroupMetadata]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Groups" Parser (Maybe (Maybe [GroupMetadata]))
-> Maybe [GroupMetadata] -> Parser (Maybe [GroupMetadata])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [GroupMetadata]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [UserMetadata] -> Participants)
-> Parser (Maybe [UserMetadata]) -> Parser Participants
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [UserMetadata]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Users" Parser (Maybe (Maybe [UserMetadata]))
-> Maybe [UserMetadata] -> Parser (Maybe [UserMetadata])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [UserMetadata]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Participants

instance Prelude.NFData Participants