{-# 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.ByteMatchSet
-- 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.WAFRegional.Types.ByteMatchSet 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.WAFRegional.Types.ByteMatchTuple

-- | 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 GetByteMatchSet request, @ByteMatchSet@ is a complex type that
-- contains the @ByteMatchSetId@ and @Name@ of a @ByteMatchSet@, and the
-- values that you specified when you updated the @ByteMatchSet@.
--
-- A complex type that contains @ByteMatchTuple@ objects, 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 @ByteMatchSet@ contains more
-- than one @ByteMatchTuple@ object, a request needs to match the settings
-- in only one @ByteMatchTuple@ to be considered a match.
--
-- /See:/ 'newByteMatchSet' smart constructor.
data ByteMatchSet = ByteMatchSet'
  { -- | A friendly name or description of the ByteMatchSet. You can\'t change
    -- @Name@ after you create a @ByteMatchSet@.
    ByteMatchSet -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The @ByteMatchSetId@ for a @ByteMatchSet@. You use @ByteMatchSetId@ to
    -- get information about a @ByteMatchSet@ (see GetByteMatchSet), update a
    -- @ByteMatchSet@ (see UpdateByteMatchSet), insert a @ByteMatchSet@ into a
    -- @Rule@ or delete one from a @Rule@ (see UpdateRule), and delete a
    -- @ByteMatchSet@ from AWS WAF (see DeleteByteMatchSet).
    --
    -- @ByteMatchSetId@ is returned by CreateByteMatchSet and by
    -- ListByteMatchSets.
    ByteMatchSet -> Text
byteMatchSetId :: Prelude.Text,
    -- | Specifies the bytes (typically a string that corresponds with ASCII
    -- characters) that you want AWS WAF to search for in web requests, the
    -- location in requests that you want AWS WAF to search, and other
    -- settings.
    ByteMatchSet -> [ByteMatchTuple]
byteMatchTuples :: [ByteMatchTuple]
  }
  deriving (ByteMatchSet -> ByteMatchSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ByteMatchSet -> ByteMatchSet -> Bool
$c/= :: ByteMatchSet -> ByteMatchSet -> Bool
== :: ByteMatchSet -> ByteMatchSet -> Bool
$c== :: ByteMatchSet -> ByteMatchSet -> Bool
Prelude.Eq, ReadPrec [ByteMatchSet]
ReadPrec ByteMatchSet
Int -> ReadS ByteMatchSet
ReadS [ByteMatchSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ByteMatchSet]
$creadListPrec :: ReadPrec [ByteMatchSet]
readPrec :: ReadPrec ByteMatchSet
$creadPrec :: ReadPrec ByteMatchSet
readList :: ReadS [ByteMatchSet]
$creadList :: ReadS [ByteMatchSet]
readsPrec :: Int -> ReadS ByteMatchSet
$creadsPrec :: Int -> ReadS ByteMatchSet
Prelude.Read, Int -> ByteMatchSet -> ShowS
[ByteMatchSet] -> ShowS
ByteMatchSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ByteMatchSet] -> ShowS
$cshowList :: [ByteMatchSet] -> ShowS
show :: ByteMatchSet -> String
$cshow :: ByteMatchSet -> String
showsPrec :: Int -> ByteMatchSet -> ShowS
$cshowsPrec :: Int -> ByteMatchSet -> ShowS
Prelude.Show, forall x. Rep ByteMatchSet x -> ByteMatchSet
forall x. ByteMatchSet -> Rep ByteMatchSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ByteMatchSet x -> ByteMatchSet
$cfrom :: forall x. ByteMatchSet -> Rep ByteMatchSet x
Prelude.Generic)

-- |
-- Create a value of 'ByteMatchSet' 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', 'byteMatchSet_name' - A friendly name or description of the ByteMatchSet. You can\'t change
-- @Name@ after you create a @ByteMatchSet@.
--
-- 'byteMatchSetId', 'byteMatchSet_byteMatchSetId' - The @ByteMatchSetId@ for a @ByteMatchSet@. You use @ByteMatchSetId@ to
-- get information about a @ByteMatchSet@ (see GetByteMatchSet), update a
-- @ByteMatchSet@ (see UpdateByteMatchSet), insert a @ByteMatchSet@ into a
-- @Rule@ or delete one from a @Rule@ (see UpdateRule), and delete a
-- @ByteMatchSet@ from AWS WAF (see DeleteByteMatchSet).
--
-- @ByteMatchSetId@ is returned by CreateByteMatchSet and by
-- ListByteMatchSets.
--
-- 'byteMatchTuples', 'byteMatchSet_byteMatchTuples' - Specifies the bytes (typically a string that corresponds with ASCII
-- characters) that you want AWS WAF to search for in web requests, the
-- location in requests that you want AWS WAF to search, and other
-- settings.
newByteMatchSet ::
  -- | 'byteMatchSetId'
  Prelude.Text ->
  ByteMatchSet
newByteMatchSet :: Text -> ByteMatchSet
newByteMatchSet Text
pByteMatchSetId_ =
  ByteMatchSet'
    { $sel:name:ByteMatchSet' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:byteMatchSetId:ByteMatchSet' :: Text
byteMatchSetId = Text
pByteMatchSetId_,
      $sel:byteMatchTuples:ByteMatchSet' :: [ByteMatchTuple]
byteMatchTuples = forall a. Monoid a => a
Prelude.mempty
    }

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

-- | The @ByteMatchSetId@ for a @ByteMatchSet@. You use @ByteMatchSetId@ to
-- get information about a @ByteMatchSet@ (see GetByteMatchSet), update a
-- @ByteMatchSet@ (see UpdateByteMatchSet), insert a @ByteMatchSet@ into a
-- @Rule@ or delete one from a @Rule@ (see UpdateRule), and delete a
-- @ByteMatchSet@ from AWS WAF (see DeleteByteMatchSet).
--
-- @ByteMatchSetId@ is returned by CreateByteMatchSet and by
-- ListByteMatchSets.
byteMatchSet_byteMatchSetId :: Lens.Lens' ByteMatchSet Prelude.Text
byteMatchSet_byteMatchSetId :: Lens' ByteMatchSet Text
byteMatchSet_byteMatchSetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ByteMatchSet' {Text
byteMatchSetId :: Text
$sel:byteMatchSetId:ByteMatchSet' :: ByteMatchSet -> Text
byteMatchSetId} -> Text
byteMatchSetId) (\s :: ByteMatchSet
s@ByteMatchSet' {} Text
a -> ByteMatchSet
s {$sel:byteMatchSetId:ByteMatchSet' :: Text
byteMatchSetId = Text
a} :: ByteMatchSet)

-- | Specifies the bytes (typically a string that corresponds with ASCII
-- characters) that you want AWS WAF to search for in web requests, the
-- location in requests that you want AWS WAF to search, and other
-- settings.
byteMatchSet_byteMatchTuples :: Lens.Lens' ByteMatchSet [ByteMatchTuple]
byteMatchSet_byteMatchTuples :: Lens' ByteMatchSet [ByteMatchTuple]
byteMatchSet_byteMatchTuples = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ByteMatchSet' {[ByteMatchTuple]
byteMatchTuples :: [ByteMatchTuple]
$sel:byteMatchTuples:ByteMatchSet' :: ByteMatchSet -> [ByteMatchTuple]
byteMatchTuples} -> [ByteMatchTuple]
byteMatchTuples) (\s :: ByteMatchSet
s@ByteMatchSet' {} [ByteMatchTuple]
a -> ByteMatchSet
s {$sel:byteMatchTuples:ByteMatchSet' :: [ByteMatchTuple]
byteMatchTuples = [ByteMatchTuple]
a} :: ByteMatchSet) 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 ByteMatchSet where
  parseJSON :: Value -> Parser ByteMatchSet
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ByteMatchSet"
      ( \Object
x ->
          Maybe Text -> Text -> [ByteMatchTuple] -> ByteMatchSet
ByteMatchSet'
            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
"ByteMatchSetId")
            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
"ByteMatchTuples"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ByteMatchSet where
  hashWithSalt :: Int -> ByteMatchSet -> Int
hashWithSalt Int
_salt ByteMatchSet' {[ByteMatchTuple]
Maybe Text
Text
byteMatchTuples :: [ByteMatchTuple]
byteMatchSetId :: Text
name :: Maybe Text
$sel:byteMatchTuples:ByteMatchSet' :: ByteMatchSet -> [ByteMatchTuple]
$sel:byteMatchSetId:ByteMatchSet' :: ByteMatchSet -> Text
$sel:name:ByteMatchSet' :: ByteMatchSet -> 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
byteMatchSetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ByteMatchTuple]
byteMatchTuples

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