{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Chime.Types.Termination where

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

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

-- | 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 :: Lens' Termination (Maybe [Text])
termination_callingRegions = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The IP addresses allowed to make calls, in CIDR format. Required.
termination_cidrAllowedList :: Lens.Lens' Termination (Prelude.Maybe [Prelude.Text])
termination_cidrAllowedList :: Lens' Termination (Maybe [Text])
termination_cidrAllowedList = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' Termination (Maybe Natural)
termination_cpsLimit = 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 default caller ID phone number.
termination_defaultPhoneNumber :: Lens.Lens' Termination (Prelude.Maybe Prelude.Text)
termination_defaultPhoneNumber :: Lens' Termination (Maybe Text)
termination_defaultPhoneNumber = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | When termination settings are disabled, outbound calls can not be made.
termination_disabled :: Lens.Lens' Termination (Prelude.Maybe Prelude.Bool)
termination_disabled :: Lens' Termination (Maybe Bool)
termination_disabled = 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)

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

instance Prelude.Hashable Termination where
  hashWithSalt :: Int -> Termination -> Int
hashWithSalt Int
_salt Termination' {Maybe Bool
Maybe Natural
Maybe [Text]
Maybe (Sensitive Text)
disabled :: Maybe Bool
defaultPhoneNumber :: Maybe (Sensitive Text)
cpsLimit :: Maybe Natural
cidrAllowedList :: Maybe [Text]
callingRegions :: Maybe [Text]
$sel:disabled:Termination' :: Termination -> Maybe Bool
$sel:defaultPhoneNumber:Termination' :: Termination -> Maybe (Sensitive Text)
$sel:cpsLimit:Termination' :: Termination -> Maybe Natural
$sel:cidrAllowedList:Termination' :: Termination -> Maybe [Text]
$sel:callingRegions:Termination' :: Termination -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
callingRegions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
cidrAllowedList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
cpsLimit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
defaultPhoneNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
disabled

instance Prelude.NFData Termination where
  rnf :: Termination -> ()
rnf Termination' {Maybe Bool
Maybe Natural
Maybe [Text]
Maybe (Sensitive Text)
disabled :: Maybe Bool
defaultPhoneNumber :: Maybe (Sensitive Text)
cpsLimit :: Maybe Natural
cidrAllowedList :: Maybe [Text]
callingRegions :: Maybe [Text]
$sel:disabled:Termination' :: Termination -> Maybe Bool
$sel:defaultPhoneNumber:Termination' :: Termination -> Maybe (Sensitive Text)
$sel:cpsLimit:Termination' :: Termination -> Maybe Natural
$sel:cidrAllowedList:Termination' :: Termination -> Maybe [Text]
$sel:callingRegions:Termination' :: Termination -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
callingRegions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
cidrAllowedList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
cpsLimit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
defaultPhoneNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
disabled

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