{-# 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.RegexPatternSet
-- 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.WAF.Types.RegexPatternSet 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

-- | 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 @RegexPatternSet@ specifies the regular expression (regex) pattern
-- that you want AWS WAF to search for, such as @B[a\@]dB[o0]t@. You can
-- then configure AWS WAF to reject those requests.
--
-- /See:/ 'newRegexPatternSet' smart constructor.
data RegexPatternSet = RegexPatternSet'
  { -- | A friendly name or description of the RegexPatternSet. You can\'t change
    -- @Name@ after you create a @RegexPatternSet@.
    RegexPatternSet -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The identifier for the @RegexPatternSet@. You use @RegexPatternSetId@ to
    -- get information about a @RegexPatternSet@, update a @RegexPatternSet@,
    -- remove a @RegexPatternSet@ from a @RegexMatchSet@, and delete a
    -- @RegexPatternSet@ from AWS WAF.
    --
    -- @RegexMatchSetId@ is returned by CreateRegexPatternSet and by
    -- ListRegexPatternSets.
    RegexPatternSet -> Text
regexPatternSetId :: Prelude.Text,
    -- | Specifies the regular expression (regex) patterns that you want AWS WAF
    -- to search for, such as @B[a\@]dB[o0]t@.
    RegexPatternSet -> [Text]
regexPatternStrings :: [Prelude.Text]
  }
  deriving (RegexPatternSet -> RegexPatternSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegexPatternSet -> RegexPatternSet -> Bool
$c/= :: RegexPatternSet -> RegexPatternSet -> Bool
== :: RegexPatternSet -> RegexPatternSet -> Bool
$c== :: RegexPatternSet -> RegexPatternSet -> Bool
Prelude.Eq, ReadPrec [RegexPatternSet]
ReadPrec RegexPatternSet
Int -> ReadS RegexPatternSet
ReadS [RegexPatternSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegexPatternSet]
$creadListPrec :: ReadPrec [RegexPatternSet]
readPrec :: ReadPrec RegexPatternSet
$creadPrec :: ReadPrec RegexPatternSet
readList :: ReadS [RegexPatternSet]
$creadList :: ReadS [RegexPatternSet]
readsPrec :: Int -> ReadS RegexPatternSet
$creadsPrec :: Int -> ReadS RegexPatternSet
Prelude.Read, Int -> RegexPatternSet -> ShowS
[RegexPatternSet] -> ShowS
RegexPatternSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegexPatternSet] -> ShowS
$cshowList :: [RegexPatternSet] -> ShowS
show :: RegexPatternSet -> String
$cshow :: RegexPatternSet -> String
showsPrec :: Int -> RegexPatternSet -> ShowS
$cshowsPrec :: Int -> RegexPatternSet -> ShowS
Prelude.Show, forall x. Rep RegexPatternSet x -> RegexPatternSet
forall x. RegexPatternSet -> Rep RegexPatternSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegexPatternSet x -> RegexPatternSet
$cfrom :: forall x. RegexPatternSet -> Rep RegexPatternSet x
Prelude.Generic)

-- |
-- Create a value of 'RegexPatternSet' 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', 'regexPatternSet_name' - A friendly name or description of the RegexPatternSet. You can\'t change
-- @Name@ after you create a @RegexPatternSet@.
--
-- 'regexPatternSetId', 'regexPatternSet_regexPatternSetId' - The identifier for the @RegexPatternSet@. You use @RegexPatternSetId@ to
-- get information about a @RegexPatternSet@, update a @RegexPatternSet@,
-- remove a @RegexPatternSet@ from a @RegexMatchSet@, and delete a
-- @RegexPatternSet@ from AWS WAF.
--
-- @RegexMatchSetId@ is returned by CreateRegexPatternSet and by
-- ListRegexPatternSets.
--
-- 'regexPatternStrings', 'regexPatternSet_regexPatternStrings' - Specifies the regular expression (regex) patterns that you want AWS WAF
-- to search for, such as @B[a\@]dB[o0]t@.
newRegexPatternSet ::
  -- | 'regexPatternSetId'
  Prelude.Text ->
  RegexPatternSet
newRegexPatternSet :: Text -> RegexPatternSet
newRegexPatternSet Text
pRegexPatternSetId_ =
  RegexPatternSet'
    { $sel:name:RegexPatternSet' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:regexPatternSetId:RegexPatternSet' :: Text
regexPatternSetId = Text
pRegexPatternSetId_,
      $sel:regexPatternStrings:RegexPatternSet' :: [Text]
regexPatternStrings = forall a. Monoid a => a
Prelude.mempty
    }

-- | A friendly name or description of the RegexPatternSet. You can\'t change
-- @Name@ after you create a @RegexPatternSet@.
regexPatternSet_name :: Lens.Lens' RegexPatternSet (Prelude.Maybe Prelude.Text)
regexPatternSet_name :: Lens' RegexPatternSet (Maybe Text)
regexPatternSet_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexPatternSet' {Maybe Text
name :: Maybe Text
$sel:name:RegexPatternSet' :: RegexPatternSet -> Maybe Text
name} -> Maybe Text
name) (\s :: RegexPatternSet
s@RegexPatternSet' {} Maybe Text
a -> RegexPatternSet
s {$sel:name:RegexPatternSet' :: Maybe Text
name = Maybe Text
a} :: RegexPatternSet)

-- | The identifier for the @RegexPatternSet@. You use @RegexPatternSetId@ to
-- get information about a @RegexPatternSet@, update a @RegexPatternSet@,
-- remove a @RegexPatternSet@ from a @RegexMatchSet@, and delete a
-- @RegexPatternSet@ from AWS WAF.
--
-- @RegexMatchSetId@ is returned by CreateRegexPatternSet and by
-- ListRegexPatternSets.
regexPatternSet_regexPatternSetId :: Lens.Lens' RegexPatternSet Prelude.Text
regexPatternSet_regexPatternSetId :: Lens' RegexPatternSet Text
regexPatternSet_regexPatternSetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexPatternSet' {Text
regexPatternSetId :: Text
$sel:regexPatternSetId:RegexPatternSet' :: RegexPatternSet -> Text
regexPatternSetId} -> Text
regexPatternSetId) (\s :: RegexPatternSet
s@RegexPatternSet' {} Text
a -> RegexPatternSet
s {$sel:regexPatternSetId:RegexPatternSet' :: Text
regexPatternSetId = Text
a} :: RegexPatternSet)

-- | Specifies the regular expression (regex) patterns that you want AWS WAF
-- to search for, such as @B[a\@]dB[o0]t@.
regexPatternSet_regexPatternStrings :: Lens.Lens' RegexPatternSet [Prelude.Text]
regexPatternSet_regexPatternStrings :: Lens' RegexPatternSet [Text]
regexPatternSet_regexPatternStrings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexPatternSet' {[Text]
regexPatternStrings :: [Text]
$sel:regexPatternStrings:RegexPatternSet' :: RegexPatternSet -> [Text]
regexPatternStrings} -> [Text]
regexPatternStrings) (\s :: RegexPatternSet
s@RegexPatternSet' {} [Text]
a -> RegexPatternSet
s {$sel:regexPatternStrings:RegexPatternSet' :: [Text]
regexPatternStrings = [Text]
a} :: RegexPatternSet) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON RegexPatternSet where
  parseJSON :: Value -> Parser RegexPatternSet
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RegexPatternSet"
      ( \Object
x ->
          Maybe Text -> Text -> [Text] -> RegexPatternSet
RegexPatternSet'
            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
"Name")
            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
"RegexPatternSetId")
            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
"RegexPatternStrings"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable RegexPatternSet where
  hashWithSalt :: Int -> RegexPatternSet -> Int
hashWithSalt Int
_salt RegexPatternSet' {[Text]
Maybe Text
Text
regexPatternStrings :: [Text]
regexPatternSetId :: Text
name :: Maybe Text
$sel:regexPatternStrings:RegexPatternSet' :: RegexPatternSet -> [Text]
$sel:regexPatternSetId:RegexPatternSet' :: RegexPatternSet -> Text
$sel:name:RegexPatternSet' :: RegexPatternSet -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
regexPatternSetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
regexPatternStrings

instance Prelude.NFData RegexPatternSet where
  rnf :: RegexPatternSet -> ()
rnf RegexPatternSet' {[Text]
Maybe Text
Text
regexPatternStrings :: [Text]
regexPatternSetId :: Text
name :: Maybe Text
$sel:regexPatternStrings:RegexPatternSet' :: RegexPatternSet -> [Text]
$sel:regexPatternSetId:RegexPatternSet' :: RegexPatternSet -> Text
$sel:name:RegexPatternSet' :: RegexPatternSet -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
regexPatternSetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
regexPatternStrings