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

import Amazonka.Config.Types.ComplianceType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 :: Core.POSIX
  }
  deriving (Evaluation -> Evaluation -> Bool
(Evaluation -> Evaluation -> Bool)
-> (Evaluation -> Evaluation -> Bool) -> Eq Evaluation
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]
(Int -> ReadS Evaluation)
-> ReadS [Evaluation]
-> ReadPrec Evaluation
-> ReadPrec [Evaluation]
-> Read 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
(Int -> Evaluation -> ShowS)
-> (Evaluation -> String)
-> ([Evaluation] -> ShowS)
-> Show Evaluation
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. Evaluation -> Rep Evaluation x)
-> (forall x. Rep Evaluation x -> Evaluation) -> Generic Evaluation
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' :: Maybe Text -> Text -> Text -> ComplianceType -> POSIX -> Evaluation
Evaluation'
      { $sel:annotation:Evaluation' :: Maybe Text
annotation = Maybe Text
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 =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
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 :: (Maybe Text -> f (Maybe Text)) -> Evaluation -> f Evaluation
evaluation_annotation = (Evaluation -> Maybe Text)
-> (Evaluation -> Maybe Text -> Evaluation)
-> Lens Evaluation Evaluation (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> Evaluation -> f Evaluation
evaluation_complianceResourceType = (Evaluation -> Text)
-> (Evaluation -> Text -> Evaluation)
-> Lens Evaluation Evaluation Text Text
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 :: (Text -> f Text) -> Evaluation -> f Evaluation
evaluation_complianceResourceId = (Evaluation -> Text)
-> (Evaluation -> Text -> Evaluation)
-> Lens Evaluation Evaluation Text Text
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 :: (ComplianceType -> f ComplianceType) -> Evaluation -> f Evaluation
evaluation_complianceType = (Evaluation -> ComplianceType)
-> (Evaluation -> ComplianceType -> Evaluation)
-> Lens Evaluation Evaluation ComplianceType 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 :: (UTCTime -> f UTCTime) -> Evaluation -> f Evaluation
evaluation_orderingTimestamp = (Evaluation -> POSIX)
-> (Evaluation -> POSIX -> Evaluation)
-> Lens Evaluation Evaluation POSIX POSIX
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) ((POSIX -> f POSIX) -> Evaluation -> f Evaluation)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> Evaluation
-> f Evaluation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.Hashable Evaluation

instance Prelude.NFData Evaluation

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Annotation" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
annotation,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ComplianceResourceType"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
complianceResourceType
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ComplianceResourceId"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
complianceResourceId
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ComplianceType" Text -> ComplianceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ComplianceType
complianceType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"OrderingTimestamp" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
orderingTimestamp)
          ]
      )