{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.WorkDocs.Types.Participants where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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, Int -> Participants -> ShowS
[Participants] -> ShowS
Participants -> String
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. 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'
    { $sel:groups:Participants' :: Maybe [GroupMetadata]
groups = forall a. Maybe a
Prelude.Nothing,
      $sel:users:Participants' :: Maybe [UserMetadata]
users = forall a. Maybe a
Prelude.Nothing
    }

-- | The list of user groups.
participants_groups :: Lens.Lens' Participants (Prelude.Maybe [GroupMetadata])
participants_groups :: Lens' Participants (Maybe [GroupMetadata])
participants_groups = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' Participants (Maybe [UserMetadata])
participants_users = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable Participants where
  hashWithSalt :: Int -> Participants -> Int
hashWithSalt Int
_salt Participants' {Maybe [GroupMetadata]
Maybe [UserMetadata]
users :: Maybe [UserMetadata]
groups :: Maybe [GroupMetadata]
$sel:users:Participants' :: Participants -> Maybe [UserMetadata]
$sel:groups:Participants' :: Participants -> Maybe [GroupMetadata]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [GroupMetadata]
groups
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [UserMetadata]
users

instance Prelude.NFData Participants where
  rnf :: Participants -> ()
rnf Participants' {Maybe [GroupMetadata]
Maybe [UserMetadata]
users :: Maybe [UserMetadata]
groups :: Maybe [GroupMetadata]
$sel:users:Participants' :: Participants -> Maybe [UserMetadata]
$sel:groups:Participants' :: Participants -> Maybe [GroupMetadata]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [GroupMetadata]
groups seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [UserMetadata]
users