{-# 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.SecurityHub.Types.AwsWafRegionalRateBasedRuleMatchPredicate
-- 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.SecurityHub.Types.AwsWafRegionalRateBasedRuleMatchPredicate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Details for a match predicate. A predicate might look for
-- characteristics such as specific IP addresses, geographic locations, or
-- sizes.
--
-- /See:/ 'newAwsWafRegionalRateBasedRuleMatchPredicate' smart constructor.
data AwsWafRegionalRateBasedRuleMatchPredicate = AwsWafRegionalRateBasedRuleMatchPredicate'
  { -- | If set to @true@, then the rule actions are performed on requests that
    -- match the predicate settings.
    --
    -- If set to @false@, then the rule actions are performed on all requests
    -- except those that match the predicate settings.
    AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Bool
negated :: Prelude.Maybe Prelude.Bool,
    -- | The unique identifier for the predicate.
    AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Text
dataId :: Prelude.Maybe Prelude.Text,
    -- | The type of predicate.
    AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsWafRegionalRateBasedRuleMatchPredicate
-> AwsWafRegionalRateBasedRuleMatchPredicate -> Bool
(AwsWafRegionalRateBasedRuleMatchPredicate
 -> AwsWafRegionalRateBasedRuleMatchPredicate -> Bool)
-> (AwsWafRegionalRateBasedRuleMatchPredicate
    -> AwsWafRegionalRateBasedRuleMatchPredicate -> Bool)
-> Eq AwsWafRegionalRateBasedRuleMatchPredicate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsWafRegionalRateBasedRuleMatchPredicate
-> AwsWafRegionalRateBasedRuleMatchPredicate -> Bool
$c/= :: AwsWafRegionalRateBasedRuleMatchPredicate
-> AwsWafRegionalRateBasedRuleMatchPredicate -> Bool
== :: AwsWafRegionalRateBasedRuleMatchPredicate
-> AwsWafRegionalRateBasedRuleMatchPredicate -> Bool
$c== :: AwsWafRegionalRateBasedRuleMatchPredicate
-> AwsWafRegionalRateBasedRuleMatchPredicate -> Bool
Prelude.Eq, ReadPrec [AwsWafRegionalRateBasedRuleMatchPredicate]
ReadPrec AwsWafRegionalRateBasedRuleMatchPredicate
Int -> ReadS AwsWafRegionalRateBasedRuleMatchPredicate
ReadS [AwsWafRegionalRateBasedRuleMatchPredicate]
(Int -> ReadS AwsWafRegionalRateBasedRuleMatchPredicate)
-> ReadS [AwsWafRegionalRateBasedRuleMatchPredicate]
-> ReadPrec AwsWafRegionalRateBasedRuleMatchPredicate
-> ReadPrec [AwsWafRegionalRateBasedRuleMatchPredicate]
-> Read AwsWafRegionalRateBasedRuleMatchPredicate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsWafRegionalRateBasedRuleMatchPredicate]
$creadListPrec :: ReadPrec [AwsWafRegionalRateBasedRuleMatchPredicate]
readPrec :: ReadPrec AwsWafRegionalRateBasedRuleMatchPredicate
$creadPrec :: ReadPrec AwsWafRegionalRateBasedRuleMatchPredicate
readList :: ReadS [AwsWafRegionalRateBasedRuleMatchPredicate]
$creadList :: ReadS [AwsWafRegionalRateBasedRuleMatchPredicate]
readsPrec :: Int -> ReadS AwsWafRegionalRateBasedRuleMatchPredicate
$creadsPrec :: Int -> ReadS AwsWafRegionalRateBasedRuleMatchPredicate
Prelude.Read, Int -> AwsWafRegionalRateBasedRuleMatchPredicate -> ShowS
[AwsWafRegionalRateBasedRuleMatchPredicate] -> ShowS
AwsWafRegionalRateBasedRuleMatchPredicate -> String
(Int -> AwsWafRegionalRateBasedRuleMatchPredicate -> ShowS)
-> (AwsWafRegionalRateBasedRuleMatchPredicate -> String)
-> ([AwsWafRegionalRateBasedRuleMatchPredicate] -> ShowS)
-> Show AwsWafRegionalRateBasedRuleMatchPredicate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsWafRegionalRateBasedRuleMatchPredicate] -> ShowS
$cshowList :: [AwsWafRegionalRateBasedRuleMatchPredicate] -> ShowS
show :: AwsWafRegionalRateBasedRuleMatchPredicate -> String
$cshow :: AwsWafRegionalRateBasedRuleMatchPredicate -> String
showsPrec :: Int -> AwsWafRegionalRateBasedRuleMatchPredicate -> ShowS
$cshowsPrec :: Int -> AwsWafRegionalRateBasedRuleMatchPredicate -> ShowS
Prelude.Show, (forall x.
 AwsWafRegionalRateBasedRuleMatchPredicate
 -> Rep AwsWafRegionalRateBasedRuleMatchPredicate x)
-> (forall x.
    Rep AwsWafRegionalRateBasedRuleMatchPredicate x
    -> AwsWafRegionalRateBasedRuleMatchPredicate)
-> Generic AwsWafRegionalRateBasedRuleMatchPredicate
forall x.
Rep AwsWafRegionalRateBasedRuleMatchPredicate x
-> AwsWafRegionalRateBasedRuleMatchPredicate
forall x.
AwsWafRegionalRateBasedRuleMatchPredicate
-> Rep AwsWafRegionalRateBasedRuleMatchPredicate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsWafRegionalRateBasedRuleMatchPredicate x
-> AwsWafRegionalRateBasedRuleMatchPredicate
$cfrom :: forall x.
AwsWafRegionalRateBasedRuleMatchPredicate
-> Rep AwsWafRegionalRateBasedRuleMatchPredicate x
Prelude.Generic)

-- |
-- Create a value of 'AwsWafRegionalRateBasedRuleMatchPredicate' 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:
--
-- 'negated', 'awsWafRegionalRateBasedRuleMatchPredicate_negated' - If set to @true@, then the rule actions are performed on requests that
-- match the predicate settings.
--
-- If set to @false@, then the rule actions are performed on all requests
-- except those that match the predicate settings.
--
-- 'dataId', 'awsWafRegionalRateBasedRuleMatchPredicate_dataId' - The unique identifier for the predicate.
--
-- 'type'', 'awsWafRegionalRateBasedRuleMatchPredicate_type' - The type of predicate.
newAwsWafRegionalRateBasedRuleMatchPredicate ::
  AwsWafRegionalRateBasedRuleMatchPredicate
newAwsWafRegionalRateBasedRuleMatchPredicate :: AwsWafRegionalRateBasedRuleMatchPredicate
newAwsWafRegionalRateBasedRuleMatchPredicate =
  AwsWafRegionalRateBasedRuleMatchPredicate' :: Maybe Bool
-> Maybe Text
-> Maybe Text
-> AwsWafRegionalRateBasedRuleMatchPredicate
AwsWafRegionalRateBasedRuleMatchPredicate'
    { $sel:negated:AwsWafRegionalRateBasedRuleMatchPredicate' :: Maybe Bool
negated =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:dataId:AwsWafRegionalRateBasedRuleMatchPredicate' :: Maybe Text
dataId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':AwsWafRegionalRateBasedRuleMatchPredicate' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | If set to @true@, then the rule actions are performed on requests that
-- match the predicate settings.
--
-- If set to @false@, then the rule actions are performed on all requests
-- except those that match the predicate settings.
awsWafRegionalRateBasedRuleMatchPredicate_negated :: Lens.Lens' AwsWafRegionalRateBasedRuleMatchPredicate (Prelude.Maybe Prelude.Bool)
awsWafRegionalRateBasedRuleMatchPredicate_negated :: (Maybe Bool -> f (Maybe Bool))
-> AwsWafRegionalRateBasedRuleMatchPredicate
-> f AwsWafRegionalRateBasedRuleMatchPredicate
awsWafRegionalRateBasedRuleMatchPredicate_negated = (AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Bool)
-> (AwsWafRegionalRateBasedRuleMatchPredicate
    -> Maybe Bool -> AwsWafRegionalRateBasedRuleMatchPredicate)
-> Lens
     AwsWafRegionalRateBasedRuleMatchPredicate
     AwsWafRegionalRateBasedRuleMatchPredicate
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafRegionalRateBasedRuleMatchPredicate' {Maybe Bool
negated :: Maybe Bool
$sel:negated:AwsWafRegionalRateBasedRuleMatchPredicate' :: AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Bool
negated} -> Maybe Bool
negated) (\s :: AwsWafRegionalRateBasedRuleMatchPredicate
s@AwsWafRegionalRateBasedRuleMatchPredicate' {} Maybe Bool
a -> AwsWafRegionalRateBasedRuleMatchPredicate
s {$sel:negated:AwsWafRegionalRateBasedRuleMatchPredicate' :: Maybe Bool
negated = Maybe Bool
a} :: AwsWafRegionalRateBasedRuleMatchPredicate)

-- | The unique identifier for the predicate.
awsWafRegionalRateBasedRuleMatchPredicate_dataId :: Lens.Lens' AwsWafRegionalRateBasedRuleMatchPredicate (Prelude.Maybe Prelude.Text)
awsWafRegionalRateBasedRuleMatchPredicate_dataId :: (Maybe Text -> f (Maybe Text))
-> AwsWafRegionalRateBasedRuleMatchPredicate
-> f AwsWafRegionalRateBasedRuleMatchPredicate
awsWafRegionalRateBasedRuleMatchPredicate_dataId = (AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Text)
-> (AwsWafRegionalRateBasedRuleMatchPredicate
    -> Maybe Text -> AwsWafRegionalRateBasedRuleMatchPredicate)
-> Lens
     AwsWafRegionalRateBasedRuleMatchPredicate
     AwsWafRegionalRateBasedRuleMatchPredicate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafRegionalRateBasedRuleMatchPredicate' {Maybe Text
dataId :: Maybe Text
$sel:dataId:AwsWafRegionalRateBasedRuleMatchPredicate' :: AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Text
dataId} -> Maybe Text
dataId) (\s :: AwsWafRegionalRateBasedRuleMatchPredicate
s@AwsWafRegionalRateBasedRuleMatchPredicate' {} Maybe Text
a -> AwsWafRegionalRateBasedRuleMatchPredicate
s {$sel:dataId:AwsWafRegionalRateBasedRuleMatchPredicate' :: Maybe Text
dataId = Maybe Text
a} :: AwsWafRegionalRateBasedRuleMatchPredicate)

-- | The type of predicate.
awsWafRegionalRateBasedRuleMatchPredicate_type :: Lens.Lens' AwsWafRegionalRateBasedRuleMatchPredicate (Prelude.Maybe Prelude.Text)
awsWafRegionalRateBasedRuleMatchPredicate_type :: (Maybe Text -> f (Maybe Text))
-> AwsWafRegionalRateBasedRuleMatchPredicate
-> f AwsWafRegionalRateBasedRuleMatchPredicate
awsWafRegionalRateBasedRuleMatchPredicate_type = (AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Text)
-> (AwsWafRegionalRateBasedRuleMatchPredicate
    -> Maybe Text -> AwsWafRegionalRateBasedRuleMatchPredicate)
-> Lens
     AwsWafRegionalRateBasedRuleMatchPredicate
     AwsWafRegionalRateBasedRuleMatchPredicate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafRegionalRateBasedRuleMatchPredicate' {Maybe Text
type' :: Maybe Text
$sel:type':AwsWafRegionalRateBasedRuleMatchPredicate' :: AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Text
type'} -> Maybe Text
type') (\s :: AwsWafRegionalRateBasedRuleMatchPredicate
s@AwsWafRegionalRateBasedRuleMatchPredicate' {} Maybe Text
a -> AwsWafRegionalRateBasedRuleMatchPredicate
s {$sel:type':AwsWafRegionalRateBasedRuleMatchPredicate' :: Maybe Text
type' = Maybe Text
a} :: AwsWafRegionalRateBasedRuleMatchPredicate)

instance
  Core.FromJSON
    AwsWafRegionalRateBasedRuleMatchPredicate
  where
  parseJSON :: Value -> Parser AwsWafRegionalRateBasedRuleMatchPredicate
parseJSON =
    String
-> (Object -> Parser AwsWafRegionalRateBasedRuleMatchPredicate)
-> Value
-> Parser AwsWafRegionalRateBasedRuleMatchPredicate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsWafRegionalRateBasedRuleMatchPredicate"
      ( \Object
x ->
          Maybe Bool
-> Maybe Text
-> Maybe Text
-> AwsWafRegionalRateBasedRuleMatchPredicate
AwsWafRegionalRateBasedRuleMatchPredicate'
            (Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> AwsWafRegionalRateBasedRuleMatchPredicate)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text
      -> Maybe Text -> AwsWafRegionalRateBasedRuleMatchPredicate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Negated")
              Parser
  (Maybe Text
   -> Maybe Text -> AwsWafRegionalRateBasedRuleMatchPredicate)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AwsWafRegionalRateBasedRuleMatchPredicate)
forall (f :: * -> *) a b. Applicative f => 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
"DataId")
              Parser (Maybe Text -> AwsWafRegionalRateBasedRuleMatchPredicate)
-> Parser (Maybe Text)
-> Parser AwsWafRegionalRateBasedRuleMatchPredicate
forall (f :: * -> *) a b. Applicative f => 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
"Type")
      )

instance
  Prelude.Hashable
    AwsWafRegionalRateBasedRuleMatchPredicate

instance
  Prelude.NFData
    AwsWafRegionalRateBasedRuleMatchPredicate

instance
  Core.ToJSON
    AwsWafRegionalRateBasedRuleMatchPredicate
  where
  toJSON :: AwsWafRegionalRateBasedRuleMatchPredicate -> Value
toJSON AwsWafRegionalRateBasedRuleMatchPredicate' {Maybe Bool
Maybe Text
type' :: Maybe Text
dataId :: Maybe Text
negated :: Maybe Bool
$sel:type':AwsWafRegionalRateBasedRuleMatchPredicate' :: AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Text
$sel:dataId:AwsWafRegionalRateBasedRuleMatchPredicate' :: AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Text
$sel:negated:AwsWafRegionalRateBasedRuleMatchPredicate' :: AwsWafRegionalRateBasedRuleMatchPredicate -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Negated" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
negated,
            (Text
"DataId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dataId,
            (Text
"Type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
type'
          ]
      )