{-# 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.WAF.Types.RuleGroup
-- 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.WAF.Types.RuleGroup 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.
--
-- A collection of predefined rules that you can add to a web ACL.
--
-- Rule groups are subject to the following limits:
--
-- -   Three rule groups per account. You can request an increase to this
--     limit by contacting customer support.
--
-- -   One rule group per web ACL.
--
-- -   Ten rules per rule group.
--
-- /See:/ 'newRuleGroup' smart constructor.
data RuleGroup = RuleGroup'
  { -- | A friendly name or description for the metrics for this @RuleGroup@. The
    -- name can contain only alphanumeric characters (A-Z, a-z, 0-9), with
    -- maximum length 128 and minimum length one. It can\'t contain whitespace
    -- or metric names reserved for AWS WAF, including \"All\" and
    -- \"Default_Action.\" You can\'t change the name of the metric after you
    -- create the @RuleGroup@.
    RuleGroup -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The friendly name or description for the @RuleGroup@. You can\'t change
    -- the name of a @RuleGroup@ after you create it.
    RuleGroup -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for a @RuleGroup@. You use @RuleGroupId@ to get more
    -- information about a @RuleGroup@ (see GetRuleGroup), update a @RuleGroup@
    -- (see UpdateRuleGroup), insert a @RuleGroup@ into a @WebACL@ or delete a
    -- one from a @WebACL@ (see UpdateWebACL), or delete a @RuleGroup@ from AWS
    -- WAF (see DeleteRuleGroup).
    --
    -- @RuleGroupId@ is returned by CreateRuleGroup and by ListRuleGroups.
    RuleGroup -> Text
ruleGroupId :: Prelude.Text
  }
  deriving (RuleGroup -> RuleGroup -> Bool
(RuleGroup -> RuleGroup -> Bool)
-> (RuleGroup -> RuleGroup -> Bool) -> Eq RuleGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleGroup -> RuleGroup -> Bool
$c/= :: RuleGroup -> RuleGroup -> Bool
== :: RuleGroup -> RuleGroup -> Bool
$c== :: RuleGroup -> RuleGroup -> Bool
Prelude.Eq, ReadPrec [RuleGroup]
ReadPrec RuleGroup
Int -> ReadS RuleGroup
ReadS [RuleGroup]
(Int -> ReadS RuleGroup)
-> ReadS [RuleGroup]
-> ReadPrec RuleGroup
-> ReadPrec [RuleGroup]
-> Read RuleGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleGroup]
$creadListPrec :: ReadPrec [RuleGroup]
readPrec :: ReadPrec RuleGroup
$creadPrec :: ReadPrec RuleGroup
readList :: ReadS [RuleGroup]
$creadList :: ReadS [RuleGroup]
readsPrec :: Int -> ReadS RuleGroup
$creadsPrec :: Int -> ReadS RuleGroup
Prelude.Read, Int -> RuleGroup -> ShowS
[RuleGroup] -> ShowS
RuleGroup -> String
(Int -> RuleGroup -> ShowS)
-> (RuleGroup -> String)
-> ([RuleGroup] -> ShowS)
-> Show RuleGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleGroup] -> ShowS
$cshowList :: [RuleGroup] -> ShowS
show :: RuleGroup -> String
$cshow :: RuleGroup -> String
showsPrec :: Int -> RuleGroup -> ShowS
$cshowsPrec :: Int -> RuleGroup -> ShowS
Prelude.Show, (forall x. RuleGroup -> Rep RuleGroup x)
-> (forall x. Rep RuleGroup x -> RuleGroup) -> Generic RuleGroup
forall x. Rep RuleGroup x -> RuleGroup
forall x. RuleGroup -> Rep RuleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleGroup x -> RuleGroup
$cfrom :: forall x. RuleGroup -> Rep RuleGroup x
Prelude.Generic)

-- |
-- Create a value of 'RuleGroup' 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:
--
-- 'metricName', 'ruleGroup_metricName' - A friendly name or description for the metrics for this @RuleGroup@. The
-- name can contain only alphanumeric characters (A-Z, a-z, 0-9), with
-- maximum length 128 and minimum length one. It can\'t contain whitespace
-- or metric names reserved for AWS WAF, including \"All\" and
-- \"Default_Action.\" You can\'t change the name of the metric after you
-- create the @RuleGroup@.
--
-- 'name', 'ruleGroup_name' - The friendly name or description for the @RuleGroup@. You can\'t change
-- the name of a @RuleGroup@ after you create it.
--
-- 'ruleGroupId', 'ruleGroup_ruleGroupId' - A unique identifier for a @RuleGroup@. You use @RuleGroupId@ to get more
-- information about a @RuleGroup@ (see GetRuleGroup), update a @RuleGroup@
-- (see UpdateRuleGroup), insert a @RuleGroup@ into a @WebACL@ or delete a
-- one from a @WebACL@ (see UpdateWebACL), or delete a @RuleGroup@ from AWS
-- WAF (see DeleteRuleGroup).
--
-- @RuleGroupId@ is returned by CreateRuleGroup and by ListRuleGroups.
newRuleGroup ::
  -- | 'ruleGroupId'
  Prelude.Text ->
  RuleGroup
newRuleGroup :: Text -> RuleGroup
newRuleGroup Text
pRuleGroupId_ =
  RuleGroup' :: Maybe Text -> Maybe Text -> Text -> RuleGroup
RuleGroup'
    { $sel:metricName:RuleGroup' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:RuleGroup' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleGroupId:RuleGroup' :: Text
ruleGroupId = Text
pRuleGroupId_
    }

-- | A friendly name or description for the metrics for this @RuleGroup@. The
-- name can contain only alphanumeric characters (A-Z, a-z, 0-9), with
-- maximum length 128 and minimum length one. It can\'t contain whitespace
-- or metric names reserved for AWS WAF, including \"All\" and
-- \"Default_Action.\" You can\'t change the name of the metric after you
-- create the @RuleGroup@.
ruleGroup_metricName :: Lens.Lens' RuleGroup (Prelude.Maybe Prelude.Text)
ruleGroup_metricName :: (Maybe Text -> f (Maybe Text)) -> RuleGroup -> f RuleGroup
ruleGroup_metricName = (RuleGroup -> Maybe Text)
-> (RuleGroup -> Maybe Text -> RuleGroup)
-> Lens RuleGroup RuleGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleGroup' {Maybe Text
metricName :: Maybe Text
$sel:metricName:RuleGroup' :: RuleGroup -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: RuleGroup
s@RuleGroup' {} Maybe Text
a -> RuleGroup
s {$sel:metricName:RuleGroup' :: Maybe Text
metricName = Maybe Text
a} :: RuleGroup)

-- | The friendly name or description for the @RuleGroup@. You can\'t change
-- the name of a @RuleGroup@ after you create it.
ruleGroup_name :: Lens.Lens' RuleGroup (Prelude.Maybe Prelude.Text)
ruleGroup_name :: (Maybe Text -> f (Maybe Text)) -> RuleGroup -> f RuleGroup
ruleGroup_name = (RuleGroup -> Maybe Text)
-> (RuleGroup -> Maybe Text -> RuleGroup)
-> Lens RuleGroup RuleGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleGroup' {Maybe Text
name :: Maybe Text
$sel:name:RuleGroup' :: RuleGroup -> Maybe Text
name} -> Maybe Text
name) (\s :: RuleGroup
s@RuleGroup' {} Maybe Text
a -> RuleGroup
s {$sel:name:RuleGroup' :: Maybe Text
name = Maybe Text
a} :: RuleGroup)

-- | A unique identifier for a @RuleGroup@. You use @RuleGroupId@ to get more
-- information about a @RuleGroup@ (see GetRuleGroup), update a @RuleGroup@
-- (see UpdateRuleGroup), insert a @RuleGroup@ into a @WebACL@ or delete a
-- one from a @WebACL@ (see UpdateWebACL), or delete a @RuleGroup@ from AWS
-- WAF (see DeleteRuleGroup).
--
-- @RuleGroupId@ is returned by CreateRuleGroup and by ListRuleGroups.
ruleGroup_ruleGroupId :: Lens.Lens' RuleGroup Prelude.Text
ruleGroup_ruleGroupId :: (Text -> f Text) -> RuleGroup -> f RuleGroup
ruleGroup_ruleGroupId = (RuleGroup -> Text)
-> (RuleGroup -> Text -> RuleGroup)
-> Lens RuleGroup RuleGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleGroup' {Text
ruleGroupId :: Text
$sel:ruleGroupId:RuleGroup' :: RuleGroup -> Text
ruleGroupId} -> Text
ruleGroupId) (\s :: RuleGroup
s@RuleGroup' {} Text
a -> RuleGroup
s {$sel:ruleGroupId:RuleGroup' :: Text
ruleGroupId = Text
a} :: RuleGroup)

instance Core.FromJSON RuleGroup where
  parseJSON :: Value -> Parser RuleGroup
parseJSON =
    String -> (Object -> Parser RuleGroup) -> Value -> Parser RuleGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RuleGroup"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> RuleGroup
RuleGroup'
            (Maybe Text -> Maybe Text -> Text -> RuleGroup)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Text -> RuleGroup)
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
"MetricName")
            Parser (Maybe Text -> Text -> RuleGroup)
-> Parser (Maybe Text) -> Parser (Text -> RuleGroup)
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
"Name")
            Parser (Text -> RuleGroup) -> Parser Text -> Parser RuleGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RuleGroupId")
      )

instance Prelude.Hashable RuleGroup

instance Prelude.NFData RuleGroup