{-# 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.Discovery.Types.NeighborConnectionDetail
-- 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.Discovery.Types.NeighborConnectionDetail where

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

-- | Details about neighboring servers.
--
-- /See:/ 'newNeighborConnectionDetail' smart constructor.
data NeighborConnectionDetail = NeighborConnectionDetail'
  { -- | The network protocol used for the connection.
    NeighborConnectionDetail -> Maybe Text
transportProtocol :: Prelude.Maybe Prelude.Text,
    -- | The destination network port for the connection.
    NeighborConnectionDetail -> Maybe Int
destinationPort :: Prelude.Maybe Prelude.Int,
    -- | The ID of the server that opened the network connection.
    NeighborConnectionDetail -> Text
sourceServerId :: Prelude.Text,
    -- | The ID of the server that accepted the network connection.
    NeighborConnectionDetail -> Text
destinationServerId :: Prelude.Text,
    -- | The number of open network connections with the neighboring server.
    NeighborConnectionDetail -> Integer
connectionsCount :: Prelude.Integer
  }
  deriving (NeighborConnectionDetail -> NeighborConnectionDetail -> Bool
(NeighborConnectionDetail -> NeighborConnectionDetail -> Bool)
-> (NeighborConnectionDetail -> NeighborConnectionDetail -> Bool)
-> Eq NeighborConnectionDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NeighborConnectionDetail -> NeighborConnectionDetail -> Bool
$c/= :: NeighborConnectionDetail -> NeighborConnectionDetail -> Bool
== :: NeighborConnectionDetail -> NeighborConnectionDetail -> Bool
$c== :: NeighborConnectionDetail -> NeighborConnectionDetail -> Bool
Prelude.Eq, ReadPrec [NeighborConnectionDetail]
ReadPrec NeighborConnectionDetail
Int -> ReadS NeighborConnectionDetail
ReadS [NeighborConnectionDetail]
(Int -> ReadS NeighborConnectionDetail)
-> ReadS [NeighborConnectionDetail]
-> ReadPrec NeighborConnectionDetail
-> ReadPrec [NeighborConnectionDetail]
-> Read NeighborConnectionDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NeighborConnectionDetail]
$creadListPrec :: ReadPrec [NeighborConnectionDetail]
readPrec :: ReadPrec NeighborConnectionDetail
$creadPrec :: ReadPrec NeighborConnectionDetail
readList :: ReadS [NeighborConnectionDetail]
$creadList :: ReadS [NeighborConnectionDetail]
readsPrec :: Int -> ReadS NeighborConnectionDetail
$creadsPrec :: Int -> ReadS NeighborConnectionDetail
Prelude.Read, Int -> NeighborConnectionDetail -> ShowS
[NeighborConnectionDetail] -> ShowS
NeighborConnectionDetail -> String
(Int -> NeighborConnectionDetail -> ShowS)
-> (NeighborConnectionDetail -> String)
-> ([NeighborConnectionDetail] -> ShowS)
-> Show NeighborConnectionDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NeighborConnectionDetail] -> ShowS
$cshowList :: [NeighborConnectionDetail] -> ShowS
show :: NeighborConnectionDetail -> String
$cshow :: NeighborConnectionDetail -> String
showsPrec :: Int -> NeighborConnectionDetail -> ShowS
$cshowsPrec :: Int -> NeighborConnectionDetail -> ShowS
Prelude.Show, (forall x.
 NeighborConnectionDetail -> Rep NeighborConnectionDetail x)
-> (forall x.
    Rep NeighborConnectionDetail x -> NeighborConnectionDetail)
-> Generic NeighborConnectionDetail
forall x.
Rep NeighborConnectionDetail x -> NeighborConnectionDetail
forall x.
NeighborConnectionDetail -> Rep NeighborConnectionDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NeighborConnectionDetail x -> NeighborConnectionDetail
$cfrom :: forall x.
NeighborConnectionDetail -> Rep NeighborConnectionDetail x
Prelude.Generic)

-- |
-- Create a value of 'NeighborConnectionDetail' 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:
--
-- 'transportProtocol', 'neighborConnectionDetail_transportProtocol' - The network protocol used for the connection.
--
-- 'destinationPort', 'neighborConnectionDetail_destinationPort' - The destination network port for the connection.
--
-- 'sourceServerId', 'neighborConnectionDetail_sourceServerId' - The ID of the server that opened the network connection.
--
-- 'destinationServerId', 'neighborConnectionDetail_destinationServerId' - The ID of the server that accepted the network connection.
--
-- 'connectionsCount', 'neighborConnectionDetail_connectionsCount' - The number of open network connections with the neighboring server.
newNeighborConnectionDetail ::
  -- | 'sourceServerId'
  Prelude.Text ->
  -- | 'destinationServerId'
  Prelude.Text ->
  -- | 'connectionsCount'
  Prelude.Integer ->
  NeighborConnectionDetail
newNeighborConnectionDetail :: Text -> Text -> Integer -> NeighborConnectionDetail
newNeighborConnectionDetail
  Text
pSourceServerId_
  Text
pDestinationServerId_
  Integer
pConnectionsCount_ =
    NeighborConnectionDetail' :: Maybe Text
-> Maybe Int -> Text -> Text -> Integer -> NeighborConnectionDetail
NeighborConnectionDetail'
      { $sel:transportProtocol:NeighborConnectionDetail' :: Maybe Text
transportProtocol =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:destinationPort:NeighborConnectionDetail' :: Maybe Int
destinationPort = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:sourceServerId:NeighborConnectionDetail' :: Text
sourceServerId = Text
pSourceServerId_,
        $sel:destinationServerId:NeighborConnectionDetail' :: Text
destinationServerId = Text
pDestinationServerId_,
        $sel:connectionsCount:NeighborConnectionDetail' :: Integer
connectionsCount = Integer
pConnectionsCount_
      }

-- | The network protocol used for the connection.
neighborConnectionDetail_transportProtocol :: Lens.Lens' NeighborConnectionDetail (Prelude.Maybe Prelude.Text)
neighborConnectionDetail_transportProtocol :: (Maybe Text -> f (Maybe Text))
-> NeighborConnectionDetail -> f NeighborConnectionDetail
neighborConnectionDetail_transportProtocol = (NeighborConnectionDetail -> Maybe Text)
-> (NeighborConnectionDetail
    -> Maybe Text -> NeighborConnectionDetail)
-> Lens
     NeighborConnectionDetail
     NeighborConnectionDetail
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NeighborConnectionDetail' {Maybe Text
transportProtocol :: Maybe Text
$sel:transportProtocol:NeighborConnectionDetail' :: NeighborConnectionDetail -> Maybe Text
transportProtocol} -> Maybe Text
transportProtocol) (\s :: NeighborConnectionDetail
s@NeighborConnectionDetail' {} Maybe Text
a -> NeighborConnectionDetail
s {$sel:transportProtocol:NeighborConnectionDetail' :: Maybe Text
transportProtocol = Maybe Text
a} :: NeighborConnectionDetail)

-- | The destination network port for the connection.
neighborConnectionDetail_destinationPort :: Lens.Lens' NeighborConnectionDetail (Prelude.Maybe Prelude.Int)
neighborConnectionDetail_destinationPort :: (Maybe Int -> f (Maybe Int))
-> NeighborConnectionDetail -> f NeighborConnectionDetail
neighborConnectionDetail_destinationPort = (NeighborConnectionDetail -> Maybe Int)
-> (NeighborConnectionDetail
    -> Maybe Int -> NeighborConnectionDetail)
-> Lens
     NeighborConnectionDetail
     NeighborConnectionDetail
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NeighborConnectionDetail' {Maybe Int
destinationPort :: Maybe Int
$sel:destinationPort:NeighborConnectionDetail' :: NeighborConnectionDetail -> Maybe Int
destinationPort} -> Maybe Int
destinationPort) (\s :: NeighborConnectionDetail
s@NeighborConnectionDetail' {} Maybe Int
a -> NeighborConnectionDetail
s {$sel:destinationPort:NeighborConnectionDetail' :: Maybe Int
destinationPort = Maybe Int
a} :: NeighborConnectionDetail)

-- | The ID of the server that opened the network connection.
neighborConnectionDetail_sourceServerId :: Lens.Lens' NeighborConnectionDetail Prelude.Text
neighborConnectionDetail_sourceServerId :: (Text -> f Text)
-> NeighborConnectionDetail -> f NeighborConnectionDetail
neighborConnectionDetail_sourceServerId = (NeighborConnectionDetail -> Text)
-> (NeighborConnectionDetail -> Text -> NeighborConnectionDetail)
-> Lens NeighborConnectionDetail NeighborConnectionDetail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NeighborConnectionDetail' {Text
sourceServerId :: Text
$sel:sourceServerId:NeighborConnectionDetail' :: NeighborConnectionDetail -> Text
sourceServerId} -> Text
sourceServerId) (\s :: NeighborConnectionDetail
s@NeighborConnectionDetail' {} Text
a -> NeighborConnectionDetail
s {$sel:sourceServerId:NeighborConnectionDetail' :: Text
sourceServerId = Text
a} :: NeighborConnectionDetail)

-- | The ID of the server that accepted the network connection.
neighborConnectionDetail_destinationServerId :: Lens.Lens' NeighborConnectionDetail Prelude.Text
neighborConnectionDetail_destinationServerId :: (Text -> f Text)
-> NeighborConnectionDetail -> f NeighborConnectionDetail
neighborConnectionDetail_destinationServerId = (NeighborConnectionDetail -> Text)
-> (NeighborConnectionDetail -> Text -> NeighborConnectionDetail)
-> Lens NeighborConnectionDetail NeighborConnectionDetail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NeighborConnectionDetail' {Text
destinationServerId :: Text
$sel:destinationServerId:NeighborConnectionDetail' :: NeighborConnectionDetail -> Text
destinationServerId} -> Text
destinationServerId) (\s :: NeighborConnectionDetail
s@NeighborConnectionDetail' {} Text
a -> NeighborConnectionDetail
s {$sel:destinationServerId:NeighborConnectionDetail' :: Text
destinationServerId = Text
a} :: NeighborConnectionDetail)

-- | The number of open network connections with the neighboring server.
neighborConnectionDetail_connectionsCount :: Lens.Lens' NeighborConnectionDetail Prelude.Integer
neighborConnectionDetail_connectionsCount :: (Integer -> f Integer)
-> NeighborConnectionDetail -> f NeighborConnectionDetail
neighborConnectionDetail_connectionsCount = (NeighborConnectionDetail -> Integer)
-> (NeighborConnectionDetail
    -> Integer -> NeighborConnectionDetail)
-> Lens
     NeighborConnectionDetail NeighborConnectionDetail Integer Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NeighborConnectionDetail' {Integer
connectionsCount :: Integer
$sel:connectionsCount:NeighborConnectionDetail' :: NeighborConnectionDetail -> Integer
connectionsCount} -> Integer
connectionsCount) (\s :: NeighborConnectionDetail
s@NeighborConnectionDetail' {} Integer
a -> NeighborConnectionDetail
s {$sel:connectionsCount:NeighborConnectionDetail' :: Integer
connectionsCount = Integer
a} :: NeighborConnectionDetail)

instance Core.FromJSON NeighborConnectionDetail where
  parseJSON :: Value -> Parser NeighborConnectionDetail
parseJSON =
    String
-> (Object -> Parser NeighborConnectionDetail)
-> Value
-> Parser NeighborConnectionDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NeighborConnectionDetail"
      ( \Object
x ->
          Maybe Text
-> Maybe Int -> Text -> Text -> Integer -> NeighborConnectionDetail
NeighborConnectionDetail'
            (Maybe Text
 -> Maybe Int
 -> Text
 -> Text
 -> Integer
 -> NeighborConnectionDetail)
-> Parser (Maybe Text)
-> Parser
     (Maybe Int -> Text -> Text -> Integer -> NeighborConnectionDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"transportProtocol")
            Parser
  (Maybe Int -> Text -> Text -> Integer -> NeighborConnectionDetail)
-> Parser (Maybe Int)
-> Parser (Text -> Text -> Integer -> NeighborConnectionDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"destinationPort")
            Parser (Text -> Text -> Integer -> NeighborConnectionDetail)
-> Parser Text
-> Parser (Text -> Integer -> NeighborConnectionDetail)
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
"sourceServerId")
            Parser (Text -> Integer -> NeighborConnectionDetail)
-> Parser Text -> Parser (Integer -> NeighborConnectionDetail)
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
"destinationServerId")
            Parser (Integer -> NeighborConnectionDetail)
-> Parser Integer -> Parser NeighborConnectionDetail
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Integer
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"connectionsCount")
      )

instance Prelude.Hashable NeighborConnectionDetail

instance Prelude.NFData NeighborConnectionDetail