{-# 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.Connect.Types.NotificationRecipientType
-- 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.Connect.Types.NotificationRecipientType 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

-- | The type of notification recipient.
--
-- /See:/ 'newNotificationRecipientType' smart constructor.
data NotificationRecipientType = NotificationRecipientType'
  { -- | A list of user IDs.
    NotificationRecipientType -> Maybe [Text]
userIds :: Prelude.Maybe [Prelude.Text],
    -- | The tags used to organize, track, or control access for this resource.
    -- For example, { \"tags\": {\"key1\":\"value1\", \"key2\":\"value2\"} }.
    -- Amazon Connect users with the specified tags will be notified.
    NotificationRecipientType -> Maybe (HashMap Text Text)
userTags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (NotificationRecipientType -> NotificationRecipientType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotificationRecipientType -> NotificationRecipientType -> Bool
$c/= :: NotificationRecipientType -> NotificationRecipientType -> Bool
== :: NotificationRecipientType -> NotificationRecipientType -> Bool
$c== :: NotificationRecipientType -> NotificationRecipientType -> Bool
Prelude.Eq, ReadPrec [NotificationRecipientType]
ReadPrec NotificationRecipientType
Int -> ReadS NotificationRecipientType
ReadS [NotificationRecipientType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotificationRecipientType]
$creadListPrec :: ReadPrec [NotificationRecipientType]
readPrec :: ReadPrec NotificationRecipientType
$creadPrec :: ReadPrec NotificationRecipientType
readList :: ReadS [NotificationRecipientType]
$creadList :: ReadS [NotificationRecipientType]
readsPrec :: Int -> ReadS NotificationRecipientType
$creadsPrec :: Int -> ReadS NotificationRecipientType
Prelude.Read, Int -> NotificationRecipientType -> ShowS
[NotificationRecipientType] -> ShowS
NotificationRecipientType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotificationRecipientType] -> ShowS
$cshowList :: [NotificationRecipientType] -> ShowS
show :: NotificationRecipientType -> String
$cshow :: NotificationRecipientType -> String
showsPrec :: Int -> NotificationRecipientType -> ShowS
$cshowsPrec :: Int -> NotificationRecipientType -> ShowS
Prelude.Show, forall x.
Rep NotificationRecipientType x -> NotificationRecipientType
forall x.
NotificationRecipientType -> Rep NotificationRecipientType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NotificationRecipientType x -> NotificationRecipientType
$cfrom :: forall x.
NotificationRecipientType -> Rep NotificationRecipientType x
Prelude.Generic)

-- |
-- Create a value of 'NotificationRecipientType' 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:
--
-- 'userIds', 'notificationRecipientType_userIds' - A list of user IDs.
--
-- 'userTags', 'notificationRecipientType_userTags' - The tags used to organize, track, or control access for this resource.
-- For example, { \"tags\": {\"key1\":\"value1\", \"key2\":\"value2\"} }.
-- Amazon Connect users with the specified tags will be notified.
newNotificationRecipientType ::
  NotificationRecipientType
newNotificationRecipientType :: NotificationRecipientType
newNotificationRecipientType =
  NotificationRecipientType'
    { $sel:userIds:NotificationRecipientType' :: Maybe [Text]
userIds =
        forall a. Maybe a
Prelude.Nothing,
      $sel:userTags:NotificationRecipientType' :: Maybe (HashMap Text Text)
userTags = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of user IDs.
notificationRecipientType_userIds :: Lens.Lens' NotificationRecipientType (Prelude.Maybe [Prelude.Text])
notificationRecipientType_userIds :: Lens' NotificationRecipientType (Maybe [Text])
notificationRecipientType_userIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationRecipientType' {Maybe [Text]
userIds :: Maybe [Text]
$sel:userIds:NotificationRecipientType' :: NotificationRecipientType -> Maybe [Text]
userIds} -> Maybe [Text]
userIds) (\s :: NotificationRecipientType
s@NotificationRecipientType' {} Maybe [Text]
a -> NotificationRecipientType
s {$sel:userIds:NotificationRecipientType' :: Maybe [Text]
userIds = Maybe [Text]
a} :: NotificationRecipientType) 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 tags used to organize, track, or control access for this resource.
-- For example, { \"tags\": {\"key1\":\"value1\", \"key2\":\"value2\"} }.
-- Amazon Connect users with the specified tags will be notified.
notificationRecipientType_userTags :: Lens.Lens' NotificationRecipientType (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
notificationRecipientType_userTags :: Lens' NotificationRecipientType (Maybe (HashMap Text Text))
notificationRecipientType_userTags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationRecipientType' {Maybe (HashMap Text Text)
userTags :: Maybe (HashMap Text Text)
$sel:userTags:NotificationRecipientType' :: NotificationRecipientType -> Maybe (HashMap Text Text)
userTags} -> Maybe (HashMap Text Text)
userTags) (\s :: NotificationRecipientType
s@NotificationRecipientType' {} Maybe (HashMap Text Text)
a -> NotificationRecipientType
s {$sel:userTags:NotificationRecipientType' :: Maybe (HashMap Text Text)
userTags = Maybe (HashMap Text Text)
a} :: NotificationRecipientType) 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 NotificationRecipientType where
  parseJSON :: Value -> Parser NotificationRecipientType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NotificationRecipientType"
      ( \Object
x ->
          Maybe [Text]
-> Maybe (HashMap Text Text) -> NotificationRecipientType
NotificationRecipientType'
            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
"UserIds" 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
"UserTags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable NotificationRecipientType where
  hashWithSalt :: Int -> NotificationRecipientType -> Int
hashWithSalt Int
_salt NotificationRecipientType' {Maybe [Text]
Maybe (HashMap Text Text)
userTags :: Maybe (HashMap Text Text)
userIds :: Maybe [Text]
$sel:userTags:NotificationRecipientType' :: NotificationRecipientType -> Maybe (HashMap Text Text)
$sel:userIds:NotificationRecipientType' :: NotificationRecipientType -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
userIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
userTags

instance Prelude.NFData NotificationRecipientType where
  rnf :: NotificationRecipientType -> ()
rnf NotificationRecipientType' {Maybe [Text]
Maybe (HashMap Text Text)
userTags :: Maybe (HashMap Text Text)
userIds :: Maybe [Text]
$sel:userTags:NotificationRecipientType' :: NotificationRecipientType -> Maybe (HashMap Text Text)
$sel:userIds:NotificationRecipientType' :: NotificationRecipientType -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
userIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
userTags

instance Data.ToJSON NotificationRecipientType where
  toJSON :: NotificationRecipientType -> Value
toJSON NotificationRecipientType' {Maybe [Text]
Maybe (HashMap Text Text)
userTags :: Maybe (HashMap Text Text)
userIds :: Maybe [Text]
$sel:userTags:NotificationRecipientType' :: NotificationRecipientType -> Maybe (HashMap Text Text)
$sel:userIds:NotificationRecipientType' :: NotificationRecipientType -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"UserIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
userIds,
            (Key
"UserTags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
userTags
          ]
      )