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

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

-- | Contains information about the NETWORK_CONNECTION action described in
-- the finding.
--
-- /See:/ 'newNetworkConnectionAction' smart constructor.
data NetworkConnectionAction = NetworkConnectionAction'
  { -- | The remote IP information of the connection.
    NetworkConnectionAction -> Maybe RemoteIpDetails
remoteIpDetails :: Prelude.Maybe RemoteIpDetails,
    -- | The network connection protocol.
    NetworkConnectionAction -> Maybe Text
protocol :: Prelude.Maybe Prelude.Text,
    -- | The local IP information of the connection.
    NetworkConnectionAction -> Maybe LocalIpDetails
localIpDetails :: Prelude.Maybe LocalIpDetails,
    -- | The remote port information of the connection.
    NetworkConnectionAction -> Maybe RemotePortDetails
remotePortDetails :: Prelude.Maybe RemotePortDetails,
    -- | 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 port information of the connection.
    NetworkConnectionAction -> Maybe LocalPortDetails
localPortDetails :: Prelude.Maybe LocalPortDetails
  }
  deriving (NetworkConnectionAction -> NetworkConnectionAction -> Bool
(NetworkConnectionAction -> NetworkConnectionAction -> Bool)
-> (NetworkConnectionAction -> NetworkConnectionAction -> Bool)
-> Eq NetworkConnectionAction
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]
(Int -> ReadS NetworkConnectionAction)
-> ReadS [NetworkConnectionAction]
-> ReadPrec NetworkConnectionAction
-> ReadPrec [NetworkConnectionAction]
-> Read 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
(Int -> NetworkConnectionAction -> ShowS)
-> (NetworkConnectionAction -> String)
-> ([NetworkConnectionAction] -> ShowS)
-> Show NetworkConnectionAction
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.
 NetworkConnectionAction -> Rep NetworkConnectionAction x)
-> (forall x.
    Rep NetworkConnectionAction x -> NetworkConnectionAction)
-> Generic NetworkConnectionAction
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:
--
-- 'remoteIpDetails', 'networkConnectionAction_remoteIpDetails' - The remote IP information of the connection.
--
-- 'protocol', 'networkConnectionAction_protocol' - The network connection protocol.
--
-- 'localIpDetails', 'networkConnectionAction_localIpDetails' - The local IP information of the connection.
--
-- 'remotePortDetails', 'networkConnectionAction_remotePortDetails' - The remote port information of the connection.
--
-- 'blocked', 'networkConnectionAction_blocked' - Indicates whether EC2 blocked the network connection to your instance.
--
-- 'connectionDirection', 'networkConnectionAction_connectionDirection' - The network connection direction.
--
-- 'localPortDetails', 'networkConnectionAction_localPortDetails' - The local port information of the connection.
newNetworkConnectionAction ::
  NetworkConnectionAction
newNetworkConnectionAction :: NetworkConnectionAction
newNetworkConnectionAction =
  NetworkConnectionAction' :: Maybe RemoteIpDetails
-> Maybe Text
-> Maybe LocalIpDetails
-> Maybe RemotePortDetails
-> Maybe Bool
-> Maybe Text
-> Maybe LocalPortDetails
-> NetworkConnectionAction
NetworkConnectionAction'
    { $sel:remoteIpDetails:NetworkConnectionAction' :: Maybe RemoteIpDetails
remoteIpDetails =
        Maybe RemoteIpDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:NetworkConnectionAction' :: Maybe Text
protocol = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:localIpDetails:NetworkConnectionAction' :: Maybe LocalIpDetails
localIpDetails = Maybe LocalIpDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:remotePortDetails:NetworkConnectionAction' :: Maybe RemotePortDetails
remotePortDetails = Maybe RemotePortDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:blocked:NetworkConnectionAction' :: Maybe Bool
blocked = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionDirection:NetworkConnectionAction' :: Maybe Text
connectionDirection = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:localPortDetails:NetworkConnectionAction' :: Maybe LocalPortDetails
localPortDetails = Maybe LocalPortDetails
forall a. Maybe a
Prelude.Nothing
    }

-- | The remote IP information of the connection.
networkConnectionAction_remoteIpDetails :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe RemoteIpDetails)
networkConnectionAction_remoteIpDetails :: (Maybe RemoteIpDetails -> f (Maybe RemoteIpDetails))
-> NetworkConnectionAction -> f NetworkConnectionAction
networkConnectionAction_remoteIpDetails = (NetworkConnectionAction -> Maybe RemoteIpDetails)
-> (NetworkConnectionAction
    -> Maybe RemoteIpDetails -> NetworkConnectionAction)
-> Lens
     NetworkConnectionAction
     NetworkConnectionAction
     (Maybe RemoteIpDetails)
     (Maybe 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 network connection protocol.
networkConnectionAction_protocol :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe Prelude.Text)
networkConnectionAction_protocol :: (Maybe Text -> f (Maybe Text))
-> NetworkConnectionAction -> f NetworkConnectionAction
networkConnectionAction_protocol = (NetworkConnectionAction -> Maybe Text)
-> (NetworkConnectionAction
    -> Maybe Text -> NetworkConnectionAction)
-> Lens
     NetworkConnectionAction
     NetworkConnectionAction
     (Maybe Text)
     (Maybe Text)
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 local IP information of the connection.
networkConnectionAction_localIpDetails :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe LocalIpDetails)
networkConnectionAction_localIpDetails :: (Maybe LocalIpDetails -> f (Maybe LocalIpDetails))
-> NetworkConnectionAction -> f NetworkConnectionAction
networkConnectionAction_localIpDetails = (NetworkConnectionAction -> Maybe LocalIpDetails)
-> (NetworkConnectionAction
    -> Maybe LocalIpDetails -> NetworkConnectionAction)
-> Lens
     NetworkConnectionAction
     NetworkConnectionAction
     (Maybe LocalIpDetails)
     (Maybe 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 remote port information of the connection.
networkConnectionAction_remotePortDetails :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe RemotePortDetails)
networkConnectionAction_remotePortDetails :: (Maybe RemotePortDetails -> f (Maybe RemotePortDetails))
-> NetworkConnectionAction -> f NetworkConnectionAction
networkConnectionAction_remotePortDetails = (NetworkConnectionAction -> Maybe RemotePortDetails)
-> (NetworkConnectionAction
    -> Maybe RemotePortDetails -> NetworkConnectionAction)
-> Lens
     NetworkConnectionAction
     NetworkConnectionAction
     (Maybe RemotePortDetails)
     (Maybe 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)

-- | Indicates whether EC2 blocked the network connection to your instance.
networkConnectionAction_blocked :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe Prelude.Bool)
networkConnectionAction_blocked :: (Maybe Bool -> f (Maybe Bool))
-> NetworkConnectionAction -> f NetworkConnectionAction
networkConnectionAction_blocked = (NetworkConnectionAction -> Maybe Bool)
-> (NetworkConnectionAction
    -> Maybe Bool -> NetworkConnectionAction)
-> Lens
     NetworkConnectionAction
     NetworkConnectionAction
     (Maybe Bool)
     (Maybe Bool)
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 :: (Maybe Text -> f (Maybe Text))
-> NetworkConnectionAction -> f NetworkConnectionAction
networkConnectionAction_connectionDirection = (NetworkConnectionAction -> Maybe Text)
-> (NetworkConnectionAction
    -> Maybe Text -> NetworkConnectionAction)
-> Lens
     NetworkConnectionAction
     NetworkConnectionAction
     (Maybe Text)
     (Maybe Text)
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 port information of the connection.
networkConnectionAction_localPortDetails :: Lens.Lens' NetworkConnectionAction (Prelude.Maybe LocalPortDetails)
networkConnectionAction_localPortDetails :: (Maybe LocalPortDetails -> f (Maybe LocalPortDetails))
-> NetworkConnectionAction -> f NetworkConnectionAction
networkConnectionAction_localPortDetails = (NetworkConnectionAction -> Maybe LocalPortDetails)
-> (NetworkConnectionAction
    -> Maybe LocalPortDetails -> NetworkConnectionAction)
-> Lens
     NetworkConnectionAction
     NetworkConnectionAction
     (Maybe LocalPortDetails)
     (Maybe 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)

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

instance Prelude.Hashable NetworkConnectionAction

instance Prelude.NFData NetworkConnectionAction