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

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

-- | A match predicate. A predicate might look for characteristics such as
-- specific IP addresses, geographic locations, or sizes.
--
-- /See:/ 'newAwsWafRateBasedRuleMatchPredicate' smart constructor.
data AwsWafRateBasedRuleMatchPredicate = AwsWafRateBasedRuleMatchPredicate'
  { -- | 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.
    AwsWafRateBasedRuleMatchPredicate -> Maybe Bool
negated :: Prelude.Maybe Prelude.Bool,
    -- | The unique identifier for the predicate.
    AwsWafRateBasedRuleMatchPredicate -> Maybe Text
dataId :: Prelude.Maybe Prelude.Text,
    -- | The type of predicate.
    AwsWafRateBasedRuleMatchPredicate -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsWafRateBasedRuleMatchPredicate
-> AwsWafRateBasedRuleMatchPredicate -> Bool
(AwsWafRateBasedRuleMatchPredicate
 -> AwsWafRateBasedRuleMatchPredicate -> Bool)
-> (AwsWafRateBasedRuleMatchPredicate
    -> AwsWafRateBasedRuleMatchPredicate -> Bool)
-> Eq AwsWafRateBasedRuleMatchPredicate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsWafRateBasedRuleMatchPredicate
-> AwsWafRateBasedRuleMatchPredicate -> Bool
$c/= :: AwsWafRateBasedRuleMatchPredicate
-> AwsWafRateBasedRuleMatchPredicate -> Bool
== :: AwsWafRateBasedRuleMatchPredicate
-> AwsWafRateBasedRuleMatchPredicate -> Bool
$c== :: AwsWafRateBasedRuleMatchPredicate
-> AwsWafRateBasedRuleMatchPredicate -> Bool
Prelude.Eq, ReadPrec [AwsWafRateBasedRuleMatchPredicate]
ReadPrec AwsWafRateBasedRuleMatchPredicate
Int -> ReadS AwsWafRateBasedRuleMatchPredicate
ReadS [AwsWafRateBasedRuleMatchPredicate]
(Int -> ReadS AwsWafRateBasedRuleMatchPredicate)
-> ReadS [AwsWafRateBasedRuleMatchPredicate]
-> ReadPrec AwsWafRateBasedRuleMatchPredicate
-> ReadPrec [AwsWafRateBasedRuleMatchPredicate]
-> Read AwsWafRateBasedRuleMatchPredicate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsWafRateBasedRuleMatchPredicate]
$creadListPrec :: ReadPrec [AwsWafRateBasedRuleMatchPredicate]
readPrec :: ReadPrec AwsWafRateBasedRuleMatchPredicate
$creadPrec :: ReadPrec AwsWafRateBasedRuleMatchPredicate
readList :: ReadS [AwsWafRateBasedRuleMatchPredicate]
$creadList :: ReadS [AwsWafRateBasedRuleMatchPredicate]
readsPrec :: Int -> ReadS AwsWafRateBasedRuleMatchPredicate
$creadsPrec :: Int -> ReadS AwsWafRateBasedRuleMatchPredicate
Prelude.Read, Int -> AwsWafRateBasedRuleMatchPredicate -> ShowS
[AwsWafRateBasedRuleMatchPredicate] -> ShowS
AwsWafRateBasedRuleMatchPredicate -> String
(Int -> AwsWafRateBasedRuleMatchPredicate -> ShowS)
-> (AwsWafRateBasedRuleMatchPredicate -> String)
-> ([AwsWafRateBasedRuleMatchPredicate] -> ShowS)
-> Show AwsWafRateBasedRuleMatchPredicate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsWafRateBasedRuleMatchPredicate] -> ShowS
$cshowList :: [AwsWafRateBasedRuleMatchPredicate] -> ShowS
show :: AwsWafRateBasedRuleMatchPredicate -> String
$cshow :: AwsWafRateBasedRuleMatchPredicate -> String
showsPrec :: Int -> AwsWafRateBasedRuleMatchPredicate -> ShowS
$cshowsPrec :: Int -> AwsWafRateBasedRuleMatchPredicate -> ShowS
Prelude.Show, (forall x.
 AwsWafRateBasedRuleMatchPredicate
 -> Rep AwsWafRateBasedRuleMatchPredicate x)
-> (forall x.
    Rep AwsWafRateBasedRuleMatchPredicate x
    -> AwsWafRateBasedRuleMatchPredicate)
-> Generic AwsWafRateBasedRuleMatchPredicate
forall x.
Rep AwsWafRateBasedRuleMatchPredicate x
-> AwsWafRateBasedRuleMatchPredicate
forall x.
AwsWafRateBasedRuleMatchPredicate
-> Rep AwsWafRateBasedRuleMatchPredicate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsWafRateBasedRuleMatchPredicate x
-> AwsWafRateBasedRuleMatchPredicate
$cfrom :: forall x.
AwsWafRateBasedRuleMatchPredicate
-> Rep AwsWafRateBasedRuleMatchPredicate x
Prelude.Generic)

-- |
-- Create a value of 'AwsWafRateBasedRuleMatchPredicate' 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', 'awsWafRateBasedRuleMatchPredicate_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', 'awsWafRateBasedRuleMatchPredicate_dataId' - The unique identifier for the predicate.
--
-- 'type'', 'awsWafRateBasedRuleMatchPredicate_type' - The type of predicate.
newAwsWafRateBasedRuleMatchPredicate ::
  AwsWafRateBasedRuleMatchPredicate
newAwsWafRateBasedRuleMatchPredicate :: AwsWafRateBasedRuleMatchPredicate
newAwsWafRateBasedRuleMatchPredicate =
  AwsWafRateBasedRuleMatchPredicate' :: Maybe Bool
-> Maybe Text -> Maybe Text -> AwsWafRateBasedRuleMatchPredicate
AwsWafRateBasedRuleMatchPredicate'
    { $sel:negated:AwsWafRateBasedRuleMatchPredicate' :: Maybe Bool
negated =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:dataId:AwsWafRateBasedRuleMatchPredicate' :: Maybe Text
dataId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':AwsWafRateBasedRuleMatchPredicate' :: 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.
awsWafRateBasedRuleMatchPredicate_negated :: Lens.Lens' AwsWafRateBasedRuleMatchPredicate (Prelude.Maybe Prelude.Bool)
awsWafRateBasedRuleMatchPredicate_negated :: (Maybe Bool -> f (Maybe Bool))
-> AwsWafRateBasedRuleMatchPredicate
-> f AwsWafRateBasedRuleMatchPredicate
awsWafRateBasedRuleMatchPredicate_negated = (AwsWafRateBasedRuleMatchPredicate -> Maybe Bool)
-> (AwsWafRateBasedRuleMatchPredicate
    -> Maybe Bool -> AwsWafRateBasedRuleMatchPredicate)
-> Lens
     AwsWafRateBasedRuleMatchPredicate
     AwsWafRateBasedRuleMatchPredicate
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafRateBasedRuleMatchPredicate' {Maybe Bool
negated :: Maybe Bool
$sel:negated:AwsWafRateBasedRuleMatchPredicate' :: AwsWafRateBasedRuleMatchPredicate -> Maybe Bool
negated} -> Maybe Bool
negated) (\s :: AwsWafRateBasedRuleMatchPredicate
s@AwsWafRateBasedRuleMatchPredicate' {} Maybe Bool
a -> AwsWafRateBasedRuleMatchPredicate
s {$sel:negated:AwsWafRateBasedRuleMatchPredicate' :: Maybe Bool
negated = Maybe Bool
a} :: AwsWafRateBasedRuleMatchPredicate)

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

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

instance
  Core.FromJSON
    AwsWafRateBasedRuleMatchPredicate
  where
  parseJSON :: Value -> Parser AwsWafRateBasedRuleMatchPredicate
parseJSON =
    String
-> (Object -> Parser AwsWafRateBasedRuleMatchPredicate)
-> Value
-> Parser AwsWafRateBasedRuleMatchPredicate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsWafRateBasedRuleMatchPredicate"
      ( \Object
x ->
          Maybe Bool
-> Maybe Text -> Maybe Text -> AwsWafRateBasedRuleMatchPredicate
AwsWafRateBasedRuleMatchPredicate'
            (Maybe Bool
 -> Maybe Text -> Maybe Text -> AwsWafRateBasedRuleMatchPredicate)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text -> Maybe Text -> AwsWafRateBasedRuleMatchPredicate)
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 -> AwsWafRateBasedRuleMatchPredicate)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AwsWafRateBasedRuleMatchPredicate)
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 -> AwsWafRateBasedRuleMatchPredicate)
-> Parser (Maybe Text) -> Parser AwsWafRateBasedRuleMatchPredicate
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
    AwsWafRateBasedRuleMatchPredicate

instance
  Prelude.NFData
    AwsWafRateBasedRuleMatchPredicate

instance
  Core.ToJSON
    AwsWafRateBasedRuleMatchPredicate
  where
  toJSON :: AwsWafRateBasedRuleMatchPredicate -> Value
toJSON AwsWafRateBasedRuleMatchPredicate' {Maybe Bool
Maybe Text
type' :: Maybe Text
dataId :: Maybe Text
negated :: Maybe Bool
$sel:type':AwsWafRateBasedRuleMatchPredicate' :: AwsWafRateBasedRuleMatchPredicate -> Maybe Text
$sel:dataId:AwsWafRateBasedRuleMatchPredicate' :: AwsWafRateBasedRuleMatchPredicate -> Maybe Text
$sel:negated:AwsWafRateBasedRuleMatchPredicate' :: AwsWafRateBasedRuleMatchPredicate -> 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'
          ]
      )