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

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

-- | Identifier for a single stateful rule group, used in a firewall policy
-- to refer to a rule group.
--
-- /See:/ 'newStatefulRuleGroupReference' smart constructor.
data StatefulRuleGroupReference = StatefulRuleGroupReference'
  { -- | An integer setting that indicates the order in which to run the stateful
    -- rule groups in a single FirewallPolicy. This setting only applies to
    -- firewall policies that specify the @STRICT_ORDER@ rule order in the
    -- stateful engine options settings.
    --
    -- Network Firewall evalutes each stateful rule group against a packet
    -- starting with the group that has the lowest priority setting. You must
    -- ensure that the priority settings are unique within each policy.
    --
    -- You can change the priority settings of your rule groups at any time. To
    -- make it easier to insert rule groups later, number them so there\'s a
    -- wide range in between, for example use 100, 200, and so on.
    StatefulRuleGroupReference -> Maybe Natural
priority :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Name (ARN) of the stateful rule group.
    StatefulRuleGroupReference -> Text
resourceArn :: Prelude.Text
  }
  deriving (StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool
(StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool)
-> (StatefulRuleGroupReference
    -> StatefulRuleGroupReference -> Bool)
-> Eq StatefulRuleGroupReference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool
$c/= :: StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool
== :: StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool
$c== :: StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool
Prelude.Eq, ReadPrec [StatefulRuleGroupReference]
ReadPrec StatefulRuleGroupReference
Int -> ReadS StatefulRuleGroupReference
ReadS [StatefulRuleGroupReference]
(Int -> ReadS StatefulRuleGroupReference)
-> ReadS [StatefulRuleGroupReference]
-> ReadPrec StatefulRuleGroupReference
-> ReadPrec [StatefulRuleGroupReference]
-> Read StatefulRuleGroupReference
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatefulRuleGroupReference]
$creadListPrec :: ReadPrec [StatefulRuleGroupReference]
readPrec :: ReadPrec StatefulRuleGroupReference
$creadPrec :: ReadPrec StatefulRuleGroupReference
readList :: ReadS [StatefulRuleGroupReference]
$creadList :: ReadS [StatefulRuleGroupReference]
readsPrec :: Int -> ReadS StatefulRuleGroupReference
$creadsPrec :: Int -> ReadS StatefulRuleGroupReference
Prelude.Read, Int -> StatefulRuleGroupReference -> ShowS
[StatefulRuleGroupReference] -> ShowS
StatefulRuleGroupReference -> String
(Int -> StatefulRuleGroupReference -> ShowS)
-> (StatefulRuleGroupReference -> String)
-> ([StatefulRuleGroupReference] -> ShowS)
-> Show StatefulRuleGroupReference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatefulRuleGroupReference] -> ShowS
$cshowList :: [StatefulRuleGroupReference] -> ShowS
show :: StatefulRuleGroupReference -> String
$cshow :: StatefulRuleGroupReference -> String
showsPrec :: Int -> StatefulRuleGroupReference -> ShowS
$cshowsPrec :: Int -> StatefulRuleGroupReference -> ShowS
Prelude.Show, (forall x.
 StatefulRuleGroupReference -> Rep StatefulRuleGroupReference x)
-> (forall x.
    Rep StatefulRuleGroupReference x -> StatefulRuleGroupReference)
-> Generic StatefulRuleGroupReference
forall x.
Rep StatefulRuleGroupReference x -> StatefulRuleGroupReference
forall x.
StatefulRuleGroupReference -> Rep StatefulRuleGroupReference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StatefulRuleGroupReference x -> StatefulRuleGroupReference
$cfrom :: forall x.
StatefulRuleGroupReference -> Rep StatefulRuleGroupReference x
Prelude.Generic)

-- |
-- Create a value of 'StatefulRuleGroupReference' 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:
--
-- 'priority', 'statefulRuleGroupReference_priority' - An integer setting that indicates the order in which to run the stateful
-- rule groups in a single FirewallPolicy. This setting only applies to
-- firewall policies that specify the @STRICT_ORDER@ rule order in the
-- stateful engine options settings.
--
-- Network Firewall evalutes each stateful rule group against a packet
-- starting with the group that has the lowest priority setting. You must
-- ensure that the priority settings are unique within each policy.
--
-- You can change the priority settings of your rule groups at any time. To
-- make it easier to insert rule groups later, number them so there\'s a
-- wide range in between, for example use 100, 200, and so on.
--
-- 'resourceArn', 'statefulRuleGroupReference_resourceArn' - The Amazon Resource Name (ARN) of the stateful rule group.
newStatefulRuleGroupReference ::
  -- | 'resourceArn'
  Prelude.Text ->
  StatefulRuleGroupReference
newStatefulRuleGroupReference :: Text -> StatefulRuleGroupReference
newStatefulRuleGroupReference Text
pResourceArn_ =
  StatefulRuleGroupReference' :: Maybe Natural -> Text -> StatefulRuleGroupReference
StatefulRuleGroupReference'
    { $sel:priority:StatefulRuleGroupReference' :: Maybe Natural
priority =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:StatefulRuleGroupReference' :: Text
resourceArn = Text
pResourceArn_
    }

-- | An integer setting that indicates the order in which to run the stateful
-- rule groups in a single FirewallPolicy. This setting only applies to
-- firewall policies that specify the @STRICT_ORDER@ rule order in the
-- stateful engine options settings.
--
-- Network Firewall evalutes each stateful rule group against a packet
-- starting with the group that has the lowest priority setting. You must
-- ensure that the priority settings are unique within each policy.
--
-- You can change the priority settings of your rule groups at any time. To
-- make it easier to insert rule groups later, number them so there\'s a
-- wide range in between, for example use 100, 200, and so on.
statefulRuleGroupReference_priority :: Lens.Lens' StatefulRuleGroupReference (Prelude.Maybe Prelude.Natural)
statefulRuleGroupReference_priority :: (Maybe Natural -> f (Maybe Natural))
-> StatefulRuleGroupReference -> f StatefulRuleGroupReference
statefulRuleGroupReference_priority = (StatefulRuleGroupReference -> Maybe Natural)
-> (StatefulRuleGroupReference
    -> Maybe Natural -> StatefulRuleGroupReference)
-> Lens
     StatefulRuleGroupReference
     StatefulRuleGroupReference
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatefulRuleGroupReference' {Maybe Natural
priority :: Maybe Natural
$sel:priority:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Maybe Natural
priority} -> Maybe Natural
priority) (\s :: StatefulRuleGroupReference
s@StatefulRuleGroupReference' {} Maybe Natural
a -> StatefulRuleGroupReference
s {$sel:priority:StatefulRuleGroupReference' :: Maybe Natural
priority = Maybe Natural
a} :: StatefulRuleGroupReference)

-- | The Amazon Resource Name (ARN) of the stateful rule group.
statefulRuleGroupReference_resourceArn :: Lens.Lens' StatefulRuleGroupReference Prelude.Text
statefulRuleGroupReference_resourceArn :: (Text -> f Text)
-> StatefulRuleGroupReference -> f StatefulRuleGroupReference
statefulRuleGroupReference_resourceArn = (StatefulRuleGroupReference -> Text)
-> (StatefulRuleGroupReference
    -> Text -> StatefulRuleGroupReference)
-> Lens
     StatefulRuleGroupReference StatefulRuleGroupReference Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatefulRuleGroupReference' {Text
resourceArn :: Text
$sel:resourceArn:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Text
resourceArn} -> Text
resourceArn) (\s :: StatefulRuleGroupReference
s@StatefulRuleGroupReference' {} Text
a -> StatefulRuleGroupReference
s {$sel:resourceArn:StatefulRuleGroupReference' :: Text
resourceArn = Text
a} :: StatefulRuleGroupReference)

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

instance Prelude.Hashable StatefulRuleGroupReference

instance Prelude.NFData StatefulRuleGroupReference

instance Core.ToJSON StatefulRuleGroupReference where
  toJSON :: StatefulRuleGroupReference -> Value
toJSON StatefulRuleGroupReference' {Maybe Natural
Text
resourceArn :: Text
priority :: Maybe Natural
$sel:resourceArn:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Text
$sel:priority:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Priority" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
priority,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ResourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceArn)
          ]
      )