{-# 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.ManagedRuleGroupConfig
-- 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.ManagedRuleGroupConfig 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.AWSManagedRulesBotControlRuleSet
import Amazonka.WAFV2.Types.PasswordField
import Amazonka.WAFV2.Types.PayloadType
import Amazonka.WAFV2.Types.UsernameField

-- | Additional information that\'s used by a managed rule group. Many
-- managed rule groups don\'t require this.
--
-- Use the @AWSManagedRulesBotControlRuleSet@ configuration object to
-- configure the protection level that you want the Bot Control rule group
-- to use.
--
-- For example specifications, see the examples section of CreateWebACL.
--
-- /See:/ 'newManagedRuleGroupConfig' smart constructor.
data ManagedRuleGroupConfig = ManagedRuleGroupConfig'
  { -- | Additional configuration for using the Bot Control managed rule group.
    -- Use this to specify the inspection level that you want to use. For
    -- information about using the Bot Control managed rule group, see
    -- <https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-bot.html WAF Bot Control rule group>
    -- and
    -- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-bot-control.html WAF Bot Control>
    -- in the /WAF Developer Guide/.
    ManagedRuleGroupConfig -> Maybe AWSManagedRulesBotControlRuleSet
aWSManagedRulesBotControlRuleSet :: Prelude.Maybe AWSManagedRulesBotControlRuleSet,
    -- | The path of the login endpoint for your application. For example, for
    -- the URL @https:\/\/example.com\/web\/login@, you would provide the path
    -- @\/web\/login@.
    ManagedRuleGroupConfig -> Maybe Text
loginPath :: Prelude.Maybe Prelude.Text,
    -- | Details about your login page password field.
    ManagedRuleGroupConfig -> Maybe PasswordField
passwordField :: Prelude.Maybe PasswordField,
    -- | The payload type for your login endpoint, either JSON or form encoded.
    ManagedRuleGroupConfig -> Maybe PayloadType
payloadType :: Prelude.Maybe PayloadType,
    -- | Details about your login page username field.
    ManagedRuleGroupConfig -> Maybe UsernameField
usernameField :: Prelude.Maybe UsernameField
  }
  deriving (ManagedRuleGroupConfig -> ManagedRuleGroupConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ManagedRuleGroupConfig -> ManagedRuleGroupConfig -> Bool
$c/= :: ManagedRuleGroupConfig -> ManagedRuleGroupConfig -> Bool
== :: ManagedRuleGroupConfig -> ManagedRuleGroupConfig -> Bool
$c== :: ManagedRuleGroupConfig -> ManagedRuleGroupConfig -> Bool
Prelude.Eq, ReadPrec [ManagedRuleGroupConfig]
ReadPrec ManagedRuleGroupConfig
Int -> ReadS ManagedRuleGroupConfig
ReadS [ManagedRuleGroupConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ManagedRuleGroupConfig]
$creadListPrec :: ReadPrec [ManagedRuleGroupConfig]
readPrec :: ReadPrec ManagedRuleGroupConfig
$creadPrec :: ReadPrec ManagedRuleGroupConfig
readList :: ReadS [ManagedRuleGroupConfig]
$creadList :: ReadS [ManagedRuleGroupConfig]
readsPrec :: Int -> ReadS ManagedRuleGroupConfig
$creadsPrec :: Int -> ReadS ManagedRuleGroupConfig
Prelude.Read, Int -> ManagedRuleGroupConfig -> ShowS
[ManagedRuleGroupConfig] -> ShowS
ManagedRuleGroupConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ManagedRuleGroupConfig] -> ShowS
$cshowList :: [ManagedRuleGroupConfig] -> ShowS
show :: ManagedRuleGroupConfig -> String
$cshow :: ManagedRuleGroupConfig -> String
showsPrec :: Int -> ManagedRuleGroupConfig -> ShowS
$cshowsPrec :: Int -> ManagedRuleGroupConfig -> ShowS
Prelude.Show, forall x. Rep ManagedRuleGroupConfig x -> ManagedRuleGroupConfig
forall x. ManagedRuleGroupConfig -> Rep ManagedRuleGroupConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ManagedRuleGroupConfig x -> ManagedRuleGroupConfig
$cfrom :: forall x. ManagedRuleGroupConfig -> Rep ManagedRuleGroupConfig x
Prelude.Generic)

-- |
-- Create a value of 'ManagedRuleGroupConfig' 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:
--
-- 'aWSManagedRulesBotControlRuleSet', 'managedRuleGroupConfig_aWSManagedRulesBotControlRuleSet' - Additional configuration for using the Bot Control managed rule group.
-- Use this to specify the inspection level that you want to use. For
-- information about using the Bot Control managed rule group, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-bot.html WAF Bot Control rule group>
-- and
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-bot-control.html WAF Bot Control>
-- in the /WAF Developer Guide/.
--
-- 'loginPath', 'managedRuleGroupConfig_loginPath' - The path of the login endpoint for your application. For example, for
-- the URL @https:\/\/example.com\/web\/login@, you would provide the path
-- @\/web\/login@.
--
-- 'passwordField', 'managedRuleGroupConfig_passwordField' - Details about your login page password field.
--
-- 'payloadType', 'managedRuleGroupConfig_payloadType' - The payload type for your login endpoint, either JSON or form encoded.
--
-- 'usernameField', 'managedRuleGroupConfig_usernameField' - Details about your login page username field.
newManagedRuleGroupConfig ::
  ManagedRuleGroupConfig
newManagedRuleGroupConfig :: ManagedRuleGroupConfig
newManagedRuleGroupConfig =
  ManagedRuleGroupConfig'
    { $sel:aWSManagedRulesBotControlRuleSet:ManagedRuleGroupConfig' :: Maybe AWSManagedRulesBotControlRuleSet
aWSManagedRulesBotControlRuleSet =
        forall a. Maybe a
Prelude.Nothing,
      $sel:loginPath:ManagedRuleGroupConfig' :: Maybe Text
loginPath = forall a. Maybe a
Prelude.Nothing,
      $sel:passwordField:ManagedRuleGroupConfig' :: Maybe PasswordField
passwordField = forall a. Maybe a
Prelude.Nothing,
      $sel:payloadType:ManagedRuleGroupConfig' :: Maybe PayloadType
payloadType = forall a. Maybe a
Prelude.Nothing,
      $sel:usernameField:ManagedRuleGroupConfig' :: Maybe UsernameField
usernameField = forall a. Maybe a
Prelude.Nothing
    }

-- | Additional configuration for using the Bot Control managed rule group.
-- Use this to specify the inspection level that you want to use. For
-- information about using the Bot Control managed rule group, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-bot.html WAF Bot Control rule group>
-- and
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-bot-control.html WAF Bot Control>
-- in the /WAF Developer Guide/.
managedRuleGroupConfig_aWSManagedRulesBotControlRuleSet :: Lens.Lens' ManagedRuleGroupConfig (Prelude.Maybe AWSManagedRulesBotControlRuleSet)
managedRuleGroupConfig_aWSManagedRulesBotControlRuleSet :: Lens'
  ManagedRuleGroupConfig (Maybe AWSManagedRulesBotControlRuleSet)
managedRuleGroupConfig_aWSManagedRulesBotControlRuleSet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleGroupConfig' {Maybe AWSManagedRulesBotControlRuleSet
aWSManagedRulesBotControlRuleSet :: Maybe AWSManagedRulesBotControlRuleSet
$sel:aWSManagedRulesBotControlRuleSet:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe AWSManagedRulesBotControlRuleSet
aWSManagedRulesBotControlRuleSet} -> Maybe AWSManagedRulesBotControlRuleSet
aWSManagedRulesBotControlRuleSet) (\s :: ManagedRuleGroupConfig
s@ManagedRuleGroupConfig' {} Maybe AWSManagedRulesBotControlRuleSet
a -> ManagedRuleGroupConfig
s {$sel:aWSManagedRulesBotControlRuleSet:ManagedRuleGroupConfig' :: Maybe AWSManagedRulesBotControlRuleSet
aWSManagedRulesBotControlRuleSet = Maybe AWSManagedRulesBotControlRuleSet
a} :: ManagedRuleGroupConfig)

-- | The path of the login endpoint for your application. For example, for
-- the URL @https:\/\/example.com\/web\/login@, you would provide the path
-- @\/web\/login@.
managedRuleGroupConfig_loginPath :: Lens.Lens' ManagedRuleGroupConfig (Prelude.Maybe Prelude.Text)
managedRuleGroupConfig_loginPath :: Lens' ManagedRuleGroupConfig (Maybe Text)
managedRuleGroupConfig_loginPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleGroupConfig' {Maybe Text
loginPath :: Maybe Text
$sel:loginPath:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe Text
loginPath} -> Maybe Text
loginPath) (\s :: ManagedRuleGroupConfig
s@ManagedRuleGroupConfig' {} Maybe Text
a -> ManagedRuleGroupConfig
s {$sel:loginPath:ManagedRuleGroupConfig' :: Maybe Text
loginPath = Maybe Text
a} :: ManagedRuleGroupConfig)

-- | Details about your login page password field.
managedRuleGroupConfig_passwordField :: Lens.Lens' ManagedRuleGroupConfig (Prelude.Maybe PasswordField)
managedRuleGroupConfig_passwordField :: Lens' ManagedRuleGroupConfig (Maybe PasswordField)
managedRuleGroupConfig_passwordField = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleGroupConfig' {Maybe PasswordField
passwordField :: Maybe PasswordField
$sel:passwordField:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe PasswordField
passwordField} -> Maybe PasswordField
passwordField) (\s :: ManagedRuleGroupConfig
s@ManagedRuleGroupConfig' {} Maybe PasswordField
a -> ManagedRuleGroupConfig
s {$sel:passwordField:ManagedRuleGroupConfig' :: Maybe PasswordField
passwordField = Maybe PasswordField
a} :: ManagedRuleGroupConfig)

-- | The payload type for your login endpoint, either JSON or form encoded.
managedRuleGroupConfig_payloadType :: Lens.Lens' ManagedRuleGroupConfig (Prelude.Maybe PayloadType)
managedRuleGroupConfig_payloadType :: Lens' ManagedRuleGroupConfig (Maybe PayloadType)
managedRuleGroupConfig_payloadType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleGroupConfig' {Maybe PayloadType
payloadType :: Maybe PayloadType
$sel:payloadType:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe PayloadType
payloadType} -> Maybe PayloadType
payloadType) (\s :: ManagedRuleGroupConfig
s@ManagedRuleGroupConfig' {} Maybe PayloadType
a -> ManagedRuleGroupConfig
s {$sel:payloadType:ManagedRuleGroupConfig' :: Maybe PayloadType
payloadType = Maybe PayloadType
a} :: ManagedRuleGroupConfig)

-- | Details about your login page username field.
managedRuleGroupConfig_usernameField :: Lens.Lens' ManagedRuleGroupConfig (Prelude.Maybe UsernameField)
managedRuleGroupConfig_usernameField :: Lens' ManagedRuleGroupConfig (Maybe UsernameField)
managedRuleGroupConfig_usernameField = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleGroupConfig' {Maybe UsernameField
usernameField :: Maybe UsernameField
$sel:usernameField:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe UsernameField
usernameField} -> Maybe UsernameField
usernameField) (\s :: ManagedRuleGroupConfig
s@ManagedRuleGroupConfig' {} Maybe UsernameField
a -> ManagedRuleGroupConfig
s {$sel:usernameField:ManagedRuleGroupConfig' :: Maybe UsernameField
usernameField = Maybe UsernameField
a} :: ManagedRuleGroupConfig)

instance Data.FromJSON ManagedRuleGroupConfig where
  parseJSON :: Value -> Parser ManagedRuleGroupConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ManagedRuleGroupConfig"
      ( \Object
x ->
          Maybe AWSManagedRulesBotControlRuleSet
-> Maybe Text
-> Maybe PasswordField
-> Maybe PayloadType
-> Maybe UsernameField
-> ManagedRuleGroupConfig
ManagedRuleGroupConfig'
            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
"AWSManagedRulesBotControlRuleSet")
            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
"LoginPath")
            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
"PasswordField")
            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
"PayloadType")
            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
"UsernameField")
      )

instance Prelude.Hashable ManagedRuleGroupConfig where
  hashWithSalt :: Int -> ManagedRuleGroupConfig -> Int
hashWithSalt Int
_salt ManagedRuleGroupConfig' {Maybe Text
Maybe AWSManagedRulesBotControlRuleSet
Maybe PasswordField
Maybe PayloadType
Maybe UsernameField
usernameField :: Maybe UsernameField
payloadType :: Maybe PayloadType
passwordField :: Maybe PasswordField
loginPath :: Maybe Text
aWSManagedRulesBotControlRuleSet :: Maybe AWSManagedRulesBotControlRuleSet
$sel:usernameField:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe UsernameField
$sel:payloadType:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe PayloadType
$sel:passwordField:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe PasswordField
$sel:loginPath:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe Text
$sel:aWSManagedRulesBotControlRuleSet:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe AWSManagedRulesBotControlRuleSet
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AWSManagedRulesBotControlRuleSet
aWSManagedRulesBotControlRuleSet
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
loginPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PasswordField
passwordField
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PayloadType
payloadType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UsernameField
usernameField

instance Prelude.NFData ManagedRuleGroupConfig where
  rnf :: ManagedRuleGroupConfig -> ()
rnf ManagedRuleGroupConfig' {Maybe Text
Maybe AWSManagedRulesBotControlRuleSet
Maybe PasswordField
Maybe PayloadType
Maybe UsernameField
usernameField :: Maybe UsernameField
payloadType :: Maybe PayloadType
passwordField :: Maybe PasswordField
loginPath :: Maybe Text
aWSManagedRulesBotControlRuleSet :: Maybe AWSManagedRulesBotControlRuleSet
$sel:usernameField:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe UsernameField
$sel:payloadType:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe PayloadType
$sel:passwordField:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe PasswordField
$sel:loginPath:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe Text
$sel:aWSManagedRulesBotControlRuleSet:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe AWSManagedRulesBotControlRuleSet
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AWSManagedRulesBotControlRuleSet
aWSManagedRulesBotControlRuleSet
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
loginPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PasswordField
passwordField
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PayloadType
payloadType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UsernameField
usernameField

instance Data.ToJSON ManagedRuleGroupConfig where
  toJSON :: ManagedRuleGroupConfig -> Value
toJSON ManagedRuleGroupConfig' {Maybe Text
Maybe AWSManagedRulesBotControlRuleSet
Maybe PasswordField
Maybe PayloadType
Maybe UsernameField
usernameField :: Maybe UsernameField
payloadType :: Maybe PayloadType
passwordField :: Maybe PasswordField
loginPath :: Maybe Text
aWSManagedRulesBotControlRuleSet :: Maybe AWSManagedRulesBotControlRuleSet
$sel:usernameField:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe UsernameField
$sel:payloadType:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe PayloadType
$sel:passwordField:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe PasswordField
$sel:loginPath:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe Text
$sel:aWSManagedRulesBotControlRuleSet:ManagedRuleGroupConfig' :: ManagedRuleGroupConfig -> Maybe AWSManagedRulesBotControlRuleSet
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AWSManagedRulesBotControlRuleSet" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AWSManagedRulesBotControlRuleSet
aWSManagedRulesBotControlRuleSet,
            (Key
"LoginPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
loginPath,
            (Key
"PasswordField" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PasswordField
passwordField,
            (Key
"PayloadType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PayloadType
payloadType,
            (Key
"UsernameField" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UsernameField
usernameField
          ]
      )