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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ByteMatchSet -> ByteMatchSet -> Bool)
-> (ByteMatchSet -> ByteMatchSet -> Bool) -> Eq ByteMatchSet
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]
(Int -> ReadS ByteMatchSet)
-> ReadS [ByteMatchSet]
-> ReadPrec ByteMatchSet
-> ReadPrec [ByteMatchSet]
-> Read 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
(Int -> ByteMatchSet -> ShowS)
-> (ByteMatchSet -> String)
-> ([ByteMatchSet] -> ShowS)
-> Show ByteMatchSet
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. ByteMatchSet -> Rep ByteMatchSet x)
-> (forall x. Rep ByteMatchSet x -> ByteMatchSet)
-> Generic ByteMatchSet
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' :: Maybe Text -> Text -> [ByteMatchTuple] -> ByteMatchSet
ByteMatchSet'
    { $sel:name:ByteMatchSet' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:byteMatchSetId:ByteMatchSet' :: Text
byteMatchSetId = Text
pByteMatchSetId_,
      $sel:byteMatchTuples:ByteMatchSet' :: [ByteMatchTuple]
byteMatchTuples = [ByteMatchTuple]
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 :: (Maybe Text -> f (Maybe Text)) -> ByteMatchSet -> f ByteMatchSet
byteMatchSet_name = (ByteMatchSet -> Maybe Text)
-> (ByteMatchSet -> Maybe Text -> ByteMatchSet)
-> Lens ByteMatchSet ByteMatchSet (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> ByteMatchSet -> f ByteMatchSet
byteMatchSet_byteMatchSetId = (ByteMatchSet -> Text)
-> (ByteMatchSet -> Text -> ByteMatchSet)
-> Lens ByteMatchSet ByteMatchSet Text Text
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 :: ([ByteMatchTuple] -> f [ByteMatchTuple])
-> ByteMatchSet -> f ByteMatchSet
byteMatchSet_byteMatchTuples = (ByteMatchSet -> [ByteMatchTuple])
-> (ByteMatchSet -> [ByteMatchTuple] -> ByteMatchSet)
-> Lens ByteMatchSet ByteMatchSet [ByteMatchTuple] [ByteMatchTuple]
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) (([ByteMatchTuple] -> f [ByteMatchTuple])
 -> ByteMatchSet -> f ByteMatchSet)
-> (([ByteMatchTuple] -> f [ByteMatchTuple])
    -> [ByteMatchTuple] -> f [ByteMatchTuple])
-> ([ByteMatchTuple] -> f [ByteMatchTuple])
-> ByteMatchSet
-> f ByteMatchSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ByteMatchTuple] -> f [ByteMatchTuple])
-> [ByteMatchTuple] -> f [ByteMatchTuple]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ByteMatchSet

instance Prelude.NFData ByteMatchSet