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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFRegional.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 UpdateRegexPatternSet request, @RegexPatternSetUpdate@ specifies
-- whether to insert or delete a @RegexPatternString@ and includes the
-- settings for the @RegexPatternString@.
--
-- /See:/ 'newRegexPatternSetUpdate' smart constructor.
data RegexPatternSetUpdate = RegexPatternSetUpdate'
  { -- | Specifies whether to insert or delete a @RegexPatternString@.
    RegexPatternSetUpdate -> ChangeAction
action :: ChangeAction,
    -- | Specifies the regular expression (regex) pattern that you want AWS WAF
    -- to search for, such as @B[a\@]dB[o0]t@.
    RegexPatternSetUpdate -> Text
regexPatternString :: Prelude.Text
  }
  deriving (RegexPatternSetUpdate -> RegexPatternSetUpdate -> Bool
(RegexPatternSetUpdate -> RegexPatternSetUpdate -> Bool)
-> (RegexPatternSetUpdate -> RegexPatternSetUpdate -> Bool)
-> Eq RegexPatternSetUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegexPatternSetUpdate -> RegexPatternSetUpdate -> Bool
$c/= :: RegexPatternSetUpdate -> RegexPatternSetUpdate -> Bool
== :: RegexPatternSetUpdate -> RegexPatternSetUpdate -> Bool
$c== :: RegexPatternSetUpdate -> RegexPatternSetUpdate -> Bool
Prelude.Eq, ReadPrec [RegexPatternSetUpdate]
ReadPrec RegexPatternSetUpdate
Int -> ReadS RegexPatternSetUpdate
ReadS [RegexPatternSetUpdate]
(Int -> ReadS RegexPatternSetUpdate)
-> ReadS [RegexPatternSetUpdate]
-> ReadPrec RegexPatternSetUpdate
-> ReadPrec [RegexPatternSetUpdate]
-> Read RegexPatternSetUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegexPatternSetUpdate]
$creadListPrec :: ReadPrec [RegexPatternSetUpdate]
readPrec :: ReadPrec RegexPatternSetUpdate
$creadPrec :: ReadPrec RegexPatternSetUpdate
readList :: ReadS [RegexPatternSetUpdate]
$creadList :: ReadS [RegexPatternSetUpdate]
readsPrec :: Int -> ReadS RegexPatternSetUpdate
$creadsPrec :: Int -> ReadS RegexPatternSetUpdate
Prelude.Read, Int -> RegexPatternSetUpdate -> ShowS
[RegexPatternSetUpdate] -> ShowS
RegexPatternSetUpdate -> String
(Int -> RegexPatternSetUpdate -> ShowS)
-> (RegexPatternSetUpdate -> String)
-> ([RegexPatternSetUpdate] -> ShowS)
-> Show RegexPatternSetUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegexPatternSetUpdate] -> ShowS
$cshowList :: [RegexPatternSetUpdate] -> ShowS
show :: RegexPatternSetUpdate -> String
$cshow :: RegexPatternSetUpdate -> String
showsPrec :: Int -> RegexPatternSetUpdate -> ShowS
$cshowsPrec :: Int -> RegexPatternSetUpdate -> ShowS
Prelude.Show, (forall x. RegexPatternSetUpdate -> Rep RegexPatternSetUpdate x)
-> (forall x. Rep RegexPatternSetUpdate x -> RegexPatternSetUpdate)
-> Generic RegexPatternSetUpdate
forall x. Rep RegexPatternSetUpdate x -> RegexPatternSetUpdate
forall x. RegexPatternSetUpdate -> Rep RegexPatternSetUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegexPatternSetUpdate x -> RegexPatternSetUpdate
$cfrom :: forall x. RegexPatternSetUpdate -> Rep RegexPatternSetUpdate x
Prelude.Generic)

-- |
-- Create a value of 'RegexPatternSetUpdate' 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', 'regexPatternSetUpdate_action' - Specifies whether to insert or delete a @RegexPatternString@.
--
-- 'regexPatternString', 'regexPatternSetUpdate_regexPatternString' - Specifies the regular expression (regex) pattern that you want AWS WAF
-- to search for, such as @B[a\@]dB[o0]t@.
newRegexPatternSetUpdate ::
  -- | 'action'
  ChangeAction ->
  -- | 'regexPatternString'
  Prelude.Text ->
  RegexPatternSetUpdate
newRegexPatternSetUpdate :: ChangeAction -> Text -> RegexPatternSetUpdate
newRegexPatternSetUpdate
  ChangeAction
pAction_
  Text
pRegexPatternString_ =
    RegexPatternSetUpdate' :: ChangeAction -> Text -> RegexPatternSetUpdate
RegexPatternSetUpdate'
      { $sel:action:RegexPatternSetUpdate' :: ChangeAction
action = ChangeAction
pAction_,
        $sel:regexPatternString:RegexPatternSetUpdate' :: Text
regexPatternString = Text
pRegexPatternString_
      }

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

-- | Specifies the regular expression (regex) pattern that you want AWS WAF
-- to search for, such as @B[a\@]dB[o0]t@.
regexPatternSetUpdate_regexPatternString :: Lens.Lens' RegexPatternSetUpdate Prelude.Text
regexPatternSetUpdate_regexPatternString :: (Text -> f Text)
-> RegexPatternSetUpdate -> f RegexPatternSetUpdate
regexPatternSetUpdate_regexPatternString = (RegexPatternSetUpdate -> Text)
-> (RegexPatternSetUpdate -> Text -> RegexPatternSetUpdate)
-> Lens RegexPatternSetUpdate RegexPatternSetUpdate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexPatternSetUpdate' {Text
regexPatternString :: Text
$sel:regexPatternString:RegexPatternSetUpdate' :: RegexPatternSetUpdate -> Text
regexPatternString} -> Text
regexPatternString) (\s :: RegexPatternSetUpdate
s@RegexPatternSetUpdate' {} Text
a -> RegexPatternSetUpdate
s {$sel:regexPatternString:RegexPatternSetUpdate' :: Text
regexPatternString = Text
a} :: RegexPatternSetUpdate)

instance Prelude.Hashable RegexPatternSetUpdate

instance Prelude.NFData RegexPatternSetUpdate

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