{-# 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.XssMatchSet
-- 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.XssMatchSet 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.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
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]
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
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. 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'
    { $sel:name:XssMatchSet' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:xssMatchSetId:XssMatchSet' :: Text
xssMatchSetId = Text
pXssMatchSetId_,
      $sel:xssMatchTuples:XssMatchSet' :: [XssMatchTuple]
xssMatchTuples = 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 :: Lens' XssMatchSet (Maybe Text)
xssMatchSet_name = 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 :: Lens' XssMatchSet Text
xssMatchSet_xssMatchSetId = 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 :: Lens' XssMatchSet [XssMatchTuple]
xssMatchSet_xssMatchTuples = 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) 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 XssMatchSet where
  parseJSON :: Value -> Parser XssMatchSet
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"XssMatchSet"
      ( \Object
x ->
          Maybe Text -> Text -> [XssMatchTuple] -> XssMatchSet
XssMatchSet'
            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
"XssMatchSetId")
            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
"XssMatchTuples"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable XssMatchSet where
  hashWithSalt :: Int -> XssMatchSet -> Int
hashWithSalt Int
_salt XssMatchSet' {[XssMatchTuple]
Maybe Text
Text
xssMatchTuples :: [XssMatchTuple]
xssMatchSetId :: Text
name :: Maybe Text
$sel:xssMatchTuples:XssMatchSet' :: XssMatchSet -> [XssMatchTuple]
$sel:xssMatchSetId:XssMatchSet' :: XssMatchSet -> Text
$sel:name:XssMatchSet' :: XssMatchSet -> 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
xssMatchSetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [XssMatchTuple]
xssMatchTuples

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