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

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

-- | Configuration settings for the handling of the stateful rule groups in a
-- firewall policy.
--
-- /See:/ 'newStatefulEngineOptions' smart constructor.
data StatefulEngineOptions = StatefulEngineOptions'
  { -- | Indicates how to manage the order of stateful rule evaluation for the
    -- policy. By default, Network Firewall leaves the rule evaluation order up
    -- to the Suricata rule processing engine. If you set this to
    -- @STRICT_ORDER@, your rules are evaluated in the exact order that you
    -- provide them in the policy. With strict ordering, the rule groups are
    -- evaluated by order of priority, starting from the lowest number, and the
    -- rules in each rule group are processed in the order that they\'re
    -- defined.
    StatefulEngineOptions -> Maybe RuleOrder
ruleOrder :: Prelude.Maybe RuleOrder
  }
  deriving (StatefulEngineOptions -> StatefulEngineOptions -> Bool
(StatefulEngineOptions -> StatefulEngineOptions -> Bool)
-> (StatefulEngineOptions -> StatefulEngineOptions -> Bool)
-> Eq StatefulEngineOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatefulEngineOptions -> StatefulEngineOptions -> Bool
$c/= :: StatefulEngineOptions -> StatefulEngineOptions -> Bool
== :: StatefulEngineOptions -> StatefulEngineOptions -> Bool
$c== :: StatefulEngineOptions -> StatefulEngineOptions -> Bool
Prelude.Eq, ReadPrec [StatefulEngineOptions]
ReadPrec StatefulEngineOptions
Int -> ReadS StatefulEngineOptions
ReadS [StatefulEngineOptions]
(Int -> ReadS StatefulEngineOptions)
-> ReadS [StatefulEngineOptions]
-> ReadPrec StatefulEngineOptions
-> ReadPrec [StatefulEngineOptions]
-> Read StatefulEngineOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatefulEngineOptions]
$creadListPrec :: ReadPrec [StatefulEngineOptions]
readPrec :: ReadPrec StatefulEngineOptions
$creadPrec :: ReadPrec StatefulEngineOptions
readList :: ReadS [StatefulEngineOptions]
$creadList :: ReadS [StatefulEngineOptions]
readsPrec :: Int -> ReadS StatefulEngineOptions
$creadsPrec :: Int -> ReadS StatefulEngineOptions
Prelude.Read, Int -> StatefulEngineOptions -> ShowS
[StatefulEngineOptions] -> ShowS
StatefulEngineOptions -> String
(Int -> StatefulEngineOptions -> ShowS)
-> (StatefulEngineOptions -> String)
-> ([StatefulEngineOptions] -> ShowS)
-> Show StatefulEngineOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatefulEngineOptions] -> ShowS
$cshowList :: [StatefulEngineOptions] -> ShowS
show :: StatefulEngineOptions -> String
$cshow :: StatefulEngineOptions -> String
showsPrec :: Int -> StatefulEngineOptions -> ShowS
$cshowsPrec :: Int -> StatefulEngineOptions -> ShowS
Prelude.Show, (forall x. StatefulEngineOptions -> Rep StatefulEngineOptions x)
-> (forall x. Rep StatefulEngineOptions x -> StatefulEngineOptions)
-> Generic StatefulEngineOptions
forall x. Rep StatefulEngineOptions x -> StatefulEngineOptions
forall x. StatefulEngineOptions -> Rep StatefulEngineOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatefulEngineOptions x -> StatefulEngineOptions
$cfrom :: forall x. StatefulEngineOptions -> Rep StatefulEngineOptions x
Prelude.Generic)

-- |
-- Create a value of 'StatefulEngineOptions' 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', 'statefulEngineOptions_ruleOrder' - Indicates how to manage the order of stateful rule evaluation for the
-- policy. By default, Network Firewall leaves the rule evaluation order up
-- to the Suricata rule processing engine. If you set this to
-- @STRICT_ORDER@, your rules are evaluated in the exact order that you
-- provide them in the policy. With strict ordering, the rule groups are
-- evaluated by order of priority, starting from the lowest number, and the
-- rules in each rule group are processed in the order that they\'re
-- defined.
newStatefulEngineOptions ::
  StatefulEngineOptions
newStatefulEngineOptions :: StatefulEngineOptions
newStatefulEngineOptions =
  StatefulEngineOptions' :: Maybe RuleOrder -> StatefulEngineOptions
StatefulEngineOptions' {$sel:ruleOrder:StatefulEngineOptions' :: Maybe RuleOrder
ruleOrder = Maybe RuleOrder
forall a. Maybe a
Prelude.Nothing}

-- | Indicates how to manage the order of stateful rule evaluation for the
-- policy. By default, Network Firewall leaves the rule evaluation order up
-- to the Suricata rule processing engine. If you set this to
-- @STRICT_ORDER@, your rules are evaluated in the exact order that you
-- provide them in the policy. With strict ordering, the rule groups are
-- evaluated by order of priority, starting from the lowest number, and the
-- rules in each rule group are processed in the order that they\'re
-- defined.
statefulEngineOptions_ruleOrder :: Lens.Lens' StatefulEngineOptions (Prelude.Maybe RuleOrder)
statefulEngineOptions_ruleOrder :: (Maybe RuleOrder -> f (Maybe RuleOrder))
-> StatefulEngineOptions -> f StatefulEngineOptions
statefulEngineOptions_ruleOrder = (StatefulEngineOptions -> Maybe RuleOrder)
-> (StatefulEngineOptions
    -> Maybe RuleOrder -> StatefulEngineOptions)
-> Lens
     StatefulEngineOptions
     StatefulEngineOptions
     (Maybe RuleOrder)
     (Maybe RuleOrder)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatefulEngineOptions' {Maybe RuleOrder
ruleOrder :: Maybe RuleOrder
$sel:ruleOrder:StatefulEngineOptions' :: StatefulEngineOptions -> Maybe RuleOrder
ruleOrder} -> Maybe RuleOrder
ruleOrder) (\s :: StatefulEngineOptions
s@StatefulEngineOptions' {} Maybe RuleOrder
a -> StatefulEngineOptions
s {$sel:ruleOrder:StatefulEngineOptions' :: Maybe RuleOrder
ruleOrder = Maybe RuleOrder
a} :: StatefulEngineOptions)

instance Core.FromJSON StatefulEngineOptions where
  parseJSON :: Value -> Parser StatefulEngineOptions
parseJSON =
    String
-> (Object -> Parser StatefulEngineOptions)
-> Value
-> Parser StatefulEngineOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StatefulEngineOptions"
      ( \Object
x ->
          Maybe RuleOrder -> StatefulEngineOptions
StatefulEngineOptions'
            (Maybe RuleOrder -> StatefulEngineOptions)
-> Parser (Maybe RuleOrder) -> Parser StatefulEngineOptions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RuleOrder)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RuleOrder")
      )

instance Prelude.Hashable StatefulEngineOptions

instance Prelude.NFData StatefulEngineOptions

instance Core.ToJSON StatefulEngineOptions where
  toJSON :: StatefulEngineOptions -> Value
toJSON StatefulEngineOptions' {Maybe RuleOrder
ruleOrder :: Maybe RuleOrder
$sel:ruleOrder:StatefulEngineOptions' :: StatefulEngineOptions -> Maybe RuleOrder
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"RuleOrder" Text -> RuleOrder -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RuleOrder -> Pair) -> Maybe RuleOrder -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RuleOrder
ruleOrder]
      )