{-# 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.ByteMatchSetUpdate
-- 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.WAF.Types.ByteMatchSetUpdate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAF.Types.ByteMatchTuple
import Amazonka.WAF.Types.ChangeAction

-- | 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 an UpdateByteMatchSet request, @ByteMatchSetUpdate@ specifies whether
-- to insert or delete a ByteMatchTuple and includes the settings for the
-- @ByteMatchTuple@.
--
-- /See:/ 'newByteMatchSetUpdate' smart constructor.
data ByteMatchSetUpdate = ByteMatchSetUpdate'
  { -- | Specifies whether to insert or delete a ByteMatchTuple.
    ByteMatchSetUpdate -> ChangeAction
action :: ChangeAction,
    -- | Information about the part of a web request that you want AWS WAF to
    -- inspect and the value that you want AWS WAF to search for. If you
    -- specify @DELETE@ for the value of @Action@, the @ByteMatchTuple@ values
    -- must exactly match the values in the @ByteMatchTuple@ that you want to
    -- delete from the @ByteMatchSet@.
    ByteMatchSetUpdate -> ByteMatchTuple
byteMatchTuple :: ByteMatchTuple
  }
  deriving (ByteMatchSetUpdate -> ByteMatchSetUpdate -> Bool
(ByteMatchSetUpdate -> ByteMatchSetUpdate -> Bool)
-> (ByteMatchSetUpdate -> ByteMatchSetUpdate -> Bool)
-> Eq ByteMatchSetUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ByteMatchSetUpdate -> ByteMatchSetUpdate -> Bool
$c/= :: ByteMatchSetUpdate -> ByteMatchSetUpdate -> Bool
== :: ByteMatchSetUpdate -> ByteMatchSetUpdate -> Bool
$c== :: ByteMatchSetUpdate -> ByteMatchSetUpdate -> Bool
Prelude.Eq, ReadPrec [ByteMatchSetUpdate]
ReadPrec ByteMatchSetUpdate
Int -> ReadS ByteMatchSetUpdate
ReadS [ByteMatchSetUpdate]
(Int -> ReadS ByteMatchSetUpdate)
-> ReadS [ByteMatchSetUpdate]
-> ReadPrec ByteMatchSetUpdate
-> ReadPrec [ByteMatchSetUpdate]
-> Read ByteMatchSetUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ByteMatchSetUpdate]
$creadListPrec :: ReadPrec [ByteMatchSetUpdate]
readPrec :: ReadPrec ByteMatchSetUpdate
$creadPrec :: ReadPrec ByteMatchSetUpdate
readList :: ReadS [ByteMatchSetUpdate]
$creadList :: ReadS [ByteMatchSetUpdate]
readsPrec :: Int -> ReadS ByteMatchSetUpdate
$creadsPrec :: Int -> ReadS ByteMatchSetUpdate
Prelude.Read, Int -> ByteMatchSetUpdate -> ShowS
[ByteMatchSetUpdate] -> ShowS
ByteMatchSetUpdate -> String
(Int -> ByteMatchSetUpdate -> ShowS)
-> (ByteMatchSetUpdate -> String)
-> ([ByteMatchSetUpdate] -> ShowS)
-> Show ByteMatchSetUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ByteMatchSetUpdate] -> ShowS
$cshowList :: [ByteMatchSetUpdate] -> ShowS
show :: ByteMatchSetUpdate -> String
$cshow :: ByteMatchSetUpdate -> String
showsPrec :: Int -> ByteMatchSetUpdate -> ShowS
$cshowsPrec :: Int -> ByteMatchSetUpdate -> ShowS
Prelude.Show, (forall x. ByteMatchSetUpdate -> Rep ByteMatchSetUpdate x)
-> (forall x. Rep ByteMatchSetUpdate x -> ByteMatchSetUpdate)
-> Generic ByteMatchSetUpdate
forall x. Rep ByteMatchSetUpdate x -> ByteMatchSetUpdate
forall x. ByteMatchSetUpdate -> Rep ByteMatchSetUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ByteMatchSetUpdate x -> ByteMatchSetUpdate
$cfrom :: forall x. ByteMatchSetUpdate -> Rep ByteMatchSetUpdate x
Prelude.Generic)

-- |
-- Create a value of 'ByteMatchSetUpdate' 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:
--
-- 'action', 'byteMatchSetUpdate_action' - Specifies whether to insert or delete a ByteMatchTuple.
--
-- 'byteMatchTuple', 'byteMatchSetUpdate_byteMatchTuple' - Information about the part of a web request that you want AWS WAF to
-- inspect and the value that you want AWS WAF to search for. If you
-- specify @DELETE@ for the value of @Action@, the @ByteMatchTuple@ values
-- must exactly match the values in the @ByteMatchTuple@ that you want to
-- delete from the @ByteMatchSet@.
newByteMatchSetUpdate ::
  -- | 'action'
  ChangeAction ->
  -- | 'byteMatchTuple'
  ByteMatchTuple ->
  ByteMatchSetUpdate
newByteMatchSetUpdate :: ChangeAction -> ByteMatchTuple -> ByteMatchSetUpdate
newByteMatchSetUpdate ChangeAction
pAction_ ByteMatchTuple
pByteMatchTuple_ =
  ByteMatchSetUpdate' :: ChangeAction -> ByteMatchTuple -> ByteMatchSetUpdate
ByteMatchSetUpdate'
    { $sel:action:ByteMatchSetUpdate' :: ChangeAction
action = ChangeAction
pAction_,
      $sel:byteMatchTuple:ByteMatchSetUpdate' :: ByteMatchTuple
byteMatchTuple = ByteMatchTuple
pByteMatchTuple_
    }

-- | Specifies whether to insert or delete a ByteMatchTuple.
byteMatchSetUpdate_action :: Lens.Lens' ByteMatchSetUpdate ChangeAction
byteMatchSetUpdate_action :: (ChangeAction -> f ChangeAction)
-> ByteMatchSetUpdate -> f ByteMatchSetUpdate
byteMatchSetUpdate_action = (ByteMatchSetUpdate -> ChangeAction)
-> (ByteMatchSetUpdate -> ChangeAction -> ByteMatchSetUpdate)
-> Lens
     ByteMatchSetUpdate ByteMatchSetUpdate ChangeAction ChangeAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ByteMatchSetUpdate' {ChangeAction
action :: ChangeAction
$sel:action:ByteMatchSetUpdate' :: ByteMatchSetUpdate -> ChangeAction
action} -> ChangeAction
action) (\s :: ByteMatchSetUpdate
s@ByteMatchSetUpdate' {} ChangeAction
a -> ByteMatchSetUpdate
s {$sel:action:ByteMatchSetUpdate' :: ChangeAction
action = ChangeAction
a} :: ByteMatchSetUpdate)

-- | Information about the part of a web request that you want AWS WAF to
-- inspect and the value that you want AWS WAF to search for. If you
-- specify @DELETE@ for the value of @Action@, the @ByteMatchTuple@ values
-- must exactly match the values in the @ByteMatchTuple@ that you want to
-- delete from the @ByteMatchSet@.
byteMatchSetUpdate_byteMatchTuple :: Lens.Lens' ByteMatchSetUpdate ByteMatchTuple
byteMatchSetUpdate_byteMatchTuple :: (ByteMatchTuple -> f ByteMatchTuple)
-> ByteMatchSetUpdate -> f ByteMatchSetUpdate
byteMatchSetUpdate_byteMatchTuple = (ByteMatchSetUpdate -> ByteMatchTuple)
-> (ByteMatchSetUpdate -> ByteMatchTuple -> ByteMatchSetUpdate)
-> Lens
     ByteMatchSetUpdate ByteMatchSetUpdate ByteMatchTuple ByteMatchTuple
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ByteMatchSetUpdate' {ByteMatchTuple
byteMatchTuple :: ByteMatchTuple
$sel:byteMatchTuple:ByteMatchSetUpdate' :: ByteMatchSetUpdate -> ByteMatchTuple
byteMatchTuple} -> ByteMatchTuple
byteMatchTuple) (\s :: ByteMatchSetUpdate
s@ByteMatchSetUpdate' {} ByteMatchTuple
a -> ByteMatchSetUpdate
s {$sel:byteMatchTuple:ByteMatchSetUpdate' :: ByteMatchTuple
byteMatchTuple = ByteMatchTuple
a} :: ByteMatchSetUpdate)

instance Prelude.Hashable ByteMatchSetUpdate

instance Prelude.NFData ByteMatchSetUpdate

instance Core.ToJSON ByteMatchSetUpdate where
  toJSON :: ByteMatchSetUpdate -> Value
toJSON ByteMatchSetUpdate' {ChangeAction
ByteMatchTuple
byteMatchTuple :: ByteMatchTuple
action :: ChangeAction
$sel:byteMatchTuple:ByteMatchSetUpdate' :: ByteMatchSetUpdate -> ByteMatchTuple
$sel:action:ByteMatchSetUpdate' :: ByteMatchSetUpdate -> ChangeAction
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Action" Text -> ChangeAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ChangeAction
action),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ByteMatchTuple" Text -> ByteMatchTuple -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ByteMatchTuple
byteMatchTuple)
          ]
      )