{-# 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.WAFV2.Types.RegexPatternSet
-- 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.WAFV2.Types.RegexPatternSet 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.WAFV2.Types.Regex

-- | Contains one or more regular expressions.
--
-- WAF assigns an ARN to each @RegexPatternSet@ that you create. To use a
-- set in a rule, you provide the ARN to the Rule statement
-- RegexPatternSetReferenceStatement.
--
-- /See:/ 'newRegexPatternSet' smart constructor.
data RegexPatternSet = RegexPatternSet'
  { -- | The Amazon Resource Name (ARN) of the entity.
    RegexPatternSet -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | A description of the set that helps with identification.
    RegexPatternSet -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the set. This ID is returned in the responses to
    -- create and list commands. You provide it to operations like update and
    -- delete.
    RegexPatternSet -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The name of the set. You cannot change the name after you create the
    -- set.
    RegexPatternSet -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The regular expression patterns in the set.
    RegexPatternSet -> Maybe [Regex]
regularExpressionList :: Prelude.Maybe [Regex]
  }
  deriving (RegexPatternSet -> RegexPatternSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegexPatternSet -> RegexPatternSet -> Bool
$c/= :: RegexPatternSet -> RegexPatternSet -> Bool
== :: RegexPatternSet -> RegexPatternSet -> Bool
$c== :: RegexPatternSet -> RegexPatternSet -> Bool
Prelude.Eq, ReadPrec [RegexPatternSet]
ReadPrec RegexPatternSet
Int -> ReadS RegexPatternSet
ReadS [RegexPatternSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegexPatternSet]
$creadListPrec :: ReadPrec [RegexPatternSet]
readPrec :: ReadPrec RegexPatternSet
$creadPrec :: ReadPrec RegexPatternSet
readList :: ReadS [RegexPatternSet]
$creadList :: ReadS [RegexPatternSet]
readsPrec :: Int -> ReadS RegexPatternSet
$creadsPrec :: Int -> ReadS RegexPatternSet
Prelude.Read, Int -> RegexPatternSet -> ShowS
[RegexPatternSet] -> ShowS
RegexPatternSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegexPatternSet] -> ShowS
$cshowList :: [RegexPatternSet] -> ShowS
show :: RegexPatternSet -> String
$cshow :: RegexPatternSet -> String
showsPrec :: Int -> RegexPatternSet -> ShowS
$cshowsPrec :: Int -> RegexPatternSet -> ShowS
Prelude.Show, forall x. Rep RegexPatternSet x -> RegexPatternSet
forall x. RegexPatternSet -> Rep RegexPatternSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegexPatternSet x -> RegexPatternSet
$cfrom :: forall x. RegexPatternSet -> Rep RegexPatternSet x
Prelude.Generic)

-- |
-- Create a value of 'RegexPatternSet' 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:
--
-- 'arn', 'regexPatternSet_arn' - The Amazon Resource Name (ARN) of the entity.
--
-- 'description', 'regexPatternSet_description' - A description of the set that helps with identification.
--
-- 'id', 'regexPatternSet_id' - A unique identifier for the set. This ID is returned in the responses to
-- create and list commands. You provide it to operations like update and
-- delete.
--
-- 'name', 'regexPatternSet_name' - The name of the set. You cannot change the name after you create the
-- set.
--
-- 'regularExpressionList', 'regexPatternSet_regularExpressionList' - The regular expression patterns in the set.
newRegexPatternSet ::
  RegexPatternSet
newRegexPatternSet :: RegexPatternSet
newRegexPatternSet =
  RegexPatternSet'
    { $sel:arn:RegexPatternSet' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:description:RegexPatternSet' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:id:RegexPatternSet' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:name:RegexPatternSet' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:regularExpressionList:RegexPatternSet' :: Maybe [Regex]
regularExpressionList = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the entity.
regexPatternSet_arn :: Lens.Lens' RegexPatternSet (Prelude.Maybe Prelude.Text)
regexPatternSet_arn :: Lens' RegexPatternSet (Maybe Text)
regexPatternSet_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexPatternSet' {Maybe Text
arn :: Maybe Text
$sel:arn:RegexPatternSet' :: RegexPatternSet -> Maybe Text
arn} -> Maybe Text
arn) (\s :: RegexPatternSet
s@RegexPatternSet' {} Maybe Text
a -> RegexPatternSet
s {$sel:arn:RegexPatternSet' :: Maybe Text
arn = Maybe Text
a} :: RegexPatternSet)

-- | A description of the set that helps with identification.
regexPatternSet_description :: Lens.Lens' RegexPatternSet (Prelude.Maybe Prelude.Text)
regexPatternSet_description :: Lens' RegexPatternSet (Maybe Text)
regexPatternSet_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexPatternSet' {Maybe Text
description :: Maybe Text
$sel:description:RegexPatternSet' :: RegexPatternSet -> Maybe Text
description} -> Maybe Text
description) (\s :: RegexPatternSet
s@RegexPatternSet' {} Maybe Text
a -> RegexPatternSet
s {$sel:description:RegexPatternSet' :: Maybe Text
description = Maybe Text
a} :: RegexPatternSet)

-- | A unique identifier for the set. This ID is returned in the responses to
-- create and list commands. You provide it to operations like update and
-- delete.
regexPatternSet_id :: Lens.Lens' RegexPatternSet (Prelude.Maybe Prelude.Text)
regexPatternSet_id :: Lens' RegexPatternSet (Maybe Text)
regexPatternSet_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexPatternSet' {Maybe Text
id :: Maybe Text
$sel:id:RegexPatternSet' :: RegexPatternSet -> Maybe Text
id} -> Maybe Text
id) (\s :: RegexPatternSet
s@RegexPatternSet' {} Maybe Text
a -> RegexPatternSet
s {$sel:id:RegexPatternSet' :: Maybe Text
id = Maybe Text
a} :: RegexPatternSet)

-- | The name of the set. You cannot change the name after you create the
-- set.
regexPatternSet_name :: Lens.Lens' RegexPatternSet (Prelude.Maybe Prelude.Text)
regexPatternSet_name :: Lens' RegexPatternSet (Maybe Text)
regexPatternSet_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexPatternSet' {Maybe Text
name :: Maybe Text
$sel:name:RegexPatternSet' :: RegexPatternSet -> Maybe Text
name} -> Maybe Text
name) (\s :: RegexPatternSet
s@RegexPatternSet' {} Maybe Text
a -> RegexPatternSet
s {$sel:name:RegexPatternSet' :: Maybe Text
name = Maybe Text
a} :: RegexPatternSet)

-- | The regular expression patterns in the set.
regexPatternSet_regularExpressionList :: Lens.Lens' RegexPatternSet (Prelude.Maybe [Regex])
regexPatternSet_regularExpressionList :: Lens' RegexPatternSet (Maybe [Regex])
regexPatternSet_regularExpressionList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegexPatternSet' {Maybe [Regex]
regularExpressionList :: Maybe [Regex]
$sel:regularExpressionList:RegexPatternSet' :: RegexPatternSet -> Maybe [Regex]
regularExpressionList} -> Maybe [Regex]
regularExpressionList) (\s :: RegexPatternSet
s@RegexPatternSet' {} Maybe [Regex]
a -> RegexPatternSet
s {$sel:regularExpressionList:RegexPatternSet' :: Maybe [Regex]
regularExpressionList = Maybe [Regex]
a} :: RegexPatternSet) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON RegexPatternSet where
  parseJSON :: Value -> Parser RegexPatternSet
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RegexPatternSet"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Regex]
-> RegexPatternSet
RegexPatternSet'
            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
"ARN")
            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
"Description")
            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
"Id")
            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
"Name")
            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
"RegularExpressionList"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable RegexPatternSet where
  hashWithSalt :: Int -> RegexPatternSet -> Int
hashWithSalt Int
_salt RegexPatternSet' {Maybe [Regex]
Maybe Text
regularExpressionList :: Maybe [Regex]
name :: Maybe Text
id :: Maybe Text
description :: Maybe Text
arn :: Maybe Text
$sel:regularExpressionList:RegexPatternSet' :: RegexPatternSet -> Maybe [Regex]
$sel:name:RegexPatternSet' :: RegexPatternSet -> Maybe Text
$sel:id:RegexPatternSet' :: RegexPatternSet -> Maybe Text
$sel:description:RegexPatternSet' :: RegexPatternSet -> Maybe Text
$sel:arn:RegexPatternSet' :: RegexPatternSet -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Regex]
regularExpressionList

instance Prelude.NFData RegexPatternSet where
  rnf :: RegexPatternSet -> ()
rnf RegexPatternSet' {Maybe [Regex]
Maybe Text
regularExpressionList :: Maybe [Regex]
name :: Maybe Text
id :: Maybe Text
description :: Maybe Text
arn :: Maybe Text
$sel:regularExpressionList:RegexPatternSet' :: RegexPatternSet -> Maybe [Regex]
$sel:name:RegexPatternSet' :: RegexPatternSet -> Maybe Text
$sel:id:RegexPatternSet' :: RegexPatternSet -> Maybe Text
$sel:description:RegexPatternSet' :: RegexPatternSet -> Maybe Text
$sel:arn:RegexPatternSet' :: RegexPatternSet -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Maybe [Regex]
regularExpressionList