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

import Amazonka.Connect.Types.Distribution
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 distribution of traffic between the instance and its replicas.
--
-- /See:/ 'newTelephonyConfig' smart constructor.
data TelephonyConfig = TelephonyConfig'
  { -- | Information about traffic distributions.
    TelephonyConfig -> [Distribution]
distributions :: [Distribution]
  }
  deriving (TelephonyConfig -> TelephonyConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TelephonyConfig -> TelephonyConfig -> Bool
$c/= :: TelephonyConfig -> TelephonyConfig -> Bool
== :: TelephonyConfig -> TelephonyConfig -> Bool
$c== :: TelephonyConfig -> TelephonyConfig -> Bool
Prelude.Eq, ReadPrec [TelephonyConfig]
ReadPrec TelephonyConfig
Int -> ReadS TelephonyConfig
ReadS [TelephonyConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TelephonyConfig]
$creadListPrec :: ReadPrec [TelephonyConfig]
readPrec :: ReadPrec TelephonyConfig
$creadPrec :: ReadPrec TelephonyConfig
readList :: ReadS [TelephonyConfig]
$creadList :: ReadS [TelephonyConfig]
readsPrec :: Int -> ReadS TelephonyConfig
$creadsPrec :: Int -> ReadS TelephonyConfig
Prelude.Read, Int -> TelephonyConfig -> ShowS
[TelephonyConfig] -> ShowS
TelephonyConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TelephonyConfig] -> ShowS
$cshowList :: [TelephonyConfig] -> ShowS
show :: TelephonyConfig -> String
$cshow :: TelephonyConfig -> String
showsPrec :: Int -> TelephonyConfig -> ShowS
$cshowsPrec :: Int -> TelephonyConfig -> ShowS
Prelude.Show, forall x. Rep TelephonyConfig x -> TelephonyConfig
forall x. TelephonyConfig -> Rep TelephonyConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TelephonyConfig x -> TelephonyConfig
$cfrom :: forall x. TelephonyConfig -> Rep TelephonyConfig x
Prelude.Generic)

-- |
-- Create a value of 'TelephonyConfig' 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:
--
-- 'distributions', 'telephonyConfig_distributions' - Information about traffic distributions.
newTelephonyConfig ::
  TelephonyConfig
newTelephonyConfig :: TelephonyConfig
newTelephonyConfig =
  TelephonyConfig' {$sel:distributions:TelephonyConfig' :: [Distribution]
distributions = forall a. Monoid a => a
Prelude.mempty}

-- | Information about traffic distributions.
telephonyConfig_distributions :: Lens.Lens' TelephonyConfig [Distribution]
telephonyConfig_distributions :: Lens' TelephonyConfig [Distribution]
telephonyConfig_distributions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelephonyConfig' {[Distribution]
distributions :: [Distribution]
$sel:distributions:TelephonyConfig' :: TelephonyConfig -> [Distribution]
distributions} -> [Distribution]
distributions) (\s :: TelephonyConfig
s@TelephonyConfig' {} [Distribution]
a -> TelephonyConfig
s {$sel:distributions:TelephonyConfig' :: [Distribution]
distributions = [Distribution]
a} :: TelephonyConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON TelephonyConfig where
  parseJSON :: Value -> Parser TelephonyConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TelephonyConfig"
      ( \Object
x ->
          [Distribution] -> TelephonyConfig
TelephonyConfig'
            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
"Distributions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable TelephonyConfig where
  hashWithSalt :: Int -> TelephonyConfig -> Int
hashWithSalt Int
_salt TelephonyConfig' {[Distribution]
distributions :: [Distribution]
$sel:distributions:TelephonyConfig' :: TelephonyConfig -> [Distribution]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Distribution]
distributions

instance Prelude.NFData TelephonyConfig where
  rnf :: TelephonyConfig -> ()
rnf TelephonyConfig' {[Distribution]
distributions :: [Distribution]
$sel:distributions:TelephonyConfig' :: TelephonyConfig -> [Distribution]
..} = forall a. NFData a => a -> ()
Prelude.rnf [Distribution]
distributions

instance Data.ToJSON TelephonyConfig where
  toJSON :: TelephonyConfig -> Value
toJSON TelephonyConfig' {[Distribution]
distributions :: [Distribution]
$sel:distributions:TelephonyConfig' :: TelephonyConfig -> [Distribution]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"Distributions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Distribution]
distributions)
          ]
      )