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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFRegional.Types.ChangeAction
import Amazonka.WAFRegional.Types.RegexMatchTuple

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

-- |
-- Create a value of 'RegexMatchSetUpdate' 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', 'regexMatchSetUpdate_action' - Specifies whether to insert or delete a RegexMatchTuple.
--
-- 'regexMatchTuple', 'regexMatchSetUpdate_regexMatchTuple' - Information about the part of a web request that you want AWS WAF to
-- inspect and the identifier of the regular expression (regex) pattern
-- that you want AWS WAF to search for. If you specify @DELETE@ for the
-- value of @Action@, the @RegexMatchTuple@ values must exactly match the
-- values in the @RegexMatchTuple@ that you want to delete from the
-- @RegexMatchSet@.
newRegexMatchSetUpdate ::
  -- | 'action'
  ChangeAction ->
  -- | 'regexMatchTuple'
  RegexMatchTuple ->
  RegexMatchSetUpdate
newRegexMatchSetUpdate :: ChangeAction -> RegexMatchTuple -> RegexMatchSetUpdate
newRegexMatchSetUpdate ChangeAction
pAction_ RegexMatchTuple
pRegexMatchTuple_ =
  RegexMatchSetUpdate' :: ChangeAction -> RegexMatchTuple -> RegexMatchSetUpdate
RegexMatchSetUpdate'
    { $sel:action:RegexMatchSetUpdate' :: ChangeAction
action = ChangeAction
pAction_,
      $sel:regexMatchTuple:RegexMatchSetUpdate' :: RegexMatchTuple
regexMatchTuple = RegexMatchTuple
pRegexMatchTuple_
    }

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

-- | Information about the part of a web request that you want AWS WAF to
-- inspect and the identifier of the regular expression (regex) pattern
-- that you want AWS WAF to search for. If you specify @DELETE@ for the
-- value of @Action@, the @RegexMatchTuple@ values must exactly match the
-- values in the @RegexMatchTuple@ that you want to delete from the
-- @RegexMatchSet@.
regexMatchSetUpdate_regexMatchTuple :: Lens.Lens' RegexMatchSetUpdate RegexMatchTuple
regexMatchSetUpdate_regexMatchTuple :: (RegexMatchTuple -> f RegexMatchTuple)
-> RegexMatchSetUpdate -> f RegexMatchSetUpdate
regexMatchSetUpdate_regexMatchTuple = (RegexMatchSetUpdate -> RegexMatchTuple)
-> (RegexMatchSetUpdate -> RegexMatchTuple -> RegexMatchSetUpdate)
-> Lens
     RegexMatchSetUpdate
     RegexMatchSetUpdate
     RegexMatchTuple
     RegexMatchTuple
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexMatchSetUpdate' {RegexMatchTuple
regexMatchTuple :: RegexMatchTuple
$sel:regexMatchTuple:RegexMatchSetUpdate' :: RegexMatchSetUpdate -> RegexMatchTuple
regexMatchTuple} -> RegexMatchTuple
regexMatchTuple) (\s :: RegexMatchSetUpdate
s@RegexMatchSetUpdate' {} RegexMatchTuple
a -> RegexMatchSetUpdate
s {$sel:regexMatchTuple:RegexMatchSetUpdate' :: RegexMatchTuple
regexMatchTuple = RegexMatchTuple
a} :: RegexMatchSetUpdate)

instance Prelude.Hashable RegexMatchSetUpdate

instance Prelude.NFData RegexMatchSetUpdate

instance Core.ToJSON RegexMatchSetUpdate where
  toJSON :: RegexMatchSetUpdate -> Value
toJSON RegexMatchSetUpdate' {ChangeAction
RegexMatchTuple
regexMatchTuple :: RegexMatchTuple
action :: ChangeAction
$sel:regexMatchTuple:RegexMatchSetUpdate' :: RegexMatchSetUpdate -> RegexMatchTuple
$sel:action:RegexMatchSetUpdate' :: RegexMatchSetUpdate -> 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
"RegexMatchTuple" Text -> RegexMatchTuple -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RegexMatchTuple
regexMatchTuple)
          ]
      )