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

import Amazonka.Chime.Types.DNISEmergencyCallingConfiguration
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The emergency calling configuration details associated with an Amazon
-- Chime Voice Connector.
--
-- /See:/ 'newEmergencyCallingConfiguration' smart constructor.
data EmergencyCallingConfiguration = EmergencyCallingConfiguration'
  { -- | The Dialed Number Identification Service (DNIS) emergency calling
    -- configuration details.
    EmergencyCallingConfiguration
-> Maybe [DNISEmergencyCallingConfiguration]
dnis :: Prelude.Maybe [DNISEmergencyCallingConfiguration]
  }
  deriving (EmergencyCallingConfiguration
-> EmergencyCallingConfiguration -> Bool
(EmergencyCallingConfiguration
 -> EmergencyCallingConfiguration -> Bool)
-> (EmergencyCallingConfiguration
    -> EmergencyCallingConfiguration -> Bool)
-> Eq EmergencyCallingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EmergencyCallingConfiguration
-> EmergencyCallingConfiguration -> Bool
$c/= :: EmergencyCallingConfiguration
-> EmergencyCallingConfiguration -> Bool
== :: EmergencyCallingConfiguration
-> EmergencyCallingConfiguration -> Bool
$c== :: EmergencyCallingConfiguration
-> EmergencyCallingConfiguration -> Bool
Prelude.Eq, Int -> EmergencyCallingConfiguration -> ShowS
[EmergencyCallingConfiguration] -> ShowS
EmergencyCallingConfiguration -> String
(Int -> EmergencyCallingConfiguration -> ShowS)
-> (EmergencyCallingConfiguration -> String)
-> ([EmergencyCallingConfiguration] -> ShowS)
-> Show EmergencyCallingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmergencyCallingConfiguration] -> ShowS
$cshowList :: [EmergencyCallingConfiguration] -> ShowS
show :: EmergencyCallingConfiguration -> String
$cshow :: EmergencyCallingConfiguration -> String
showsPrec :: Int -> EmergencyCallingConfiguration -> ShowS
$cshowsPrec :: Int -> EmergencyCallingConfiguration -> ShowS
Prelude.Show, (forall x.
 EmergencyCallingConfiguration
 -> Rep EmergencyCallingConfiguration x)
-> (forall x.
    Rep EmergencyCallingConfiguration x
    -> EmergencyCallingConfiguration)
-> Generic EmergencyCallingConfiguration
forall x.
Rep EmergencyCallingConfiguration x
-> EmergencyCallingConfiguration
forall x.
EmergencyCallingConfiguration
-> Rep EmergencyCallingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EmergencyCallingConfiguration x
-> EmergencyCallingConfiguration
$cfrom :: forall x.
EmergencyCallingConfiguration
-> Rep EmergencyCallingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EmergencyCallingConfiguration' 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:
--
-- 'dnis', 'emergencyCallingConfiguration_dnis' - The Dialed Number Identification Service (DNIS) emergency calling
-- configuration details.
newEmergencyCallingConfiguration ::
  EmergencyCallingConfiguration
newEmergencyCallingConfiguration :: EmergencyCallingConfiguration
newEmergencyCallingConfiguration =
  EmergencyCallingConfiguration' :: Maybe [DNISEmergencyCallingConfiguration]
-> EmergencyCallingConfiguration
EmergencyCallingConfiguration'
    { $sel:dnis:EmergencyCallingConfiguration' :: Maybe [DNISEmergencyCallingConfiguration]
dnis =
        Maybe [DNISEmergencyCallingConfiguration]
forall a. Maybe a
Prelude.Nothing
    }

-- | The Dialed Number Identification Service (DNIS) emergency calling
-- configuration details.
emergencyCallingConfiguration_dnis :: Lens.Lens' EmergencyCallingConfiguration (Prelude.Maybe [DNISEmergencyCallingConfiguration])
emergencyCallingConfiguration_dnis :: (Maybe [DNISEmergencyCallingConfiguration]
 -> f (Maybe [DNISEmergencyCallingConfiguration]))
-> EmergencyCallingConfiguration -> f EmergencyCallingConfiguration
emergencyCallingConfiguration_dnis = (EmergencyCallingConfiguration
 -> Maybe [DNISEmergencyCallingConfiguration])
-> (EmergencyCallingConfiguration
    -> Maybe [DNISEmergencyCallingConfiguration]
    -> EmergencyCallingConfiguration)
-> Lens
     EmergencyCallingConfiguration
     EmergencyCallingConfiguration
     (Maybe [DNISEmergencyCallingConfiguration])
     (Maybe [DNISEmergencyCallingConfiguration])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmergencyCallingConfiguration' {Maybe [DNISEmergencyCallingConfiguration]
dnis :: Maybe [DNISEmergencyCallingConfiguration]
$sel:dnis:EmergencyCallingConfiguration' :: EmergencyCallingConfiguration
-> Maybe [DNISEmergencyCallingConfiguration]
dnis} -> Maybe [DNISEmergencyCallingConfiguration]
dnis) (\s :: EmergencyCallingConfiguration
s@EmergencyCallingConfiguration' {} Maybe [DNISEmergencyCallingConfiguration]
a -> EmergencyCallingConfiguration
s {$sel:dnis:EmergencyCallingConfiguration' :: Maybe [DNISEmergencyCallingConfiguration]
dnis = Maybe [DNISEmergencyCallingConfiguration]
a} :: EmergencyCallingConfiguration) ((Maybe [DNISEmergencyCallingConfiguration]
  -> f (Maybe [DNISEmergencyCallingConfiguration]))
 -> EmergencyCallingConfiguration
 -> f EmergencyCallingConfiguration)
-> ((Maybe [DNISEmergencyCallingConfiguration]
     -> f (Maybe [DNISEmergencyCallingConfiguration]))
    -> Maybe [DNISEmergencyCallingConfiguration]
    -> f (Maybe [DNISEmergencyCallingConfiguration]))
-> (Maybe [DNISEmergencyCallingConfiguration]
    -> f (Maybe [DNISEmergencyCallingConfiguration]))
-> EmergencyCallingConfiguration
-> f EmergencyCallingConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DNISEmergencyCallingConfiguration]
  [DNISEmergencyCallingConfiguration]
  [DNISEmergencyCallingConfiguration]
  [DNISEmergencyCallingConfiguration]
-> Iso
     (Maybe [DNISEmergencyCallingConfiguration])
     (Maybe [DNISEmergencyCallingConfiguration])
     (Maybe [DNISEmergencyCallingConfiguration])
     (Maybe [DNISEmergencyCallingConfiguration])
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 AnIso
  [DNISEmergencyCallingConfiguration]
  [DNISEmergencyCallingConfiguration]
  [DNISEmergencyCallingConfiguration]
  [DNISEmergencyCallingConfiguration]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON EmergencyCallingConfiguration where
  parseJSON :: Value -> Parser EmergencyCallingConfiguration
parseJSON =
    String
-> (Object -> Parser EmergencyCallingConfiguration)
-> Value
-> Parser EmergencyCallingConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EmergencyCallingConfiguration"
      ( \Object
x ->
          Maybe [DNISEmergencyCallingConfiguration]
-> EmergencyCallingConfiguration
EmergencyCallingConfiguration'
            (Maybe [DNISEmergencyCallingConfiguration]
 -> EmergencyCallingConfiguration)
-> Parser (Maybe [DNISEmergencyCallingConfiguration])
-> Parser EmergencyCallingConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Parser (Maybe (Maybe [DNISEmergencyCallingConfiguration]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DNIS" Parser (Maybe (Maybe [DNISEmergencyCallingConfiguration]))
-> Maybe [DNISEmergencyCallingConfiguration]
-> Parser (Maybe [DNISEmergencyCallingConfiguration])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DNISEmergencyCallingConfiguration]
forall a. Monoid a => a
Prelude.mempty)
      )

instance
  Prelude.Hashable
    EmergencyCallingConfiguration

instance Prelude.NFData EmergencyCallingConfiguration

instance Core.ToJSON EmergencyCallingConfiguration where
  toJSON :: EmergencyCallingConfiguration -> Value
toJSON EmergencyCallingConfiguration' {Maybe [DNISEmergencyCallingConfiguration]
dnis :: Maybe [DNISEmergencyCallingConfiguration]
$sel:dnis:EmergencyCallingConfiguration' :: EmergencyCallingConfiguration
-> Maybe [DNISEmergencyCallingConfiguration]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"DNIS" Text -> [DNISEmergencyCallingConfiguration] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([DNISEmergencyCallingConfiguration] -> Pair)
-> Maybe [DNISEmergencyCallingConfiguration] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DNISEmergencyCallingConfiguration]
dnis]
      )