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

import Amazonka.Connect.Types.Channel
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(MediaConcurrency -> MediaConcurrency -> Bool)
-> (MediaConcurrency -> MediaConcurrency -> Bool)
-> Eq MediaConcurrency
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]
(Int -> ReadS MediaConcurrency)
-> ReadS [MediaConcurrency]
-> ReadPrec MediaConcurrency
-> ReadPrec [MediaConcurrency]
-> Read 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
(Int -> MediaConcurrency -> ShowS)
-> (MediaConcurrency -> String)
-> ([MediaConcurrency] -> ShowS)
-> Show MediaConcurrency
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. MediaConcurrency -> Rep MediaConcurrency x)
-> (forall x. Rep MediaConcurrency x -> MediaConcurrency)
-> Generic MediaConcurrency
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' :: Channel -> Natural -> MediaConcurrency
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 :: (Channel -> f Channel) -> MediaConcurrency -> f MediaConcurrency
mediaConcurrency_channel = (MediaConcurrency -> Channel)
-> (MediaConcurrency -> Channel -> MediaConcurrency)
-> Lens MediaConcurrency MediaConcurrency Channel 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 :: (Natural -> f Natural) -> MediaConcurrency -> f MediaConcurrency
mediaConcurrency_concurrency = (MediaConcurrency -> Natural)
-> (MediaConcurrency -> Natural -> MediaConcurrency)
-> Lens MediaConcurrency MediaConcurrency Natural Natural
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 Core.FromJSON MediaConcurrency where
  parseJSON :: Value -> Parser MediaConcurrency
parseJSON =
    String
-> (Object -> Parser MediaConcurrency)
-> Value
-> Parser MediaConcurrency
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MediaConcurrency"
      ( \Object
x ->
          Channel -> Natural -> MediaConcurrency
MediaConcurrency'
            (Channel -> Natural -> MediaConcurrency)
-> Parser Channel -> Parser (Natural -> MediaConcurrency)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Channel
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Channel")
            Parser (Natural -> MediaConcurrency)
-> Parser Natural -> Parser MediaConcurrency
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Concurrency")
      )

instance Prelude.Hashable MediaConcurrency

instance Prelude.NFData MediaConcurrency

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Channel" Text -> Channel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Channel
channel),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Concurrency" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
concurrency)
          ]
      )