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

import Amazonka.Config.Types.ComplianceType
import Amazonka.Config.Types.EvaluationResultIdentifier
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | Uniquely identifies the evaluation result.
    EvaluationResult -> Maybe EvaluationResultIdentifier
evaluationResultIdentifier :: Prelude.Maybe EvaluationResultIdentifier,
    -- | Supplementary information about how the evaluation determined the
    -- compliance.
    EvaluationResult -> Maybe Text
annotation :: Prelude.Maybe Prelude.Text,
    -- | The time when the Config rule evaluated the Amazon Web Services
    -- resource.
    EvaluationResult -> Maybe POSIX
configRuleInvokedTime :: Prelude.Maybe Core.POSIX,
    -- | The time when Config recorded the evaluation result.
    EvaluationResult -> Maybe POSIX
resultRecordedTime :: Prelude.Maybe Core.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,
    -- | 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
  }
  deriving (EvaluationResult -> EvaluationResult -> Bool
(EvaluationResult -> EvaluationResult -> Bool)
-> (EvaluationResult -> EvaluationResult -> Bool)
-> Eq EvaluationResult
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]
(Int -> ReadS EvaluationResult)
-> ReadS [EvaluationResult]
-> ReadPrec EvaluationResult
-> ReadPrec [EvaluationResult]
-> Read 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
(Int -> EvaluationResult -> ShowS)
-> (EvaluationResult -> String)
-> ([EvaluationResult] -> ShowS)
-> Show EvaluationResult
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. EvaluationResult -> Rep EvaluationResult x)
-> (forall x. Rep EvaluationResult x -> EvaluationResult)
-> Generic EvaluationResult
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:
--
-- 'evaluationResultIdentifier', 'evaluationResult_evaluationResultIdentifier' - Uniquely identifies the evaluation result.
--
-- 'annotation', 'evaluationResult_annotation' - Supplementary information about how the evaluation determined the
-- compliance.
--
-- 'configRuleInvokedTime', 'evaluationResult_configRuleInvokedTime' - The time when the Config rule evaluated the Amazon Web Services
-- resource.
--
-- '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.
--
-- '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.
newEvaluationResult ::
  EvaluationResult
newEvaluationResult :: EvaluationResult
newEvaluationResult =
  EvaluationResult' :: Maybe EvaluationResultIdentifier
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe ComplianceType
-> EvaluationResult
EvaluationResult'
    { $sel:evaluationResultIdentifier:EvaluationResult' :: Maybe EvaluationResultIdentifier
evaluationResultIdentifier =
        Maybe EvaluationResultIdentifier
forall a. Maybe a
Prelude.Nothing,
      $sel:annotation:EvaluationResult' :: Maybe Text
annotation = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:configRuleInvokedTime:EvaluationResult' :: Maybe POSIX
configRuleInvokedTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:resultRecordedTime:EvaluationResult' :: Maybe POSIX
resultRecordedTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:resultToken:EvaluationResult' :: Maybe Text
resultToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:complianceType:EvaluationResult' :: Maybe ComplianceType
complianceType = Maybe ComplianceType
forall a. Maybe a
Prelude.Nothing
    }

-- | Uniquely identifies the evaluation result.
evaluationResult_evaluationResultIdentifier :: Lens.Lens' EvaluationResult (Prelude.Maybe EvaluationResultIdentifier)
evaluationResult_evaluationResultIdentifier :: (Maybe EvaluationResultIdentifier
 -> f (Maybe EvaluationResultIdentifier))
-> EvaluationResult -> f EvaluationResult
evaluationResult_evaluationResultIdentifier = (EvaluationResult -> Maybe EvaluationResultIdentifier)
-> (EvaluationResult
    -> Maybe EvaluationResultIdentifier -> EvaluationResult)
-> Lens
     EvaluationResult
     EvaluationResult
     (Maybe EvaluationResultIdentifier)
     (Maybe 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)

-- | Supplementary information about how the evaluation determined the
-- compliance.
evaluationResult_annotation :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.Text)
evaluationResult_annotation :: (Maybe Text -> f (Maybe Text))
-> EvaluationResult -> f EvaluationResult
evaluationResult_annotation = (EvaluationResult -> Maybe Text)
-> (EvaluationResult -> Maybe Text -> EvaluationResult)
-> Lens EvaluationResult EvaluationResult (Maybe Text) (Maybe Text)
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)

-- | The time when the Config rule evaluated the Amazon Web Services
-- resource.
evaluationResult_configRuleInvokedTime :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.UTCTime)
evaluationResult_configRuleInvokedTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> EvaluationResult -> f EvaluationResult
evaluationResult_configRuleInvokedTime = (EvaluationResult -> Maybe POSIX)
-> (EvaluationResult -> Maybe POSIX -> EvaluationResult)
-> Lens
     EvaluationResult EvaluationResult (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> EvaluationResult -> f EvaluationResult)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EvaluationResult
-> f EvaluationResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The time when Config recorded the evaluation result.
evaluationResult_resultRecordedTime :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.UTCTime)
evaluationResult_resultRecordedTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> EvaluationResult -> f EvaluationResult
evaluationResult_resultRecordedTime = (EvaluationResult -> Maybe POSIX)
-> (EvaluationResult -> Maybe POSIX -> EvaluationResult)
-> Lens
     EvaluationResult EvaluationResult (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> EvaluationResult -> f EvaluationResult)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EvaluationResult
-> f EvaluationResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._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 :: (Maybe Text -> f (Maybe Text))
-> EvaluationResult -> f EvaluationResult
evaluationResult_resultToken = (EvaluationResult -> Maybe Text)
-> (EvaluationResult -> Maybe Text -> EvaluationResult)
-> Lens EvaluationResult EvaluationResult (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe ComplianceType -> f (Maybe ComplianceType))
-> EvaluationResult -> f EvaluationResult
evaluationResult_complianceType = (EvaluationResult -> Maybe ComplianceType)
-> (EvaluationResult -> Maybe ComplianceType -> EvaluationResult)
-> Lens
     EvaluationResult
     EvaluationResult
     (Maybe ComplianceType)
     (Maybe 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)

instance Core.FromJSON EvaluationResult where
  parseJSON :: Value -> Parser EvaluationResult
parseJSON =
    String
-> (Object -> Parser EvaluationResult)
-> Value
-> Parser EvaluationResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EvaluationResult"
      ( \Object
x ->
          Maybe EvaluationResultIdentifier
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe ComplianceType
-> EvaluationResult
EvaluationResult'
            (Maybe EvaluationResultIdentifier
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe ComplianceType
 -> EvaluationResult)
-> Parser (Maybe EvaluationResultIdentifier)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe ComplianceType
      -> EvaluationResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EvaluationResultIdentifier)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EvaluationResultIdentifier")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe ComplianceType
   -> EvaluationResult)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe ComplianceType
      -> EvaluationResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Annotation")
            Parser
  (Maybe POSIX
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe ComplianceType
   -> EvaluationResult)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX
      -> Maybe Text -> Maybe ComplianceType -> EvaluationResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConfigRuleInvokedTime")
            Parser
  (Maybe POSIX
   -> Maybe Text -> Maybe ComplianceType -> EvaluationResult)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe ComplianceType -> EvaluationResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResultRecordedTime")
            Parser (Maybe Text -> Maybe ComplianceType -> EvaluationResult)
-> Parser (Maybe Text)
-> Parser (Maybe ComplianceType -> EvaluationResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResultToken")
            Parser (Maybe ComplianceType -> EvaluationResult)
-> Parser (Maybe ComplianceType) -> Parser EvaluationResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ComplianceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ComplianceType")
      )

instance Prelude.Hashable EvaluationResult

instance Prelude.NFData EvaluationResult