{-# 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.NetworkFirewall.Types.StatefulRuleOptions
-- 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.NetworkFirewall.Types.StatefulRuleOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.NetworkFirewall.Types.RuleOrder
import qualified Amazonka.Prelude as Prelude

-- | Additional options governing how Network Firewall handles the rule
-- group. You can only use these for stateful rule groups.
--
-- /See:/ 'newStatefulRuleOptions' smart constructor.
data StatefulRuleOptions = StatefulRuleOptions'
  { -- | Indicates how to manage the order of the rule evaluation for the rule
    -- group. @DEFAULT_ACTION_ORDER@ is the default behavior. Stateful rules
    -- are provided to the rule engine as Suricata compatible strings, and
    -- Suricata evaluates them based on certain settings. For more information,
    -- see
    -- <https://docs.aws.amazon.com/network-firewall/latest/developerguide/suricata-rule-evaluation-order.html Evaluation order for stateful rules>
    -- in the /Network Firewall Developer Guide/.
    StatefulRuleOptions -> Maybe RuleOrder
ruleOrder :: Prelude.Maybe RuleOrder
  }
  deriving (StatefulRuleOptions -> StatefulRuleOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatefulRuleOptions -> StatefulRuleOptions -> Bool
$c/= :: StatefulRuleOptions -> StatefulRuleOptions -> Bool
== :: StatefulRuleOptions -> StatefulRuleOptions -> Bool
$c== :: StatefulRuleOptions -> StatefulRuleOptions -> Bool
Prelude.Eq, ReadPrec [StatefulRuleOptions]
ReadPrec StatefulRuleOptions
Int -> ReadS StatefulRuleOptions
ReadS [StatefulRuleOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatefulRuleOptions]
$creadListPrec :: ReadPrec [StatefulRuleOptions]
readPrec :: ReadPrec StatefulRuleOptions
$creadPrec :: ReadPrec StatefulRuleOptions
readList :: ReadS [StatefulRuleOptions]
$creadList :: ReadS [StatefulRuleOptions]
readsPrec :: Int -> ReadS StatefulRuleOptions
$creadsPrec :: Int -> ReadS StatefulRuleOptions
Prelude.Read, Int -> StatefulRuleOptions -> ShowS
[StatefulRuleOptions] -> ShowS
StatefulRuleOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatefulRuleOptions] -> ShowS
$cshowList :: [StatefulRuleOptions] -> ShowS
show :: StatefulRuleOptions -> String
$cshow :: StatefulRuleOptions -> String
showsPrec :: Int -> StatefulRuleOptions -> ShowS
$cshowsPrec :: Int -> StatefulRuleOptions -> ShowS
Prelude.Show, forall x. Rep StatefulRuleOptions x -> StatefulRuleOptions
forall x. StatefulRuleOptions -> Rep StatefulRuleOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatefulRuleOptions x -> StatefulRuleOptions
$cfrom :: forall x. StatefulRuleOptions -> Rep StatefulRuleOptions x
Prelude.Generic)

-- |
-- Create a value of 'StatefulRuleOptions' 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:
--
-- 'ruleOrder', 'statefulRuleOptions_ruleOrder' - Indicates how to manage the order of the rule evaluation for the rule
-- group. @DEFAULT_ACTION_ORDER@ is the default behavior. Stateful rules
-- are provided to the rule engine as Suricata compatible strings, and
-- Suricata evaluates them based on certain settings. For more information,
-- see
-- <https://docs.aws.amazon.com/network-firewall/latest/developerguide/suricata-rule-evaluation-order.html Evaluation order for stateful rules>
-- in the /Network Firewall Developer Guide/.
newStatefulRuleOptions ::
  StatefulRuleOptions
newStatefulRuleOptions :: StatefulRuleOptions
newStatefulRuleOptions =
  StatefulRuleOptions' {$sel:ruleOrder:StatefulRuleOptions' :: Maybe RuleOrder
ruleOrder = forall a. Maybe a
Prelude.Nothing}

-- | Indicates how to manage the order of the rule evaluation for the rule
-- group. @DEFAULT_ACTION_ORDER@ is the default behavior. Stateful rules
-- are provided to the rule engine as Suricata compatible strings, and
-- Suricata evaluates them based on certain settings. For more information,
-- see
-- <https://docs.aws.amazon.com/network-firewall/latest/developerguide/suricata-rule-evaluation-order.html Evaluation order for stateful rules>
-- in the /Network Firewall Developer Guide/.
statefulRuleOptions_ruleOrder :: Lens.Lens' StatefulRuleOptions (Prelude.Maybe RuleOrder)
statefulRuleOptions_ruleOrder :: Lens' StatefulRuleOptions (Maybe RuleOrder)
statefulRuleOptions_ruleOrder = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatefulRuleOptions' {Maybe RuleOrder
ruleOrder :: Maybe RuleOrder
$sel:ruleOrder:StatefulRuleOptions' :: StatefulRuleOptions -> Maybe RuleOrder
ruleOrder} -> Maybe RuleOrder
ruleOrder) (\s :: StatefulRuleOptions
s@StatefulRuleOptions' {} Maybe RuleOrder
a -> StatefulRuleOptions
s {$sel:ruleOrder:StatefulRuleOptions' :: Maybe RuleOrder
ruleOrder = Maybe RuleOrder
a} :: StatefulRuleOptions)

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

instance Prelude.Hashable StatefulRuleOptions where
  hashWithSalt :: Int -> StatefulRuleOptions -> Int
hashWithSalt Int
_salt StatefulRuleOptions' {Maybe RuleOrder
ruleOrder :: Maybe RuleOrder
$sel:ruleOrder:StatefulRuleOptions' :: StatefulRuleOptions -> Maybe RuleOrder
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RuleOrder
ruleOrder

instance Prelude.NFData StatefulRuleOptions where
  rnf :: StatefulRuleOptions -> ()
rnf StatefulRuleOptions' {Maybe RuleOrder
ruleOrder :: Maybe RuleOrder
$sel:ruleOrder:StatefulRuleOptions' :: StatefulRuleOptions -> Maybe RuleOrder
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe RuleOrder
ruleOrder

instance Data.ToJSON StatefulRuleOptions where
  toJSON :: StatefulRuleOptions -> Value
toJSON StatefulRuleOptions' {Maybe RuleOrder
ruleOrder :: Maybe RuleOrder
$sel:ruleOrder:StatefulRuleOptions' :: StatefulRuleOptions -> Maybe RuleOrder
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"RuleOrder" 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 RuleOrder
ruleOrder]
      )