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

import Amazonka.Config.Types.ComplianceType
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

-- | Identifies an Amazon Web Services resource and indicates whether it
-- complies with the Config rule that it was evaluated against.
--
-- /See:/ 'newEvaluation' smart constructor.
data Evaluation = Evaluation'
  { -- | Supplementary information about how the evaluation determined the
    -- compliance.
    Evaluation -> Maybe Text
annotation :: Prelude.Maybe Prelude.Text,
    -- | The type of Amazon Web Services resource that was evaluated.
    Evaluation -> Text
complianceResourceType :: Prelude.Text,
    -- | The ID of the Amazon Web Services resource that was evaluated.
    Evaluation -> Text
complianceResourceId :: Prelude.Text,
    -- | Indicates whether the Amazon Web Services resource complies with the
    -- Config rule that it was evaluated against.
    --
    -- For the @Evaluation@ data type, Config supports only the @COMPLIANT@,
    -- @NON_COMPLIANT@, and @NOT_APPLICABLE@ values. Config does not support
    -- the @INSUFFICIENT_DATA@ value for this data type.
    --
    -- Similarly, Config does not accept @INSUFFICIENT_DATA@ as the value for
    -- @ComplianceType@ from a @PutEvaluations@ request. For example, an Lambda
    -- function for a custom Config rule cannot pass an @INSUFFICIENT_DATA@
    -- value to Config.
    Evaluation -> ComplianceType
complianceType :: ComplianceType,
    -- | The time of the event in Config that triggered the evaluation. For
    -- event-based evaluations, the time indicates when Config created the
    -- configuration item that triggered the evaluation. For periodic
    -- evaluations, the time indicates when Config triggered the evaluation at
    -- the frequency that you specified (for example, every 24 hours).
    Evaluation -> POSIX
orderingTimestamp :: Data.POSIX
  }
  deriving (Evaluation -> Evaluation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Evaluation -> Evaluation -> Bool
$c/= :: Evaluation -> Evaluation -> Bool
== :: Evaluation -> Evaluation -> Bool
$c== :: Evaluation -> Evaluation -> Bool
Prelude.Eq, ReadPrec [Evaluation]
ReadPrec Evaluation
Int -> ReadS Evaluation
ReadS [Evaluation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Evaluation]
$creadListPrec :: ReadPrec [Evaluation]
readPrec :: ReadPrec Evaluation
$creadPrec :: ReadPrec Evaluation
readList :: ReadS [Evaluation]
$creadList :: ReadS [Evaluation]
readsPrec :: Int -> ReadS Evaluation
$creadsPrec :: Int -> ReadS Evaluation
Prelude.Read, Int -> Evaluation -> ShowS
[Evaluation] -> ShowS
Evaluation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Evaluation] -> ShowS
$cshowList :: [Evaluation] -> ShowS
show :: Evaluation -> String
$cshow :: Evaluation -> String
showsPrec :: Int -> Evaluation -> ShowS
$cshowsPrec :: Int -> Evaluation -> ShowS
Prelude.Show, forall x. Rep Evaluation x -> Evaluation
forall x. Evaluation -> Rep Evaluation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Evaluation x -> Evaluation
$cfrom :: forall x. Evaluation -> Rep Evaluation x
Prelude.Generic)

-- |
-- Create a value of 'Evaluation' 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', 'evaluation_annotation' - Supplementary information about how the evaluation determined the
-- compliance.
--
-- 'complianceResourceType', 'evaluation_complianceResourceType' - The type of Amazon Web Services resource that was evaluated.
--
-- 'complianceResourceId', 'evaluation_complianceResourceId' - The ID of the Amazon Web Services resource that was evaluated.
--
-- 'complianceType', 'evaluation_complianceType' - Indicates whether the Amazon Web Services resource complies with the
-- Config rule that it was evaluated against.
--
-- For the @Evaluation@ data type, Config supports only the @COMPLIANT@,
-- @NON_COMPLIANT@, and @NOT_APPLICABLE@ values. Config does not support
-- the @INSUFFICIENT_DATA@ value for this data type.
--
-- Similarly, Config does not accept @INSUFFICIENT_DATA@ as the value for
-- @ComplianceType@ from a @PutEvaluations@ request. For example, an Lambda
-- function for a custom Config rule cannot pass an @INSUFFICIENT_DATA@
-- value to Config.
--
-- 'orderingTimestamp', 'evaluation_orderingTimestamp' - The time of the event in Config that triggered the evaluation. For
-- event-based evaluations, the time indicates when Config created the
-- configuration item that triggered the evaluation. For periodic
-- evaluations, the time indicates when Config triggered the evaluation at
-- the frequency that you specified (for example, every 24 hours).
newEvaluation ::
  -- | 'complianceResourceType'
  Prelude.Text ->
  -- | 'complianceResourceId'
  Prelude.Text ->
  -- | 'complianceType'
  ComplianceType ->
  -- | 'orderingTimestamp'
  Prelude.UTCTime ->
  Evaluation
newEvaluation :: Text -> Text -> ComplianceType -> UTCTime -> Evaluation
newEvaluation
  Text
pComplianceResourceType_
  Text
pComplianceResourceId_
  ComplianceType
pComplianceType_
  UTCTime
pOrderingTimestamp_ =
    Evaluation'
      { $sel:annotation:Evaluation' :: Maybe Text
annotation = forall a. Maybe a
Prelude.Nothing,
        $sel:complianceResourceType:Evaluation' :: Text
complianceResourceType = Text
pComplianceResourceType_,
        $sel:complianceResourceId:Evaluation' :: Text
complianceResourceId = Text
pComplianceResourceId_,
        $sel:complianceType:Evaluation' :: ComplianceType
complianceType = ComplianceType
pComplianceType_,
        $sel:orderingTimestamp:Evaluation' :: POSIX
orderingTimestamp =
          forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pOrderingTimestamp_
      }

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

-- | The type of Amazon Web Services resource that was evaluated.
evaluation_complianceResourceType :: Lens.Lens' Evaluation Prelude.Text
evaluation_complianceResourceType :: Lens' Evaluation Text
evaluation_complianceResourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Evaluation' {Text
complianceResourceType :: Text
$sel:complianceResourceType:Evaluation' :: Evaluation -> Text
complianceResourceType} -> Text
complianceResourceType) (\s :: Evaluation
s@Evaluation' {} Text
a -> Evaluation
s {$sel:complianceResourceType:Evaluation' :: Text
complianceResourceType = Text
a} :: Evaluation)

-- | The ID of the Amazon Web Services resource that was evaluated.
evaluation_complianceResourceId :: Lens.Lens' Evaluation Prelude.Text
evaluation_complianceResourceId :: Lens' Evaluation Text
evaluation_complianceResourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Evaluation' {Text
complianceResourceId :: Text
$sel:complianceResourceId:Evaluation' :: Evaluation -> Text
complianceResourceId} -> Text
complianceResourceId) (\s :: Evaluation
s@Evaluation' {} Text
a -> Evaluation
s {$sel:complianceResourceId:Evaluation' :: Text
complianceResourceId = Text
a} :: Evaluation)

-- | Indicates whether the Amazon Web Services resource complies with the
-- Config rule that it was evaluated against.
--
-- For the @Evaluation@ data type, Config supports only the @COMPLIANT@,
-- @NON_COMPLIANT@, and @NOT_APPLICABLE@ values. Config does not support
-- the @INSUFFICIENT_DATA@ value for this data type.
--
-- Similarly, Config does not accept @INSUFFICIENT_DATA@ as the value for
-- @ComplianceType@ from a @PutEvaluations@ request. For example, an Lambda
-- function for a custom Config rule cannot pass an @INSUFFICIENT_DATA@
-- value to Config.
evaluation_complianceType :: Lens.Lens' Evaluation ComplianceType
evaluation_complianceType :: Lens' Evaluation ComplianceType
evaluation_complianceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Evaluation' {ComplianceType
complianceType :: ComplianceType
$sel:complianceType:Evaluation' :: Evaluation -> ComplianceType
complianceType} -> ComplianceType
complianceType) (\s :: Evaluation
s@Evaluation' {} ComplianceType
a -> Evaluation
s {$sel:complianceType:Evaluation' :: ComplianceType
complianceType = ComplianceType
a} :: Evaluation)

-- | The time of the event in Config that triggered the evaluation. For
-- event-based evaluations, the time indicates when Config created the
-- configuration item that triggered the evaluation. For periodic
-- evaluations, the time indicates when Config triggered the evaluation at
-- the frequency that you specified (for example, every 24 hours).
evaluation_orderingTimestamp :: Lens.Lens' Evaluation Prelude.UTCTime
evaluation_orderingTimestamp :: Lens' Evaluation UTCTime
evaluation_orderingTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Evaluation' {POSIX
orderingTimestamp :: POSIX
$sel:orderingTimestamp:Evaluation' :: Evaluation -> POSIX
orderingTimestamp} -> POSIX
orderingTimestamp) (\s :: Evaluation
s@Evaluation' {} POSIX
a -> Evaluation
s {$sel:orderingTimestamp:Evaluation' :: POSIX
orderingTimestamp = POSIX
a} :: Evaluation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON Evaluation where
  parseJSON :: Value -> Parser Evaluation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Evaluation"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> ComplianceType -> POSIX -> Evaluation
Evaluation'
            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 a
Data..: Key
"ComplianceResourceType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ComplianceResourceId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"OrderingTimestamp")
      )

instance Prelude.Hashable Evaluation where
  hashWithSalt :: Int -> Evaluation -> Int
hashWithSalt Int
_salt Evaluation' {Maybe Text
Text
POSIX
ComplianceType
orderingTimestamp :: POSIX
complianceType :: ComplianceType
complianceResourceId :: Text
complianceResourceType :: Text
annotation :: Maybe Text
$sel:orderingTimestamp:Evaluation' :: Evaluation -> POSIX
$sel:complianceType:Evaluation' :: Evaluation -> ComplianceType
$sel:complianceResourceId:Evaluation' :: Evaluation -> Text
$sel:complianceResourceType:Evaluation' :: Evaluation -> Text
$sel:annotation:Evaluation' :: Evaluation -> 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` Text
complianceResourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
complianceResourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ComplianceType
complianceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
orderingTimestamp

instance Prelude.NFData Evaluation where
  rnf :: Evaluation -> ()
rnf Evaluation' {Maybe Text
Text
POSIX
ComplianceType
orderingTimestamp :: POSIX
complianceType :: ComplianceType
complianceResourceId :: Text
complianceResourceType :: Text
annotation :: Maybe Text
$sel:orderingTimestamp:Evaluation' :: Evaluation -> POSIX
$sel:complianceType:Evaluation' :: Evaluation -> ComplianceType
$sel:complianceResourceId:Evaluation' :: Evaluation -> Text
$sel:complianceResourceType:Evaluation' :: Evaluation -> Text
$sel:annotation:Evaluation' :: Evaluation -> 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 Text
complianceResourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
complianceResourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ComplianceType
complianceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
orderingTimestamp

instance Data.ToJSON Evaluation where
  toJSON :: Evaluation -> Value
toJSON Evaluation' {Maybe Text
Text
POSIX
ComplianceType
orderingTimestamp :: POSIX
complianceType :: ComplianceType
complianceResourceId :: Text
complianceResourceType :: Text
annotation :: Maybe Text
$sel:orderingTimestamp:Evaluation' :: Evaluation -> POSIX
$sel:complianceType:Evaluation' :: Evaluation -> ComplianceType
$sel:complianceResourceId:Evaluation' :: Evaluation -> Text
$sel:complianceResourceType:Evaluation' :: Evaluation -> Text
$sel:annotation:Evaluation' :: Evaluation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Annotation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
annotation,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"ComplianceResourceType"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
complianceResourceType
              ),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"ComplianceResourceId"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
complianceResourceId
              ),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ComplianceType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ComplianceType
complianceType),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"OrderingTimestamp" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= POSIX
orderingTimestamp)
          ]
      )