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

import Amazonka.Config.Types.ConfigRuleState
import Amazonka.Config.Types.MaximumExecutionFrequency
import Amazonka.Config.Types.Scope
import Amazonka.Config.Types.Source
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An Config rule represents an Lambda function that you create for a
-- custom rule or a predefined function for an Config managed rule. The
-- function evaluates configuration items to assess whether your Amazon Web
-- Services resources comply with your desired configurations. This
-- function can run when Config detects a configuration change to an Amazon
-- Web Services resource and at a periodic frequency that you choose (for
-- example, every 24 hours).
--
-- You can use the Amazon Web Services CLI and Amazon Web Services SDKs if
-- you want to create a rule that triggers evaluations for your resources
-- when Config delivers the configuration snapshot. For more information,
-- see ConfigSnapshotDeliveryProperties.
--
-- For more information about developing and using Config rules, see
-- <https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config.html Evaluating Amazon Web Services resource Configurations with Config>
-- in the /Config Developer Guide/.
--
-- /See:/ 'newConfigRule' smart constructor.
data ConfigRule = ConfigRule'
  { -- | A string, in JSON format, that is passed to the Config rule Lambda
    -- function.
    ConfigRule -> Maybe Text
inputParameters :: Prelude.Maybe Prelude.Text,
    -- | The name that you assign to the Config rule. The name is required if you
    -- are adding a new rule.
    ConfigRule -> Maybe Text
configRuleName :: Prelude.Maybe Prelude.Text,
    -- | Service principal name of the service that created the rule.
    --
    -- The field is populated only if the service linked rule is created by a
    -- service. The field is empty if you create your own rule.
    ConfigRule -> Maybe Text
createdBy :: Prelude.Maybe Prelude.Text,
    -- | The maximum frequency with which Config runs evaluations for a rule. You
    -- can specify a value for @MaximumExecutionFrequency@ when:
    --
    -- -   You are using an Config managed rule that is triggered at a periodic
    --     frequency.
    --
    -- -   Your custom rule is triggered when Config delivers the configuration
    --     snapshot. For more information, see
    --     ConfigSnapshotDeliveryProperties.
    --
    -- By default, rules with a periodic trigger are evaluated every 24 hours.
    -- To change the frequency, specify a valid value for the
    -- @MaximumExecutionFrequency@ parameter.
    ConfigRule -> Maybe MaximumExecutionFrequency
maximumExecutionFrequency :: Prelude.Maybe MaximumExecutionFrequency,
    -- | The ID of the Config rule.
    ConfigRule -> Maybe Text
configRuleId :: Prelude.Maybe Prelude.Text,
    -- | Defines which resources can trigger an evaluation for the rule. The
    -- scope can include one or more resource types, a combination of one
    -- resource type and one resource ID, or a combination of a tag key and
    -- value. Specify a scope to constrain the resources that can trigger an
    -- evaluation for the rule. If you do not specify a scope, evaluations are
    -- triggered when any resource in the recording group changes.
    --
    -- The scope can be empty.
    ConfigRule -> Maybe Scope
scope :: Prelude.Maybe Scope,
    -- | Indicates whether the Config rule is active or is currently being
    -- deleted by Config. It can also indicate the evaluation status for the
    -- Config rule.
    --
    -- Config sets the state of the rule to @EVALUATING@ temporarily after you
    -- use the @StartConfigRulesEvaluation@ request to evaluate your resources
    -- against the Config rule.
    --
    -- Config sets the state of the rule to @DELETING_RESULTS@ temporarily
    -- after you use the @DeleteEvaluationResults@ request to delete the
    -- current evaluation results for the Config rule.
    --
    -- Config temporarily sets the state of a rule to @DELETING@ after you use
    -- the @DeleteConfigRule@ request to delete the rule. After Config deletes
    -- the rule, the rule and all of its evaluations are erased and are no
    -- longer available.
    ConfigRule -> Maybe ConfigRuleState
configRuleState :: Prelude.Maybe ConfigRuleState,
    -- | The description that you provide for the Config rule.
    ConfigRule -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Config rule.
    ConfigRule -> Maybe Text
configRuleArn :: Prelude.Maybe Prelude.Text,
    -- | Provides the rule owner (Amazon Web Services or customer), the rule
    -- identifier, and the notifications that cause the function to evaluate
    -- your Amazon Web Services resources.
    ConfigRule -> Source
source :: Source
  }
  deriving (ConfigRule -> ConfigRule -> Bool
(ConfigRule -> ConfigRule -> Bool)
-> (ConfigRule -> ConfigRule -> Bool) -> Eq ConfigRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigRule -> ConfigRule -> Bool
$c/= :: ConfigRule -> ConfigRule -> Bool
== :: ConfigRule -> ConfigRule -> Bool
$c== :: ConfigRule -> ConfigRule -> Bool
Prelude.Eq, ReadPrec [ConfigRule]
ReadPrec ConfigRule
Int -> ReadS ConfigRule
ReadS [ConfigRule]
(Int -> ReadS ConfigRule)
-> ReadS [ConfigRule]
-> ReadPrec ConfigRule
-> ReadPrec [ConfigRule]
-> Read ConfigRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigRule]
$creadListPrec :: ReadPrec [ConfigRule]
readPrec :: ReadPrec ConfigRule
$creadPrec :: ReadPrec ConfigRule
readList :: ReadS [ConfigRule]
$creadList :: ReadS [ConfigRule]
readsPrec :: Int -> ReadS ConfigRule
$creadsPrec :: Int -> ReadS ConfigRule
Prelude.Read, Int -> ConfigRule -> ShowS
[ConfigRule] -> ShowS
ConfigRule -> String
(Int -> ConfigRule -> ShowS)
-> (ConfigRule -> String)
-> ([ConfigRule] -> ShowS)
-> Show ConfigRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigRule] -> ShowS
$cshowList :: [ConfigRule] -> ShowS
show :: ConfigRule -> String
$cshow :: ConfigRule -> String
showsPrec :: Int -> ConfigRule -> ShowS
$cshowsPrec :: Int -> ConfigRule -> ShowS
Prelude.Show, (forall x. ConfigRule -> Rep ConfigRule x)
-> (forall x. Rep ConfigRule x -> ConfigRule) -> Generic ConfigRule
forall x. Rep ConfigRule x -> ConfigRule
forall x. ConfigRule -> Rep ConfigRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfigRule x -> ConfigRule
$cfrom :: forall x. ConfigRule -> Rep ConfigRule x
Prelude.Generic)

-- |
-- Create a value of 'ConfigRule' 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:
--
-- 'inputParameters', 'configRule_inputParameters' - A string, in JSON format, that is passed to the Config rule Lambda
-- function.
--
-- 'configRuleName', 'configRule_configRuleName' - The name that you assign to the Config rule. The name is required if you
-- are adding a new rule.
--
-- 'createdBy', 'configRule_createdBy' - Service principal name of the service that created the rule.
--
-- The field is populated only if the service linked rule is created by a
-- service. The field is empty if you create your own rule.
--
-- 'maximumExecutionFrequency', 'configRule_maximumExecutionFrequency' - The maximum frequency with which Config runs evaluations for a rule. You
-- can specify a value for @MaximumExecutionFrequency@ when:
--
-- -   You are using an Config managed rule that is triggered at a periodic
--     frequency.
--
-- -   Your custom rule is triggered when Config delivers the configuration
--     snapshot. For more information, see
--     ConfigSnapshotDeliveryProperties.
--
-- By default, rules with a periodic trigger are evaluated every 24 hours.
-- To change the frequency, specify a valid value for the
-- @MaximumExecutionFrequency@ parameter.
--
-- 'configRuleId', 'configRule_configRuleId' - The ID of the Config rule.
--
-- 'scope', 'configRule_scope' - Defines which resources can trigger an evaluation for the rule. The
-- scope can include one or more resource types, a combination of one
-- resource type and one resource ID, or a combination of a tag key and
-- value. Specify a scope to constrain the resources that can trigger an
-- evaluation for the rule. If you do not specify a scope, evaluations are
-- triggered when any resource in the recording group changes.
--
-- The scope can be empty.
--
-- 'configRuleState', 'configRule_configRuleState' - Indicates whether the Config rule is active or is currently being
-- deleted by Config. It can also indicate the evaluation status for the
-- Config rule.
--
-- Config sets the state of the rule to @EVALUATING@ temporarily after you
-- use the @StartConfigRulesEvaluation@ request to evaluate your resources
-- against the Config rule.
--
-- Config sets the state of the rule to @DELETING_RESULTS@ temporarily
-- after you use the @DeleteEvaluationResults@ request to delete the
-- current evaluation results for the Config rule.
--
-- Config temporarily sets the state of a rule to @DELETING@ after you use
-- the @DeleteConfigRule@ request to delete the rule. After Config deletes
-- the rule, the rule and all of its evaluations are erased and are no
-- longer available.
--
-- 'description', 'configRule_description' - The description that you provide for the Config rule.
--
-- 'configRuleArn', 'configRule_configRuleArn' - The Amazon Resource Name (ARN) of the Config rule.
--
-- 'source', 'configRule_source' - Provides the rule owner (Amazon Web Services or customer), the rule
-- identifier, and the notifications that cause the function to evaluate
-- your Amazon Web Services resources.
newConfigRule ::
  -- | 'source'
  Source ->
  ConfigRule
newConfigRule :: Source -> ConfigRule
newConfigRule Source
pSource_ =
  ConfigRule' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe MaximumExecutionFrequency
-> Maybe Text
-> Maybe Scope
-> Maybe ConfigRuleState
-> Maybe Text
-> Maybe Text
-> Source
-> ConfigRule
ConfigRule'
    { $sel:inputParameters:ConfigRule' :: Maybe Text
inputParameters = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:configRuleName:ConfigRule' :: Maybe Text
configRuleName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdBy:ConfigRule' :: Maybe Text
createdBy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumExecutionFrequency:ConfigRule' :: Maybe MaximumExecutionFrequency
maximumExecutionFrequency = Maybe MaximumExecutionFrequency
forall a. Maybe a
Prelude.Nothing,
      $sel:configRuleId:ConfigRule' :: Maybe Text
configRuleId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scope:ConfigRule' :: Maybe Scope
scope = Maybe Scope
forall a. Maybe a
Prelude.Nothing,
      $sel:configRuleState:ConfigRule' :: Maybe ConfigRuleState
configRuleState = Maybe ConfigRuleState
forall a. Maybe a
Prelude.Nothing,
      $sel:description:ConfigRule' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:configRuleArn:ConfigRule' :: Maybe Text
configRuleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:source:ConfigRule' :: Source
source = Source
pSource_
    }

-- | A string, in JSON format, that is passed to the Config rule Lambda
-- function.
configRule_inputParameters :: Lens.Lens' ConfigRule (Prelude.Maybe Prelude.Text)
configRule_inputParameters :: (Maybe Text -> f (Maybe Text)) -> ConfigRule -> f ConfigRule
configRule_inputParameters = (ConfigRule -> Maybe Text)
-> (ConfigRule -> Maybe Text -> ConfigRule)
-> Lens ConfigRule ConfigRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigRule' {Maybe Text
inputParameters :: Maybe Text
$sel:inputParameters:ConfigRule' :: ConfigRule -> Maybe Text
inputParameters} -> Maybe Text
inputParameters) (\s :: ConfigRule
s@ConfigRule' {} Maybe Text
a -> ConfigRule
s {$sel:inputParameters:ConfigRule' :: Maybe Text
inputParameters = Maybe Text
a} :: ConfigRule)

-- | The name that you assign to the Config rule. The name is required if you
-- are adding a new rule.
configRule_configRuleName :: Lens.Lens' ConfigRule (Prelude.Maybe Prelude.Text)
configRule_configRuleName :: (Maybe Text -> f (Maybe Text)) -> ConfigRule -> f ConfigRule
configRule_configRuleName = (ConfigRule -> Maybe Text)
-> (ConfigRule -> Maybe Text -> ConfigRule)
-> Lens ConfigRule ConfigRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigRule' {Maybe Text
configRuleName :: Maybe Text
$sel:configRuleName:ConfigRule' :: ConfigRule -> Maybe Text
configRuleName} -> Maybe Text
configRuleName) (\s :: ConfigRule
s@ConfigRule' {} Maybe Text
a -> ConfigRule
s {$sel:configRuleName:ConfigRule' :: Maybe Text
configRuleName = Maybe Text
a} :: ConfigRule)

-- | Service principal name of the service that created the rule.
--
-- The field is populated only if the service linked rule is created by a
-- service. The field is empty if you create your own rule.
configRule_createdBy :: Lens.Lens' ConfigRule (Prelude.Maybe Prelude.Text)
configRule_createdBy :: (Maybe Text -> f (Maybe Text)) -> ConfigRule -> f ConfigRule
configRule_createdBy = (ConfigRule -> Maybe Text)
-> (ConfigRule -> Maybe Text -> ConfigRule)
-> Lens ConfigRule ConfigRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigRule' {Maybe Text
createdBy :: Maybe Text
$sel:createdBy:ConfigRule' :: ConfigRule -> Maybe Text
createdBy} -> Maybe Text
createdBy) (\s :: ConfigRule
s@ConfigRule' {} Maybe Text
a -> ConfigRule
s {$sel:createdBy:ConfigRule' :: Maybe Text
createdBy = Maybe Text
a} :: ConfigRule)

-- | The maximum frequency with which Config runs evaluations for a rule. You
-- can specify a value for @MaximumExecutionFrequency@ when:
--
-- -   You are using an Config managed rule that is triggered at a periodic
--     frequency.
--
-- -   Your custom rule is triggered when Config delivers the configuration
--     snapshot. For more information, see
--     ConfigSnapshotDeliveryProperties.
--
-- By default, rules with a periodic trigger are evaluated every 24 hours.
-- To change the frequency, specify a valid value for the
-- @MaximumExecutionFrequency@ parameter.
configRule_maximumExecutionFrequency :: Lens.Lens' ConfigRule (Prelude.Maybe MaximumExecutionFrequency)
configRule_maximumExecutionFrequency :: (Maybe MaximumExecutionFrequency
 -> f (Maybe MaximumExecutionFrequency))
-> ConfigRule -> f ConfigRule
configRule_maximumExecutionFrequency = (ConfigRule -> Maybe MaximumExecutionFrequency)
-> (ConfigRule -> Maybe MaximumExecutionFrequency -> ConfigRule)
-> Lens
     ConfigRule
     ConfigRule
     (Maybe MaximumExecutionFrequency)
     (Maybe MaximumExecutionFrequency)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigRule' {Maybe MaximumExecutionFrequency
maximumExecutionFrequency :: Maybe MaximumExecutionFrequency
$sel:maximumExecutionFrequency:ConfigRule' :: ConfigRule -> Maybe MaximumExecutionFrequency
maximumExecutionFrequency} -> Maybe MaximumExecutionFrequency
maximumExecutionFrequency) (\s :: ConfigRule
s@ConfigRule' {} Maybe MaximumExecutionFrequency
a -> ConfigRule
s {$sel:maximumExecutionFrequency:ConfigRule' :: Maybe MaximumExecutionFrequency
maximumExecutionFrequency = Maybe MaximumExecutionFrequency
a} :: ConfigRule)

-- | The ID of the Config rule.
configRule_configRuleId :: Lens.Lens' ConfigRule (Prelude.Maybe Prelude.Text)
configRule_configRuleId :: (Maybe Text -> f (Maybe Text)) -> ConfigRule -> f ConfigRule
configRule_configRuleId = (ConfigRule -> Maybe Text)
-> (ConfigRule -> Maybe Text -> ConfigRule)
-> Lens ConfigRule ConfigRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigRule' {Maybe Text
configRuleId :: Maybe Text
$sel:configRuleId:ConfigRule' :: ConfigRule -> Maybe Text
configRuleId} -> Maybe Text
configRuleId) (\s :: ConfigRule
s@ConfigRule' {} Maybe Text
a -> ConfigRule
s {$sel:configRuleId:ConfigRule' :: Maybe Text
configRuleId = Maybe Text
a} :: ConfigRule)

-- | Defines which resources can trigger an evaluation for the rule. The
-- scope can include one or more resource types, a combination of one
-- resource type and one resource ID, or a combination of a tag key and
-- value. Specify a scope to constrain the resources that can trigger an
-- evaluation for the rule. If you do not specify a scope, evaluations are
-- triggered when any resource in the recording group changes.
--
-- The scope can be empty.
configRule_scope :: Lens.Lens' ConfigRule (Prelude.Maybe Scope)
configRule_scope :: (Maybe Scope -> f (Maybe Scope)) -> ConfigRule -> f ConfigRule
configRule_scope = (ConfigRule -> Maybe Scope)
-> (ConfigRule -> Maybe Scope -> ConfigRule)
-> Lens ConfigRule ConfigRule (Maybe Scope) (Maybe Scope)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigRule' {Maybe Scope
scope :: Maybe Scope
$sel:scope:ConfigRule' :: ConfigRule -> Maybe Scope
scope} -> Maybe Scope
scope) (\s :: ConfigRule
s@ConfigRule' {} Maybe Scope
a -> ConfigRule
s {$sel:scope:ConfigRule' :: Maybe Scope
scope = Maybe Scope
a} :: ConfigRule)

-- | Indicates whether the Config rule is active or is currently being
-- deleted by Config. It can also indicate the evaluation status for the
-- Config rule.
--
-- Config sets the state of the rule to @EVALUATING@ temporarily after you
-- use the @StartConfigRulesEvaluation@ request to evaluate your resources
-- against the Config rule.
--
-- Config sets the state of the rule to @DELETING_RESULTS@ temporarily
-- after you use the @DeleteEvaluationResults@ request to delete the
-- current evaluation results for the Config rule.
--
-- Config temporarily sets the state of a rule to @DELETING@ after you use
-- the @DeleteConfigRule@ request to delete the rule. After Config deletes
-- the rule, the rule and all of its evaluations are erased and are no
-- longer available.
configRule_configRuleState :: Lens.Lens' ConfigRule (Prelude.Maybe ConfigRuleState)
configRule_configRuleState :: (Maybe ConfigRuleState -> f (Maybe ConfigRuleState))
-> ConfigRule -> f ConfigRule
configRule_configRuleState = (ConfigRule -> Maybe ConfigRuleState)
-> (ConfigRule -> Maybe ConfigRuleState -> ConfigRule)
-> Lens
     ConfigRule
     ConfigRule
     (Maybe ConfigRuleState)
     (Maybe ConfigRuleState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigRule' {Maybe ConfigRuleState
configRuleState :: Maybe ConfigRuleState
$sel:configRuleState:ConfigRule' :: ConfigRule -> Maybe ConfigRuleState
configRuleState} -> Maybe ConfigRuleState
configRuleState) (\s :: ConfigRule
s@ConfigRule' {} Maybe ConfigRuleState
a -> ConfigRule
s {$sel:configRuleState:ConfigRule' :: Maybe ConfigRuleState
configRuleState = Maybe ConfigRuleState
a} :: ConfigRule)

-- | The description that you provide for the Config rule.
configRule_description :: Lens.Lens' ConfigRule (Prelude.Maybe Prelude.Text)
configRule_description :: (Maybe Text -> f (Maybe Text)) -> ConfigRule -> f ConfigRule
configRule_description = (ConfigRule -> Maybe Text)
-> (ConfigRule -> Maybe Text -> ConfigRule)
-> Lens ConfigRule ConfigRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigRule' {Maybe Text
description :: Maybe Text
$sel:description:ConfigRule' :: ConfigRule -> Maybe Text
description} -> Maybe Text
description) (\s :: ConfigRule
s@ConfigRule' {} Maybe Text
a -> ConfigRule
s {$sel:description:ConfigRule' :: Maybe Text
description = Maybe Text
a} :: ConfigRule)

-- | The Amazon Resource Name (ARN) of the Config rule.
configRule_configRuleArn :: Lens.Lens' ConfigRule (Prelude.Maybe Prelude.Text)
configRule_configRuleArn :: (Maybe Text -> f (Maybe Text)) -> ConfigRule -> f ConfigRule
configRule_configRuleArn = (ConfigRule -> Maybe Text)
-> (ConfigRule -> Maybe Text -> ConfigRule)
-> Lens ConfigRule ConfigRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigRule' {Maybe Text
configRuleArn :: Maybe Text
$sel:configRuleArn:ConfigRule' :: ConfigRule -> Maybe Text
configRuleArn} -> Maybe Text
configRuleArn) (\s :: ConfigRule
s@ConfigRule' {} Maybe Text
a -> ConfigRule
s {$sel:configRuleArn:ConfigRule' :: Maybe Text
configRuleArn = Maybe Text
a} :: ConfigRule)

-- | Provides the rule owner (Amazon Web Services or customer), the rule
-- identifier, and the notifications that cause the function to evaluate
-- your Amazon Web Services resources.
configRule_source :: Lens.Lens' ConfigRule Source
configRule_source :: (Source -> f Source) -> ConfigRule -> f ConfigRule
configRule_source = (ConfigRule -> Source)
-> (ConfigRule -> Source -> ConfigRule)
-> Lens ConfigRule ConfigRule Source Source
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigRule' {Source
source :: Source
$sel:source:ConfigRule' :: ConfigRule -> Source
source} -> Source
source) (\s :: ConfigRule
s@ConfigRule' {} Source
a -> ConfigRule
s {$sel:source:ConfigRule' :: Source
source = Source
a} :: ConfigRule)

instance Core.FromJSON ConfigRule where
  parseJSON :: Value -> Parser ConfigRule
parseJSON =
    String
-> (Object -> Parser ConfigRule) -> Value -> Parser ConfigRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConfigRule"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe MaximumExecutionFrequency
-> Maybe Text
-> Maybe Scope
-> Maybe ConfigRuleState
-> Maybe Text
-> Maybe Text
-> Source
-> ConfigRule
ConfigRule'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe MaximumExecutionFrequency
 -> Maybe Text
 -> Maybe Scope
 -> Maybe ConfigRuleState
 -> Maybe Text
 -> Maybe Text
 -> Source
 -> ConfigRule)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe MaximumExecutionFrequency
      -> Maybe Text
      -> Maybe Scope
      -> Maybe ConfigRuleState
      -> Maybe Text
      -> Maybe Text
      -> Source
      -> ConfigRule)
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
"InputParameters")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe MaximumExecutionFrequency
   -> Maybe Text
   -> Maybe Scope
   -> Maybe ConfigRuleState
   -> Maybe Text
   -> Maybe Text
   -> Source
   -> ConfigRule)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe MaximumExecutionFrequency
      -> Maybe Text
      -> Maybe Scope
      -> Maybe ConfigRuleState
      -> Maybe Text
      -> Maybe Text
      -> Source
      -> ConfigRule)
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
"ConfigRuleName")
            Parser
  (Maybe Text
   -> Maybe MaximumExecutionFrequency
   -> Maybe Text
   -> Maybe Scope
   -> Maybe ConfigRuleState
   -> Maybe Text
   -> Maybe Text
   -> Source
   -> ConfigRule)
-> Parser (Maybe Text)
-> Parser
     (Maybe MaximumExecutionFrequency
      -> Maybe Text
      -> Maybe Scope
      -> Maybe ConfigRuleState
      -> Maybe Text
      -> Maybe Text
      -> Source
      -> ConfigRule)
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
"CreatedBy")
            Parser
  (Maybe MaximumExecutionFrequency
   -> Maybe Text
   -> Maybe Scope
   -> Maybe ConfigRuleState
   -> Maybe Text
   -> Maybe Text
   -> Source
   -> ConfigRule)
-> Parser (Maybe MaximumExecutionFrequency)
-> Parser
     (Maybe Text
      -> Maybe Scope
      -> Maybe ConfigRuleState
      -> Maybe Text
      -> Maybe Text
      -> Source
      -> ConfigRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MaximumExecutionFrequency)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaximumExecutionFrequency")
            Parser
  (Maybe Text
   -> Maybe Scope
   -> Maybe ConfigRuleState
   -> Maybe Text
   -> Maybe Text
   -> Source
   -> ConfigRule)
-> Parser (Maybe Text)
-> Parser
     (Maybe Scope
      -> Maybe ConfigRuleState
      -> Maybe Text
      -> Maybe Text
      -> Source
      -> ConfigRule)
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
"ConfigRuleId")
            Parser
  (Maybe Scope
   -> Maybe ConfigRuleState
   -> Maybe Text
   -> Maybe Text
   -> Source
   -> ConfigRule)
-> Parser (Maybe Scope)
-> Parser
     (Maybe ConfigRuleState
      -> Maybe Text -> Maybe Text -> Source -> ConfigRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Scope)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Scope")
            Parser
  (Maybe ConfigRuleState
   -> Maybe Text -> Maybe Text -> Source -> ConfigRule)
-> Parser (Maybe ConfigRuleState)
-> Parser (Maybe Text -> Maybe Text -> Source -> ConfigRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ConfigRuleState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConfigRuleState")
            Parser (Maybe Text -> Maybe Text -> Source -> ConfigRule)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Source -> ConfigRule)
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
"Description")
            Parser (Maybe Text -> Source -> ConfigRule)
-> Parser (Maybe Text) -> Parser (Source -> ConfigRule)
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
"ConfigRuleArn")
            Parser (Source -> ConfigRule) -> Parser Source -> Parser ConfigRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Source
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Source")
      )

instance Prelude.Hashable ConfigRule

instance Prelude.NFData ConfigRule

instance Core.ToJSON ConfigRule where
  toJSON :: ConfigRule -> Value
toJSON ConfigRule' {Maybe Text
Maybe ConfigRuleState
Maybe MaximumExecutionFrequency
Maybe Scope
Source
source :: Source
configRuleArn :: Maybe Text
description :: Maybe Text
configRuleState :: Maybe ConfigRuleState
scope :: Maybe Scope
configRuleId :: Maybe Text
maximumExecutionFrequency :: Maybe MaximumExecutionFrequency
createdBy :: Maybe Text
configRuleName :: Maybe Text
inputParameters :: Maybe Text
$sel:source:ConfigRule' :: ConfigRule -> Source
$sel:configRuleArn:ConfigRule' :: ConfigRule -> Maybe Text
$sel:description:ConfigRule' :: ConfigRule -> Maybe Text
$sel:configRuleState:ConfigRule' :: ConfigRule -> Maybe ConfigRuleState
$sel:scope:ConfigRule' :: ConfigRule -> Maybe Scope
$sel:configRuleId:ConfigRule' :: ConfigRule -> Maybe Text
$sel:maximumExecutionFrequency:ConfigRule' :: ConfigRule -> Maybe MaximumExecutionFrequency
$sel:createdBy:ConfigRule' :: ConfigRule -> Maybe Text
$sel:configRuleName:ConfigRule' :: ConfigRule -> Maybe Text
$sel:inputParameters:ConfigRule' :: ConfigRule -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"InputParameters" 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
inputParameters,
            (Text
"ConfigRuleName" 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
configRuleName,
            (Text
"CreatedBy" 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
createdBy,
            (Text
"MaximumExecutionFrequency" Text -> MaximumExecutionFrequency -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (MaximumExecutionFrequency -> Pair)
-> Maybe MaximumExecutionFrequency -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MaximumExecutionFrequency
maximumExecutionFrequency,
            (Text
"ConfigRuleId" 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
configRuleId,
            (Text
"Scope" Text -> Scope -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Scope -> Pair) -> Maybe Scope -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Scope
scope,
            (Text
"ConfigRuleState" Text -> ConfigRuleState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ConfigRuleState -> Pair) -> Maybe ConfigRuleState -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ConfigRuleState
configRuleState,
            (Text
"Description" 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
description,
            (Text
"ConfigRuleArn" 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
configRuleArn,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Source" Text -> Source -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Source
source)
          ]
      )