{-# 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.Inspector2.Types.NetworkReachabilityDetails
-- 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.Inspector2.Types.NetworkReachabilityDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector2.Types.NetworkPath
import Amazonka.Inspector2.Types.NetworkProtocol
import Amazonka.Inspector2.Types.PortRange
import qualified Amazonka.Prelude as Prelude

-- | Contains the details of a network reachability finding.
--
-- /See:/ 'newNetworkReachabilityDetails' smart constructor.
data NetworkReachabilityDetails = NetworkReachabilityDetails'
  { -- | An object that contains details about a network path associated with a
    -- finding.
    NetworkReachabilityDetails -> NetworkPath
networkPath :: NetworkPath,
    -- | An object that contains details about the open port range associated
    -- with a finding.
    NetworkReachabilityDetails -> PortRange
openPortRange :: PortRange,
    -- | The protocol associated with a finding.
    NetworkReachabilityDetails -> NetworkProtocol
protocol :: NetworkProtocol
  }
  deriving (NetworkReachabilityDetails -> NetworkReachabilityDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NetworkReachabilityDetails -> NetworkReachabilityDetails -> Bool
$c/= :: NetworkReachabilityDetails -> NetworkReachabilityDetails -> Bool
== :: NetworkReachabilityDetails -> NetworkReachabilityDetails -> Bool
$c== :: NetworkReachabilityDetails -> NetworkReachabilityDetails -> Bool
Prelude.Eq, ReadPrec [NetworkReachabilityDetails]
ReadPrec NetworkReachabilityDetails
Int -> ReadS NetworkReachabilityDetails
ReadS [NetworkReachabilityDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NetworkReachabilityDetails]
$creadListPrec :: ReadPrec [NetworkReachabilityDetails]
readPrec :: ReadPrec NetworkReachabilityDetails
$creadPrec :: ReadPrec NetworkReachabilityDetails
readList :: ReadS [NetworkReachabilityDetails]
$creadList :: ReadS [NetworkReachabilityDetails]
readsPrec :: Int -> ReadS NetworkReachabilityDetails
$creadsPrec :: Int -> ReadS NetworkReachabilityDetails
Prelude.Read, Int -> NetworkReachabilityDetails -> ShowS
[NetworkReachabilityDetails] -> ShowS
NetworkReachabilityDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NetworkReachabilityDetails] -> ShowS
$cshowList :: [NetworkReachabilityDetails] -> ShowS
show :: NetworkReachabilityDetails -> String
$cshow :: NetworkReachabilityDetails -> String
showsPrec :: Int -> NetworkReachabilityDetails -> ShowS
$cshowsPrec :: Int -> NetworkReachabilityDetails -> ShowS
Prelude.Show, forall x.
Rep NetworkReachabilityDetails x -> NetworkReachabilityDetails
forall x.
NetworkReachabilityDetails -> Rep NetworkReachabilityDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NetworkReachabilityDetails x -> NetworkReachabilityDetails
$cfrom :: forall x.
NetworkReachabilityDetails -> Rep NetworkReachabilityDetails x
Prelude.Generic)

-- |
-- Create a value of 'NetworkReachabilityDetails' 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:
--
-- 'networkPath', 'networkReachabilityDetails_networkPath' - An object that contains details about a network path associated with a
-- finding.
--
-- 'openPortRange', 'networkReachabilityDetails_openPortRange' - An object that contains details about the open port range associated
-- with a finding.
--
-- 'protocol', 'networkReachabilityDetails_protocol' - The protocol associated with a finding.
newNetworkReachabilityDetails ::
  -- | 'networkPath'
  NetworkPath ->
  -- | 'openPortRange'
  PortRange ->
  -- | 'protocol'
  NetworkProtocol ->
  NetworkReachabilityDetails
newNetworkReachabilityDetails :: NetworkPath
-> PortRange -> NetworkProtocol -> NetworkReachabilityDetails
newNetworkReachabilityDetails
  NetworkPath
pNetworkPath_
  PortRange
pOpenPortRange_
  NetworkProtocol
pProtocol_ =
    NetworkReachabilityDetails'
      { $sel:networkPath:NetworkReachabilityDetails' :: NetworkPath
networkPath =
          NetworkPath
pNetworkPath_,
        $sel:openPortRange:NetworkReachabilityDetails' :: PortRange
openPortRange = PortRange
pOpenPortRange_,
        $sel:protocol:NetworkReachabilityDetails' :: NetworkProtocol
protocol = NetworkProtocol
pProtocol_
      }

-- | An object that contains details about a network path associated with a
-- finding.
networkReachabilityDetails_networkPath :: Lens.Lens' NetworkReachabilityDetails NetworkPath
networkReachabilityDetails_networkPath :: Lens' NetworkReachabilityDetails NetworkPath
networkReachabilityDetails_networkPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkReachabilityDetails' {NetworkPath
networkPath :: NetworkPath
$sel:networkPath:NetworkReachabilityDetails' :: NetworkReachabilityDetails -> NetworkPath
networkPath} -> NetworkPath
networkPath) (\s :: NetworkReachabilityDetails
s@NetworkReachabilityDetails' {} NetworkPath
a -> NetworkReachabilityDetails
s {$sel:networkPath:NetworkReachabilityDetails' :: NetworkPath
networkPath = NetworkPath
a} :: NetworkReachabilityDetails)

-- | An object that contains details about the open port range associated
-- with a finding.
networkReachabilityDetails_openPortRange :: Lens.Lens' NetworkReachabilityDetails PortRange
networkReachabilityDetails_openPortRange :: Lens' NetworkReachabilityDetails PortRange
networkReachabilityDetails_openPortRange = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkReachabilityDetails' {PortRange
openPortRange :: PortRange
$sel:openPortRange:NetworkReachabilityDetails' :: NetworkReachabilityDetails -> PortRange
openPortRange} -> PortRange
openPortRange) (\s :: NetworkReachabilityDetails
s@NetworkReachabilityDetails' {} PortRange
a -> NetworkReachabilityDetails
s {$sel:openPortRange:NetworkReachabilityDetails' :: PortRange
openPortRange = PortRange
a} :: NetworkReachabilityDetails)

-- | The protocol associated with a finding.
networkReachabilityDetails_protocol :: Lens.Lens' NetworkReachabilityDetails NetworkProtocol
networkReachabilityDetails_protocol :: Lens' NetworkReachabilityDetails NetworkProtocol
networkReachabilityDetails_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkReachabilityDetails' {NetworkProtocol
protocol :: NetworkProtocol
$sel:protocol:NetworkReachabilityDetails' :: NetworkReachabilityDetails -> NetworkProtocol
protocol} -> NetworkProtocol
protocol) (\s :: NetworkReachabilityDetails
s@NetworkReachabilityDetails' {} NetworkProtocol
a -> NetworkReachabilityDetails
s {$sel:protocol:NetworkReachabilityDetails' :: NetworkProtocol
protocol = NetworkProtocol
a} :: NetworkReachabilityDetails)

instance Data.FromJSON NetworkReachabilityDetails where
  parseJSON :: Value -> Parser NetworkReachabilityDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NetworkReachabilityDetails"
      ( \Object
x ->
          NetworkPath
-> PortRange -> NetworkProtocol -> NetworkReachabilityDetails
NetworkReachabilityDetails'
            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
"networkPath")
            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
"openPortRange")
            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
"protocol")
      )

instance Prelude.Hashable NetworkReachabilityDetails where
  hashWithSalt :: Int -> NetworkReachabilityDetails -> Int
hashWithSalt Int
_salt NetworkReachabilityDetails' {NetworkProtocol
PortRange
NetworkPath
protocol :: NetworkProtocol
openPortRange :: PortRange
networkPath :: NetworkPath
$sel:protocol:NetworkReachabilityDetails' :: NetworkReachabilityDetails -> NetworkProtocol
$sel:openPortRange:NetworkReachabilityDetails' :: NetworkReachabilityDetails -> PortRange
$sel:networkPath:NetworkReachabilityDetails' :: NetworkReachabilityDetails -> NetworkPath
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NetworkPath
networkPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PortRange
openPortRange
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NetworkProtocol
protocol

instance Prelude.NFData NetworkReachabilityDetails where
  rnf :: NetworkReachabilityDetails -> ()
rnf NetworkReachabilityDetails' {NetworkProtocol
PortRange
NetworkPath
protocol :: NetworkProtocol
openPortRange :: PortRange
networkPath :: NetworkPath
$sel:protocol:NetworkReachabilityDetails' :: NetworkReachabilityDetails -> NetworkProtocol
$sel:openPortRange:NetworkReachabilityDetails' :: NetworkReachabilityDetails -> PortRange
$sel:networkPath:NetworkReachabilityDetails' :: NetworkReachabilityDetails -> NetworkPath
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NetworkPath
networkPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PortRange
openPortRange
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NetworkProtocol
protocol