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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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. 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
    -- they\'re listed in your Suricata rules string.
    StatefulRuleOptions -> Maybe RuleOrder
ruleOrder :: Prelude.Maybe RuleOrder
  }
  deriving (StatefulRuleOptions -> StatefulRuleOptions -> Bool
(StatefulRuleOptions -> StatefulRuleOptions -> Bool)
-> (StatefulRuleOptions -> StatefulRuleOptions -> Bool)
-> Eq StatefulRuleOptions
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]
(Int -> ReadS StatefulRuleOptions)
-> ReadS [StatefulRuleOptions]
-> ReadPrec StatefulRuleOptions
-> ReadPrec [StatefulRuleOptions]
-> Read 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
(Int -> StatefulRuleOptions -> ShowS)
-> (StatefulRuleOptions -> String)
-> ([StatefulRuleOptions] -> ShowS)
-> Show StatefulRuleOptions
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. StatefulRuleOptions -> Rep StatefulRuleOptions x)
-> (forall x. Rep StatefulRuleOptions x -> StatefulRuleOptions)
-> Generic StatefulRuleOptions
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. 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
-- they\'re listed in your Suricata rules string.
newStatefulRuleOptions ::
  StatefulRuleOptions
newStatefulRuleOptions :: StatefulRuleOptions
newStatefulRuleOptions =
  StatefulRuleOptions' :: Maybe RuleOrder -> StatefulRuleOptions
StatefulRuleOptions' {$sel:ruleOrder:StatefulRuleOptions' :: Maybe RuleOrder
ruleOrder = Maybe RuleOrder
forall a. Maybe a
Prelude.Nothing}

-- | Indicates how to manage the order of the rule evaluation for the rule
-- group. 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
-- they\'re listed in your Suricata rules string.
statefulRuleOptions_ruleOrder :: Lens.Lens' StatefulRuleOptions (Prelude.Maybe RuleOrder)
statefulRuleOptions_ruleOrder :: (Maybe RuleOrder -> f (Maybe RuleOrder))
-> StatefulRuleOptions -> f StatefulRuleOptions
statefulRuleOptions_ruleOrder = (StatefulRuleOptions -> Maybe RuleOrder)
-> (StatefulRuleOptions -> Maybe RuleOrder -> StatefulRuleOptions)
-> Lens
     StatefulRuleOptions
     StatefulRuleOptions
     (Maybe RuleOrder)
     (Maybe 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 Core.FromJSON StatefulRuleOptions where
  parseJSON :: Value -> Parser StatefulRuleOptions
parseJSON =
    String
-> (Object -> Parser StatefulRuleOptions)
-> Value
-> Parser StatefulRuleOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StatefulRuleOptions"
      ( \Object
x ->
          Maybe RuleOrder -> StatefulRuleOptions
StatefulRuleOptions'
            (Maybe RuleOrder -> StatefulRuleOptions)
-> Parser (Maybe RuleOrder) -> Parser StatefulRuleOptions
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 StatefulRuleOptions

instance Prelude.NFData StatefulRuleOptions

instance Core.ToJSON StatefulRuleOptions where
  toJSON :: StatefulRuleOptions -> Value
toJSON StatefulRuleOptions' {Maybe RuleOrder
ruleOrder :: Maybe RuleOrder
$sel:ruleOrder:StatefulRuleOptions' :: StatefulRuleOptions -> 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]
      )