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

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

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

-- |
-- Create a value of 'RemotePortDetails' 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', 'remotePortDetails_portName' - The port name of the remote connection.
--
-- 'port', 'remotePortDetails_port' - The port number of the remote connection.
newRemotePortDetails ::
  RemotePortDetails
newRemotePortDetails :: RemotePortDetails
newRemotePortDetails =
  RemotePortDetails' :: Maybe Text -> Maybe Int -> RemotePortDetails
RemotePortDetails'
    { $sel:portName:RemotePortDetails' :: Maybe Text
portName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:port:RemotePortDetails' :: Maybe Int
port = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Prelude.NFData RemotePortDetails