{-# 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.SecurityHub.Types.PortProbeDetail
-- 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.SecurityHub.Types.PortProbeDetail where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.ActionLocalIpDetails
import Amazonka.SecurityHub.Types.ActionLocalPortDetails
import Amazonka.SecurityHub.Types.ActionRemoteIpDetails

-- | A port scan that was part of the port probe. For each scan,
-- PortProbeDetails provides information about the local IP address and
-- port that were scanned, and the remote IP address that the scan
-- originated from.
--
-- /See:/ 'newPortProbeDetail' smart constructor.
data PortProbeDetail = PortProbeDetail'
  { -- | Provides information about the remote IP address that performed the
    -- scan.
    PortProbeDetail -> Maybe ActionRemoteIpDetails
remoteIpDetails :: Prelude.Maybe ActionRemoteIpDetails,
    -- | Provides information about the IP address where the scanned port is
    -- located.
    PortProbeDetail -> Maybe ActionLocalIpDetails
localIpDetails :: Prelude.Maybe ActionLocalIpDetails,
    -- | Provides information about the port that was scanned.
    PortProbeDetail -> Maybe ActionLocalPortDetails
localPortDetails :: Prelude.Maybe ActionLocalPortDetails
  }
  deriving (PortProbeDetail -> PortProbeDetail -> Bool
(PortProbeDetail -> PortProbeDetail -> Bool)
-> (PortProbeDetail -> PortProbeDetail -> Bool)
-> Eq PortProbeDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortProbeDetail -> PortProbeDetail -> Bool
$c/= :: PortProbeDetail -> PortProbeDetail -> Bool
== :: PortProbeDetail -> PortProbeDetail -> Bool
$c== :: PortProbeDetail -> PortProbeDetail -> Bool
Prelude.Eq, ReadPrec [PortProbeDetail]
ReadPrec PortProbeDetail
Int -> ReadS PortProbeDetail
ReadS [PortProbeDetail]
(Int -> ReadS PortProbeDetail)
-> ReadS [PortProbeDetail]
-> ReadPrec PortProbeDetail
-> ReadPrec [PortProbeDetail]
-> Read PortProbeDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PortProbeDetail]
$creadListPrec :: ReadPrec [PortProbeDetail]
readPrec :: ReadPrec PortProbeDetail
$creadPrec :: ReadPrec PortProbeDetail
readList :: ReadS [PortProbeDetail]
$creadList :: ReadS [PortProbeDetail]
readsPrec :: Int -> ReadS PortProbeDetail
$creadsPrec :: Int -> ReadS PortProbeDetail
Prelude.Read, Int -> PortProbeDetail -> ShowS
[PortProbeDetail] -> ShowS
PortProbeDetail -> String
(Int -> PortProbeDetail -> ShowS)
-> (PortProbeDetail -> String)
-> ([PortProbeDetail] -> ShowS)
-> Show PortProbeDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortProbeDetail] -> ShowS
$cshowList :: [PortProbeDetail] -> ShowS
show :: PortProbeDetail -> String
$cshow :: PortProbeDetail -> String
showsPrec :: Int -> PortProbeDetail -> ShowS
$cshowsPrec :: Int -> PortProbeDetail -> ShowS
Prelude.Show, (forall x. PortProbeDetail -> Rep PortProbeDetail x)
-> (forall x. Rep PortProbeDetail x -> PortProbeDetail)
-> Generic PortProbeDetail
forall x. Rep PortProbeDetail x -> PortProbeDetail
forall x. PortProbeDetail -> Rep PortProbeDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PortProbeDetail x -> PortProbeDetail
$cfrom :: forall x. PortProbeDetail -> Rep PortProbeDetail x
Prelude.Generic)

-- |
-- Create a value of 'PortProbeDetail' 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:
--
-- 'remoteIpDetails', 'portProbeDetail_remoteIpDetails' - Provides information about the remote IP address that performed the
-- scan.
--
-- 'localIpDetails', 'portProbeDetail_localIpDetails' - Provides information about the IP address where the scanned port is
-- located.
--
-- 'localPortDetails', 'portProbeDetail_localPortDetails' - Provides information about the port that was scanned.
newPortProbeDetail ::
  PortProbeDetail
newPortProbeDetail :: PortProbeDetail
newPortProbeDetail =
  PortProbeDetail' :: Maybe ActionRemoteIpDetails
-> Maybe ActionLocalIpDetails
-> Maybe ActionLocalPortDetails
-> PortProbeDetail
PortProbeDetail'
    { $sel:remoteIpDetails:PortProbeDetail' :: Maybe ActionRemoteIpDetails
remoteIpDetails = Maybe ActionRemoteIpDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:localIpDetails:PortProbeDetail' :: Maybe ActionLocalIpDetails
localIpDetails = Maybe ActionLocalIpDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:localPortDetails:PortProbeDetail' :: Maybe ActionLocalPortDetails
localPortDetails = Maybe ActionLocalPortDetails
forall a. Maybe a
Prelude.Nothing
    }

-- | Provides information about the remote IP address that performed the
-- scan.
portProbeDetail_remoteIpDetails :: Lens.Lens' PortProbeDetail (Prelude.Maybe ActionRemoteIpDetails)
portProbeDetail_remoteIpDetails :: (Maybe ActionRemoteIpDetails -> f (Maybe ActionRemoteIpDetails))
-> PortProbeDetail -> f PortProbeDetail
portProbeDetail_remoteIpDetails = (PortProbeDetail -> Maybe ActionRemoteIpDetails)
-> (PortProbeDetail
    -> Maybe ActionRemoteIpDetails -> PortProbeDetail)
-> Lens
     PortProbeDetail
     PortProbeDetail
     (Maybe ActionRemoteIpDetails)
     (Maybe ActionRemoteIpDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortProbeDetail' {Maybe ActionRemoteIpDetails
remoteIpDetails :: Maybe ActionRemoteIpDetails
$sel:remoteIpDetails:PortProbeDetail' :: PortProbeDetail -> Maybe ActionRemoteIpDetails
remoteIpDetails} -> Maybe ActionRemoteIpDetails
remoteIpDetails) (\s :: PortProbeDetail
s@PortProbeDetail' {} Maybe ActionRemoteIpDetails
a -> PortProbeDetail
s {$sel:remoteIpDetails:PortProbeDetail' :: Maybe ActionRemoteIpDetails
remoteIpDetails = Maybe ActionRemoteIpDetails
a} :: PortProbeDetail)

-- | Provides information about the IP address where the scanned port is
-- located.
portProbeDetail_localIpDetails :: Lens.Lens' PortProbeDetail (Prelude.Maybe ActionLocalIpDetails)
portProbeDetail_localIpDetails :: (Maybe ActionLocalIpDetails -> f (Maybe ActionLocalIpDetails))
-> PortProbeDetail -> f PortProbeDetail
portProbeDetail_localIpDetails = (PortProbeDetail -> Maybe ActionLocalIpDetails)
-> (PortProbeDetail
    -> Maybe ActionLocalIpDetails -> PortProbeDetail)
-> Lens
     PortProbeDetail
     PortProbeDetail
     (Maybe ActionLocalIpDetails)
     (Maybe ActionLocalIpDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortProbeDetail' {Maybe ActionLocalIpDetails
localIpDetails :: Maybe ActionLocalIpDetails
$sel:localIpDetails:PortProbeDetail' :: PortProbeDetail -> Maybe ActionLocalIpDetails
localIpDetails} -> Maybe ActionLocalIpDetails
localIpDetails) (\s :: PortProbeDetail
s@PortProbeDetail' {} Maybe ActionLocalIpDetails
a -> PortProbeDetail
s {$sel:localIpDetails:PortProbeDetail' :: Maybe ActionLocalIpDetails
localIpDetails = Maybe ActionLocalIpDetails
a} :: PortProbeDetail)

-- | Provides information about the port that was scanned.
portProbeDetail_localPortDetails :: Lens.Lens' PortProbeDetail (Prelude.Maybe ActionLocalPortDetails)
portProbeDetail_localPortDetails :: (Maybe ActionLocalPortDetails -> f (Maybe ActionLocalPortDetails))
-> PortProbeDetail -> f PortProbeDetail
portProbeDetail_localPortDetails = (PortProbeDetail -> Maybe ActionLocalPortDetails)
-> (PortProbeDetail
    -> Maybe ActionLocalPortDetails -> PortProbeDetail)
-> Lens
     PortProbeDetail
     PortProbeDetail
     (Maybe ActionLocalPortDetails)
     (Maybe ActionLocalPortDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortProbeDetail' {Maybe ActionLocalPortDetails
localPortDetails :: Maybe ActionLocalPortDetails
$sel:localPortDetails:PortProbeDetail' :: PortProbeDetail -> Maybe ActionLocalPortDetails
localPortDetails} -> Maybe ActionLocalPortDetails
localPortDetails) (\s :: PortProbeDetail
s@PortProbeDetail' {} Maybe ActionLocalPortDetails
a -> PortProbeDetail
s {$sel:localPortDetails:PortProbeDetail' :: Maybe ActionLocalPortDetails
localPortDetails = Maybe ActionLocalPortDetails
a} :: PortProbeDetail)

instance Core.FromJSON PortProbeDetail where
  parseJSON :: Value -> Parser PortProbeDetail
parseJSON =
    String
-> (Object -> Parser PortProbeDetail)
-> Value
-> Parser PortProbeDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PortProbeDetail"
      ( \Object
x ->
          Maybe ActionRemoteIpDetails
-> Maybe ActionLocalIpDetails
-> Maybe ActionLocalPortDetails
-> PortProbeDetail
PortProbeDetail'
            (Maybe ActionRemoteIpDetails
 -> Maybe ActionLocalIpDetails
 -> Maybe ActionLocalPortDetails
 -> PortProbeDetail)
-> Parser (Maybe ActionRemoteIpDetails)
-> Parser
     (Maybe ActionLocalIpDetails
      -> Maybe ActionLocalPortDetails -> PortProbeDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ActionRemoteIpDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RemoteIpDetails")
            Parser
  (Maybe ActionLocalIpDetails
   -> Maybe ActionLocalPortDetails -> PortProbeDetail)
-> Parser (Maybe ActionLocalIpDetails)
-> Parser (Maybe ActionLocalPortDetails -> PortProbeDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ActionLocalIpDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LocalIpDetails")
            Parser (Maybe ActionLocalPortDetails -> PortProbeDetail)
-> Parser (Maybe ActionLocalPortDetails) -> Parser PortProbeDetail
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ActionLocalPortDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LocalPortDetails")
      )

instance Prelude.Hashable PortProbeDetail

instance Prelude.NFData PortProbeDetail

instance Core.ToJSON PortProbeDetail where
  toJSON :: PortProbeDetail -> Value
toJSON PortProbeDetail' {Maybe ActionLocalIpDetails
Maybe ActionLocalPortDetails
Maybe ActionRemoteIpDetails
localPortDetails :: Maybe ActionLocalPortDetails
localIpDetails :: Maybe ActionLocalIpDetails
remoteIpDetails :: Maybe ActionRemoteIpDetails
$sel:localPortDetails:PortProbeDetail' :: PortProbeDetail -> Maybe ActionLocalPortDetails
$sel:localIpDetails:PortProbeDetail' :: PortProbeDetail -> Maybe ActionLocalIpDetails
$sel:remoteIpDetails:PortProbeDetail' :: PortProbeDetail -> Maybe ActionRemoteIpDetails
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RemoteIpDetails" Text -> ActionRemoteIpDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ActionRemoteIpDetails -> Pair)
-> Maybe ActionRemoteIpDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ActionRemoteIpDetails
remoteIpDetails,
            (Text
"LocalIpDetails" Text -> ActionLocalIpDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ActionLocalIpDetails -> Pair)
-> Maybe ActionLocalIpDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ActionLocalIpDetails
localIpDetails,
            (Text
"LocalPortDetails" Text -> ActionLocalPortDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ActionLocalPortDetails -> Pair)
-> Maybe ActionLocalPortDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ActionLocalPortDetails
localPortDetails
          ]
      )