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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (FindingAction -> FindingAction -> Bool
(FindingAction -> FindingAction -> Bool)
-> (FindingAction -> FindingAction -> Bool) -> Eq FindingAction
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]
(Int -> ReadS FindingAction)
-> ReadS [FindingAction]
-> ReadPrec FindingAction
-> ReadPrec [FindingAction]
-> Read 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
(Int -> FindingAction -> ShowS)
-> (FindingAction -> String)
-> ([FindingAction] -> ShowS)
-> Show FindingAction
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. FindingAction -> Rep FindingAction x)
-> (forall x. Rep FindingAction x -> FindingAction)
-> Generic FindingAction
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:
--
-- '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.
--
-- '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.
newFindingAction ::
  FindingAction
newFindingAction :: FindingAction
newFindingAction =
  FindingAction' :: Maybe ApiCallDetails -> Maybe FindingActionType -> FindingAction
FindingAction'
    { $sel:apiCallDetails:FindingAction' :: Maybe ApiCallDetails
apiCallDetails = Maybe ApiCallDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:actionType:FindingAction' :: Maybe FindingActionType
actionType = Maybe FindingActionType
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe ApiCallDetails -> f (Maybe ApiCallDetails))
-> FindingAction -> f FindingAction
findingAction_apiCallDetails = (FindingAction -> Maybe ApiCallDetails)
-> (FindingAction -> Maybe ApiCallDetails -> FindingAction)
-> Lens
     FindingAction
     FindingAction
     (Maybe ApiCallDetails)
     (Maybe 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)

-- | 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 :: (Maybe FindingActionType -> f (Maybe FindingActionType))
-> FindingAction -> f FindingAction
findingAction_actionType = (FindingAction -> Maybe FindingActionType)
-> (FindingAction -> Maybe FindingActionType -> FindingAction)
-> Lens
     FindingAction
     FindingAction
     (Maybe FindingActionType)
     (Maybe FindingActionType)
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)

instance Core.FromJSON FindingAction where
  parseJSON :: Value -> Parser FindingAction
parseJSON =
    String
-> (Object -> Parser FindingAction)
-> Value
-> Parser FindingAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FindingAction"
      ( \Object
x ->
          Maybe ApiCallDetails -> Maybe FindingActionType -> FindingAction
FindingAction'
            (Maybe ApiCallDetails -> Maybe FindingActionType -> FindingAction)
-> Parser (Maybe ApiCallDetails)
-> Parser (Maybe FindingActionType -> FindingAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ApiCallDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"apiCallDetails")
            Parser (Maybe FindingActionType -> FindingAction)
-> Parser (Maybe FindingActionType) -> Parser FindingAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FindingActionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"actionType")
      )

instance Prelude.Hashable FindingAction

instance Prelude.NFData FindingAction