{-# 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.RegexMatchSet
-- 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.RegexMatchSet where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFRegional.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,
    -- | 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],
    -- | 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
  }
  deriving (RegexMatchSet -> RegexMatchSet -> Bool
(RegexMatchSet -> RegexMatchSet -> Bool)
-> (RegexMatchSet -> RegexMatchSet -> Bool) -> Eq RegexMatchSet
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]
(Int -> ReadS RegexMatchSet)
-> ReadS [RegexMatchSet]
-> ReadPrec RegexMatchSet
-> ReadPrec [RegexMatchSet]
-> Read 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
(Int -> RegexMatchSet -> ShowS)
-> (RegexMatchSet -> String)
-> ([RegexMatchSet] -> ShowS)
-> Show RegexMatchSet
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. RegexMatchSet -> Rep RegexMatchSet x)
-> (forall x. Rep RegexMatchSet x -> RegexMatchSet)
-> Generic RegexMatchSet
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@.
--
-- '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.
--
-- '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.
newRegexMatchSet ::
  RegexMatchSet
newRegexMatchSet :: RegexMatchSet
newRegexMatchSet =
  RegexMatchSet' :: Maybe Text
-> Maybe [RegexMatchTuple] -> Maybe Text -> RegexMatchSet
RegexMatchSet'
    { $sel:name:RegexMatchSet' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:regexMatchTuples:RegexMatchSet' :: Maybe [RegexMatchTuple]
regexMatchTuples = Maybe [RegexMatchTuple]
forall a. Maybe a
Prelude.Nothing,
      $sel:regexMatchSetId:RegexMatchSet' :: Maybe Text
regexMatchSetId = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> RegexMatchSet -> f RegexMatchSet
regexMatchSet_name = (RegexMatchSet -> Maybe Text)
-> (RegexMatchSet -> Maybe Text -> RegexMatchSet)
-> Lens RegexMatchSet RegexMatchSet (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe [RegexMatchTuple] -> f (Maybe [RegexMatchTuple]))
-> RegexMatchSet -> f RegexMatchSet
regexMatchSet_regexMatchTuples = (RegexMatchSet -> Maybe [RegexMatchTuple])
-> (RegexMatchSet -> Maybe [RegexMatchTuple] -> RegexMatchSet)
-> Lens
     RegexMatchSet
     RegexMatchSet
     (Maybe [RegexMatchTuple])
     (Maybe [RegexMatchTuple])
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) ((Maybe [RegexMatchTuple] -> f (Maybe [RegexMatchTuple]))
 -> RegexMatchSet -> f RegexMatchSet)
-> ((Maybe [RegexMatchTuple] -> f (Maybe [RegexMatchTuple]))
    -> Maybe [RegexMatchTuple] -> f (Maybe [RegexMatchTuple]))
-> (Maybe [RegexMatchTuple] -> f (Maybe [RegexMatchTuple]))
-> RegexMatchSet
-> f RegexMatchSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [RegexMatchTuple]
  [RegexMatchTuple]
  [RegexMatchTuple]
  [RegexMatchTuple]
-> Iso
     (Maybe [RegexMatchTuple])
     (Maybe [RegexMatchTuple])
     (Maybe [RegexMatchTuple])
     (Maybe [RegexMatchTuple])
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 AnIso
  [RegexMatchTuple]
  [RegexMatchTuple]
  [RegexMatchTuple]
  [RegexMatchTuple]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> RegexMatchSet -> f RegexMatchSet
regexMatchSet_regexMatchSetId = (RegexMatchSet -> Maybe Text)
-> (RegexMatchSet -> Maybe Text -> RegexMatchSet)
-> Lens RegexMatchSet RegexMatchSet (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable RegexMatchSet

instance Prelude.NFData RegexMatchSet