{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' IPDialIn Text
iPDialIn_endpoint = 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 :: Lens' IPDialIn CommsProtocol
iPDialIn_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 Data.FromJSON IPDialIn where
  parseJSON :: Value -> Parser IPDialIn
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IPDialIn"
      ( \Object
x ->
          Text -> CommsProtocol -> IPDialIn
IPDialIn'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Endpoint")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"CommsProtocol")
      )

instance Prelude.Hashable IPDialIn where
  hashWithSalt :: Int -> IPDialIn -> Int
hashWithSalt Int
_salt IPDialIn' {Text
CommsProtocol
commsProtocol :: CommsProtocol
endpoint :: Text
$sel:commsProtocol:IPDialIn' :: IPDialIn -> CommsProtocol
$sel:endpoint:IPDialIn' :: IPDialIn -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
endpoint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CommsProtocol
commsProtocol

instance Prelude.NFData IPDialIn where
  rnf :: IPDialIn -> ()
rnf IPDialIn' {Text
CommsProtocol
commsProtocol :: CommsProtocol
endpoint :: Text
$sel:commsProtocol:IPDialIn' :: IPDialIn -> CommsProtocol
$sel:endpoint:IPDialIn' :: IPDialIn -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
endpoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CommsProtocol
commsProtocol

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Endpoint" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
endpoint),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"CommsProtocol" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= CommsProtocol
commsProtocol)
          ]
      )