{-# 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.Config.Types.EvaluationResult
-- 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.Config.Types.EvaluationResult where

import Amazonka.Config.Types.ComplianceType
import Amazonka.Config.Types.EvaluationResultIdentifier
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The details of an Config evaluation. Provides the Amazon Web Services
-- resource that was evaluated, the compliance of the resource, related
-- time stamps, and supplementary information.
--
-- /See:/ 'newEvaluationResult' smart constructor.
data EvaluationResult = EvaluationResult'
  { -- | Supplementary information about how the evaluation determined the
    -- compliance.
    EvaluationResult -> Maybe Text
annotation :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether the Amazon Web Services resource complies with the
    -- Config rule that evaluated it.
    --
    -- For the @EvaluationResult@ data type, Config supports only the
    -- @COMPLIANT@, @NON_COMPLIANT@, and @NOT_APPLICABLE@ values. Config does
    -- not support the @INSUFFICIENT_DATA@ value for the @EvaluationResult@
    -- data type.
    EvaluationResult -> Maybe ComplianceType
complianceType :: Prelude.Maybe ComplianceType,
    -- | The time when the Config rule evaluated the Amazon Web Services
    -- resource.
    EvaluationResult -> Maybe POSIX
configRuleInvokedTime :: Prelude.Maybe Data.POSIX,
    -- | Uniquely identifies the evaluation result.
    EvaluationResult -> Maybe EvaluationResultIdentifier
evaluationResultIdentifier :: Prelude.Maybe EvaluationResultIdentifier,
    -- | The time when Config recorded the evaluation result.
    EvaluationResult -> Maybe POSIX
resultRecordedTime :: Prelude.Maybe Data.POSIX,
    -- | An encrypted token that associates an evaluation with an Config rule.
    -- The token identifies the rule, the Amazon Web Services resource being
    -- evaluated, and the event that triggered the evaluation.
    EvaluationResult -> Maybe Text
resultToken :: Prelude.Maybe Prelude.Text
  }
  deriving (EvaluationResult -> EvaluationResult -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EvaluationResult -> EvaluationResult -> Bool
$c/= :: EvaluationResult -> EvaluationResult -> Bool
== :: EvaluationResult -> EvaluationResult -> Bool
$c== :: EvaluationResult -> EvaluationResult -> Bool
Prelude.Eq, ReadPrec [EvaluationResult]
ReadPrec EvaluationResult
Int -> ReadS EvaluationResult
ReadS [EvaluationResult]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EvaluationResult]
$creadListPrec :: ReadPrec [EvaluationResult]
readPrec :: ReadPrec EvaluationResult
$creadPrec :: ReadPrec EvaluationResult
readList :: ReadS [EvaluationResult]
$creadList :: ReadS [EvaluationResult]
readsPrec :: Int -> ReadS EvaluationResult
$creadsPrec :: Int -> ReadS EvaluationResult
Prelude.Read, Int -> EvaluationResult -> ShowS
[EvaluationResult] -> ShowS
EvaluationResult -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EvaluationResult] -> ShowS
$cshowList :: [EvaluationResult] -> ShowS
show :: EvaluationResult -> String
$cshow :: EvaluationResult -> String
showsPrec :: Int -> EvaluationResult -> ShowS
$cshowsPrec :: Int -> EvaluationResult -> ShowS
Prelude.Show, forall x. Rep EvaluationResult x -> EvaluationResult
forall x. EvaluationResult -> Rep EvaluationResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EvaluationResult x -> EvaluationResult
$cfrom :: forall x. EvaluationResult -> Rep EvaluationResult x
Prelude.Generic)

-- |
-- Create a value of 'EvaluationResult' 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:
--
-- 'annotation', 'evaluationResult_annotation' - Supplementary information about how the evaluation determined the
-- compliance.
--
-- 'complianceType', 'evaluationResult_complianceType' - Indicates whether the Amazon Web Services resource complies with the
-- Config rule that evaluated it.
--
-- For the @EvaluationResult@ data type, Config supports only the
-- @COMPLIANT@, @NON_COMPLIANT@, and @NOT_APPLICABLE@ values. Config does
-- not support the @INSUFFICIENT_DATA@ value for the @EvaluationResult@
-- data type.
--
-- 'configRuleInvokedTime', 'evaluationResult_configRuleInvokedTime' - The time when the Config rule evaluated the Amazon Web Services
-- resource.
--
-- 'evaluationResultIdentifier', 'evaluationResult_evaluationResultIdentifier' - Uniquely identifies the evaluation result.
--
-- 'resultRecordedTime', 'evaluationResult_resultRecordedTime' - The time when Config recorded the evaluation result.
--
-- 'resultToken', 'evaluationResult_resultToken' - An encrypted token that associates an evaluation with an Config rule.
-- The token identifies the rule, the Amazon Web Services resource being
-- evaluated, and the event that triggered the evaluation.
newEvaluationResult ::
  EvaluationResult
newEvaluationResult :: EvaluationResult
newEvaluationResult =
  EvaluationResult'
    { $sel:annotation:EvaluationResult' :: Maybe Text
annotation = forall a. Maybe a
Prelude.Nothing,
      $sel:complianceType:EvaluationResult' :: Maybe ComplianceType
complianceType = forall a. Maybe a
Prelude.Nothing,
      $sel:configRuleInvokedTime:EvaluationResult' :: Maybe POSIX
configRuleInvokedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:evaluationResultIdentifier:EvaluationResult' :: Maybe EvaluationResultIdentifier
evaluationResultIdentifier = forall a. Maybe a
Prelude.Nothing,
      $sel:resultRecordedTime:EvaluationResult' :: Maybe POSIX
resultRecordedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:resultToken:EvaluationResult' :: Maybe Text
resultToken = forall a. Maybe a
Prelude.Nothing
    }

-- | Supplementary information about how the evaluation determined the
-- compliance.
evaluationResult_annotation :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.Text)
evaluationResult_annotation :: Lens' EvaluationResult (Maybe Text)
evaluationResult_annotation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe Text
annotation :: Maybe Text
$sel:annotation:EvaluationResult' :: EvaluationResult -> Maybe Text
annotation} -> Maybe Text
annotation) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe Text
a -> EvaluationResult
s {$sel:annotation:EvaluationResult' :: Maybe Text
annotation = Maybe Text
a} :: EvaluationResult)

-- | Indicates whether the Amazon Web Services resource complies with the
-- Config rule that evaluated it.
--
-- For the @EvaluationResult@ data type, Config supports only the
-- @COMPLIANT@, @NON_COMPLIANT@, and @NOT_APPLICABLE@ values. Config does
-- not support the @INSUFFICIENT_DATA@ value for the @EvaluationResult@
-- data type.
evaluationResult_complianceType :: Lens.Lens' EvaluationResult (Prelude.Maybe ComplianceType)
evaluationResult_complianceType :: Lens' EvaluationResult (Maybe ComplianceType)
evaluationResult_complianceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe ComplianceType
complianceType :: Maybe ComplianceType
$sel:complianceType:EvaluationResult' :: EvaluationResult -> Maybe ComplianceType
complianceType} -> Maybe ComplianceType
complianceType) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe ComplianceType
a -> EvaluationResult
s {$sel:complianceType:EvaluationResult' :: Maybe ComplianceType
complianceType = Maybe ComplianceType
a} :: EvaluationResult)

-- | The time when the Config rule evaluated the Amazon Web Services
-- resource.
evaluationResult_configRuleInvokedTime :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.UTCTime)
evaluationResult_configRuleInvokedTime :: Lens' EvaluationResult (Maybe UTCTime)
evaluationResult_configRuleInvokedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe POSIX
configRuleInvokedTime :: Maybe POSIX
$sel:configRuleInvokedTime:EvaluationResult' :: EvaluationResult -> Maybe POSIX
configRuleInvokedTime} -> Maybe POSIX
configRuleInvokedTime) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe POSIX
a -> EvaluationResult
s {$sel:configRuleInvokedTime:EvaluationResult' :: Maybe POSIX
configRuleInvokedTime = Maybe POSIX
a} :: EvaluationResult) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Uniquely identifies the evaluation result.
evaluationResult_evaluationResultIdentifier :: Lens.Lens' EvaluationResult (Prelude.Maybe EvaluationResultIdentifier)
evaluationResult_evaluationResultIdentifier :: Lens' EvaluationResult (Maybe EvaluationResultIdentifier)
evaluationResult_evaluationResultIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe EvaluationResultIdentifier
evaluationResultIdentifier :: Maybe EvaluationResultIdentifier
$sel:evaluationResultIdentifier:EvaluationResult' :: EvaluationResult -> Maybe EvaluationResultIdentifier
evaluationResultIdentifier} -> Maybe EvaluationResultIdentifier
evaluationResultIdentifier) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe EvaluationResultIdentifier
a -> EvaluationResult
s {$sel:evaluationResultIdentifier:EvaluationResult' :: Maybe EvaluationResultIdentifier
evaluationResultIdentifier = Maybe EvaluationResultIdentifier
a} :: EvaluationResult)

-- | The time when Config recorded the evaluation result.
evaluationResult_resultRecordedTime :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.UTCTime)
evaluationResult_resultRecordedTime :: Lens' EvaluationResult (Maybe UTCTime)
evaluationResult_resultRecordedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe POSIX
resultRecordedTime :: Maybe POSIX
$sel:resultRecordedTime:EvaluationResult' :: EvaluationResult -> Maybe POSIX
resultRecordedTime} -> Maybe POSIX
resultRecordedTime) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe POSIX
a -> EvaluationResult
s {$sel:resultRecordedTime:EvaluationResult' :: Maybe POSIX
resultRecordedTime = Maybe POSIX
a} :: EvaluationResult) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | An encrypted token that associates an evaluation with an Config rule.
-- The token identifies the rule, the Amazon Web Services resource being
-- evaluated, and the event that triggered the evaluation.
evaluationResult_resultToken :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.Text)
evaluationResult_resultToken :: Lens' EvaluationResult (Maybe Text)
evaluationResult_resultToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe Text
resultToken :: Maybe Text
$sel:resultToken:EvaluationResult' :: EvaluationResult -> Maybe Text
resultToken} -> Maybe Text
resultToken) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe Text
a -> EvaluationResult
s {$sel:resultToken:EvaluationResult' :: Maybe Text
resultToken = Maybe Text
a} :: EvaluationResult)

instance Data.FromJSON EvaluationResult where
  parseJSON :: Value -> Parser EvaluationResult
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EvaluationResult"
      ( \Object
x ->
          Maybe Text
-> Maybe ComplianceType
-> Maybe POSIX
-> Maybe EvaluationResultIdentifier
-> Maybe POSIX
-> Maybe Text
-> EvaluationResult
EvaluationResult'
            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
"Annotation")
            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
"ComplianceType")
            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
"ConfigRuleInvokedTime")
            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
"EvaluationResultIdentifier")
            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
"ResultRecordedTime")
            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
"ResultToken")
      )

instance Prelude.Hashable EvaluationResult where
  hashWithSalt :: Int -> EvaluationResult -> Int
hashWithSalt Int
_salt EvaluationResult' {Maybe Text
Maybe POSIX
Maybe ComplianceType
Maybe EvaluationResultIdentifier
resultToken :: Maybe Text
resultRecordedTime :: Maybe POSIX
evaluationResultIdentifier :: Maybe EvaluationResultIdentifier
configRuleInvokedTime :: Maybe POSIX
complianceType :: Maybe ComplianceType
annotation :: Maybe Text
$sel:resultToken:EvaluationResult' :: EvaluationResult -> Maybe Text
$sel:resultRecordedTime:EvaluationResult' :: EvaluationResult -> Maybe POSIX
$sel:evaluationResultIdentifier:EvaluationResult' :: EvaluationResult -> Maybe EvaluationResultIdentifier
$sel:configRuleInvokedTime:EvaluationResult' :: EvaluationResult -> Maybe POSIX
$sel:complianceType:EvaluationResult' :: EvaluationResult -> Maybe ComplianceType
$sel:annotation:EvaluationResult' :: EvaluationResult -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
annotation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ComplianceType
complianceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
configRuleInvokedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EvaluationResultIdentifier
evaluationResultIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
resultRecordedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resultToken

instance Prelude.NFData EvaluationResult where
  rnf :: EvaluationResult -> ()
rnf EvaluationResult' {Maybe Text
Maybe POSIX
Maybe ComplianceType
Maybe EvaluationResultIdentifier
resultToken :: Maybe Text
resultRecordedTime :: Maybe POSIX
evaluationResultIdentifier :: Maybe EvaluationResultIdentifier
configRuleInvokedTime :: Maybe POSIX
complianceType :: Maybe ComplianceType
annotation :: Maybe Text
$sel:resultToken:EvaluationResult' :: EvaluationResult -> Maybe Text
$sel:resultRecordedTime:EvaluationResult' :: EvaluationResult -> Maybe POSIX
$sel:evaluationResultIdentifier:EvaluationResult' :: EvaluationResult -> Maybe EvaluationResultIdentifier
$sel:configRuleInvokedTime:EvaluationResult' :: EvaluationResult -> Maybe POSIX
$sel:complianceType:EvaluationResult' :: EvaluationResult -> Maybe ComplianceType
$sel:annotation:EvaluationResult' :: EvaluationResult -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
annotation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ComplianceType
complianceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
configRuleInvokedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EvaluationResultIdentifier
evaluationResultIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
resultRecordedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resultToken