{-# 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.CustomPolicyDetails
-- 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.CustomPolicyDetails 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

-- | Provides the runtime system, policy definition, and whether debug
-- logging enabled. You can specify the following CustomPolicyDetails
-- parameter values only for Config Custom Policy rules.
--
-- /See:/ 'newCustomPolicyDetails' smart constructor.
data CustomPolicyDetails = CustomPolicyDetails'
  { -- | The boolean expression for enabling debug logging for your Config Custom
    -- Policy rule. The default value is @false@.
    CustomPolicyDetails -> Maybe Bool
enableDebugLogDelivery :: Prelude.Maybe Prelude.Bool,
    -- | The runtime system for your Config Custom Policy rule. Guard is a
    -- policy-as-code language that allows you to write policies that are
    -- enforced by Config Custom Policy rules. For more information about
    -- Guard, see the
    -- <https://github.com/aws-cloudformation/cloudformation-guard Guard GitHub Repository>.
    CustomPolicyDetails -> Text
policyRuntime :: Prelude.Text,
    -- | The policy definition containing the logic for your Config Custom Policy
    -- rule.
    CustomPolicyDetails -> Text
policyText :: Prelude.Text
  }
  deriving (CustomPolicyDetails -> CustomPolicyDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomPolicyDetails -> CustomPolicyDetails -> Bool
$c/= :: CustomPolicyDetails -> CustomPolicyDetails -> Bool
== :: CustomPolicyDetails -> CustomPolicyDetails -> Bool
$c== :: CustomPolicyDetails -> CustomPolicyDetails -> Bool
Prelude.Eq, ReadPrec [CustomPolicyDetails]
ReadPrec CustomPolicyDetails
Int -> ReadS CustomPolicyDetails
ReadS [CustomPolicyDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomPolicyDetails]
$creadListPrec :: ReadPrec [CustomPolicyDetails]
readPrec :: ReadPrec CustomPolicyDetails
$creadPrec :: ReadPrec CustomPolicyDetails
readList :: ReadS [CustomPolicyDetails]
$creadList :: ReadS [CustomPolicyDetails]
readsPrec :: Int -> ReadS CustomPolicyDetails
$creadsPrec :: Int -> ReadS CustomPolicyDetails
Prelude.Read, Int -> CustomPolicyDetails -> ShowS
[CustomPolicyDetails] -> ShowS
CustomPolicyDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomPolicyDetails] -> ShowS
$cshowList :: [CustomPolicyDetails] -> ShowS
show :: CustomPolicyDetails -> String
$cshow :: CustomPolicyDetails -> String
showsPrec :: Int -> CustomPolicyDetails -> ShowS
$cshowsPrec :: Int -> CustomPolicyDetails -> ShowS
Prelude.Show, forall x. Rep CustomPolicyDetails x -> CustomPolicyDetails
forall x. CustomPolicyDetails -> Rep CustomPolicyDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomPolicyDetails x -> CustomPolicyDetails
$cfrom :: forall x. CustomPolicyDetails -> Rep CustomPolicyDetails x
Prelude.Generic)

-- |
-- Create a value of 'CustomPolicyDetails' 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:
--
-- 'enableDebugLogDelivery', 'customPolicyDetails_enableDebugLogDelivery' - The boolean expression for enabling debug logging for your Config Custom
-- Policy rule. The default value is @false@.
--
-- 'policyRuntime', 'customPolicyDetails_policyRuntime' - The runtime system for your Config Custom Policy rule. Guard is a
-- policy-as-code language that allows you to write policies that are
-- enforced by Config Custom Policy rules. For more information about
-- Guard, see the
-- <https://github.com/aws-cloudformation/cloudformation-guard Guard GitHub Repository>.
--
-- 'policyText', 'customPolicyDetails_policyText' - The policy definition containing the logic for your Config Custom Policy
-- rule.
newCustomPolicyDetails ::
  -- | 'policyRuntime'
  Prelude.Text ->
  -- | 'policyText'
  Prelude.Text ->
  CustomPolicyDetails
newCustomPolicyDetails :: Text -> Text -> CustomPolicyDetails
newCustomPolicyDetails Text
pPolicyRuntime_ Text
pPolicyText_ =
  CustomPolicyDetails'
    { $sel:enableDebugLogDelivery:CustomPolicyDetails' :: Maybe Bool
enableDebugLogDelivery =
        forall a. Maybe a
Prelude.Nothing,
      $sel:policyRuntime:CustomPolicyDetails' :: Text
policyRuntime = Text
pPolicyRuntime_,
      $sel:policyText:CustomPolicyDetails' :: Text
policyText = Text
pPolicyText_
    }

-- | The boolean expression for enabling debug logging for your Config Custom
-- Policy rule. The default value is @false@.
customPolicyDetails_enableDebugLogDelivery :: Lens.Lens' CustomPolicyDetails (Prelude.Maybe Prelude.Bool)
customPolicyDetails_enableDebugLogDelivery :: Lens' CustomPolicyDetails (Maybe Bool)
customPolicyDetails_enableDebugLogDelivery = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomPolicyDetails' {Maybe Bool
enableDebugLogDelivery :: Maybe Bool
$sel:enableDebugLogDelivery:CustomPolicyDetails' :: CustomPolicyDetails -> Maybe Bool
enableDebugLogDelivery} -> Maybe Bool
enableDebugLogDelivery) (\s :: CustomPolicyDetails
s@CustomPolicyDetails' {} Maybe Bool
a -> CustomPolicyDetails
s {$sel:enableDebugLogDelivery:CustomPolicyDetails' :: Maybe Bool
enableDebugLogDelivery = Maybe Bool
a} :: CustomPolicyDetails)

-- | The runtime system for your Config Custom Policy rule. Guard is a
-- policy-as-code language that allows you to write policies that are
-- enforced by Config Custom Policy rules. For more information about
-- Guard, see the
-- <https://github.com/aws-cloudformation/cloudformation-guard Guard GitHub Repository>.
customPolicyDetails_policyRuntime :: Lens.Lens' CustomPolicyDetails Prelude.Text
customPolicyDetails_policyRuntime :: Lens' CustomPolicyDetails Text
customPolicyDetails_policyRuntime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomPolicyDetails' {Text
policyRuntime :: Text
$sel:policyRuntime:CustomPolicyDetails' :: CustomPolicyDetails -> Text
policyRuntime} -> Text
policyRuntime) (\s :: CustomPolicyDetails
s@CustomPolicyDetails' {} Text
a -> CustomPolicyDetails
s {$sel:policyRuntime:CustomPolicyDetails' :: Text
policyRuntime = Text
a} :: CustomPolicyDetails)

-- | The policy definition containing the logic for your Config Custom Policy
-- rule.
customPolicyDetails_policyText :: Lens.Lens' CustomPolicyDetails Prelude.Text
customPolicyDetails_policyText :: Lens' CustomPolicyDetails Text
customPolicyDetails_policyText = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomPolicyDetails' {Text
policyText :: Text
$sel:policyText:CustomPolicyDetails' :: CustomPolicyDetails -> Text
policyText} -> Text
policyText) (\s :: CustomPolicyDetails
s@CustomPolicyDetails' {} Text
a -> CustomPolicyDetails
s {$sel:policyText:CustomPolicyDetails' :: Text
policyText = Text
a} :: CustomPolicyDetails)

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

instance Prelude.Hashable CustomPolicyDetails where
  hashWithSalt :: Int -> CustomPolicyDetails -> Int
hashWithSalt Int
_salt CustomPolicyDetails' {Maybe Bool
Text
policyText :: Text
policyRuntime :: Text
enableDebugLogDelivery :: Maybe Bool
$sel:policyText:CustomPolicyDetails' :: CustomPolicyDetails -> Text
$sel:policyRuntime:CustomPolicyDetails' :: CustomPolicyDetails -> Text
$sel:enableDebugLogDelivery:CustomPolicyDetails' :: CustomPolicyDetails -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enableDebugLogDelivery
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyRuntime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyText

instance Prelude.NFData CustomPolicyDetails where
  rnf :: CustomPolicyDetails -> ()
rnf CustomPolicyDetails' {Maybe Bool
Text
policyText :: Text
policyRuntime :: Text
enableDebugLogDelivery :: Maybe Bool
$sel:policyText:CustomPolicyDetails' :: CustomPolicyDetails -> Text
$sel:policyRuntime:CustomPolicyDetails' :: CustomPolicyDetails -> Text
$sel:enableDebugLogDelivery:CustomPolicyDetails' :: CustomPolicyDetails -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enableDebugLogDelivery
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
policyRuntime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
policyText

instance Data.ToJSON CustomPolicyDetails where
  toJSON :: CustomPolicyDetails -> Value
toJSON CustomPolicyDetails' {Maybe Bool
Text
policyText :: Text
policyRuntime :: Text
enableDebugLogDelivery :: Maybe Bool
$sel:policyText:CustomPolicyDetails' :: CustomPolicyDetails -> Text
$sel:policyRuntime:CustomPolicyDetails' :: CustomPolicyDetails -> Text
$sel:enableDebugLogDelivery:CustomPolicyDetails' :: CustomPolicyDetails -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EnableDebugLogDelivery" 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 Bool
enableDebugLogDelivery,
            forall a. a -> Maybe a
Prelude.Just (Key
"PolicyRuntime" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
policyRuntime),
            forall a. a -> Maybe a
Prelude.Just (Key
"PolicyText" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
policyText)
          ]
      )