{-# 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.Chime.Types.VoiceConnectorItem
-- 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.Chime.Types.VoiceConnectorItem where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | For Amazon Chime Voice Connector groups, the Amazon Chime Voice
-- Connectors to which to route inbound calls. Includes priority
-- configuration settings. Limit: 3 @VoiceConnectorItems@ per Amazon Chime
-- Voice Connector group.
--
-- /See:/ 'newVoiceConnectorItem' smart constructor.
data VoiceConnectorItem = VoiceConnectorItem'
  { -- | The Amazon Chime Voice Connector ID.
    VoiceConnectorItem -> Text
voiceConnectorId :: Prelude.Text,
    -- | The priority associated with the Amazon Chime Voice Connector, with 1
    -- being the highest priority. Higher priority Amazon Chime Voice
    -- Connectors are attempted first.
    VoiceConnectorItem -> Natural
priority :: Prelude.Natural
  }
  deriving (VoiceConnectorItem -> VoiceConnectorItem -> Bool
(VoiceConnectorItem -> VoiceConnectorItem -> Bool)
-> (VoiceConnectorItem -> VoiceConnectorItem -> Bool)
-> Eq VoiceConnectorItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VoiceConnectorItem -> VoiceConnectorItem -> Bool
$c/= :: VoiceConnectorItem -> VoiceConnectorItem -> Bool
== :: VoiceConnectorItem -> VoiceConnectorItem -> Bool
$c== :: VoiceConnectorItem -> VoiceConnectorItem -> Bool
Prelude.Eq, ReadPrec [VoiceConnectorItem]
ReadPrec VoiceConnectorItem
Int -> ReadS VoiceConnectorItem
ReadS [VoiceConnectorItem]
(Int -> ReadS VoiceConnectorItem)
-> ReadS [VoiceConnectorItem]
-> ReadPrec VoiceConnectorItem
-> ReadPrec [VoiceConnectorItem]
-> Read VoiceConnectorItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VoiceConnectorItem]
$creadListPrec :: ReadPrec [VoiceConnectorItem]
readPrec :: ReadPrec VoiceConnectorItem
$creadPrec :: ReadPrec VoiceConnectorItem
readList :: ReadS [VoiceConnectorItem]
$creadList :: ReadS [VoiceConnectorItem]
readsPrec :: Int -> ReadS VoiceConnectorItem
$creadsPrec :: Int -> ReadS VoiceConnectorItem
Prelude.Read, Int -> VoiceConnectorItem -> ShowS
[VoiceConnectorItem] -> ShowS
VoiceConnectorItem -> String
(Int -> VoiceConnectorItem -> ShowS)
-> (VoiceConnectorItem -> String)
-> ([VoiceConnectorItem] -> ShowS)
-> Show VoiceConnectorItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VoiceConnectorItem] -> ShowS
$cshowList :: [VoiceConnectorItem] -> ShowS
show :: VoiceConnectorItem -> String
$cshow :: VoiceConnectorItem -> String
showsPrec :: Int -> VoiceConnectorItem -> ShowS
$cshowsPrec :: Int -> VoiceConnectorItem -> ShowS
Prelude.Show, (forall x. VoiceConnectorItem -> Rep VoiceConnectorItem x)
-> (forall x. Rep VoiceConnectorItem x -> VoiceConnectorItem)
-> Generic VoiceConnectorItem
forall x. Rep VoiceConnectorItem x -> VoiceConnectorItem
forall x. VoiceConnectorItem -> Rep VoiceConnectorItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VoiceConnectorItem x -> VoiceConnectorItem
$cfrom :: forall x. VoiceConnectorItem -> Rep VoiceConnectorItem x
Prelude.Generic)

-- |
-- Create a value of 'VoiceConnectorItem' 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:
--
-- 'voiceConnectorId', 'voiceConnectorItem_voiceConnectorId' - The Amazon Chime Voice Connector ID.
--
-- 'priority', 'voiceConnectorItem_priority' - The priority associated with the Amazon Chime Voice Connector, with 1
-- being the highest priority. Higher priority Amazon Chime Voice
-- Connectors are attempted first.
newVoiceConnectorItem ::
  -- | 'voiceConnectorId'
  Prelude.Text ->
  -- | 'priority'
  Prelude.Natural ->
  VoiceConnectorItem
newVoiceConnectorItem :: Text -> Natural -> VoiceConnectorItem
newVoiceConnectorItem Text
pVoiceConnectorId_ Natural
pPriority_ =
  VoiceConnectorItem' :: Text -> Natural -> VoiceConnectorItem
VoiceConnectorItem'
    { $sel:voiceConnectorId:VoiceConnectorItem' :: Text
voiceConnectorId =
        Text
pVoiceConnectorId_,
      $sel:priority:VoiceConnectorItem' :: Natural
priority = Natural
pPriority_
    }

-- | The Amazon Chime Voice Connector ID.
voiceConnectorItem_voiceConnectorId :: Lens.Lens' VoiceConnectorItem Prelude.Text
voiceConnectorItem_voiceConnectorId :: (Text -> f Text) -> VoiceConnectorItem -> f VoiceConnectorItem
voiceConnectorItem_voiceConnectorId = (VoiceConnectorItem -> Text)
-> (VoiceConnectorItem -> Text -> VoiceConnectorItem)
-> Lens VoiceConnectorItem VoiceConnectorItem Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VoiceConnectorItem' {Text
voiceConnectorId :: Text
$sel:voiceConnectorId:VoiceConnectorItem' :: VoiceConnectorItem -> Text
voiceConnectorId} -> Text
voiceConnectorId) (\s :: VoiceConnectorItem
s@VoiceConnectorItem' {} Text
a -> VoiceConnectorItem
s {$sel:voiceConnectorId:VoiceConnectorItem' :: Text
voiceConnectorId = Text
a} :: VoiceConnectorItem)

-- | The priority associated with the Amazon Chime Voice Connector, with 1
-- being the highest priority. Higher priority Amazon Chime Voice
-- Connectors are attempted first.
voiceConnectorItem_priority :: Lens.Lens' VoiceConnectorItem Prelude.Natural
voiceConnectorItem_priority :: (Natural -> f Natural)
-> VoiceConnectorItem -> f VoiceConnectorItem
voiceConnectorItem_priority = (VoiceConnectorItem -> Natural)
-> (VoiceConnectorItem -> Natural -> VoiceConnectorItem)
-> Lens VoiceConnectorItem VoiceConnectorItem Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VoiceConnectorItem' {Natural
priority :: Natural
$sel:priority:VoiceConnectorItem' :: VoiceConnectorItem -> Natural
priority} -> Natural
priority) (\s :: VoiceConnectorItem
s@VoiceConnectorItem' {} Natural
a -> VoiceConnectorItem
s {$sel:priority:VoiceConnectorItem' :: Natural
priority = Natural
a} :: VoiceConnectorItem)

instance Core.FromJSON VoiceConnectorItem where
  parseJSON :: Value -> Parser VoiceConnectorItem
parseJSON =
    String
-> (Object -> Parser VoiceConnectorItem)
-> Value
-> Parser VoiceConnectorItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VoiceConnectorItem"
      ( \Object
x ->
          Text -> Natural -> VoiceConnectorItem
VoiceConnectorItem'
            (Text -> Natural -> VoiceConnectorItem)
-> Parser Text -> Parser (Natural -> VoiceConnectorItem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"VoiceConnectorId")
            Parser (Natural -> VoiceConnectorItem)
-> Parser Natural -> Parser VoiceConnectorItem
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
"Priority")
      )

instance Prelude.Hashable VoiceConnectorItem

instance Prelude.NFData VoiceConnectorItem

instance Core.ToJSON VoiceConnectorItem where
  toJSON :: VoiceConnectorItem -> Value
toJSON VoiceConnectorItem' {Natural
Text
priority :: Natural
voiceConnectorId :: Text
$sel:priority:VoiceConnectorItem' :: VoiceConnectorItem -> Natural
$sel:voiceConnectorId:VoiceConnectorItem' :: VoiceConnectorItem -> Text
..} =
    [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
"VoiceConnectorId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
voiceConnectorId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Priority" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
priority)
          ]
      )