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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.FindingAction
import Amazonka.MacieV2.Types.FindingActor
import qualified Amazonka.Prelude as Prelude

-- | Provides the details of a policy finding.
--
-- /See:/ 'newPolicyDetails' smart constructor.
data PolicyDetails = PolicyDetails'
  { -- | The entity that performed the action that produced the finding.
    PolicyDetails -> Maybe FindingActor
actor :: Prelude.Maybe FindingActor,
    -- | The action that produced the finding.
    PolicyDetails -> Maybe FindingAction
action :: Prelude.Maybe FindingAction
  }
  deriving (PolicyDetails -> PolicyDetails -> Bool
(PolicyDetails -> PolicyDetails -> Bool)
-> (PolicyDetails -> PolicyDetails -> Bool) -> Eq PolicyDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyDetails -> PolicyDetails -> Bool
$c/= :: PolicyDetails -> PolicyDetails -> Bool
== :: PolicyDetails -> PolicyDetails -> Bool
$c== :: PolicyDetails -> PolicyDetails -> Bool
Prelude.Eq, ReadPrec [PolicyDetails]
ReadPrec PolicyDetails
Int -> ReadS PolicyDetails
ReadS [PolicyDetails]
(Int -> ReadS PolicyDetails)
-> ReadS [PolicyDetails]
-> ReadPrec PolicyDetails
-> ReadPrec [PolicyDetails]
-> Read PolicyDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyDetails]
$creadListPrec :: ReadPrec [PolicyDetails]
readPrec :: ReadPrec PolicyDetails
$creadPrec :: ReadPrec PolicyDetails
readList :: ReadS [PolicyDetails]
$creadList :: ReadS [PolicyDetails]
readsPrec :: Int -> ReadS PolicyDetails
$creadsPrec :: Int -> ReadS PolicyDetails
Prelude.Read, Int -> PolicyDetails -> ShowS
[PolicyDetails] -> ShowS
PolicyDetails -> String
(Int -> PolicyDetails -> ShowS)
-> (PolicyDetails -> String)
-> ([PolicyDetails] -> ShowS)
-> Show PolicyDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyDetails] -> ShowS
$cshowList :: [PolicyDetails] -> ShowS
show :: PolicyDetails -> String
$cshow :: PolicyDetails -> String
showsPrec :: Int -> PolicyDetails -> ShowS
$cshowsPrec :: Int -> PolicyDetails -> ShowS
Prelude.Show, (forall x. PolicyDetails -> Rep PolicyDetails x)
-> (forall x. Rep PolicyDetails x -> PolicyDetails)
-> Generic PolicyDetails
forall x. Rep PolicyDetails x -> PolicyDetails
forall x. PolicyDetails -> Rep PolicyDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyDetails x -> PolicyDetails
$cfrom :: forall x. PolicyDetails -> Rep PolicyDetails x
Prelude.Generic)

-- |
-- Create a value of 'PolicyDetails' 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:
--
-- 'actor', 'policyDetails_actor' - The entity that performed the action that produced the finding.
--
-- 'action', 'policyDetails_action' - The action that produced the finding.
newPolicyDetails ::
  PolicyDetails
newPolicyDetails :: PolicyDetails
newPolicyDetails =
  PolicyDetails' :: Maybe FindingActor -> Maybe FindingAction -> PolicyDetails
PolicyDetails'
    { $sel:actor:PolicyDetails' :: Maybe FindingActor
actor = Maybe FindingActor
forall a. Maybe a
Prelude.Nothing,
      $sel:action:PolicyDetails' :: Maybe FindingAction
action = Maybe FindingAction
forall a. Maybe a
Prelude.Nothing
    }

-- | The entity that performed the action that produced the finding.
policyDetails_actor :: Lens.Lens' PolicyDetails (Prelude.Maybe FindingActor)
policyDetails_actor :: (Maybe FindingActor -> f (Maybe FindingActor))
-> PolicyDetails -> f PolicyDetails
policyDetails_actor = (PolicyDetails -> Maybe FindingActor)
-> (PolicyDetails -> Maybe FindingActor -> PolicyDetails)
-> Lens
     PolicyDetails
     PolicyDetails
     (Maybe FindingActor)
     (Maybe FindingActor)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetails' {Maybe FindingActor
actor :: Maybe FindingActor
$sel:actor:PolicyDetails' :: PolicyDetails -> Maybe FindingActor
actor} -> Maybe FindingActor
actor) (\s :: PolicyDetails
s@PolicyDetails' {} Maybe FindingActor
a -> PolicyDetails
s {$sel:actor:PolicyDetails' :: Maybe FindingActor
actor = Maybe FindingActor
a} :: PolicyDetails)

-- | The action that produced the finding.
policyDetails_action :: Lens.Lens' PolicyDetails (Prelude.Maybe FindingAction)
policyDetails_action :: (Maybe FindingAction -> f (Maybe FindingAction))
-> PolicyDetails -> f PolicyDetails
policyDetails_action = (PolicyDetails -> Maybe FindingAction)
-> (PolicyDetails -> Maybe FindingAction -> PolicyDetails)
-> Lens
     PolicyDetails
     PolicyDetails
     (Maybe FindingAction)
     (Maybe FindingAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetails' {Maybe FindingAction
action :: Maybe FindingAction
$sel:action:PolicyDetails' :: PolicyDetails -> Maybe FindingAction
action} -> Maybe FindingAction
action) (\s :: PolicyDetails
s@PolicyDetails' {} Maybe FindingAction
a -> PolicyDetails
s {$sel:action:PolicyDetails' :: Maybe FindingAction
action = Maybe FindingAction
a} :: PolicyDetails)

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

instance Prelude.Hashable PolicyDetails

instance Prelude.NFData PolicyDetails