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

-- | 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.
--
-- In a GetRegexMatchSet request, @RegexMatchSet@ is a complex type that
-- contains the @RegexMatchSetId@ and @Name@ of a @RegexMatchSet@, and the
-- values that you specified when you updated the @RegexMatchSet@.
--
-- The values are contained in a @RegexMatchTuple@ object, which specify
-- the parts of web requests that you want AWS WAF to inspect and the
-- values that you want AWS WAF to search for. If a @RegexMatchSet@
-- contains more than one @RegexMatchTuple@ object, a request needs to
-- match the settings in only one @ByteMatchTuple@ to be considered a
-- match.
--
-- /See:/ 'newRegexMatchSet' smart constructor.
data RegexMatchSet = RegexMatchSet'
  { -- | A friendly name or description of the RegexMatchSet. You can\'t change
    -- @Name@ after you create a @RegexMatchSet@.
    RegexMatchSet -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The @RegexMatchSetId@ for a @RegexMatchSet@. You use @RegexMatchSetId@
    -- to get information about a @RegexMatchSet@ (see GetRegexMatchSet),
    -- update a @RegexMatchSet@ (see UpdateRegexMatchSet), insert a
    -- @RegexMatchSet@ into a @Rule@ or delete one from a @Rule@ (see
    -- UpdateRule), and delete a @RegexMatchSet@ from AWS WAF (see
    -- DeleteRegexMatchSet).
    --
    -- @RegexMatchSetId@ is returned by CreateRegexMatchSet and by
    -- ListRegexMatchSets.
    RegexMatchSet -> Maybe Text
regexMatchSetId :: Prelude.Maybe Prelude.Text,
    -- | Contains an array of RegexMatchTuple objects. Each @RegexMatchTuple@
    -- object contains:
    --
    -- -   The part of a web request that you want AWS WAF to inspect, such as
    --     a query string or the value of the @User-Agent@ header.
    --
    -- -   The identifier of the pattern (a regular expression) that you want
    --     AWS WAF to look for. For more information, see RegexPatternSet.
    --
    -- -   Whether to perform any conversions on the request, such as
    --     converting it to lowercase, before inspecting it for the specified
    --     string.
    RegexMatchSet -> Maybe [RegexMatchTuple]
regexMatchTuples :: Prelude.Maybe [RegexMatchTuple]
  }
  deriving (RegexMatchSet -> RegexMatchSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegexMatchSet -> RegexMatchSet -> Bool
$c/= :: RegexMatchSet -> RegexMatchSet -> Bool
== :: RegexMatchSet -> RegexMatchSet -> Bool
$c== :: RegexMatchSet -> RegexMatchSet -> Bool
Prelude.Eq, ReadPrec [RegexMatchSet]
ReadPrec RegexMatchSet
Int -> ReadS RegexMatchSet
ReadS [RegexMatchSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegexMatchSet]
$creadListPrec :: ReadPrec [RegexMatchSet]
readPrec :: ReadPrec RegexMatchSet
$creadPrec :: ReadPrec RegexMatchSet
readList :: ReadS [RegexMatchSet]
$creadList :: ReadS [RegexMatchSet]
readsPrec :: Int -> ReadS RegexMatchSet
$creadsPrec :: Int -> ReadS RegexMatchSet
Prelude.Read, Int -> RegexMatchSet -> ShowS
[RegexMatchSet] -> ShowS
RegexMatchSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegexMatchSet] -> ShowS
$cshowList :: [RegexMatchSet] -> ShowS
show :: RegexMatchSet -> String
$cshow :: RegexMatchSet -> String
showsPrec :: Int -> RegexMatchSet -> ShowS
$cshowsPrec :: Int -> RegexMatchSet -> ShowS
Prelude.Show, forall x. Rep RegexMatchSet x -> RegexMatchSet
forall x. RegexMatchSet -> Rep RegexMatchSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegexMatchSet x -> RegexMatchSet
$cfrom :: forall x. RegexMatchSet -> Rep RegexMatchSet x
Prelude.Generic)

-- |
-- Create a value of 'RegexMatchSet' 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', 'regexMatchSet_name' - A friendly name or description of the RegexMatchSet. You can\'t change
-- @Name@ after you create a @RegexMatchSet@.
--
-- 'regexMatchSetId', 'regexMatchSet_regexMatchSetId' - The @RegexMatchSetId@ for a @RegexMatchSet@. You use @RegexMatchSetId@
-- to get information about a @RegexMatchSet@ (see GetRegexMatchSet),
-- update a @RegexMatchSet@ (see UpdateRegexMatchSet), insert a
-- @RegexMatchSet@ into a @Rule@ or delete one from a @Rule@ (see
-- UpdateRule), and delete a @RegexMatchSet@ from AWS WAF (see
-- DeleteRegexMatchSet).
--
-- @RegexMatchSetId@ is returned by CreateRegexMatchSet and by
-- ListRegexMatchSets.
--
-- 'regexMatchTuples', 'regexMatchSet_regexMatchTuples' - Contains an array of RegexMatchTuple objects. Each @RegexMatchTuple@
-- object contains:
--
-- -   The part of a web request that you want AWS WAF to inspect, such as
--     a query string or the value of the @User-Agent@ header.
--
-- -   The identifier of the pattern (a regular expression) that you want
--     AWS WAF to look for. For more information, see RegexPatternSet.
--
-- -   Whether to perform any conversions on the request, such as
--     converting it to lowercase, before inspecting it for the specified
--     string.
newRegexMatchSet ::
  RegexMatchSet
newRegexMatchSet :: RegexMatchSet
newRegexMatchSet =
  RegexMatchSet'
    { $sel:name:RegexMatchSet' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:regexMatchSetId:RegexMatchSet' :: Maybe Text
regexMatchSetId = forall a. Maybe a
Prelude.Nothing,
      $sel:regexMatchTuples:RegexMatchSet' :: Maybe [RegexMatchTuple]
regexMatchTuples = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The @RegexMatchSetId@ for a @RegexMatchSet@. You use @RegexMatchSetId@
-- to get information about a @RegexMatchSet@ (see GetRegexMatchSet),
-- update a @RegexMatchSet@ (see UpdateRegexMatchSet), insert a
-- @RegexMatchSet@ into a @Rule@ or delete one from a @Rule@ (see
-- UpdateRule), and delete a @RegexMatchSet@ from AWS WAF (see
-- DeleteRegexMatchSet).
--
-- @RegexMatchSetId@ is returned by CreateRegexMatchSet and by
-- ListRegexMatchSets.
regexMatchSet_regexMatchSetId :: Lens.Lens' RegexMatchSet (Prelude.Maybe Prelude.Text)
regexMatchSet_regexMatchSetId :: Lens' RegexMatchSet (Maybe Text)
regexMatchSet_regexMatchSetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexMatchSet' {Maybe Text
regexMatchSetId :: Maybe Text
$sel:regexMatchSetId:RegexMatchSet' :: RegexMatchSet -> Maybe Text
regexMatchSetId} -> Maybe Text
regexMatchSetId) (\s :: RegexMatchSet
s@RegexMatchSet' {} Maybe Text
a -> RegexMatchSet
s {$sel:regexMatchSetId:RegexMatchSet' :: Maybe Text
regexMatchSetId = Maybe Text
a} :: RegexMatchSet)

-- | Contains an array of RegexMatchTuple objects. Each @RegexMatchTuple@
-- object contains:
--
-- -   The part of a web request that you want AWS WAF to inspect, such as
--     a query string or the value of the @User-Agent@ header.
--
-- -   The identifier of the pattern (a regular expression) that you want
--     AWS WAF to look for. For more information, see RegexPatternSet.
--
-- -   Whether to perform any conversions on the request, such as
--     converting it to lowercase, before inspecting it for the specified
--     string.
regexMatchSet_regexMatchTuples :: Lens.Lens' RegexMatchSet (Prelude.Maybe [RegexMatchTuple])
regexMatchSet_regexMatchTuples :: Lens' RegexMatchSet (Maybe [RegexMatchTuple])
regexMatchSet_regexMatchTuples = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexMatchSet' {Maybe [RegexMatchTuple]
regexMatchTuples :: Maybe [RegexMatchTuple]
$sel:regexMatchTuples:RegexMatchSet' :: RegexMatchSet -> Maybe [RegexMatchTuple]
regexMatchTuples} -> Maybe [RegexMatchTuple]
regexMatchTuples) (\s :: RegexMatchSet
s@RegexMatchSet' {} Maybe [RegexMatchTuple]
a -> RegexMatchSet
s {$sel:regexMatchTuples:RegexMatchSet' :: Maybe [RegexMatchTuple]
regexMatchTuples = Maybe [RegexMatchTuple]
a} :: RegexMatchSet) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON RegexMatchSet where
  parseJSON :: Value -> Parser RegexMatchSet
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RegexMatchSet"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe [RegexMatchTuple] -> RegexMatchSet
RegexMatchSet'
            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 (Maybe a)
Data..:? Key
"RegexMatchSetId")
            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
"RegexMatchTuples"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable RegexMatchSet where
  hashWithSalt :: Int -> RegexMatchSet -> Int
hashWithSalt Int
_salt RegexMatchSet' {Maybe [RegexMatchTuple]
Maybe Text
regexMatchTuples :: Maybe [RegexMatchTuple]
regexMatchSetId :: Maybe Text
name :: Maybe Text
$sel:regexMatchTuples:RegexMatchSet' :: RegexMatchSet -> Maybe [RegexMatchTuple]
$sel:regexMatchSetId:RegexMatchSet' :: RegexMatchSet -> Maybe Text
$sel:name:RegexMatchSet' :: RegexMatchSet -> 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` Maybe Text
regexMatchSetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [RegexMatchTuple]
regexMatchTuples

instance Prelude.NFData RegexMatchSet where
  rnf :: RegexMatchSet -> ()
rnf RegexMatchSet' {Maybe [RegexMatchTuple]
Maybe Text
regexMatchTuples :: Maybe [RegexMatchTuple]
regexMatchSetId :: Maybe Text
name :: Maybe Text
$sel:regexMatchTuples:RegexMatchSet' :: RegexMatchSet -> Maybe [RegexMatchTuple]
$sel:regexMatchSetId:RegexMatchSet' :: RegexMatchSet -> Maybe Text
$sel:name:RegexMatchSet' :: RegexMatchSet -> 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 Maybe Text
regexMatchSetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [RegexMatchTuple]
regexMatchTuples