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

-- | Specifies a single rule in a rule group whose action you want to
-- override to @Count@.
--
-- Instead of this option, use @RuleActionOverrides@. It accepts any valid
-- action setting, including @Count@.
--
-- /See:/ 'newExcludedRule' smart constructor.
data ExcludedRule = ExcludedRule'
  { -- | The name of the rule whose action you want to override to @Count@.
    ExcludedRule -> Text
name :: Prelude.Text
  }
  deriving (ExcludedRule -> ExcludedRule -> Bool
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]
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
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. 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:
--
-- 'name', 'excludedRule_name' - The name of the rule whose action you want to override to @Count@.
newExcludedRule ::
  -- | 'name'
  Prelude.Text ->
  ExcludedRule
newExcludedRule :: Text -> ExcludedRule
newExcludedRule Text
pName_ = ExcludedRule' {$sel:name:ExcludedRule' :: Text
name = Text
pName_}

-- | The name of the rule whose action you want to override to @Count@.
excludedRule_name :: Lens.Lens' ExcludedRule Prelude.Text
excludedRule_name :: Lens' ExcludedRule Text
excludedRule_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExcludedRule' {Text
name :: Text
$sel:name:ExcludedRule' :: ExcludedRule -> Text
name} -> Text
name) (\s :: ExcludedRule
s@ExcludedRule' {} Text
a -> ExcludedRule
s {$sel:name:ExcludedRule' :: Text
name = Text
a} :: ExcludedRule)

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

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

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

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