{-# 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.RegexPatternSet
-- 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.RegexPatternSet 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 @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
(RegexPatternSet -> RegexPatternSet -> Bool)
-> (RegexPatternSet -> RegexPatternSet -> Bool)
-> Eq RegexPatternSet
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]
(Int -> ReadS RegexPatternSet)
-> ReadS [RegexPatternSet]
-> ReadPrec RegexPatternSet
-> ReadPrec [RegexPatternSet]
-> Read 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
(Int -> RegexPatternSet -> ShowS)
-> (RegexPatternSet -> String)
-> ([RegexPatternSet] -> ShowS)
-> Show RegexPatternSet
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. RegexPatternSet -> Rep RegexPatternSet x)
-> (forall x. Rep RegexPatternSet x -> RegexPatternSet)
-> Generic RegexPatternSet
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' :: Maybe Text -> Text -> [Text] -> RegexPatternSet
RegexPatternSet'
    { $sel:name:RegexPatternSet' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:regexPatternSetId:RegexPatternSet' :: Text
regexPatternSetId = Text
pRegexPatternSetId_,
      $sel:regexPatternStrings:RegexPatternSet' :: [Text]
regexPatternStrings = [Text]
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 :: (Maybe Text -> f (Maybe Text))
-> RegexPatternSet -> f RegexPatternSet
regexPatternSet_name = (RegexPatternSet -> Maybe Text)
-> (RegexPatternSet -> Maybe Text -> RegexPatternSet)
-> Lens RegexPatternSet RegexPatternSet (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> RegexPatternSet -> f RegexPatternSet
regexPatternSet_regexPatternSetId = (RegexPatternSet -> Text)
-> (RegexPatternSet -> Text -> RegexPatternSet)
-> Lens RegexPatternSet RegexPatternSet Text Text
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 :: ([Text] -> f [Text]) -> RegexPatternSet -> f RegexPatternSet
regexPatternSet_regexPatternStrings = (RegexPatternSet -> [Text])
-> (RegexPatternSet -> [Text] -> RegexPatternSet)
-> Lens RegexPatternSet RegexPatternSet [Text] [Text]
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) (([Text] -> f [Text]) -> RegexPatternSet -> f RegexPatternSet)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> RegexPatternSet
-> f RegexPatternSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable RegexPatternSet

instance Prelude.NFData RegexPatternSet