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

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

-- | Identifier for a single stateless rule group, used in a firewall policy
-- to refer to the rule group.
--
-- /See:/ 'newStatelessRuleGroupReference' smart constructor.
data StatelessRuleGroupReference = StatelessRuleGroupReference'
  { -- | The Amazon Resource Name (ARN) of the stateless rule group.
    StatelessRuleGroupReference -> Text
resourceArn :: Prelude.Text,
    -- | An integer setting that indicates the order in which to run the
    -- stateless rule groups in a single FirewallPolicy. Network Firewall
    -- applies each stateless rule group to a packet starting with the group
    -- that has the lowest priority setting. You must ensure that the priority
    -- settings are unique within each policy.
    StatelessRuleGroupReference -> Natural
priority :: Prelude.Natural
  }
  deriving (StatelessRuleGroupReference -> StatelessRuleGroupReference -> Bool
(StatelessRuleGroupReference
 -> StatelessRuleGroupReference -> Bool)
-> (StatelessRuleGroupReference
    -> StatelessRuleGroupReference -> Bool)
-> Eq StatelessRuleGroupReference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatelessRuleGroupReference -> StatelessRuleGroupReference -> Bool
$c/= :: StatelessRuleGroupReference -> StatelessRuleGroupReference -> Bool
== :: StatelessRuleGroupReference -> StatelessRuleGroupReference -> Bool
$c== :: StatelessRuleGroupReference -> StatelessRuleGroupReference -> Bool
Prelude.Eq, ReadPrec [StatelessRuleGroupReference]
ReadPrec StatelessRuleGroupReference
Int -> ReadS StatelessRuleGroupReference
ReadS [StatelessRuleGroupReference]
(Int -> ReadS StatelessRuleGroupReference)
-> ReadS [StatelessRuleGroupReference]
-> ReadPrec StatelessRuleGroupReference
-> ReadPrec [StatelessRuleGroupReference]
-> Read StatelessRuleGroupReference
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatelessRuleGroupReference]
$creadListPrec :: ReadPrec [StatelessRuleGroupReference]
readPrec :: ReadPrec StatelessRuleGroupReference
$creadPrec :: ReadPrec StatelessRuleGroupReference
readList :: ReadS [StatelessRuleGroupReference]
$creadList :: ReadS [StatelessRuleGroupReference]
readsPrec :: Int -> ReadS StatelessRuleGroupReference
$creadsPrec :: Int -> ReadS StatelessRuleGroupReference
Prelude.Read, Int -> StatelessRuleGroupReference -> ShowS
[StatelessRuleGroupReference] -> ShowS
StatelessRuleGroupReference -> String
(Int -> StatelessRuleGroupReference -> ShowS)
-> (StatelessRuleGroupReference -> String)
-> ([StatelessRuleGroupReference] -> ShowS)
-> Show StatelessRuleGroupReference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatelessRuleGroupReference] -> ShowS
$cshowList :: [StatelessRuleGroupReference] -> ShowS
show :: StatelessRuleGroupReference -> String
$cshow :: StatelessRuleGroupReference -> String
showsPrec :: Int -> StatelessRuleGroupReference -> ShowS
$cshowsPrec :: Int -> StatelessRuleGroupReference -> ShowS
Prelude.Show, (forall x.
 StatelessRuleGroupReference -> Rep StatelessRuleGroupReference x)
-> (forall x.
    Rep StatelessRuleGroupReference x -> StatelessRuleGroupReference)
-> Generic StatelessRuleGroupReference
forall x.
Rep StatelessRuleGroupReference x -> StatelessRuleGroupReference
forall x.
StatelessRuleGroupReference -> Rep StatelessRuleGroupReference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StatelessRuleGroupReference x -> StatelessRuleGroupReference
$cfrom :: forall x.
StatelessRuleGroupReference -> Rep StatelessRuleGroupReference x
Prelude.Generic)

-- |
-- Create a value of 'StatelessRuleGroupReference' 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:
--
-- 'resourceArn', 'statelessRuleGroupReference_resourceArn' - The Amazon Resource Name (ARN) of the stateless rule group.
--
-- 'priority', 'statelessRuleGroupReference_priority' - An integer setting that indicates the order in which to run the
-- stateless rule groups in a single FirewallPolicy. Network Firewall
-- applies each stateless rule group to a packet starting with the group
-- that has the lowest priority setting. You must ensure that the priority
-- settings are unique within each policy.
newStatelessRuleGroupReference ::
  -- | 'resourceArn'
  Prelude.Text ->
  -- | 'priority'
  Prelude.Natural ->
  StatelessRuleGroupReference
newStatelessRuleGroupReference :: Text -> Natural -> StatelessRuleGroupReference
newStatelessRuleGroupReference
  Text
pResourceArn_
  Natural
pPriority_ =
    StatelessRuleGroupReference' :: Text -> Natural -> StatelessRuleGroupReference
StatelessRuleGroupReference'
      { $sel:resourceArn:StatelessRuleGroupReference' :: Text
resourceArn =
          Text
pResourceArn_,
        $sel:priority:StatelessRuleGroupReference' :: Natural
priority = Natural
pPriority_
      }

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

-- | An integer setting that indicates the order in which to run the
-- stateless rule groups in a single FirewallPolicy. Network Firewall
-- applies each stateless rule group to a packet starting with the group
-- that has the lowest priority setting. You must ensure that the priority
-- settings are unique within each policy.
statelessRuleGroupReference_priority :: Lens.Lens' StatelessRuleGroupReference Prelude.Natural
statelessRuleGroupReference_priority :: (Natural -> f Natural)
-> StatelessRuleGroupReference -> f StatelessRuleGroupReference
statelessRuleGroupReference_priority = (StatelessRuleGroupReference -> Natural)
-> (StatelessRuleGroupReference
    -> Natural -> StatelessRuleGroupReference)
-> Lens
     StatelessRuleGroupReference
     StatelessRuleGroupReference
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatelessRuleGroupReference' {Natural
priority :: Natural
$sel:priority:StatelessRuleGroupReference' :: StatelessRuleGroupReference -> Natural
priority} -> Natural
priority) (\s :: StatelessRuleGroupReference
s@StatelessRuleGroupReference' {} Natural
a -> StatelessRuleGroupReference
s {$sel:priority:StatelessRuleGroupReference' :: Natural
priority = Natural
a} :: StatelessRuleGroupReference)

instance Core.FromJSON StatelessRuleGroupReference where
  parseJSON :: Value -> Parser StatelessRuleGroupReference
parseJSON =
    String
-> (Object -> Parser StatelessRuleGroupReference)
-> Value
-> Parser StatelessRuleGroupReference
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StatelessRuleGroupReference"
      ( \Object
x ->
          Text -> Natural -> StatelessRuleGroupReference
StatelessRuleGroupReference'
            (Text -> Natural -> StatelessRuleGroupReference)
-> Parser Text -> Parser (Natural -> StatelessRuleGroupReference)
forall (f :: * -> *) a b. Functor 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")
            Parser (Natural -> StatelessRuleGroupReference)
-> Parser Natural -> Parser StatelessRuleGroupReference
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Priority")
      )

instance Prelude.Hashable StatelessRuleGroupReference

instance Prelude.NFData StatelessRuleGroupReference

instance Core.ToJSON StatelessRuleGroupReference where
  toJSON :: StatelessRuleGroupReference -> Value
toJSON StatelessRuleGroupReference' {Natural
Text
priority :: Natural
resourceArn :: Text
$sel:priority:StatelessRuleGroupReference' :: StatelessRuleGroupReference -> Natural
$sel:resourceArn:StatelessRuleGroupReference' :: StatelessRuleGroupReference -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Priority" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
priority)
          ]
      )