{-# 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.RuleSummary
-- 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.RuleSummary 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
import Amazonka.WAFV2.Types.RuleAction

-- | High-level information about a Rule, returned by operations like
-- DescribeManagedRuleGroup. This provides information like the ID, that
-- you can use to retrieve and manage a @RuleGroup@, and the ARN, that you
-- provide to the RuleGroupReferenceStatement to use the rule group in a
-- Rule.
--
-- /See:/ 'newRuleSummary' smart constructor.
data RuleSummary = RuleSummary'
  { -- | The action that WAF should take on a web request when it matches a
    -- rule\'s statement. Settings at the web ACL level can override the rule
    -- action setting.
    RuleSummary -> Maybe RuleAction
action :: Prelude.Maybe RuleAction,
    -- | The name of the rule.
    RuleSummary -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (RuleSummary -> RuleSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleSummary -> RuleSummary -> Bool
$c/= :: RuleSummary -> RuleSummary -> Bool
== :: RuleSummary -> RuleSummary -> Bool
$c== :: RuleSummary -> RuleSummary -> Bool
Prelude.Eq, ReadPrec [RuleSummary]
ReadPrec RuleSummary
Int -> ReadS RuleSummary
ReadS [RuleSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleSummary]
$creadListPrec :: ReadPrec [RuleSummary]
readPrec :: ReadPrec RuleSummary
$creadPrec :: ReadPrec RuleSummary
readList :: ReadS [RuleSummary]
$creadList :: ReadS [RuleSummary]
readsPrec :: Int -> ReadS RuleSummary
$creadsPrec :: Int -> ReadS RuleSummary
Prelude.Read, Int -> RuleSummary -> ShowS
[RuleSummary] -> ShowS
RuleSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleSummary] -> ShowS
$cshowList :: [RuleSummary] -> ShowS
show :: RuleSummary -> String
$cshow :: RuleSummary -> String
showsPrec :: Int -> RuleSummary -> ShowS
$cshowsPrec :: Int -> RuleSummary -> ShowS
Prelude.Show, forall x. Rep RuleSummary x -> RuleSummary
forall x. RuleSummary -> Rep RuleSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleSummary x -> RuleSummary
$cfrom :: forall x. RuleSummary -> Rep RuleSummary x
Prelude.Generic)

-- |
-- Create a value of 'RuleSummary' 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:
--
-- 'action', 'ruleSummary_action' - The action that WAF should take on a web request when it matches a
-- rule\'s statement. Settings at the web ACL level can override the rule
-- action setting.
--
-- 'name', 'ruleSummary_name' - The name of the rule.
newRuleSummary ::
  RuleSummary
newRuleSummary :: RuleSummary
newRuleSummary =
  RuleSummary'
    { $sel:action:RuleSummary' :: Maybe RuleAction
action = forall a. Maybe a
Prelude.Nothing,
      $sel:name:RuleSummary' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | The action that WAF should take on a web request when it matches a
-- rule\'s statement. Settings at the web ACL level can override the rule
-- action setting.
ruleSummary_action :: Lens.Lens' RuleSummary (Prelude.Maybe RuleAction)
ruleSummary_action :: Lens' RuleSummary (Maybe RuleAction)
ruleSummary_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {Maybe RuleAction
action :: Maybe RuleAction
$sel:action:RuleSummary' :: RuleSummary -> Maybe RuleAction
action} -> Maybe RuleAction
action) (\s :: RuleSummary
s@RuleSummary' {} Maybe RuleAction
a -> RuleSummary
s {$sel:action:RuleSummary' :: Maybe RuleAction
action = Maybe RuleAction
a} :: RuleSummary)

-- | The name of the rule.
ruleSummary_name :: Lens.Lens' RuleSummary (Prelude.Maybe Prelude.Text)
ruleSummary_name :: Lens' RuleSummary (Maybe Text)
ruleSummary_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleSummary' {Maybe Text
name :: Maybe Text
$sel:name:RuleSummary' :: RuleSummary -> Maybe Text
name} -> Maybe Text
name) (\s :: RuleSummary
s@RuleSummary' {} Maybe Text
a -> RuleSummary
s {$sel:name:RuleSummary' :: Maybe Text
name = Maybe Text
a} :: RuleSummary)

instance Data.FromJSON RuleSummary where
  parseJSON :: Value -> Parser RuleSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RuleSummary"
      ( \Object
x ->
          Maybe RuleAction -> Maybe Text -> RuleSummary
RuleSummary'
            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
"Action")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
      )

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

instance Prelude.NFData RuleSummary where
  rnf :: RuleSummary -> ()
rnf RuleSummary' {Maybe Text
Maybe RuleAction
name :: Maybe Text
action :: Maybe RuleAction
$sel:name:RuleSummary' :: RuleSummary -> Maybe Text
$sel:action:RuleSummary' :: RuleSummary -> Maybe RuleAction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RuleAction
action seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name