{-# 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.Action
-- 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.Action 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.AwsApiCallAction
import Amazonka.GuardDuty.Types.DnsRequestAction
import Amazonka.GuardDuty.Types.KubernetesApiCallAction
import Amazonka.GuardDuty.Types.NetworkConnectionAction
import Amazonka.GuardDuty.Types.PortProbeAction
import qualified Amazonka.Prelude as Prelude

-- | Contains information about actions.
--
-- /See:/ 'newAction' smart constructor.
data Action = Action'
  { -- | The GuardDuty finding activity type.
    Action -> Maybe Text
actionType :: Prelude.Maybe Prelude.Text,
    -- | Information about the AWS_API_CALL action described in this finding.
    Action -> Maybe AwsApiCallAction
awsApiCallAction :: Prelude.Maybe AwsApiCallAction,
    -- | Information about the DNS_REQUEST action described in this finding.
    Action -> Maybe DnsRequestAction
dnsRequestAction :: Prelude.Maybe DnsRequestAction,
    -- | Information about the Kubernetes API call action described in this
    -- finding.
    Action -> Maybe KubernetesApiCallAction
kubernetesApiCallAction :: Prelude.Maybe KubernetesApiCallAction,
    -- | Information about the NETWORK_CONNECTION action described in this
    -- finding.
    Action -> Maybe NetworkConnectionAction
networkConnectionAction :: Prelude.Maybe NetworkConnectionAction,
    -- | Information about the PORT_PROBE action described in this finding.
    Action -> Maybe PortProbeAction
portProbeAction :: Prelude.Maybe PortProbeAction
  }
  deriving (Action -> Action -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Action -> Action -> Bool
$c/= :: Action -> Action -> Bool
== :: Action -> Action -> Bool
$c== :: Action -> Action -> Bool
Prelude.Eq, ReadPrec [Action]
ReadPrec Action
Int -> ReadS Action
ReadS [Action]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Action]
$creadListPrec :: ReadPrec [Action]
readPrec :: ReadPrec Action
$creadPrec :: ReadPrec Action
readList :: ReadS [Action]
$creadList :: ReadS [Action]
readsPrec :: Int -> ReadS Action
$creadsPrec :: Int -> ReadS Action
Prelude.Read, Int -> Action -> ShowS
[Action] -> ShowS
Action -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Action] -> ShowS
$cshowList :: [Action] -> ShowS
show :: Action -> String
$cshow :: Action -> String
showsPrec :: Int -> Action -> ShowS
$cshowsPrec :: Int -> Action -> ShowS
Prelude.Show, forall x. Rep Action x -> Action
forall x. Action -> Rep Action x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Action x -> Action
$cfrom :: forall x. Action -> Rep Action x
Prelude.Generic)

-- |
-- Create a value of 'Action' 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:
--
-- 'actionType', 'action_actionType' - The GuardDuty finding activity type.
--
-- 'awsApiCallAction', 'action_awsApiCallAction' - Information about the AWS_API_CALL action described in this finding.
--
-- 'dnsRequestAction', 'action_dnsRequestAction' - Information about the DNS_REQUEST action described in this finding.
--
-- 'kubernetesApiCallAction', 'action_kubernetesApiCallAction' - Information about the Kubernetes API call action described in this
-- finding.
--
-- 'networkConnectionAction', 'action_networkConnectionAction' - Information about the NETWORK_CONNECTION action described in this
-- finding.
--
-- 'portProbeAction', 'action_portProbeAction' - Information about the PORT_PROBE action described in this finding.
newAction ::
  Action
newAction :: Action
newAction =
  Action'
    { $sel:actionType:Action' :: Maybe Text
actionType = forall a. Maybe a
Prelude.Nothing,
      $sel:awsApiCallAction:Action' :: Maybe AwsApiCallAction
awsApiCallAction = forall a. Maybe a
Prelude.Nothing,
      $sel:dnsRequestAction:Action' :: Maybe DnsRequestAction
dnsRequestAction = forall a. Maybe a
Prelude.Nothing,
      $sel:kubernetesApiCallAction:Action' :: Maybe KubernetesApiCallAction
kubernetesApiCallAction = forall a. Maybe a
Prelude.Nothing,
      $sel:networkConnectionAction:Action' :: Maybe NetworkConnectionAction
networkConnectionAction = forall a. Maybe a
Prelude.Nothing,
      $sel:portProbeAction:Action' :: Maybe PortProbeAction
portProbeAction = forall a. Maybe a
Prelude.Nothing
    }

-- | The GuardDuty finding activity type.
action_actionType :: Lens.Lens' Action (Prelude.Maybe Prelude.Text)
action_actionType :: Lens' Action (Maybe Text)
action_actionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe Text
actionType :: Maybe Text
$sel:actionType:Action' :: Action -> Maybe Text
actionType} -> Maybe Text
actionType) (\s :: Action
s@Action' {} Maybe Text
a -> Action
s {$sel:actionType:Action' :: Maybe Text
actionType = Maybe Text
a} :: Action)

-- | Information about the AWS_API_CALL action described in this finding.
action_awsApiCallAction :: Lens.Lens' Action (Prelude.Maybe AwsApiCallAction)
action_awsApiCallAction :: Lens' Action (Maybe AwsApiCallAction)
action_awsApiCallAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe AwsApiCallAction
awsApiCallAction :: Maybe AwsApiCallAction
$sel:awsApiCallAction:Action' :: Action -> Maybe AwsApiCallAction
awsApiCallAction} -> Maybe AwsApiCallAction
awsApiCallAction) (\s :: Action
s@Action' {} Maybe AwsApiCallAction
a -> Action
s {$sel:awsApiCallAction:Action' :: Maybe AwsApiCallAction
awsApiCallAction = Maybe AwsApiCallAction
a} :: Action)

-- | Information about the DNS_REQUEST action described in this finding.
action_dnsRequestAction :: Lens.Lens' Action (Prelude.Maybe DnsRequestAction)
action_dnsRequestAction :: Lens' Action (Maybe DnsRequestAction)
action_dnsRequestAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe DnsRequestAction
dnsRequestAction :: Maybe DnsRequestAction
$sel:dnsRequestAction:Action' :: Action -> Maybe DnsRequestAction
dnsRequestAction} -> Maybe DnsRequestAction
dnsRequestAction) (\s :: Action
s@Action' {} Maybe DnsRequestAction
a -> Action
s {$sel:dnsRequestAction:Action' :: Maybe DnsRequestAction
dnsRequestAction = Maybe DnsRequestAction
a} :: Action)

-- | Information about the Kubernetes API call action described in this
-- finding.
action_kubernetesApiCallAction :: Lens.Lens' Action (Prelude.Maybe KubernetesApiCallAction)
action_kubernetesApiCallAction :: Lens' Action (Maybe KubernetesApiCallAction)
action_kubernetesApiCallAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe KubernetesApiCallAction
kubernetesApiCallAction :: Maybe KubernetesApiCallAction
$sel:kubernetesApiCallAction:Action' :: Action -> Maybe KubernetesApiCallAction
kubernetesApiCallAction} -> Maybe KubernetesApiCallAction
kubernetesApiCallAction) (\s :: Action
s@Action' {} Maybe KubernetesApiCallAction
a -> Action
s {$sel:kubernetesApiCallAction:Action' :: Maybe KubernetesApiCallAction
kubernetesApiCallAction = Maybe KubernetesApiCallAction
a} :: Action)

-- | Information about the NETWORK_CONNECTION action described in this
-- finding.
action_networkConnectionAction :: Lens.Lens' Action (Prelude.Maybe NetworkConnectionAction)
action_networkConnectionAction :: Lens' Action (Maybe NetworkConnectionAction)
action_networkConnectionAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe NetworkConnectionAction
networkConnectionAction :: Maybe NetworkConnectionAction
$sel:networkConnectionAction:Action' :: Action -> Maybe NetworkConnectionAction
networkConnectionAction} -> Maybe NetworkConnectionAction
networkConnectionAction) (\s :: Action
s@Action' {} Maybe NetworkConnectionAction
a -> Action
s {$sel:networkConnectionAction:Action' :: Maybe NetworkConnectionAction
networkConnectionAction = Maybe NetworkConnectionAction
a} :: Action)

-- | Information about the PORT_PROBE action described in this finding.
action_portProbeAction :: Lens.Lens' Action (Prelude.Maybe PortProbeAction)
action_portProbeAction :: Lens' Action (Maybe PortProbeAction)
action_portProbeAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe PortProbeAction
portProbeAction :: Maybe PortProbeAction
$sel:portProbeAction:Action' :: Action -> Maybe PortProbeAction
portProbeAction} -> Maybe PortProbeAction
portProbeAction) (\s :: Action
s@Action' {} Maybe PortProbeAction
a -> Action
s {$sel:portProbeAction:Action' :: Maybe PortProbeAction
portProbeAction = Maybe PortProbeAction
a} :: Action)

instance Data.FromJSON Action where
  parseJSON :: Value -> Parser Action
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Action"
      ( \Object
x ->
          Maybe Text
-> Maybe AwsApiCallAction
-> Maybe DnsRequestAction
-> Maybe KubernetesApiCallAction
-> Maybe NetworkConnectionAction
-> Maybe PortProbeAction
-> Action
Action'
            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
"actionType")
            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
"awsApiCallAction")
            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
"dnsRequestAction")
            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
"kubernetesApiCallAction")
            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
"networkConnectionAction")
            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
"portProbeAction")
      )

instance Prelude.Hashable Action where
  hashWithSalt :: Int -> Action -> Int
hashWithSalt Int
_salt Action' {Maybe Text
Maybe DnsRequestAction
Maybe PortProbeAction
Maybe KubernetesApiCallAction
Maybe AwsApiCallAction
Maybe NetworkConnectionAction
portProbeAction :: Maybe PortProbeAction
networkConnectionAction :: Maybe NetworkConnectionAction
kubernetesApiCallAction :: Maybe KubernetesApiCallAction
dnsRequestAction :: Maybe DnsRequestAction
awsApiCallAction :: Maybe AwsApiCallAction
actionType :: Maybe Text
$sel:portProbeAction:Action' :: Action -> Maybe PortProbeAction
$sel:networkConnectionAction:Action' :: Action -> Maybe NetworkConnectionAction
$sel:kubernetesApiCallAction:Action' :: Action -> Maybe KubernetesApiCallAction
$sel:dnsRequestAction:Action' :: Action -> Maybe DnsRequestAction
$sel:awsApiCallAction:Action' :: Action -> Maybe AwsApiCallAction
$sel:actionType:Action' :: Action -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
actionType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AwsApiCallAction
awsApiCallAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DnsRequestAction
dnsRequestAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe KubernetesApiCallAction
kubernetesApiCallAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NetworkConnectionAction
networkConnectionAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PortProbeAction
portProbeAction

instance Prelude.NFData Action where
  rnf :: Action -> ()
rnf Action' {Maybe Text
Maybe DnsRequestAction
Maybe PortProbeAction
Maybe KubernetesApiCallAction
Maybe AwsApiCallAction
Maybe NetworkConnectionAction
portProbeAction :: Maybe PortProbeAction
networkConnectionAction :: Maybe NetworkConnectionAction
kubernetesApiCallAction :: Maybe KubernetesApiCallAction
dnsRequestAction :: Maybe DnsRequestAction
awsApiCallAction :: Maybe AwsApiCallAction
actionType :: Maybe Text
$sel:portProbeAction:Action' :: Action -> Maybe PortProbeAction
$sel:networkConnectionAction:Action' :: Action -> Maybe NetworkConnectionAction
$sel:kubernetesApiCallAction:Action' :: Action -> Maybe KubernetesApiCallAction
$sel:dnsRequestAction:Action' :: Action -> Maybe DnsRequestAction
$sel:awsApiCallAction:Action' :: Action -> Maybe AwsApiCallAction
$sel:actionType:Action' :: Action -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
actionType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AwsApiCallAction
awsApiCallAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DnsRequestAction
dnsRequestAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe KubernetesApiCallAction
kubernetesApiCallAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NetworkConnectionAction
networkConnectionAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PortProbeAction
portProbeAction