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

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

-- | Termination settings enable your SIP hosts to make outbound calls using
-- your Amazon Chime Voice Connector.
--
-- /See:/ 'newTermination' smart constructor.
data Termination = Termination'
  { -- | The default caller ID phone number.
    Termination -> Maybe (Sensitive Text)
defaultPhoneNumber :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | When termination settings are disabled, outbound calls can not be made.
    Termination -> Maybe Bool
disabled :: Prelude.Maybe Prelude.Bool,
    -- | The countries to which calls are allowed, in ISO 3166-1 alpha-2 format.
    -- Required.
    Termination -> Maybe [Text]
callingRegions :: Prelude.Maybe [Prelude.Text],
    -- | The limit on calls per second. Max value based on account service quota.
    -- Default value of 1.
    Termination -> Maybe Natural
cpsLimit :: Prelude.Maybe Prelude.Natural,
    -- | The IP addresses allowed to make calls, in CIDR format. Required.
    Termination -> Maybe [Text]
cidrAllowedList :: Prelude.Maybe [Prelude.Text]
  }
  deriving (Termination -> Termination -> Bool
(Termination -> Termination -> Bool)
-> (Termination -> Termination -> Bool) -> Eq Termination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Termination -> Termination -> Bool
$c/= :: Termination -> Termination -> Bool
== :: Termination -> Termination -> Bool
$c== :: Termination -> Termination -> Bool
Prelude.Eq, Int -> Termination -> ShowS
[Termination] -> ShowS
Termination -> String
(Int -> Termination -> ShowS)
-> (Termination -> String)
-> ([Termination] -> ShowS)
-> Show Termination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Termination] -> ShowS
$cshowList :: [Termination] -> ShowS
show :: Termination -> String
$cshow :: Termination -> String
showsPrec :: Int -> Termination -> ShowS
$cshowsPrec :: Int -> Termination -> ShowS
Prelude.Show, (forall x. Termination -> Rep Termination x)
-> (forall x. Rep Termination x -> Termination)
-> Generic Termination
forall x. Rep Termination x -> Termination
forall x. Termination -> Rep Termination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Termination x -> Termination
$cfrom :: forall x. Termination -> Rep Termination x
Prelude.Generic)

-- |
-- Create a value of 'Termination' 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:
--
-- 'defaultPhoneNumber', 'termination_defaultPhoneNumber' - The default caller ID phone number.
--
-- 'disabled', 'termination_disabled' - When termination settings are disabled, outbound calls can not be made.
--
-- 'callingRegions', 'termination_callingRegions' - The countries to which calls are allowed, in ISO 3166-1 alpha-2 format.
-- Required.
--
-- 'cpsLimit', 'termination_cpsLimit' - The limit on calls per second. Max value based on account service quota.
-- Default value of 1.
--
-- 'cidrAllowedList', 'termination_cidrAllowedList' - The IP addresses allowed to make calls, in CIDR format. Required.
newTermination ::
  Termination
newTermination :: Termination
newTermination =
  Termination' :: Maybe (Sensitive Text)
-> Maybe Bool
-> Maybe [Text]
-> Maybe Natural
-> Maybe [Text]
-> Termination
Termination'
    { $sel:defaultPhoneNumber:Termination' :: Maybe (Sensitive Text)
defaultPhoneNumber = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:disabled:Termination' :: Maybe Bool
disabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:callingRegions:Termination' :: Maybe [Text]
callingRegions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:cpsLimit:Termination' :: Maybe Natural
cpsLimit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:cidrAllowedList:Termination' :: Maybe [Text]
cidrAllowedList = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The default caller ID phone number.
termination_defaultPhoneNumber :: Lens.Lens' Termination (Prelude.Maybe Prelude.Text)
termination_defaultPhoneNumber :: (Maybe Text -> f (Maybe Text)) -> Termination -> f Termination
termination_defaultPhoneNumber = (Termination -> Maybe (Sensitive Text))
-> (Termination -> Maybe (Sensitive Text) -> Termination)
-> Lens
     Termination
     Termination
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Termination' {Maybe (Sensitive Text)
defaultPhoneNumber :: Maybe (Sensitive Text)
$sel:defaultPhoneNumber:Termination' :: Termination -> Maybe (Sensitive Text)
defaultPhoneNumber} -> Maybe (Sensitive Text)
defaultPhoneNumber) (\s :: Termination
s@Termination' {} Maybe (Sensitive Text)
a -> Termination
s {$sel:defaultPhoneNumber:Termination' :: Maybe (Sensitive Text)
defaultPhoneNumber = Maybe (Sensitive Text)
a} :: Termination) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> Termination -> f Termination)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> Termination
-> f Termination
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

-- | When termination settings are disabled, outbound calls can not be made.
termination_disabled :: Lens.Lens' Termination (Prelude.Maybe Prelude.Bool)
termination_disabled :: (Maybe Bool -> f (Maybe Bool)) -> Termination -> f Termination
termination_disabled = (Termination -> Maybe Bool)
-> (Termination -> Maybe Bool -> Termination)
-> Lens Termination Termination (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Termination' {Maybe Bool
disabled :: Maybe Bool
$sel:disabled:Termination' :: Termination -> Maybe Bool
disabled} -> Maybe Bool
disabled) (\s :: Termination
s@Termination' {} Maybe Bool
a -> Termination
s {$sel:disabled:Termination' :: Maybe Bool
disabled = Maybe Bool
a} :: Termination)

-- | The countries to which calls are allowed, in ISO 3166-1 alpha-2 format.
-- Required.
termination_callingRegions :: Lens.Lens' Termination (Prelude.Maybe [Prelude.Text])
termination_callingRegions :: (Maybe [Text] -> f (Maybe [Text])) -> Termination -> f Termination
termination_callingRegions = (Termination -> Maybe [Text])
-> (Termination -> Maybe [Text] -> Termination)
-> Lens Termination Termination (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Termination' {Maybe [Text]
callingRegions :: Maybe [Text]
$sel:callingRegions:Termination' :: Termination -> Maybe [Text]
callingRegions} -> Maybe [Text]
callingRegions) (\s :: Termination
s@Termination' {} Maybe [Text]
a -> Termination
s {$sel:callingRegions:Termination' :: Maybe [Text]
callingRegions = Maybe [Text]
a} :: Termination) ((Maybe [Text] -> f (Maybe [Text]))
 -> Termination -> f Termination)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Termination
-> f Termination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The limit on calls per second. Max value based on account service quota.
-- Default value of 1.
termination_cpsLimit :: Lens.Lens' Termination (Prelude.Maybe Prelude.Natural)
termination_cpsLimit :: (Maybe Natural -> f (Maybe Natural))
-> Termination -> f Termination
termination_cpsLimit = (Termination -> Maybe Natural)
-> (Termination -> Maybe Natural -> Termination)
-> Lens Termination Termination (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Termination' {Maybe Natural
cpsLimit :: Maybe Natural
$sel:cpsLimit:Termination' :: Termination -> Maybe Natural
cpsLimit} -> Maybe Natural
cpsLimit) (\s :: Termination
s@Termination' {} Maybe Natural
a -> Termination
s {$sel:cpsLimit:Termination' :: Maybe Natural
cpsLimit = Maybe Natural
a} :: Termination)

-- | The IP addresses allowed to make calls, in CIDR format. Required.
termination_cidrAllowedList :: Lens.Lens' Termination (Prelude.Maybe [Prelude.Text])
termination_cidrAllowedList :: (Maybe [Text] -> f (Maybe [Text])) -> Termination -> f Termination
termination_cidrAllowedList = (Termination -> Maybe [Text])
-> (Termination -> Maybe [Text] -> Termination)
-> Lens Termination Termination (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Termination' {Maybe [Text]
cidrAllowedList :: Maybe [Text]
$sel:cidrAllowedList:Termination' :: Termination -> Maybe [Text]
cidrAllowedList} -> Maybe [Text]
cidrAllowedList) (\s :: Termination
s@Termination' {} Maybe [Text]
a -> Termination
s {$sel:cidrAllowedList:Termination' :: Maybe [Text]
cidrAllowedList = Maybe [Text]
a} :: Termination) ((Maybe [Text] -> f (Maybe [Text]))
 -> Termination -> f Termination)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Termination
-> f Termination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Termination where
  parseJSON :: Value -> Parser Termination
parseJSON =
    String
-> (Object -> Parser Termination) -> Value -> Parser Termination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Termination"
      ( \Object
x ->
          Maybe (Sensitive Text)
-> Maybe Bool
-> Maybe [Text]
-> Maybe Natural
-> Maybe [Text]
-> Termination
Termination'
            (Maybe (Sensitive Text)
 -> Maybe Bool
 -> Maybe [Text]
 -> Maybe Natural
 -> Maybe [Text]
 -> Termination)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe Bool
      -> Maybe [Text] -> Maybe Natural -> Maybe [Text] -> Termination)
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
"DefaultPhoneNumber")
            Parser
  (Maybe Bool
   -> Maybe [Text] -> Maybe Natural -> Maybe [Text] -> Termination)
-> Parser (Maybe Bool)
-> Parser
     (Maybe [Text] -> Maybe Natural -> Maybe [Text] -> Termination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Disabled")
            Parser
  (Maybe [Text] -> Maybe Natural -> Maybe [Text] -> Termination)
-> Parser (Maybe [Text])
-> Parser (Maybe Natural -> Maybe [Text] -> Termination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CallingRegions" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Natural -> Maybe [Text] -> Termination)
-> Parser (Maybe Natural) -> Parser (Maybe [Text] -> Termination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CpsLimit")
            Parser (Maybe [Text] -> Termination)
-> Parser (Maybe [Text]) -> Parser Termination
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CidrAllowedList"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable Termination

instance Prelude.NFData Termination

instance Core.ToJSON Termination where
  toJSON :: Termination -> Value
toJSON Termination' {Maybe Bool
Maybe Natural
Maybe [Text]
Maybe (Sensitive Text)
cidrAllowedList :: Maybe [Text]
cpsLimit :: Maybe Natural
callingRegions :: Maybe [Text]
disabled :: Maybe Bool
defaultPhoneNumber :: Maybe (Sensitive Text)
$sel:cidrAllowedList:Termination' :: Termination -> Maybe [Text]
$sel:cpsLimit:Termination' :: Termination -> Maybe Natural
$sel:callingRegions:Termination' :: Termination -> Maybe [Text]
$sel:disabled:Termination' :: Termination -> Maybe Bool
$sel:defaultPhoneNumber:Termination' :: Termination -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DefaultPhoneNumber" 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)
defaultPhoneNumber,
            (Text
"Disabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
disabled,
            (Text
"CallingRegions" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
callingRegions,
            (Text
"CpsLimit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
cpsLimit,
            (Text
"CidrAllowedList" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
cidrAllowedList
          ]
      )