{-# 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.AlexaBusiness.Types.IPDialIn
-- 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.AlexaBusiness.Types.IPDialIn where

import Amazonka.AlexaBusiness.Types.CommsProtocol
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The IP endpoint and protocol for calling.
--
-- /See:/ 'newIPDialIn' smart constructor.
data IPDialIn = IPDialIn'
  { -- | The IP address.
    IPDialIn -> Text
endpoint :: Prelude.Text,
    -- | The protocol, including SIP, SIPS, and H323.
    IPDialIn -> CommsProtocol
commsProtocol :: CommsProtocol
  }
  deriving (IPDialIn -> IPDialIn -> Bool
(IPDialIn -> IPDialIn -> Bool)
-> (IPDialIn -> IPDialIn -> Bool) -> Eq IPDialIn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IPDialIn -> IPDialIn -> Bool
$c/= :: IPDialIn -> IPDialIn -> Bool
== :: IPDialIn -> IPDialIn -> Bool
$c== :: IPDialIn -> IPDialIn -> Bool
Prelude.Eq, ReadPrec [IPDialIn]
ReadPrec IPDialIn
Int -> ReadS IPDialIn
ReadS [IPDialIn]
(Int -> ReadS IPDialIn)
-> ReadS [IPDialIn]
-> ReadPrec IPDialIn
-> ReadPrec [IPDialIn]
-> Read IPDialIn
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IPDialIn]
$creadListPrec :: ReadPrec [IPDialIn]
readPrec :: ReadPrec IPDialIn
$creadPrec :: ReadPrec IPDialIn
readList :: ReadS [IPDialIn]
$creadList :: ReadS [IPDialIn]
readsPrec :: Int -> ReadS IPDialIn
$creadsPrec :: Int -> ReadS IPDialIn
Prelude.Read, Int -> IPDialIn -> ShowS
[IPDialIn] -> ShowS
IPDialIn -> String
(Int -> IPDialIn -> ShowS)
-> (IPDialIn -> String) -> ([IPDialIn] -> ShowS) -> Show IPDialIn
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IPDialIn] -> ShowS
$cshowList :: [IPDialIn] -> ShowS
show :: IPDialIn -> String
$cshow :: IPDialIn -> String
showsPrec :: Int -> IPDialIn -> ShowS
$cshowsPrec :: Int -> IPDialIn -> ShowS
Prelude.Show, (forall x. IPDialIn -> Rep IPDialIn x)
-> (forall x. Rep IPDialIn x -> IPDialIn) -> Generic IPDialIn
forall x. Rep IPDialIn x -> IPDialIn
forall x. IPDialIn -> Rep IPDialIn x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IPDialIn x -> IPDialIn
$cfrom :: forall x. IPDialIn -> Rep IPDialIn x
Prelude.Generic)

-- |
-- Create a value of 'IPDialIn' 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:
--
-- 'endpoint', 'iPDialIn_endpoint' - The IP address.
--
-- 'commsProtocol', 'iPDialIn_commsProtocol' - The protocol, including SIP, SIPS, and H323.
newIPDialIn ::
  -- | 'endpoint'
  Prelude.Text ->
  -- | 'commsProtocol'
  CommsProtocol ->
  IPDialIn
newIPDialIn :: Text -> CommsProtocol -> IPDialIn
newIPDialIn Text
pEndpoint_ CommsProtocol
pCommsProtocol_ =
  IPDialIn' :: Text -> CommsProtocol -> IPDialIn
IPDialIn'
    { $sel:endpoint:IPDialIn' :: Text
endpoint = Text
pEndpoint_,
      $sel:commsProtocol:IPDialIn' :: CommsProtocol
commsProtocol = CommsProtocol
pCommsProtocol_
    }

-- | The IP address.
iPDialIn_endpoint :: Lens.Lens' IPDialIn Prelude.Text
iPDialIn_endpoint :: (Text -> f Text) -> IPDialIn -> f IPDialIn
iPDialIn_endpoint = (IPDialIn -> Text)
-> (IPDialIn -> Text -> IPDialIn)
-> Lens IPDialIn IPDialIn Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IPDialIn' {Text
endpoint :: Text
$sel:endpoint:IPDialIn' :: IPDialIn -> Text
endpoint} -> Text
endpoint) (\s :: IPDialIn
s@IPDialIn' {} Text
a -> IPDialIn
s {$sel:endpoint:IPDialIn' :: Text
endpoint = Text
a} :: IPDialIn)

-- | The protocol, including SIP, SIPS, and H323.
iPDialIn_commsProtocol :: Lens.Lens' IPDialIn CommsProtocol
iPDialIn_commsProtocol :: (CommsProtocol -> f CommsProtocol) -> IPDialIn -> f IPDialIn
iPDialIn_commsProtocol = (IPDialIn -> CommsProtocol)
-> (IPDialIn -> CommsProtocol -> IPDialIn)
-> Lens IPDialIn IPDialIn CommsProtocol CommsProtocol
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IPDialIn' {CommsProtocol
commsProtocol :: CommsProtocol
$sel:commsProtocol:IPDialIn' :: IPDialIn -> CommsProtocol
commsProtocol} -> CommsProtocol
commsProtocol) (\s :: IPDialIn
s@IPDialIn' {} CommsProtocol
a -> IPDialIn
s {$sel:commsProtocol:IPDialIn' :: CommsProtocol
commsProtocol = CommsProtocol
a} :: IPDialIn)

instance Core.FromJSON IPDialIn where
  parseJSON :: Value -> Parser IPDialIn
parseJSON =
    String -> (Object -> Parser IPDialIn) -> Value -> Parser IPDialIn
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IPDialIn"
      ( \Object
x ->
          Text -> CommsProtocol -> IPDialIn
IPDialIn'
            (Text -> CommsProtocol -> IPDialIn)
-> Parser Text -> Parser (CommsProtocol -> IPDialIn)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Endpoint")
            Parser (CommsProtocol -> IPDialIn)
-> Parser CommsProtocol -> Parser IPDialIn
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser CommsProtocol
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"CommsProtocol")
      )

instance Prelude.Hashable IPDialIn

instance Prelude.NFData IPDialIn

instance Core.ToJSON IPDialIn where
  toJSON :: IPDialIn -> Value
toJSON IPDialIn' {Text
CommsProtocol
commsProtocol :: CommsProtocol
endpoint :: Text
$sel:commsProtocol:IPDialIn' :: IPDialIn -> CommsProtocol
$sel:endpoint:IPDialIn' :: IPDialIn -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Endpoint" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
endpoint),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CommsProtocol" Text -> CommsProtocol -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CommsProtocol
commsProtocol)
          ]
      )