{-# 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.WAFRegional.Types.ExcludedRule
-- 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.WAFRegional.Types.ExcludedRule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | This is __AWS WAF Classic__ documentation. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html AWS WAF Classic>
-- in the developer guide.
--
-- __For the latest version of AWS WAF__, use the AWS WAFV2 API and see the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html AWS WAF Developer Guide>.
-- With the latest version, AWS WAF has a single set of endpoints for
-- regional and global use.
--
-- The rule to exclude from a rule group. This is applicable only when the
-- @ActivatedRule@ refers to a @RuleGroup@. The rule must belong to the
-- @RuleGroup@ that is specified by the @ActivatedRule@.
--
-- /See:/ 'newExcludedRule' smart constructor.
data ExcludedRule = ExcludedRule'
  { -- | The unique identifier for the rule to exclude from the rule group.
    ExcludedRule -> Text
ruleId :: Prelude.Text
  }
  deriving (ExcludedRule -> ExcludedRule -> Bool
(ExcludedRule -> ExcludedRule -> Bool)
-> (ExcludedRule -> ExcludedRule -> Bool) -> Eq ExcludedRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExcludedRule -> ExcludedRule -> Bool
$c/= :: ExcludedRule -> ExcludedRule -> Bool
== :: ExcludedRule -> ExcludedRule -> Bool
$c== :: ExcludedRule -> ExcludedRule -> Bool
Prelude.Eq, ReadPrec [ExcludedRule]
ReadPrec ExcludedRule
Int -> ReadS ExcludedRule
ReadS [ExcludedRule]
(Int -> ReadS ExcludedRule)
-> ReadS [ExcludedRule]
-> ReadPrec ExcludedRule
-> ReadPrec [ExcludedRule]
-> Read ExcludedRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExcludedRule]
$creadListPrec :: ReadPrec [ExcludedRule]
readPrec :: ReadPrec ExcludedRule
$creadPrec :: ReadPrec ExcludedRule
readList :: ReadS [ExcludedRule]
$creadList :: ReadS [ExcludedRule]
readsPrec :: Int -> ReadS ExcludedRule
$creadsPrec :: Int -> ReadS ExcludedRule
Prelude.Read, Int -> ExcludedRule -> ShowS
[ExcludedRule] -> ShowS
ExcludedRule -> String
(Int -> ExcludedRule -> ShowS)
-> (ExcludedRule -> String)
-> ([ExcludedRule] -> ShowS)
-> Show ExcludedRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExcludedRule] -> ShowS
$cshowList :: [ExcludedRule] -> ShowS
show :: ExcludedRule -> String
$cshow :: ExcludedRule -> String
showsPrec :: Int -> ExcludedRule -> ShowS
$cshowsPrec :: Int -> ExcludedRule -> ShowS
Prelude.Show, (forall x. ExcludedRule -> Rep ExcludedRule x)
-> (forall x. Rep ExcludedRule x -> ExcludedRule)
-> Generic ExcludedRule
forall x. Rep ExcludedRule x -> ExcludedRule
forall x. ExcludedRule -> Rep ExcludedRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExcludedRule x -> ExcludedRule
$cfrom :: forall x. ExcludedRule -> Rep ExcludedRule x
Prelude.Generic)

-- |
-- Create a value of 'ExcludedRule' 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:
--
-- 'ruleId', 'excludedRule_ruleId' - The unique identifier for the rule to exclude from the rule group.
newExcludedRule ::
  -- | 'ruleId'
  Prelude.Text ->
  ExcludedRule
newExcludedRule :: Text -> ExcludedRule
newExcludedRule Text
pRuleId_ =
  ExcludedRule' :: Text -> ExcludedRule
ExcludedRule' {$sel:ruleId:ExcludedRule' :: Text
ruleId = Text
pRuleId_}

-- | The unique identifier for the rule to exclude from the rule group.
excludedRule_ruleId :: Lens.Lens' ExcludedRule Prelude.Text
excludedRule_ruleId :: (Text -> f Text) -> ExcludedRule -> f ExcludedRule
excludedRule_ruleId = (ExcludedRule -> Text)
-> (ExcludedRule -> Text -> ExcludedRule)
-> Lens ExcludedRule ExcludedRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExcludedRule' {Text
ruleId :: Text
$sel:ruleId:ExcludedRule' :: ExcludedRule -> Text
ruleId} -> Text
ruleId) (\s :: ExcludedRule
s@ExcludedRule' {} Text
a -> ExcludedRule
s {$sel:ruleId:ExcludedRule' :: Text
ruleId = Text
a} :: ExcludedRule)

instance Core.FromJSON ExcludedRule where
  parseJSON :: Value -> Parser ExcludedRule
parseJSON =
    String
-> (Object -> Parser ExcludedRule) -> Value -> Parser ExcludedRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExcludedRule"
      ( \Object
x ->
          Text -> ExcludedRule
ExcludedRule' (Text -> ExcludedRule) -> Parser Text -> Parser ExcludedRule
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RuleId")
      )

instance Prelude.Hashable ExcludedRule

instance Prelude.NFData ExcludedRule

instance Core.ToJSON ExcludedRule where
  toJSON :: ExcludedRule -> Value
toJSON ExcludedRule' {Text
ruleId :: Text
$sel:ruleId:ExcludedRule' :: ExcludedRule -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RuleId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
ruleId)]
      )