{-# 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.GuardDuty.Types.LocalPortDetails
-- 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.GuardDuty.Types.LocalPortDetails 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

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

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

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

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

instance Data.FromJSON LocalPortDetails where
  parseJSON :: Value -> Parser LocalPortDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LocalPortDetails"
      ( \Object
x ->
          Maybe Int -> Maybe Text -> LocalPortDetails
LocalPortDetails'
            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
"port")
            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
"portName")
      )

instance Prelude.Hashable LocalPortDetails where
  hashWithSalt :: Int -> LocalPortDetails -> Int
hashWithSalt Int
_salt LocalPortDetails' {Maybe Int
Maybe Text
portName :: Maybe Text
port :: Maybe Int
$sel:portName:LocalPortDetails' :: LocalPortDetails -> Maybe Text
$sel:port:LocalPortDetails' :: LocalPortDetails -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
port
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
portName

instance Prelude.NFData LocalPortDetails where
  rnf :: LocalPortDetails -> ()
rnf LocalPortDetails' {Maybe Int
Maybe Text
portName :: Maybe Text
port :: Maybe Int
$sel:portName:LocalPortDetails' :: LocalPortDetails -> Maybe Text
$sel:port:LocalPortDetails' :: LocalPortDetails -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
port seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
portName