{-# 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.MacieV2.Types.FindingAction
-- 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.MacieV2.Types.FindingAction where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MacieV2.Types.ApiCallDetails
import Amazonka.MacieV2.Types.FindingActionType
import qualified Amazonka.Prelude as Prelude

-- | Provides information about an action that occurred for a resource and
-- produced a policy finding.
--
-- /See:/ 'newFindingAction' smart constructor.
data FindingAction = FindingAction'
  { -- | The type of action that occurred for the affected resource. This value
    -- is typically AWS_API_CALL, which indicates that an entity invoked an API
    -- operation for the resource.
    FindingAction -> Maybe FindingActionType
actionType :: Prelude.Maybe FindingActionType,
    -- | The invocation details of the API operation that an entity invoked for
    -- the affected resource, if the value for the actionType property is
    -- AWS_API_CALL.
    FindingAction -> Maybe ApiCallDetails
apiCallDetails :: Prelude.Maybe ApiCallDetails
  }
  deriving (FindingAction -> FindingAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FindingAction -> FindingAction -> Bool
$c/= :: FindingAction -> FindingAction -> Bool
== :: FindingAction -> FindingAction -> Bool
$c== :: FindingAction -> FindingAction -> Bool
Prelude.Eq, ReadPrec [FindingAction]
ReadPrec FindingAction
Int -> ReadS FindingAction
ReadS [FindingAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FindingAction]
$creadListPrec :: ReadPrec [FindingAction]
readPrec :: ReadPrec FindingAction
$creadPrec :: ReadPrec FindingAction
readList :: ReadS [FindingAction]
$creadList :: ReadS [FindingAction]
readsPrec :: Int -> ReadS FindingAction
$creadsPrec :: Int -> ReadS FindingAction
Prelude.Read, Int -> FindingAction -> ShowS
[FindingAction] -> ShowS
FindingAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FindingAction] -> ShowS
$cshowList :: [FindingAction] -> ShowS
show :: FindingAction -> String
$cshow :: FindingAction -> String
showsPrec :: Int -> FindingAction -> ShowS
$cshowsPrec :: Int -> FindingAction -> ShowS
Prelude.Show, forall x. Rep FindingAction x -> FindingAction
forall x. FindingAction -> Rep FindingAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FindingAction x -> FindingAction
$cfrom :: forall x. FindingAction -> Rep FindingAction x
Prelude.Generic)

-- |
-- Create a value of 'FindingAction' 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', 'findingAction_actionType' - The type of action that occurred for the affected resource. This value
-- is typically AWS_API_CALL, which indicates that an entity invoked an API
-- operation for the resource.
--
-- 'apiCallDetails', 'findingAction_apiCallDetails' - The invocation details of the API operation that an entity invoked for
-- the affected resource, if the value for the actionType property is
-- AWS_API_CALL.
newFindingAction ::
  FindingAction
newFindingAction :: FindingAction
newFindingAction =
  FindingAction'
    { $sel:actionType:FindingAction' :: Maybe FindingActionType
actionType = forall a. Maybe a
Prelude.Nothing,
      $sel:apiCallDetails:FindingAction' :: Maybe ApiCallDetails
apiCallDetails = forall a. Maybe a
Prelude.Nothing
    }

-- | The type of action that occurred for the affected resource. This value
-- is typically AWS_API_CALL, which indicates that an entity invoked an API
-- operation for the resource.
findingAction_actionType :: Lens.Lens' FindingAction (Prelude.Maybe FindingActionType)
findingAction_actionType :: Lens' FindingAction (Maybe FindingActionType)
findingAction_actionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindingAction' {Maybe FindingActionType
actionType :: Maybe FindingActionType
$sel:actionType:FindingAction' :: FindingAction -> Maybe FindingActionType
actionType} -> Maybe FindingActionType
actionType) (\s :: FindingAction
s@FindingAction' {} Maybe FindingActionType
a -> FindingAction
s {$sel:actionType:FindingAction' :: Maybe FindingActionType
actionType = Maybe FindingActionType
a} :: FindingAction)

-- | The invocation details of the API operation that an entity invoked for
-- the affected resource, if the value for the actionType property is
-- AWS_API_CALL.
findingAction_apiCallDetails :: Lens.Lens' FindingAction (Prelude.Maybe ApiCallDetails)
findingAction_apiCallDetails :: Lens' FindingAction (Maybe ApiCallDetails)
findingAction_apiCallDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindingAction' {Maybe ApiCallDetails
apiCallDetails :: Maybe ApiCallDetails
$sel:apiCallDetails:FindingAction' :: FindingAction -> Maybe ApiCallDetails
apiCallDetails} -> Maybe ApiCallDetails
apiCallDetails) (\s :: FindingAction
s@FindingAction' {} Maybe ApiCallDetails
a -> FindingAction
s {$sel:apiCallDetails:FindingAction' :: Maybe ApiCallDetails
apiCallDetails = Maybe ApiCallDetails
a} :: FindingAction)

instance Data.FromJSON FindingAction where
  parseJSON :: Value -> Parser FindingAction
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FindingAction"
      ( \Object
x ->
          Maybe FindingActionType -> Maybe ApiCallDetails -> FindingAction
FindingAction'
            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
"apiCallDetails")
      )

instance Prelude.Hashable FindingAction where
  hashWithSalt :: Int -> FindingAction -> Int
hashWithSalt Int
_salt FindingAction' {Maybe ApiCallDetails
Maybe FindingActionType
apiCallDetails :: Maybe ApiCallDetails
actionType :: Maybe FindingActionType
$sel:apiCallDetails:FindingAction' :: FindingAction -> Maybe ApiCallDetails
$sel:actionType:FindingAction' :: FindingAction -> Maybe FindingActionType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FindingActionType
actionType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ApiCallDetails
apiCallDetails

instance Prelude.NFData FindingAction where
  rnf :: FindingAction -> ()
rnf FindingAction' {Maybe ApiCallDetails
Maybe FindingActionType
apiCallDetails :: Maybe ApiCallDetails
actionType :: Maybe FindingActionType
$sel:apiCallDetails:FindingAction' :: FindingAction -> Maybe ApiCallDetails
$sel:actionType:FindingAction' :: FindingAction -> Maybe FindingActionType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FindingActionType
actionType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ApiCallDetails
apiCallDetails