{-# 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.ExternalEvaluation
-- 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.ExternalEvaluation 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:/ 'newExternalEvaluation' smart constructor.
data ExternalEvaluation = ExternalEvaluation'
  { -- | Supplementary information about the reason of compliance. For example,
    -- this task was completed on a specific date.
    ExternalEvaluation -> Maybe Text
annotation :: Prelude.Maybe Prelude.Text,
    -- | The evaluated compliance resource type. Config accepts @AWS::::Account@
    -- resource type.
    ExternalEvaluation -> Text
complianceResourceType :: Prelude.Text,
    -- | The evaluated compliance resource ID. Config accepts only Amazon Web
    -- Services account ID.
    ExternalEvaluation -> Text
complianceResourceId :: Prelude.Text,
    -- | The compliance of the Amazon Web Services resource. The valid values are
    -- @COMPLIANT, NON_COMPLIANT, @ and @NOT_APPLICABLE@.
    ExternalEvaluation -> ComplianceType
complianceType :: ComplianceType,
    -- | The time when the compliance was recorded.
    ExternalEvaluation -> POSIX
orderingTimestamp :: Core.POSIX
  }
  deriving (ExternalEvaluation -> ExternalEvaluation -> Bool
(ExternalEvaluation -> ExternalEvaluation -> Bool)
-> (ExternalEvaluation -> ExternalEvaluation -> Bool)
-> Eq ExternalEvaluation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExternalEvaluation -> ExternalEvaluation -> Bool
$c/= :: ExternalEvaluation -> ExternalEvaluation -> Bool
== :: ExternalEvaluation -> ExternalEvaluation -> Bool
$c== :: ExternalEvaluation -> ExternalEvaluation -> Bool
Prelude.Eq, ReadPrec [ExternalEvaluation]
ReadPrec ExternalEvaluation
Int -> ReadS ExternalEvaluation
ReadS [ExternalEvaluation]
(Int -> ReadS ExternalEvaluation)
-> ReadS [ExternalEvaluation]
-> ReadPrec ExternalEvaluation
-> ReadPrec [ExternalEvaluation]
-> Read ExternalEvaluation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExternalEvaluation]
$creadListPrec :: ReadPrec [ExternalEvaluation]
readPrec :: ReadPrec ExternalEvaluation
$creadPrec :: ReadPrec ExternalEvaluation
readList :: ReadS [ExternalEvaluation]
$creadList :: ReadS [ExternalEvaluation]
readsPrec :: Int -> ReadS ExternalEvaluation
$creadsPrec :: Int -> ReadS ExternalEvaluation
Prelude.Read, Int -> ExternalEvaluation -> ShowS
[ExternalEvaluation] -> ShowS
ExternalEvaluation -> String
(Int -> ExternalEvaluation -> ShowS)
-> (ExternalEvaluation -> String)
-> ([ExternalEvaluation] -> ShowS)
-> Show ExternalEvaluation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExternalEvaluation] -> ShowS
$cshowList :: [ExternalEvaluation] -> ShowS
show :: ExternalEvaluation -> String
$cshow :: ExternalEvaluation -> String
showsPrec :: Int -> ExternalEvaluation -> ShowS
$cshowsPrec :: Int -> ExternalEvaluation -> ShowS
Prelude.Show, (forall x. ExternalEvaluation -> Rep ExternalEvaluation x)
-> (forall x. Rep ExternalEvaluation x -> ExternalEvaluation)
-> Generic ExternalEvaluation
forall x. Rep ExternalEvaluation x -> ExternalEvaluation
forall x. ExternalEvaluation -> Rep ExternalEvaluation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExternalEvaluation x -> ExternalEvaluation
$cfrom :: forall x. ExternalEvaluation -> Rep ExternalEvaluation x
Prelude.Generic)

-- |
-- Create a value of 'ExternalEvaluation' 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', 'externalEvaluation_annotation' - Supplementary information about the reason of compliance. For example,
-- this task was completed on a specific date.
--
-- 'complianceResourceType', 'externalEvaluation_complianceResourceType' - The evaluated compliance resource type. Config accepts @AWS::::Account@
-- resource type.
--
-- 'complianceResourceId', 'externalEvaluation_complianceResourceId' - The evaluated compliance resource ID. Config accepts only Amazon Web
-- Services account ID.
--
-- 'complianceType', 'externalEvaluation_complianceType' - The compliance of the Amazon Web Services resource. The valid values are
-- @COMPLIANT, NON_COMPLIANT, @ and @NOT_APPLICABLE@.
--
-- 'orderingTimestamp', 'externalEvaluation_orderingTimestamp' - The time when the compliance was recorded.
newExternalEvaluation ::
  -- | 'complianceResourceType'
  Prelude.Text ->
  -- | 'complianceResourceId'
  Prelude.Text ->
  -- | 'complianceType'
  ComplianceType ->
  -- | 'orderingTimestamp'
  Prelude.UTCTime ->
  ExternalEvaluation
newExternalEvaluation :: Text -> Text -> ComplianceType -> UTCTime -> ExternalEvaluation
newExternalEvaluation
  Text
pComplianceResourceType_
  Text
pComplianceResourceId_
  ComplianceType
pComplianceType_
  UTCTime
pOrderingTimestamp_ =
    ExternalEvaluation' :: Maybe Text
-> Text -> Text -> ComplianceType -> POSIX -> ExternalEvaluation
ExternalEvaluation'
      { $sel:annotation:ExternalEvaluation' :: Maybe Text
annotation = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:complianceResourceType:ExternalEvaluation' :: Text
complianceResourceType = Text
pComplianceResourceType_,
        $sel:complianceResourceId:ExternalEvaluation' :: Text
complianceResourceId = Text
pComplianceResourceId_,
        $sel:complianceType:ExternalEvaluation' :: ComplianceType
complianceType = ComplianceType
pComplianceType_,
        $sel:orderingTimestamp:ExternalEvaluation' :: 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 the reason of compliance. For example,
-- this task was completed on a specific date.
externalEvaluation_annotation :: Lens.Lens' ExternalEvaluation (Prelude.Maybe Prelude.Text)
externalEvaluation_annotation :: (Maybe Text -> f (Maybe Text))
-> ExternalEvaluation -> f ExternalEvaluation
externalEvaluation_annotation = (ExternalEvaluation -> Maybe Text)
-> (ExternalEvaluation -> Maybe Text -> ExternalEvaluation)
-> Lens
     ExternalEvaluation ExternalEvaluation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExternalEvaluation' {Maybe Text
annotation :: Maybe Text
$sel:annotation:ExternalEvaluation' :: ExternalEvaluation -> Maybe Text
annotation} -> Maybe Text
annotation) (\s :: ExternalEvaluation
s@ExternalEvaluation' {} Maybe Text
a -> ExternalEvaluation
s {$sel:annotation:ExternalEvaluation' :: Maybe Text
annotation = Maybe Text
a} :: ExternalEvaluation)

-- | The evaluated compliance resource type. Config accepts @AWS::::Account@
-- resource type.
externalEvaluation_complianceResourceType :: Lens.Lens' ExternalEvaluation Prelude.Text
externalEvaluation_complianceResourceType :: (Text -> f Text) -> ExternalEvaluation -> f ExternalEvaluation
externalEvaluation_complianceResourceType = (ExternalEvaluation -> Text)
-> (ExternalEvaluation -> Text -> ExternalEvaluation)
-> Lens ExternalEvaluation ExternalEvaluation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExternalEvaluation' {Text
complianceResourceType :: Text
$sel:complianceResourceType:ExternalEvaluation' :: ExternalEvaluation -> Text
complianceResourceType} -> Text
complianceResourceType) (\s :: ExternalEvaluation
s@ExternalEvaluation' {} Text
a -> ExternalEvaluation
s {$sel:complianceResourceType:ExternalEvaluation' :: Text
complianceResourceType = Text
a} :: ExternalEvaluation)

-- | The evaluated compliance resource ID. Config accepts only Amazon Web
-- Services account ID.
externalEvaluation_complianceResourceId :: Lens.Lens' ExternalEvaluation Prelude.Text
externalEvaluation_complianceResourceId :: (Text -> f Text) -> ExternalEvaluation -> f ExternalEvaluation
externalEvaluation_complianceResourceId = (ExternalEvaluation -> Text)
-> (ExternalEvaluation -> Text -> ExternalEvaluation)
-> Lens ExternalEvaluation ExternalEvaluation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExternalEvaluation' {Text
complianceResourceId :: Text
$sel:complianceResourceId:ExternalEvaluation' :: ExternalEvaluation -> Text
complianceResourceId} -> Text
complianceResourceId) (\s :: ExternalEvaluation
s@ExternalEvaluation' {} Text
a -> ExternalEvaluation
s {$sel:complianceResourceId:ExternalEvaluation' :: Text
complianceResourceId = Text
a} :: ExternalEvaluation)

-- | The compliance of the Amazon Web Services resource. The valid values are
-- @COMPLIANT, NON_COMPLIANT, @ and @NOT_APPLICABLE@.
externalEvaluation_complianceType :: Lens.Lens' ExternalEvaluation ComplianceType
externalEvaluation_complianceType :: (ComplianceType -> f ComplianceType)
-> ExternalEvaluation -> f ExternalEvaluation
externalEvaluation_complianceType = (ExternalEvaluation -> ComplianceType)
-> (ExternalEvaluation -> ComplianceType -> ExternalEvaluation)
-> Lens
     ExternalEvaluation ExternalEvaluation ComplianceType ComplianceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExternalEvaluation' {ComplianceType
complianceType :: ComplianceType
$sel:complianceType:ExternalEvaluation' :: ExternalEvaluation -> ComplianceType
complianceType} -> ComplianceType
complianceType) (\s :: ExternalEvaluation
s@ExternalEvaluation' {} ComplianceType
a -> ExternalEvaluation
s {$sel:complianceType:ExternalEvaluation' :: ComplianceType
complianceType = ComplianceType
a} :: ExternalEvaluation)

-- | The time when the compliance was recorded.
externalEvaluation_orderingTimestamp :: Lens.Lens' ExternalEvaluation Prelude.UTCTime
externalEvaluation_orderingTimestamp :: (UTCTime -> f UTCTime)
-> ExternalEvaluation -> f ExternalEvaluation
externalEvaluation_orderingTimestamp = (ExternalEvaluation -> POSIX)
-> (ExternalEvaluation -> POSIX -> ExternalEvaluation)
-> Lens ExternalEvaluation ExternalEvaluation POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExternalEvaluation' {POSIX
orderingTimestamp :: POSIX
$sel:orderingTimestamp:ExternalEvaluation' :: ExternalEvaluation -> POSIX
orderingTimestamp} -> POSIX
orderingTimestamp) (\s :: ExternalEvaluation
s@ExternalEvaluation' {} POSIX
a -> ExternalEvaluation
s {$sel:orderingTimestamp:ExternalEvaluation' :: POSIX
orderingTimestamp = POSIX
a} :: ExternalEvaluation) ((POSIX -> f POSIX) -> ExternalEvaluation -> f ExternalEvaluation)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ExternalEvaluation
-> f ExternalEvaluation
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 Prelude.Hashable ExternalEvaluation

instance Prelude.NFData ExternalEvaluation

instance Core.ToJSON ExternalEvaluation where
  toJSON :: ExternalEvaluation -> Value
toJSON ExternalEvaluation' {Maybe Text
Text
POSIX
ComplianceType
orderingTimestamp :: POSIX
complianceType :: ComplianceType
complianceResourceId :: Text
complianceResourceType :: Text
annotation :: Maybe Text
$sel:orderingTimestamp:ExternalEvaluation' :: ExternalEvaluation -> POSIX
$sel:complianceType:ExternalEvaluation' :: ExternalEvaluation -> ComplianceType
$sel:complianceResourceId:ExternalEvaluation' :: ExternalEvaluation -> Text
$sel:complianceResourceType:ExternalEvaluation' :: ExternalEvaluation -> Text
$sel:annotation:ExternalEvaluation' :: ExternalEvaluation -> 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)
          ]
      )