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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GuardDuty.Types.LocalIpDetails
import Amazonka.GuardDuty.Types.LocalPortDetails
import Amazonka.GuardDuty.Types.RemoteIpDetails
import Amazonka.GuardDuty.Types.RemotePortDetails
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the NETWORK_CONNECTION action described in
-- the finding.
--
-- /See:/ 'newNetworkConnectionAction' smart constructor.
data NetworkConnectionAction = NetworkConnectionAction'
  { -- | Indicates whether EC2 blocked the network connection to your instance.
    NetworkConnectionAction -> Maybe Bool
blocked :: Prelude.Maybe Prelude.Bool,
    -- | The network connection direction.
    NetworkConnectionAction -> Maybe Text
connectionDirection :: Prelude.Maybe Prelude.Text,
    -- | The local IP information of the connection.
    NetworkConnectionAction -> Maybe LocalIpDetails
localIpDetails :: Prelude.Maybe LocalIpDetails,
    -- | The local port information of the connection.
    NetworkConnectionAction -> Maybe LocalPortDetails
localPortDetails :: Prelude.Maybe LocalPortDetails,
    -- | The network connection protocol.
    NetworkConnectionAction -> Maybe Text
protocol :: Prelude.Maybe Prelude.Text,
    -- | The remote IP information of the connection.
    NetworkConnectionAction -> Maybe RemoteIpDetails
remoteIpDetails :: Prelude.Maybe RemoteIpDetails,
    -- | The remote port information of the connection.
    NetworkConnectionAction -> Maybe RemotePortDetails
remotePortDetails :: Prelude.Maybe RemotePortDetails
  }
  deriving (NetworkConnectionAction -> NetworkConnectionAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NetworkConnectionAction -> NetworkConnectionAction -> Bool
$c/= :: NetworkConnectionAction -> NetworkConnectionAction -> Bool
== :: NetworkConnectionAction -> NetworkConnectionAction -> Bool
$c== :: NetworkConnectionAction -> NetworkConnectionAction -> Bool
Prelude.Eq, ReadPrec [NetworkConnectionAction]
ReadPrec NetworkConnectionAction
Int -> ReadS NetworkConnectionAction
ReadS [NetworkConnectionAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NetworkConnectionAction]
$creadListPrec :: ReadPrec [NetworkConnectionAction]
readPrec :: ReadPrec NetworkConnectionAction
$creadPrec :: ReadPrec NetworkConnectionAction
readList :: ReadS [NetworkConnectionAction]
$creadList :: ReadS [NetworkConnectionAction]
readsPrec :: Int -> ReadS NetworkConnectionAction
$creadsPrec :: Int -> ReadS NetworkConnectionAction
Prelude.Read, Int -> NetworkConnectionAction -> ShowS
[NetworkConnectionAction] -> ShowS
NetworkConnectionAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NetworkConnectionAction] -> ShowS
$cshowList :: [NetworkConnectionAction] -> ShowS
show :: NetworkConnectionAction -> String
$cshow :: NetworkConnectionAction -> String
showsPrec :: Int -> NetworkConnectionAction -> ShowS
$cshowsPrec :: Int -> NetworkConnectionAction -> ShowS
Prelude.Show, forall x. Rep NetworkConnectionAction x -> NetworkConnectionAction
forall x. NetworkConnectionAction -> Rep NetworkConnectionAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NetworkConnectionAction x -> NetworkConnectionAction
$cfrom :: forall x. NetworkConnectionAction -> Rep NetworkConnectionAction x
Prelude.Generic)

-- |
-- Create a value of 'NetworkConnectionAction' 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:
--
-- 'blocked', 'networkConnectionAction_blocked' - Indicates whether EC2 blocked the network connection to your instance.
--
-- 'connectionDirection', 'networkConnectionAction_connectionDirection' - The network connection direction.
--
-- 'localIpDetails', 'networkConnectionAction_localIpDetails' - The local IP information of the connection.
--
-- 'localPortDetails', 'networkConnectionAction_localPortDetails' - The local port information of the connection.
--
-- 'protocol', 'networkConnectionAction_protocol' - The network connection protocol.
--
-- 'remoteIpDetails', 'networkConnectionAction_remoteIpDetails' - The remote IP information of the connection.
--
-- 'remotePortDetails', 'networkConnectionAction_remotePortDetails' - The remote port information of the connection.
newNetworkConnectionAction ::
  NetworkConnectionAction
newNetworkConnectionAction :: NetworkConnectionAction
newNetworkConnectionAction =
  NetworkConnectionAction'
    { $sel:blocked:NetworkConnectionAction' :: Maybe Bool
blocked = forall a. Maybe a
Prelude.Nothing,
      $sel:connectionDirection:NetworkConnectionAction' :: Maybe Text
connectionDirection = forall a. Maybe a
Prelude.Nothing,
      $sel:localIpDetails:NetworkConnectionAction' :: Maybe LocalIpDetails
localIpDetails = forall a. Maybe a
Prelude.Nothing,
      $sel:localPortDetails:NetworkConnectionAction' :: Maybe LocalPortDetails
localPortDetails = forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:NetworkConnectionAction' :: Maybe Text
protocol = forall a. Maybe a
Prelude.Nothing,
      $sel:remoteIpDetails:NetworkConnectionAction' :: Maybe RemoteIpDetails
remoteIpDetails = forall a. Maybe a
Prelude.Nothing,
      $sel:remotePortDetails:NetworkConnectionAction' :: Maybe RemotePortDetails
remotePortDetails = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether EC2 blocked the network connection to your instance.
networkConnectionAction_blocked :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe Prelude.Bool)
networkConnectionAction_blocked :: Lens' NetworkConnectionAction (Maybe Bool)
networkConnectionAction_blocked = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConnectionAction' {Maybe Bool
blocked :: Maybe Bool
$sel:blocked:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe Bool
blocked} -> Maybe Bool
blocked) (\s :: NetworkConnectionAction
s@NetworkConnectionAction' {} Maybe Bool
a -> NetworkConnectionAction
s {$sel:blocked:NetworkConnectionAction' :: Maybe Bool
blocked = Maybe Bool
a} :: NetworkConnectionAction)

-- | The network connection direction.
networkConnectionAction_connectionDirection :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe Prelude.Text)
networkConnectionAction_connectionDirection :: Lens' NetworkConnectionAction (Maybe Text)
networkConnectionAction_connectionDirection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConnectionAction' {Maybe Text
connectionDirection :: Maybe Text
$sel:connectionDirection:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe Text
connectionDirection} -> Maybe Text
connectionDirection) (\s :: NetworkConnectionAction
s@NetworkConnectionAction' {} Maybe Text
a -> NetworkConnectionAction
s {$sel:connectionDirection:NetworkConnectionAction' :: Maybe Text
connectionDirection = Maybe Text
a} :: NetworkConnectionAction)

-- | The local IP information of the connection.
networkConnectionAction_localIpDetails :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe LocalIpDetails)
networkConnectionAction_localIpDetails :: Lens' NetworkConnectionAction (Maybe LocalIpDetails)
networkConnectionAction_localIpDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConnectionAction' {Maybe LocalIpDetails
localIpDetails :: Maybe LocalIpDetails
$sel:localIpDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe LocalIpDetails
localIpDetails} -> Maybe LocalIpDetails
localIpDetails) (\s :: NetworkConnectionAction
s@NetworkConnectionAction' {} Maybe LocalIpDetails
a -> NetworkConnectionAction
s {$sel:localIpDetails:NetworkConnectionAction' :: Maybe LocalIpDetails
localIpDetails = Maybe LocalIpDetails
a} :: NetworkConnectionAction)

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

-- | The network connection protocol.
networkConnectionAction_protocol :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe Prelude.Text)
networkConnectionAction_protocol :: Lens' NetworkConnectionAction (Maybe Text)
networkConnectionAction_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConnectionAction' {Maybe Text
protocol :: Maybe Text
$sel:protocol:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe Text
protocol} -> Maybe Text
protocol) (\s :: NetworkConnectionAction
s@NetworkConnectionAction' {} Maybe Text
a -> NetworkConnectionAction
s {$sel:protocol:NetworkConnectionAction' :: Maybe Text
protocol = Maybe Text
a} :: NetworkConnectionAction)

-- | The remote IP information of the connection.
networkConnectionAction_remoteIpDetails :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe RemoteIpDetails)
networkConnectionAction_remoteIpDetails :: Lens' NetworkConnectionAction (Maybe RemoteIpDetails)
networkConnectionAction_remoteIpDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConnectionAction' {Maybe RemoteIpDetails
remoteIpDetails :: Maybe RemoteIpDetails
$sel:remoteIpDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe RemoteIpDetails
remoteIpDetails} -> Maybe RemoteIpDetails
remoteIpDetails) (\s :: NetworkConnectionAction
s@NetworkConnectionAction' {} Maybe RemoteIpDetails
a -> NetworkConnectionAction
s {$sel:remoteIpDetails:NetworkConnectionAction' :: Maybe RemoteIpDetails
remoteIpDetails = Maybe RemoteIpDetails
a} :: NetworkConnectionAction)

-- | The remote port information of the connection.
networkConnectionAction_remotePortDetails :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe RemotePortDetails)
networkConnectionAction_remotePortDetails :: Lens' NetworkConnectionAction (Maybe RemotePortDetails)
networkConnectionAction_remotePortDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConnectionAction' {Maybe RemotePortDetails
remotePortDetails :: Maybe RemotePortDetails
$sel:remotePortDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe RemotePortDetails
remotePortDetails} -> Maybe RemotePortDetails
remotePortDetails) (\s :: NetworkConnectionAction
s@NetworkConnectionAction' {} Maybe RemotePortDetails
a -> NetworkConnectionAction
s {$sel:remotePortDetails:NetworkConnectionAction' :: Maybe RemotePortDetails
remotePortDetails = Maybe RemotePortDetails
a} :: NetworkConnectionAction)

instance Data.FromJSON NetworkConnectionAction where
  parseJSON :: Value -> Parser NetworkConnectionAction
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NetworkConnectionAction"
      ( \Object
x ->
          Maybe Bool
-> Maybe Text
-> Maybe LocalIpDetails
-> Maybe LocalPortDetails
-> Maybe Text
-> Maybe RemoteIpDetails
-> Maybe RemotePortDetails
-> NetworkConnectionAction
NetworkConnectionAction'
            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
"blocked")
            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
"connectionDirection")
            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
"localIpDetails")
            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
"localPortDetails")
            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
"protocol")
            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
"remoteIpDetails")
            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
"remotePortDetails")
      )

instance Prelude.Hashable NetworkConnectionAction where
  hashWithSalt :: Int -> NetworkConnectionAction -> Int
hashWithSalt Int
_salt NetworkConnectionAction' {Maybe Bool
Maybe Text
Maybe LocalIpDetails
Maybe LocalPortDetails
Maybe RemoteIpDetails
Maybe RemotePortDetails
remotePortDetails :: Maybe RemotePortDetails
remoteIpDetails :: Maybe RemoteIpDetails
protocol :: Maybe Text
localPortDetails :: Maybe LocalPortDetails
localIpDetails :: Maybe LocalIpDetails
connectionDirection :: Maybe Text
blocked :: Maybe Bool
$sel:remotePortDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe RemotePortDetails
$sel:remoteIpDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe RemoteIpDetails
$sel:protocol:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe Text
$sel:localPortDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe LocalPortDetails
$sel:localIpDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe LocalIpDetails
$sel:connectionDirection:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe Text
$sel:blocked:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
blocked
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectionDirection
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LocalIpDetails
localIpDetails
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LocalPortDetails
localPortDetails
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
protocol
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RemoteIpDetails
remoteIpDetails
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RemotePortDetails
remotePortDetails

instance Prelude.NFData NetworkConnectionAction where
  rnf :: NetworkConnectionAction -> ()
rnf NetworkConnectionAction' {Maybe Bool
Maybe Text
Maybe LocalIpDetails
Maybe LocalPortDetails
Maybe RemoteIpDetails
Maybe RemotePortDetails
remotePortDetails :: Maybe RemotePortDetails
remoteIpDetails :: Maybe RemoteIpDetails
protocol :: Maybe Text
localPortDetails :: Maybe LocalPortDetails
localIpDetails :: Maybe LocalIpDetails
connectionDirection :: Maybe Text
blocked :: Maybe Bool
$sel:remotePortDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe RemotePortDetails
$sel:remoteIpDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe RemoteIpDetails
$sel:protocol:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe Text
$sel:localPortDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe LocalPortDetails
$sel:localIpDetails:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe LocalIpDetails
$sel:connectionDirection:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe Text
$sel:blocked:NetworkConnectionAction' :: NetworkConnectionAction -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
blocked
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectionDirection
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LocalIpDetails
localIpDetails
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LocalPortDetails
localPortDetails
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
protocol
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RemoteIpDetails
remoteIpDetails
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RemotePortDetails
remotePortDetails