{-# 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.ActionLocalPortDetails
-- 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.ActionLocalPortDetails where

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

-- | For @NetworkConnectionAction@ and @PortProbeDetails@, @LocalPortDetails@
-- provides information about the local port that was involved in the
-- action.
--
-- /See:/ 'newActionLocalPortDetails' smart constructor.
data ActionLocalPortDetails = ActionLocalPortDetails'
  { -- | The port name of the local connection.
    ActionLocalPortDetails -> Maybe Text
portName :: Prelude.Maybe Prelude.Text,
    -- | The number of the port.
    ActionLocalPortDetails -> Maybe Int
port :: Prelude.Maybe Prelude.Int
  }
  deriving (ActionLocalPortDetails -> ActionLocalPortDetails -> Bool
(ActionLocalPortDetails -> ActionLocalPortDetails -> Bool)
-> (ActionLocalPortDetails -> ActionLocalPortDetails -> Bool)
-> Eq ActionLocalPortDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionLocalPortDetails -> ActionLocalPortDetails -> Bool
$c/= :: ActionLocalPortDetails -> ActionLocalPortDetails -> Bool
== :: ActionLocalPortDetails -> ActionLocalPortDetails -> Bool
$c== :: ActionLocalPortDetails -> ActionLocalPortDetails -> Bool
Prelude.Eq, ReadPrec [ActionLocalPortDetails]
ReadPrec ActionLocalPortDetails
Int -> ReadS ActionLocalPortDetails
ReadS [ActionLocalPortDetails]
(Int -> ReadS ActionLocalPortDetails)
-> ReadS [ActionLocalPortDetails]
-> ReadPrec ActionLocalPortDetails
-> ReadPrec [ActionLocalPortDetails]
-> Read ActionLocalPortDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActionLocalPortDetails]
$creadListPrec :: ReadPrec [ActionLocalPortDetails]
readPrec :: ReadPrec ActionLocalPortDetails
$creadPrec :: ReadPrec ActionLocalPortDetails
readList :: ReadS [ActionLocalPortDetails]
$creadList :: ReadS [ActionLocalPortDetails]
readsPrec :: Int -> ReadS ActionLocalPortDetails
$creadsPrec :: Int -> ReadS ActionLocalPortDetails
Prelude.Read, Int -> ActionLocalPortDetails -> ShowS
[ActionLocalPortDetails] -> ShowS
ActionLocalPortDetails -> String
(Int -> ActionLocalPortDetails -> ShowS)
-> (ActionLocalPortDetails -> String)
-> ([ActionLocalPortDetails] -> ShowS)
-> Show ActionLocalPortDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActionLocalPortDetails] -> ShowS
$cshowList :: [ActionLocalPortDetails] -> ShowS
show :: ActionLocalPortDetails -> String
$cshow :: ActionLocalPortDetails -> String
showsPrec :: Int -> ActionLocalPortDetails -> ShowS
$cshowsPrec :: Int -> ActionLocalPortDetails -> ShowS
Prelude.Show, (forall x. ActionLocalPortDetails -> Rep ActionLocalPortDetails x)
-> (forall x.
    Rep ActionLocalPortDetails x -> ActionLocalPortDetails)
-> Generic ActionLocalPortDetails
forall x. Rep ActionLocalPortDetails x -> ActionLocalPortDetails
forall x. ActionLocalPortDetails -> Rep ActionLocalPortDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActionLocalPortDetails x -> ActionLocalPortDetails
$cfrom :: forall x. ActionLocalPortDetails -> Rep ActionLocalPortDetails x
Prelude.Generic)

-- |
-- Create a value of 'ActionLocalPortDetails' 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:
--
-- 'portName', 'actionLocalPortDetails_portName' - The port name of the local connection.
--
-- 'port', 'actionLocalPortDetails_port' - The number of the port.
newActionLocalPortDetails ::
  ActionLocalPortDetails
newActionLocalPortDetails :: ActionLocalPortDetails
newActionLocalPortDetails =
  ActionLocalPortDetails' :: Maybe Text -> Maybe Int -> ActionLocalPortDetails
ActionLocalPortDetails'
    { $sel:portName:ActionLocalPortDetails' :: Maybe Text
portName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:port:ActionLocalPortDetails' :: Maybe Int
port = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The port name of the local connection.
actionLocalPortDetails_portName :: Lens.Lens' ActionLocalPortDetails (Prelude.Maybe Prelude.Text)
actionLocalPortDetails_portName :: (Maybe Text -> f (Maybe Text))
-> ActionLocalPortDetails -> f ActionLocalPortDetails
actionLocalPortDetails_portName = (ActionLocalPortDetails -> Maybe Text)
-> (ActionLocalPortDetails -> Maybe Text -> ActionLocalPortDetails)
-> Lens
     ActionLocalPortDetails
     ActionLocalPortDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionLocalPortDetails' {Maybe Text
portName :: Maybe Text
$sel:portName:ActionLocalPortDetails' :: ActionLocalPortDetails -> Maybe Text
portName} -> Maybe Text
portName) (\s :: ActionLocalPortDetails
s@ActionLocalPortDetails' {} Maybe Text
a -> ActionLocalPortDetails
s {$sel:portName:ActionLocalPortDetails' :: Maybe Text
portName = Maybe Text
a} :: ActionLocalPortDetails)

-- | The number of the port.
actionLocalPortDetails_port :: Lens.Lens' ActionLocalPortDetails (Prelude.Maybe Prelude.Int)
actionLocalPortDetails_port :: (Maybe Int -> f (Maybe Int))
-> ActionLocalPortDetails -> f ActionLocalPortDetails
actionLocalPortDetails_port = (ActionLocalPortDetails -> Maybe Int)
-> (ActionLocalPortDetails -> Maybe Int -> ActionLocalPortDetails)
-> Lens
     ActionLocalPortDetails
     ActionLocalPortDetails
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionLocalPortDetails' {Maybe Int
port :: Maybe Int
$sel:port:ActionLocalPortDetails' :: ActionLocalPortDetails -> Maybe Int
port} -> Maybe Int
port) (\s :: ActionLocalPortDetails
s@ActionLocalPortDetails' {} Maybe Int
a -> ActionLocalPortDetails
s {$sel:port:ActionLocalPortDetails' :: Maybe Int
port = Maybe Int
a} :: ActionLocalPortDetails)

instance Core.FromJSON ActionLocalPortDetails where
  parseJSON :: Value -> Parser ActionLocalPortDetails
parseJSON =
    String
-> (Object -> Parser ActionLocalPortDetails)
-> Value
-> Parser ActionLocalPortDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ActionLocalPortDetails"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> ActionLocalPortDetails
ActionLocalPortDetails'
            (Maybe Text -> Maybe Int -> ActionLocalPortDetails)
-> Parser (Maybe Text)
-> Parser (Maybe Int -> ActionLocalPortDetails)
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
"PortName")
            Parser (Maybe Int -> ActionLocalPortDetails)
-> Parser (Maybe Int) -> Parser ActionLocalPortDetails
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
"Port")
      )

instance Prelude.Hashable ActionLocalPortDetails

instance Prelude.NFData ActionLocalPortDetails

instance Core.ToJSON ActionLocalPortDetails where
  toJSON :: ActionLocalPortDetails -> Value
toJSON ActionLocalPortDetails' {Maybe Int
Maybe Text
port :: Maybe Int
portName :: Maybe Text
$sel:port:ActionLocalPortDetails' :: ActionLocalPortDetails -> Maybe Int
$sel:portName:ActionLocalPortDetails' :: ActionLocalPortDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PortName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
portName,
            (Text
"Port" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
port
          ]
      )