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

-- | Details about neighboring servers.
--
-- /See:/ 'newNeighborConnectionDetail' smart constructor.
data NeighborConnectionDetail = NeighborConnectionDetail'
  { -- | The destination network port for the connection.
    NeighborConnectionDetail -> Maybe Int
destinationPort :: Prelude.Maybe Prelude.Int,
    -- | The network protocol used for the connection.
    NeighborConnectionDetail -> Maybe Text
transportProtocol :: Prelude.Maybe Prelude.Text,
    -- | 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
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]
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
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.
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:
--
-- 'destinationPort', 'neighborConnectionDetail_destinationPort' - The destination network port for the connection.
--
-- 'transportProtocol', 'neighborConnectionDetail_transportProtocol' - The network protocol used 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'
      { $sel:destinationPort:NeighborConnectionDetail' :: Maybe Int
destinationPort =
          forall a. Maybe a
Prelude.Nothing,
        $sel:transportProtocol:NeighborConnectionDetail' :: Maybe Text
transportProtocol = 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 destination network port for the connection.
neighborConnectionDetail_destinationPort :: Lens.Lens' NeighborConnectionDetail (Prelude.Maybe Prelude.Int)
neighborConnectionDetail_destinationPort :: Lens' NeighborConnectionDetail (Maybe Int)
neighborConnectionDetail_destinationPort = 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 network protocol used for the connection.
neighborConnectionDetail_transportProtocol :: Lens.Lens' NeighborConnectionDetail (Prelude.Maybe Prelude.Text)
neighborConnectionDetail_transportProtocol :: Lens' NeighborConnectionDetail (Maybe Text)
neighborConnectionDetail_transportProtocol = 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 ID of the server that opened the network connection.
neighborConnectionDetail_sourceServerId :: Lens.Lens' NeighborConnectionDetail Prelude.Text
neighborConnectionDetail_sourceServerId :: Lens' NeighborConnectionDetail Text
neighborConnectionDetail_sourceServerId = 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 :: Lens' NeighborConnectionDetail Text
neighborConnectionDetail_destinationServerId = 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 :: Lens' NeighborConnectionDetail Integer
neighborConnectionDetail_connectionsCount = 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 Data.FromJSON NeighborConnectionDetail where
  parseJSON :: Value -> Parser NeighborConnectionDetail
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NeighborConnectionDetail"
      ( \Object
x ->
          Maybe Int
-> Maybe Text
-> Text
-> Text
-> Integer
-> NeighborConnectionDetail
NeighborConnectionDetail'
            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
"destinationPort")
            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
"transportProtocol")
            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
"sourceServerId")
            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
"destinationServerId")
            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
"connectionsCount")
      )

instance Prelude.Hashable NeighborConnectionDetail where
  hashWithSalt :: Int -> NeighborConnectionDetail -> Int
hashWithSalt Int
_salt NeighborConnectionDetail' {Integer
Maybe Int
Maybe Text
Text
connectionsCount :: Integer
destinationServerId :: Text
sourceServerId :: Text
transportProtocol :: Maybe Text
destinationPort :: Maybe Int
$sel:connectionsCount:NeighborConnectionDetail' :: NeighborConnectionDetail -> Integer
$sel:destinationServerId:NeighborConnectionDetail' :: NeighborConnectionDetail -> Text
$sel:sourceServerId:NeighborConnectionDetail' :: NeighborConnectionDetail -> Text
$sel:transportProtocol:NeighborConnectionDetail' :: NeighborConnectionDetail -> Maybe Text
$sel:destinationPort:NeighborConnectionDetail' :: NeighborConnectionDetail -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
destinationPort
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
transportProtocol
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourceServerId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
destinationServerId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
connectionsCount

instance Prelude.NFData NeighborConnectionDetail where
  rnf :: NeighborConnectionDetail -> ()
rnf NeighborConnectionDetail' {Integer
Maybe Int
Maybe Text
Text
connectionsCount :: Integer
destinationServerId :: Text
sourceServerId :: Text
transportProtocol :: Maybe Text
destinationPort :: Maybe Int
$sel:connectionsCount:NeighborConnectionDetail' :: NeighborConnectionDetail -> Integer
$sel:destinationServerId:NeighborConnectionDetail' :: NeighborConnectionDetail -> Text
$sel:sourceServerId:NeighborConnectionDetail' :: NeighborConnectionDetail -> Text
$sel:transportProtocol:NeighborConnectionDetail' :: NeighborConnectionDetail -> Maybe Text
$sel:destinationPort:NeighborConnectionDetail' :: NeighborConnectionDetail -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
destinationPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
transportProtocol
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sourceServerId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
destinationServerId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
connectionsCount