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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFRegional.Types.XssMatchTuple

-- | 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 complex type that contains @XssMatchTuple@ objects, which specify the
-- parts of web requests that you want AWS WAF to inspect for cross-site
-- scripting attacks and, if you want AWS WAF to inspect a header, the name
-- of the header. If a @XssMatchSet@ contains more than one @XssMatchTuple@
-- object, a request needs to include cross-site scripting attacks in only
-- one of the specified parts of the request to be considered a match.
--
-- /See:/ 'newXssMatchSet' smart constructor.
data XssMatchSet = XssMatchSet'
  { -- | The name, if any, of the @XssMatchSet@.
    XssMatchSet -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for an @XssMatchSet@. You use @XssMatchSetId@ to get
    -- information about an @XssMatchSet@ (see GetXssMatchSet), update an
    -- @XssMatchSet@ (see UpdateXssMatchSet), insert an @XssMatchSet@ into a
    -- @Rule@ or delete one from a @Rule@ (see UpdateRule), and delete an
    -- @XssMatchSet@ from AWS WAF (see DeleteXssMatchSet).
    --
    -- @XssMatchSetId@ is returned by CreateXssMatchSet and by
    -- ListXssMatchSets.
    XssMatchSet -> Text
xssMatchSetId :: Prelude.Text,
    -- | Specifies the parts of web requests that you want to inspect for
    -- cross-site scripting attacks.
    XssMatchSet -> [XssMatchTuple]
xssMatchTuples :: [XssMatchTuple]
  }
  deriving (XssMatchSet -> XssMatchSet -> Bool
(XssMatchSet -> XssMatchSet -> Bool)
-> (XssMatchSet -> XssMatchSet -> Bool) -> Eq XssMatchSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XssMatchSet -> XssMatchSet -> Bool
$c/= :: XssMatchSet -> XssMatchSet -> Bool
== :: XssMatchSet -> XssMatchSet -> Bool
$c== :: XssMatchSet -> XssMatchSet -> Bool
Prelude.Eq, ReadPrec [XssMatchSet]
ReadPrec XssMatchSet
Int -> ReadS XssMatchSet
ReadS [XssMatchSet]
(Int -> ReadS XssMatchSet)
-> ReadS [XssMatchSet]
-> ReadPrec XssMatchSet
-> ReadPrec [XssMatchSet]
-> Read XssMatchSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [XssMatchSet]
$creadListPrec :: ReadPrec [XssMatchSet]
readPrec :: ReadPrec XssMatchSet
$creadPrec :: ReadPrec XssMatchSet
readList :: ReadS [XssMatchSet]
$creadList :: ReadS [XssMatchSet]
readsPrec :: Int -> ReadS XssMatchSet
$creadsPrec :: Int -> ReadS XssMatchSet
Prelude.Read, Int -> XssMatchSet -> ShowS
[XssMatchSet] -> ShowS
XssMatchSet -> String
(Int -> XssMatchSet -> ShowS)
-> (XssMatchSet -> String)
-> ([XssMatchSet] -> ShowS)
-> Show XssMatchSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XssMatchSet] -> ShowS
$cshowList :: [XssMatchSet] -> ShowS
show :: XssMatchSet -> String
$cshow :: XssMatchSet -> String
showsPrec :: Int -> XssMatchSet -> ShowS
$cshowsPrec :: Int -> XssMatchSet -> ShowS
Prelude.Show, (forall x. XssMatchSet -> Rep XssMatchSet x)
-> (forall x. Rep XssMatchSet x -> XssMatchSet)
-> Generic XssMatchSet
forall x. Rep XssMatchSet x -> XssMatchSet
forall x. XssMatchSet -> Rep XssMatchSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep XssMatchSet x -> XssMatchSet
$cfrom :: forall x. XssMatchSet -> Rep XssMatchSet x
Prelude.Generic)

-- |
-- Create a value of 'XssMatchSet' 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', 'xssMatchSet_name' - The name, if any, of the @XssMatchSet@.
--
-- 'xssMatchSetId', 'xssMatchSet_xssMatchSetId' - A unique identifier for an @XssMatchSet@. You use @XssMatchSetId@ to get
-- information about an @XssMatchSet@ (see GetXssMatchSet), update an
-- @XssMatchSet@ (see UpdateXssMatchSet), insert an @XssMatchSet@ into a
-- @Rule@ or delete one from a @Rule@ (see UpdateRule), and delete an
-- @XssMatchSet@ from AWS WAF (see DeleteXssMatchSet).
--
-- @XssMatchSetId@ is returned by CreateXssMatchSet and by
-- ListXssMatchSets.
--
-- 'xssMatchTuples', 'xssMatchSet_xssMatchTuples' - Specifies the parts of web requests that you want to inspect for
-- cross-site scripting attacks.
newXssMatchSet ::
  -- | 'xssMatchSetId'
  Prelude.Text ->
  XssMatchSet
newXssMatchSet :: Text -> XssMatchSet
newXssMatchSet Text
pXssMatchSetId_ =
  XssMatchSet' :: Maybe Text -> Text -> [XssMatchTuple] -> XssMatchSet
XssMatchSet'
    { $sel:name:XssMatchSet' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:xssMatchSetId:XssMatchSet' :: Text
xssMatchSetId = Text
pXssMatchSetId_,
      $sel:xssMatchTuples:XssMatchSet' :: [XssMatchTuple]
xssMatchTuples = [XssMatchTuple]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name, if any, of the @XssMatchSet@.
xssMatchSet_name :: Lens.Lens' XssMatchSet (Prelude.Maybe Prelude.Text)
xssMatchSet_name :: (Maybe Text -> f (Maybe Text)) -> XssMatchSet -> f XssMatchSet
xssMatchSet_name = (XssMatchSet -> Maybe Text)
-> (XssMatchSet -> Maybe Text -> XssMatchSet)
-> Lens XssMatchSet XssMatchSet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\XssMatchSet' {Maybe Text
name :: Maybe Text
$sel:name:XssMatchSet' :: XssMatchSet -> Maybe Text
name} -> Maybe Text
name) (\s :: XssMatchSet
s@XssMatchSet' {} Maybe Text
a -> XssMatchSet
s {$sel:name:XssMatchSet' :: Maybe Text
name = Maybe Text
a} :: XssMatchSet)

-- | A unique identifier for an @XssMatchSet@. You use @XssMatchSetId@ to get
-- information about an @XssMatchSet@ (see GetXssMatchSet), update an
-- @XssMatchSet@ (see UpdateXssMatchSet), insert an @XssMatchSet@ into a
-- @Rule@ or delete one from a @Rule@ (see UpdateRule), and delete an
-- @XssMatchSet@ from AWS WAF (see DeleteXssMatchSet).
--
-- @XssMatchSetId@ is returned by CreateXssMatchSet and by
-- ListXssMatchSets.
xssMatchSet_xssMatchSetId :: Lens.Lens' XssMatchSet Prelude.Text
xssMatchSet_xssMatchSetId :: (Text -> f Text) -> XssMatchSet -> f XssMatchSet
xssMatchSet_xssMatchSetId = (XssMatchSet -> Text)
-> (XssMatchSet -> Text -> XssMatchSet)
-> Lens XssMatchSet XssMatchSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\XssMatchSet' {Text
xssMatchSetId :: Text
$sel:xssMatchSetId:XssMatchSet' :: XssMatchSet -> Text
xssMatchSetId} -> Text
xssMatchSetId) (\s :: XssMatchSet
s@XssMatchSet' {} Text
a -> XssMatchSet
s {$sel:xssMatchSetId:XssMatchSet' :: Text
xssMatchSetId = Text
a} :: XssMatchSet)

-- | Specifies the parts of web requests that you want to inspect for
-- cross-site scripting attacks.
xssMatchSet_xssMatchTuples :: Lens.Lens' XssMatchSet [XssMatchTuple]
xssMatchSet_xssMatchTuples :: ([XssMatchTuple] -> f [XssMatchTuple])
-> XssMatchSet -> f XssMatchSet
xssMatchSet_xssMatchTuples = (XssMatchSet -> [XssMatchTuple])
-> (XssMatchSet -> [XssMatchTuple] -> XssMatchSet)
-> Lens XssMatchSet XssMatchSet [XssMatchTuple] [XssMatchTuple]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\XssMatchSet' {[XssMatchTuple]
xssMatchTuples :: [XssMatchTuple]
$sel:xssMatchTuples:XssMatchSet' :: XssMatchSet -> [XssMatchTuple]
xssMatchTuples} -> [XssMatchTuple]
xssMatchTuples) (\s :: XssMatchSet
s@XssMatchSet' {} [XssMatchTuple]
a -> XssMatchSet
s {$sel:xssMatchTuples:XssMatchSet' :: [XssMatchTuple]
xssMatchTuples = [XssMatchTuple]
a} :: XssMatchSet) (([XssMatchTuple] -> f [XssMatchTuple])
 -> XssMatchSet -> f XssMatchSet)
-> (([XssMatchTuple] -> f [XssMatchTuple])
    -> [XssMatchTuple] -> f [XssMatchTuple])
-> ([XssMatchTuple] -> f [XssMatchTuple])
-> XssMatchSet
-> f XssMatchSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([XssMatchTuple] -> f [XssMatchTuple])
-> [XssMatchTuple] -> f [XssMatchTuple]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable XssMatchSet

instance Prelude.NFData XssMatchSet