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

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

-- | The Dialed Number Identification Service (DNIS) emergency calling
-- configuration details associated with an Amazon Chime Voice Connector\'s
-- emergency calling configuration.
--
-- /See:/ 'newDNISEmergencyCallingConfiguration' smart constructor.
data DNISEmergencyCallingConfiguration = DNISEmergencyCallingConfiguration'
  { -- | The DNIS phone number to route test emergency calls to, in E.164 format.
    DNISEmergencyCallingConfiguration -> Maybe (Sensitive Text)
testPhoneNumber :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The DNIS phone number to route emergency calls to, in E.164 format.
    DNISEmergencyCallingConfiguration -> Sensitive Text
emergencyPhoneNumber :: Core.Sensitive Prelude.Text,
    -- | The country from which emergency calls are allowed, in ISO 3166-1
    -- alpha-2 format.
    DNISEmergencyCallingConfiguration -> Text
callingCountry :: Prelude.Text
  }
  deriving (DNISEmergencyCallingConfiguration
-> DNISEmergencyCallingConfiguration -> Bool
(DNISEmergencyCallingConfiguration
 -> DNISEmergencyCallingConfiguration -> Bool)
-> (DNISEmergencyCallingConfiguration
    -> DNISEmergencyCallingConfiguration -> Bool)
-> Eq DNISEmergencyCallingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DNISEmergencyCallingConfiguration
-> DNISEmergencyCallingConfiguration -> Bool
$c/= :: DNISEmergencyCallingConfiguration
-> DNISEmergencyCallingConfiguration -> Bool
== :: DNISEmergencyCallingConfiguration
-> DNISEmergencyCallingConfiguration -> Bool
$c== :: DNISEmergencyCallingConfiguration
-> DNISEmergencyCallingConfiguration -> Bool
Prelude.Eq, Int -> DNISEmergencyCallingConfiguration -> ShowS
[DNISEmergencyCallingConfiguration] -> ShowS
DNISEmergencyCallingConfiguration -> String
(Int -> DNISEmergencyCallingConfiguration -> ShowS)
-> (DNISEmergencyCallingConfiguration -> String)
-> ([DNISEmergencyCallingConfiguration] -> ShowS)
-> Show DNISEmergencyCallingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DNISEmergencyCallingConfiguration] -> ShowS
$cshowList :: [DNISEmergencyCallingConfiguration] -> ShowS
show :: DNISEmergencyCallingConfiguration -> String
$cshow :: DNISEmergencyCallingConfiguration -> String
showsPrec :: Int -> DNISEmergencyCallingConfiguration -> ShowS
$cshowsPrec :: Int -> DNISEmergencyCallingConfiguration -> ShowS
Prelude.Show, (forall x.
 DNISEmergencyCallingConfiguration
 -> Rep DNISEmergencyCallingConfiguration x)
-> (forall x.
    Rep DNISEmergencyCallingConfiguration x
    -> DNISEmergencyCallingConfiguration)
-> Generic DNISEmergencyCallingConfiguration
forall x.
Rep DNISEmergencyCallingConfiguration x
-> DNISEmergencyCallingConfiguration
forall x.
DNISEmergencyCallingConfiguration
-> Rep DNISEmergencyCallingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DNISEmergencyCallingConfiguration x
-> DNISEmergencyCallingConfiguration
$cfrom :: forall x.
DNISEmergencyCallingConfiguration
-> Rep DNISEmergencyCallingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DNISEmergencyCallingConfiguration' 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:
--
-- 'testPhoneNumber', 'dNISEmergencyCallingConfiguration_testPhoneNumber' - The DNIS phone number to route test emergency calls to, in E.164 format.
--
-- 'emergencyPhoneNumber', 'dNISEmergencyCallingConfiguration_emergencyPhoneNumber' - The DNIS phone number to route emergency calls to, in E.164 format.
--
-- 'callingCountry', 'dNISEmergencyCallingConfiguration_callingCountry' - The country from which emergency calls are allowed, in ISO 3166-1
-- alpha-2 format.
newDNISEmergencyCallingConfiguration ::
  -- | 'emergencyPhoneNumber'
  Prelude.Text ->
  -- | 'callingCountry'
  Prelude.Text ->
  DNISEmergencyCallingConfiguration
newDNISEmergencyCallingConfiguration :: Text -> Text -> DNISEmergencyCallingConfiguration
newDNISEmergencyCallingConfiguration
  Text
pEmergencyPhoneNumber_
  Text
pCallingCountry_ =
    DNISEmergencyCallingConfiguration' :: Maybe (Sensitive Text)
-> Sensitive Text -> Text -> DNISEmergencyCallingConfiguration
DNISEmergencyCallingConfiguration'
      { $sel:testPhoneNumber:DNISEmergencyCallingConfiguration' :: Maybe (Sensitive Text)
testPhoneNumber =
          Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:emergencyPhoneNumber:DNISEmergencyCallingConfiguration' :: Sensitive Text
emergencyPhoneNumber =
          Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive
            (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pEmergencyPhoneNumber_,
        $sel:callingCountry:DNISEmergencyCallingConfiguration' :: Text
callingCountry = Text
pCallingCountry_
      }

-- | The DNIS phone number to route test emergency calls to, in E.164 format.
dNISEmergencyCallingConfiguration_testPhoneNumber :: Lens.Lens' DNISEmergencyCallingConfiguration (Prelude.Maybe Prelude.Text)
dNISEmergencyCallingConfiguration_testPhoneNumber :: (Maybe Text -> f (Maybe Text))
-> DNISEmergencyCallingConfiguration
-> f DNISEmergencyCallingConfiguration
dNISEmergencyCallingConfiguration_testPhoneNumber = (DNISEmergencyCallingConfiguration -> Maybe (Sensitive Text))
-> (DNISEmergencyCallingConfiguration
    -> Maybe (Sensitive Text) -> DNISEmergencyCallingConfiguration)
-> Lens
     DNISEmergencyCallingConfiguration
     DNISEmergencyCallingConfiguration
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DNISEmergencyCallingConfiguration' {Maybe (Sensitive Text)
testPhoneNumber :: Maybe (Sensitive Text)
$sel:testPhoneNumber:DNISEmergencyCallingConfiguration' :: DNISEmergencyCallingConfiguration -> Maybe (Sensitive Text)
testPhoneNumber} -> Maybe (Sensitive Text)
testPhoneNumber) (\s :: DNISEmergencyCallingConfiguration
s@DNISEmergencyCallingConfiguration' {} Maybe (Sensitive Text)
a -> DNISEmergencyCallingConfiguration
s {$sel:testPhoneNumber:DNISEmergencyCallingConfiguration' :: Maybe (Sensitive Text)
testPhoneNumber = Maybe (Sensitive Text)
a} :: DNISEmergencyCallingConfiguration) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> DNISEmergencyCallingConfiguration
 -> f DNISEmergencyCallingConfiguration)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> DNISEmergencyCallingConfiguration
-> f DNISEmergencyCallingConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The DNIS phone number to route emergency calls to, in E.164 format.
dNISEmergencyCallingConfiguration_emergencyPhoneNumber :: Lens.Lens' DNISEmergencyCallingConfiguration Prelude.Text
dNISEmergencyCallingConfiguration_emergencyPhoneNumber :: (Text -> f Text)
-> DNISEmergencyCallingConfiguration
-> f DNISEmergencyCallingConfiguration
dNISEmergencyCallingConfiguration_emergencyPhoneNumber = (DNISEmergencyCallingConfiguration -> Sensitive Text)
-> (DNISEmergencyCallingConfiguration
    -> Sensitive Text -> DNISEmergencyCallingConfiguration)
-> Lens
     DNISEmergencyCallingConfiguration
     DNISEmergencyCallingConfiguration
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DNISEmergencyCallingConfiguration' {Sensitive Text
emergencyPhoneNumber :: Sensitive Text
$sel:emergencyPhoneNumber:DNISEmergencyCallingConfiguration' :: DNISEmergencyCallingConfiguration -> Sensitive Text
emergencyPhoneNumber} -> Sensitive Text
emergencyPhoneNumber) (\s :: DNISEmergencyCallingConfiguration
s@DNISEmergencyCallingConfiguration' {} Sensitive Text
a -> DNISEmergencyCallingConfiguration
s {$sel:emergencyPhoneNumber:DNISEmergencyCallingConfiguration' :: Sensitive Text
emergencyPhoneNumber = Sensitive Text
a} :: DNISEmergencyCallingConfiguration) ((Sensitive Text -> f (Sensitive Text))
 -> DNISEmergencyCallingConfiguration
 -> f DNISEmergencyCallingConfiguration)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> DNISEmergencyCallingConfiguration
-> f DNISEmergencyCallingConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The country from which emergency calls are allowed, in ISO 3166-1
-- alpha-2 format.
dNISEmergencyCallingConfiguration_callingCountry :: Lens.Lens' DNISEmergencyCallingConfiguration Prelude.Text
dNISEmergencyCallingConfiguration_callingCountry :: (Text -> f Text)
-> DNISEmergencyCallingConfiguration
-> f DNISEmergencyCallingConfiguration
dNISEmergencyCallingConfiguration_callingCountry = (DNISEmergencyCallingConfiguration -> Text)
-> (DNISEmergencyCallingConfiguration
    -> Text -> DNISEmergencyCallingConfiguration)
-> Lens
     DNISEmergencyCallingConfiguration
     DNISEmergencyCallingConfiguration
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DNISEmergencyCallingConfiguration' {Text
callingCountry :: Text
$sel:callingCountry:DNISEmergencyCallingConfiguration' :: DNISEmergencyCallingConfiguration -> Text
callingCountry} -> Text
callingCountry) (\s :: DNISEmergencyCallingConfiguration
s@DNISEmergencyCallingConfiguration' {} Text
a -> DNISEmergencyCallingConfiguration
s {$sel:callingCountry:DNISEmergencyCallingConfiguration' :: Text
callingCountry = Text
a} :: DNISEmergencyCallingConfiguration)

instance
  Core.FromJSON
    DNISEmergencyCallingConfiguration
  where
  parseJSON :: Value -> Parser DNISEmergencyCallingConfiguration
parseJSON =
    String
-> (Object -> Parser DNISEmergencyCallingConfiguration)
-> Value
-> Parser DNISEmergencyCallingConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DNISEmergencyCallingConfiguration"
      ( \Object
x ->
          Maybe (Sensitive Text)
-> Sensitive Text -> Text -> DNISEmergencyCallingConfiguration
DNISEmergencyCallingConfiguration'
            (Maybe (Sensitive Text)
 -> Sensitive Text -> Text -> DNISEmergencyCallingConfiguration)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Sensitive Text -> Text -> DNISEmergencyCallingConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TestPhoneNumber")
            Parser
  (Sensitive Text -> Text -> DNISEmergencyCallingConfiguration)
-> Parser (Sensitive Text)
-> Parser (Text -> DNISEmergencyCallingConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EmergencyPhoneNumber")
            Parser (Text -> DNISEmergencyCallingConfiguration)
-> Parser Text -> Parser DNISEmergencyCallingConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"CallingCountry")
      )

instance
  Prelude.Hashable
    DNISEmergencyCallingConfiguration

instance
  Prelude.NFData
    DNISEmergencyCallingConfiguration

instance
  Core.ToJSON
    DNISEmergencyCallingConfiguration
  where
  toJSON :: DNISEmergencyCallingConfiguration -> Value
toJSON DNISEmergencyCallingConfiguration' {Maybe (Sensitive Text)
Text
Sensitive Text
callingCountry :: Text
emergencyPhoneNumber :: Sensitive Text
testPhoneNumber :: Maybe (Sensitive Text)
$sel:callingCountry:DNISEmergencyCallingConfiguration' :: DNISEmergencyCallingConfiguration -> Text
$sel:emergencyPhoneNumber:DNISEmergencyCallingConfiguration' :: DNISEmergencyCallingConfiguration -> Sensitive Text
$sel:testPhoneNumber:DNISEmergencyCallingConfiguration' :: DNISEmergencyCallingConfiguration -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TestPhoneNumber" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
testPhoneNumber,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"EmergencyPhoneNumber"
                  Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
emergencyPhoneNumber
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CallingCountry" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
callingCountry)
          ]
      )