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

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

-- | Use EvaluationContext to group independently initiated proactive
-- resource evaluations. For example, CFN Stack. If you want to check just
-- a resource definition, you do not need to provide evaluation context.
--
-- /See:/ 'newEvaluationContext' smart constructor.
data EvaluationContext = EvaluationContext'
  { -- | A unique EvaluationContextIdentifier ID for an EvaluationContext.
    EvaluationContext -> Maybe Text
evaluationContextIdentifier :: Prelude.Maybe Prelude.Text
  }
  deriving (EvaluationContext -> EvaluationContext -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EvaluationContext -> EvaluationContext -> Bool
$c/= :: EvaluationContext -> EvaluationContext -> Bool
== :: EvaluationContext -> EvaluationContext -> Bool
$c== :: EvaluationContext -> EvaluationContext -> Bool
Prelude.Eq, ReadPrec [EvaluationContext]
ReadPrec EvaluationContext
Int -> ReadS EvaluationContext
ReadS [EvaluationContext]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EvaluationContext]
$creadListPrec :: ReadPrec [EvaluationContext]
readPrec :: ReadPrec EvaluationContext
$creadPrec :: ReadPrec EvaluationContext
readList :: ReadS [EvaluationContext]
$creadList :: ReadS [EvaluationContext]
readsPrec :: Int -> ReadS EvaluationContext
$creadsPrec :: Int -> ReadS EvaluationContext
Prelude.Read, Int -> EvaluationContext -> ShowS
[EvaluationContext] -> ShowS
EvaluationContext -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EvaluationContext] -> ShowS
$cshowList :: [EvaluationContext] -> ShowS
show :: EvaluationContext -> String
$cshow :: EvaluationContext -> String
showsPrec :: Int -> EvaluationContext -> ShowS
$cshowsPrec :: Int -> EvaluationContext -> ShowS
Prelude.Show, forall x. Rep EvaluationContext x -> EvaluationContext
forall x. EvaluationContext -> Rep EvaluationContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EvaluationContext x -> EvaluationContext
$cfrom :: forall x. EvaluationContext -> Rep EvaluationContext x
Prelude.Generic)

-- |
-- Create a value of 'EvaluationContext' 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:
--
-- 'evaluationContextIdentifier', 'evaluationContext_evaluationContextIdentifier' - A unique EvaluationContextIdentifier ID for an EvaluationContext.
newEvaluationContext ::
  EvaluationContext
newEvaluationContext :: EvaluationContext
newEvaluationContext =
  EvaluationContext'
    { $sel:evaluationContextIdentifier:EvaluationContext' :: Maybe Text
evaluationContextIdentifier =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A unique EvaluationContextIdentifier ID for an EvaluationContext.
evaluationContext_evaluationContextIdentifier :: Lens.Lens' EvaluationContext (Prelude.Maybe Prelude.Text)
evaluationContext_evaluationContextIdentifier :: Lens' EvaluationContext (Maybe Text)
evaluationContext_evaluationContextIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationContext' {Maybe Text
evaluationContextIdentifier :: Maybe Text
$sel:evaluationContextIdentifier:EvaluationContext' :: EvaluationContext -> Maybe Text
evaluationContextIdentifier} -> Maybe Text
evaluationContextIdentifier) (\s :: EvaluationContext
s@EvaluationContext' {} Maybe Text
a -> EvaluationContext
s {$sel:evaluationContextIdentifier:EvaluationContext' :: Maybe Text
evaluationContextIdentifier = Maybe Text
a} :: EvaluationContext)

instance Data.FromJSON EvaluationContext where
  parseJSON :: Value -> Parser EvaluationContext
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EvaluationContext"
      ( \Object
x ->
          Maybe Text -> EvaluationContext
EvaluationContext'
            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
"EvaluationContextIdentifier")
      )

instance Prelude.Hashable EvaluationContext where
  hashWithSalt :: Int -> EvaluationContext -> Int
hashWithSalt Int
_salt EvaluationContext' {Maybe Text
evaluationContextIdentifier :: Maybe Text
$sel:evaluationContextIdentifier:EvaluationContext' :: EvaluationContext -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
evaluationContextIdentifier

instance Prelude.NFData EvaluationContext where
  rnf :: EvaluationContext -> ()
rnf EvaluationContext' {Maybe Text
evaluationContextIdentifier :: Maybe Text
$sel:evaluationContextIdentifier:EvaluationContext' :: EvaluationContext -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
evaluationContextIdentifier

instance Data.ToJSON EvaluationContext where
  toJSON :: EvaluationContext -> Value
toJSON EvaluationContext' {Maybe Text
evaluationContextIdentifier :: Maybe Text
$sel:evaluationContextIdentifier:EvaluationContext' :: EvaluationContext -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EvaluationContextIdentifier" 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
evaluationContextIdentifier
          ]
      )