{-# 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.MediaConcurrency
-- 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.MediaConcurrency where

import Amazonka.Connect.Types.Channel
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

-- | Contains information about which channels are supported, and how many
-- contacts an agent can have on a channel simultaneously.
--
-- /See:/ 'newMediaConcurrency' smart constructor.
data MediaConcurrency = MediaConcurrency'
  { -- | The channels that agents can handle in the Contact Control Panel (CCP).
    MediaConcurrency -> Channel
channel :: Channel,
    -- | The number of contacts an agent can have on a channel simultaneously.
    --
    -- Valid Range for @VOICE@: Minimum value of 1. Maximum value of 1.
    --
    -- Valid Range for @CHAT@: Minimum value of 1. Maximum value of 10.
    --
    -- Valid Range for @TASK@: Minimum value of 1. Maximum value of 10.
    MediaConcurrency -> Natural
concurrency :: Prelude.Natural
  }
  deriving (MediaConcurrency -> MediaConcurrency -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MediaConcurrency -> MediaConcurrency -> Bool
$c/= :: MediaConcurrency -> MediaConcurrency -> Bool
== :: MediaConcurrency -> MediaConcurrency -> Bool
$c== :: MediaConcurrency -> MediaConcurrency -> Bool
Prelude.Eq, ReadPrec [MediaConcurrency]
ReadPrec MediaConcurrency
Int -> ReadS MediaConcurrency
ReadS [MediaConcurrency]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MediaConcurrency]
$creadListPrec :: ReadPrec [MediaConcurrency]
readPrec :: ReadPrec MediaConcurrency
$creadPrec :: ReadPrec MediaConcurrency
readList :: ReadS [MediaConcurrency]
$creadList :: ReadS [MediaConcurrency]
readsPrec :: Int -> ReadS MediaConcurrency
$creadsPrec :: Int -> ReadS MediaConcurrency
Prelude.Read, Int -> MediaConcurrency -> ShowS
[MediaConcurrency] -> ShowS
MediaConcurrency -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MediaConcurrency] -> ShowS
$cshowList :: [MediaConcurrency] -> ShowS
show :: MediaConcurrency -> String
$cshow :: MediaConcurrency -> String
showsPrec :: Int -> MediaConcurrency -> ShowS
$cshowsPrec :: Int -> MediaConcurrency -> ShowS
Prelude.Show, forall x. Rep MediaConcurrency x -> MediaConcurrency
forall x. MediaConcurrency -> Rep MediaConcurrency x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MediaConcurrency x -> MediaConcurrency
$cfrom :: forall x. MediaConcurrency -> Rep MediaConcurrency x
Prelude.Generic)

-- |
-- Create a value of 'MediaConcurrency' 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:
--
-- 'channel', 'mediaConcurrency_channel' - The channels that agents can handle in the Contact Control Panel (CCP).
--
-- 'concurrency', 'mediaConcurrency_concurrency' - The number of contacts an agent can have on a channel simultaneously.
--
-- Valid Range for @VOICE@: Minimum value of 1. Maximum value of 1.
--
-- Valid Range for @CHAT@: Minimum value of 1. Maximum value of 10.
--
-- Valid Range for @TASK@: Minimum value of 1. Maximum value of 10.
newMediaConcurrency ::
  -- | 'channel'
  Channel ->
  -- | 'concurrency'
  Prelude.Natural ->
  MediaConcurrency
newMediaConcurrency :: Channel -> Natural -> MediaConcurrency
newMediaConcurrency Channel
pChannel_ Natural
pConcurrency_ =
  MediaConcurrency'
    { $sel:channel:MediaConcurrency' :: Channel
channel = Channel
pChannel_,
      $sel:concurrency:MediaConcurrency' :: Natural
concurrency = Natural
pConcurrency_
    }

-- | The channels that agents can handle in the Contact Control Panel (CCP).
mediaConcurrency_channel :: Lens.Lens' MediaConcurrency Channel
mediaConcurrency_channel :: Lens' MediaConcurrency Channel
mediaConcurrency_channel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MediaConcurrency' {Channel
channel :: Channel
$sel:channel:MediaConcurrency' :: MediaConcurrency -> Channel
channel} -> Channel
channel) (\s :: MediaConcurrency
s@MediaConcurrency' {} Channel
a -> MediaConcurrency
s {$sel:channel:MediaConcurrency' :: Channel
channel = Channel
a} :: MediaConcurrency)

-- | The number of contacts an agent can have on a channel simultaneously.
--
-- Valid Range for @VOICE@: Minimum value of 1. Maximum value of 1.
--
-- Valid Range for @CHAT@: Minimum value of 1. Maximum value of 10.
--
-- Valid Range for @TASK@: Minimum value of 1. Maximum value of 10.
mediaConcurrency_concurrency :: Lens.Lens' MediaConcurrency Prelude.Natural
mediaConcurrency_concurrency :: Lens' MediaConcurrency Natural
mediaConcurrency_concurrency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MediaConcurrency' {Natural
concurrency :: Natural
$sel:concurrency:MediaConcurrency' :: MediaConcurrency -> Natural
concurrency} -> Natural
concurrency) (\s :: MediaConcurrency
s@MediaConcurrency' {} Natural
a -> MediaConcurrency
s {$sel:concurrency:MediaConcurrency' :: Natural
concurrency = Natural
a} :: MediaConcurrency)

instance Data.FromJSON MediaConcurrency where
  parseJSON :: Value -> Parser MediaConcurrency
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MediaConcurrency"
      ( \Object
x ->
          Channel -> Natural -> MediaConcurrency
MediaConcurrency'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Channel")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Concurrency")
      )

instance Prelude.Hashable MediaConcurrency where
  hashWithSalt :: Int -> MediaConcurrency -> Int
hashWithSalt Int
_salt MediaConcurrency' {Natural
Channel
concurrency :: Natural
channel :: Channel
$sel:concurrency:MediaConcurrency' :: MediaConcurrency -> Natural
$sel:channel:MediaConcurrency' :: MediaConcurrency -> Channel
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Channel
channel
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
concurrency

instance Prelude.NFData MediaConcurrency where
  rnf :: MediaConcurrency -> ()
rnf MediaConcurrency' {Natural
Channel
concurrency :: Natural
channel :: Channel
$sel:concurrency:MediaConcurrency' :: MediaConcurrency -> Natural
$sel:channel:MediaConcurrency' :: MediaConcurrency -> Channel
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Channel
channel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
concurrency

instance Data.ToJSON MediaConcurrency where
  toJSON :: MediaConcurrency -> Value
toJSON MediaConcurrency' {Natural
Channel
concurrency :: Natural
channel :: Channel
$sel:concurrency:MediaConcurrency' :: MediaConcurrency -> Natural
$sel:channel:MediaConcurrency' :: MediaConcurrency -> Channel
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Channel" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Channel
channel),
            forall a. a -> Maybe a
Prelude.Just (Key
"Concurrency" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
concurrency)
          ]
      )