{-# 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.EC2.Types.TransitGatewayPolicyRule
-- 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.EC2.Types.TransitGatewayPolicyRule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.TransitGatewayPolicyRuleMetaData
import qualified Amazonka.Prelude as Prelude

-- | Describes a rule associated with a transit gateway policy.
--
-- /See:/ 'newTransitGatewayPolicyRule' smart constructor.
data TransitGatewayPolicyRule = TransitGatewayPolicyRule'
  { -- | The destination CIDR block for the transit gateway policy rule.
    TransitGatewayPolicyRule -> Maybe Text
destinationCidrBlock :: Prelude.Maybe Prelude.Text,
    -- | The port range for the transit gateway policy rule. Currently this is
    -- set to * (all).
    TransitGatewayPolicyRule -> Maybe Text
destinationPortRange :: Prelude.Maybe Prelude.Text,
    -- | The meta data tags used for the transit gateway policy rule.
    TransitGatewayPolicyRule -> Maybe TransitGatewayPolicyRuleMetaData
metaData :: Prelude.Maybe TransitGatewayPolicyRuleMetaData,
    -- | The protocol used by the transit gateway policy rule.
    TransitGatewayPolicyRule -> Maybe Text
protocol :: Prelude.Maybe Prelude.Text,
    -- | The source CIDR block for the transit gateway policy rule.
    TransitGatewayPolicyRule -> Maybe Text
sourceCidrBlock :: Prelude.Maybe Prelude.Text,
    -- | The port range for the transit gateway policy rule. Currently this is
    -- set to * (all).
    TransitGatewayPolicyRule -> Maybe Text
sourcePortRange :: Prelude.Maybe Prelude.Text
  }
  deriving (TransitGatewayPolicyRule -> TransitGatewayPolicyRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransitGatewayPolicyRule -> TransitGatewayPolicyRule -> Bool
$c/= :: TransitGatewayPolicyRule -> TransitGatewayPolicyRule -> Bool
== :: TransitGatewayPolicyRule -> TransitGatewayPolicyRule -> Bool
$c== :: TransitGatewayPolicyRule -> TransitGatewayPolicyRule -> Bool
Prelude.Eq, ReadPrec [TransitGatewayPolicyRule]
ReadPrec TransitGatewayPolicyRule
Int -> ReadS TransitGatewayPolicyRule
ReadS [TransitGatewayPolicyRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TransitGatewayPolicyRule]
$creadListPrec :: ReadPrec [TransitGatewayPolicyRule]
readPrec :: ReadPrec TransitGatewayPolicyRule
$creadPrec :: ReadPrec TransitGatewayPolicyRule
readList :: ReadS [TransitGatewayPolicyRule]
$creadList :: ReadS [TransitGatewayPolicyRule]
readsPrec :: Int -> ReadS TransitGatewayPolicyRule
$creadsPrec :: Int -> ReadS TransitGatewayPolicyRule
Prelude.Read, Int -> TransitGatewayPolicyRule -> ShowS
[TransitGatewayPolicyRule] -> ShowS
TransitGatewayPolicyRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransitGatewayPolicyRule] -> ShowS
$cshowList :: [TransitGatewayPolicyRule] -> ShowS
show :: TransitGatewayPolicyRule -> String
$cshow :: TransitGatewayPolicyRule -> String
showsPrec :: Int -> TransitGatewayPolicyRule -> ShowS
$cshowsPrec :: Int -> TransitGatewayPolicyRule -> ShowS
Prelude.Show, forall x.
Rep TransitGatewayPolicyRule x -> TransitGatewayPolicyRule
forall x.
TransitGatewayPolicyRule -> Rep TransitGatewayPolicyRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TransitGatewayPolicyRule x -> TransitGatewayPolicyRule
$cfrom :: forall x.
TransitGatewayPolicyRule -> Rep TransitGatewayPolicyRule x
Prelude.Generic)

-- |
-- Create a value of 'TransitGatewayPolicyRule' 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:
--
-- 'destinationCidrBlock', 'transitGatewayPolicyRule_destinationCidrBlock' - The destination CIDR block for the transit gateway policy rule.
--
-- 'destinationPortRange', 'transitGatewayPolicyRule_destinationPortRange' - The port range for the transit gateway policy rule. Currently this is
-- set to * (all).
--
-- 'metaData', 'transitGatewayPolicyRule_metaData' - The meta data tags used for the transit gateway policy rule.
--
-- 'protocol', 'transitGatewayPolicyRule_protocol' - The protocol used by the transit gateway policy rule.
--
-- 'sourceCidrBlock', 'transitGatewayPolicyRule_sourceCidrBlock' - The source CIDR block for the transit gateway policy rule.
--
-- 'sourcePortRange', 'transitGatewayPolicyRule_sourcePortRange' - The port range for the transit gateway policy rule. Currently this is
-- set to * (all).
newTransitGatewayPolicyRule ::
  TransitGatewayPolicyRule
newTransitGatewayPolicyRule :: TransitGatewayPolicyRule
newTransitGatewayPolicyRule =
  TransitGatewayPolicyRule'
    { $sel:destinationCidrBlock:TransitGatewayPolicyRule' :: Maybe Text
destinationCidrBlock =
        forall a. Maybe a
Prelude.Nothing,
      $sel:destinationPortRange:TransitGatewayPolicyRule' :: Maybe Text
destinationPortRange = forall a. Maybe a
Prelude.Nothing,
      $sel:metaData:TransitGatewayPolicyRule' :: Maybe TransitGatewayPolicyRuleMetaData
metaData = forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:TransitGatewayPolicyRule' :: Maybe Text
protocol = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceCidrBlock:TransitGatewayPolicyRule' :: Maybe Text
sourceCidrBlock = forall a. Maybe a
Prelude.Nothing,
      $sel:sourcePortRange:TransitGatewayPolicyRule' :: Maybe Text
sourcePortRange = forall a. Maybe a
Prelude.Nothing
    }

-- | The destination CIDR block for the transit gateway policy rule.
transitGatewayPolicyRule_destinationCidrBlock :: Lens.Lens' TransitGatewayPolicyRule (Prelude.Maybe Prelude.Text)
transitGatewayPolicyRule_destinationCidrBlock :: Lens' TransitGatewayPolicyRule (Maybe Text)
transitGatewayPolicyRule_destinationCidrBlock = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitGatewayPolicyRule' {Maybe Text
destinationCidrBlock :: Maybe Text
$sel:destinationCidrBlock:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
destinationCidrBlock} -> Maybe Text
destinationCidrBlock) (\s :: TransitGatewayPolicyRule
s@TransitGatewayPolicyRule' {} Maybe Text
a -> TransitGatewayPolicyRule
s {$sel:destinationCidrBlock:TransitGatewayPolicyRule' :: Maybe Text
destinationCidrBlock = Maybe Text
a} :: TransitGatewayPolicyRule)

-- | The port range for the transit gateway policy rule. Currently this is
-- set to * (all).
transitGatewayPolicyRule_destinationPortRange :: Lens.Lens' TransitGatewayPolicyRule (Prelude.Maybe Prelude.Text)
transitGatewayPolicyRule_destinationPortRange :: Lens' TransitGatewayPolicyRule (Maybe Text)
transitGatewayPolicyRule_destinationPortRange = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitGatewayPolicyRule' {Maybe Text
destinationPortRange :: Maybe Text
$sel:destinationPortRange:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
destinationPortRange} -> Maybe Text
destinationPortRange) (\s :: TransitGatewayPolicyRule
s@TransitGatewayPolicyRule' {} Maybe Text
a -> TransitGatewayPolicyRule
s {$sel:destinationPortRange:TransitGatewayPolicyRule' :: Maybe Text
destinationPortRange = Maybe Text
a} :: TransitGatewayPolicyRule)

-- | The meta data tags used for the transit gateway policy rule.
transitGatewayPolicyRule_metaData :: Lens.Lens' TransitGatewayPolicyRule (Prelude.Maybe TransitGatewayPolicyRuleMetaData)
transitGatewayPolicyRule_metaData :: Lens'
  TransitGatewayPolicyRule (Maybe TransitGatewayPolicyRuleMetaData)
transitGatewayPolicyRule_metaData = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitGatewayPolicyRule' {Maybe TransitGatewayPolicyRuleMetaData
metaData :: Maybe TransitGatewayPolicyRuleMetaData
$sel:metaData:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe TransitGatewayPolicyRuleMetaData
metaData} -> Maybe TransitGatewayPolicyRuleMetaData
metaData) (\s :: TransitGatewayPolicyRule
s@TransitGatewayPolicyRule' {} Maybe TransitGatewayPolicyRuleMetaData
a -> TransitGatewayPolicyRule
s {$sel:metaData:TransitGatewayPolicyRule' :: Maybe TransitGatewayPolicyRuleMetaData
metaData = Maybe TransitGatewayPolicyRuleMetaData
a} :: TransitGatewayPolicyRule)

-- | The protocol used by the transit gateway policy rule.
transitGatewayPolicyRule_protocol :: Lens.Lens' TransitGatewayPolicyRule (Prelude.Maybe Prelude.Text)
transitGatewayPolicyRule_protocol :: Lens' TransitGatewayPolicyRule (Maybe Text)
transitGatewayPolicyRule_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitGatewayPolicyRule' {Maybe Text
protocol :: Maybe Text
$sel:protocol:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
protocol} -> Maybe Text
protocol) (\s :: TransitGatewayPolicyRule
s@TransitGatewayPolicyRule' {} Maybe Text
a -> TransitGatewayPolicyRule
s {$sel:protocol:TransitGatewayPolicyRule' :: Maybe Text
protocol = Maybe Text
a} :: TransitGatewayPolicyRule)

-- | The source CIDR block for the transit gateway policy rule.
transitGatewayPolicyRule_sourceCidrBlock :: Lens.Lens' TransitGatewayPolicyRule (Prelude.Maybe Prelude.Text)
transitGatewayPolicyRule_sourceCidrBlock :: Lens' TransitGatewayPolicyRule (Maybe Text)
transitGatewayPolicyRule_sourceCidrBlock = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitGatewayPolicyRule' {Maybe Text
sourceCidrBlock :: Maybe Text
$sel:sourceCidrBlock:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
sourceCidrBlock} -> Maybe Text
sourceCidrBlock) (\s :: TransitGatewayPolicyRule
s@TransitGatewayPolicyRule' {} Maybe Text
a -> TransitGatewayPolicyRule
s {$sel:sourceCidrBlock:TransitGatewayPolicyRule' :: Maybe Text
sourceCidrBlock = Maybe Text
a} :: TransitGatewayPolicyRule)

-- | The port range for the transit gateway policy rule. Currently this is
-- set to * (all).
transitGatewayPolicyRule_sourcePortRange :: Lens.Lens' TransitGatewayPolicyRule (Prelude.Maybe Prelude.Text)
transitGatewayPolicyRule_sourcePortRange :: Lens' TransitGatewayPolicyRule (Maybe Text)
transitGatewayPolicyRule_sourcePortRange = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitGatewayPolicyRule' {Maybe Text
sourcePortRange :: Maybe Text
$sel:sourcePortRange:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
sourcePortRange} -> Maybe Text
sourcePortRange) (\s :: TransitGatewayPolicyRule
s@TransitGatewayPolicyRule' {} Maybe Text
a -> TransitGatewayPolicyRule
s {$sel:sourcePortRange:TransitGatewayPolicyRule' :: Maybe Text
sourcePortRange = Maybe Text
a} :: TransitGatewayPolicyRule)

instance Data.FromXML TransitGatewayPolicyRule where
  parseXML :: [Node] -> Either String TransitGatewayPolicyRule
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe TransitGatewayPolicyRuleMetaData
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> TransitGatewayPolicyRule
TransitGatewayPolicyRule'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"destinationCidrBlock")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"destinationPortRange")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"metaData")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"protocol")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"sourceCidrBlock")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"sourcePortRange")

instance Prelude.Hashable TransitGatewayPolicyRule where
  hashWithSalt :: Int -> TransitGatewayPolicyRule -> Int
hashWithSalt Int
_salt TransitGatewayPolicyRule' {Maybe Text
Maybe TransitGatewayPolicyRuleMetaData
sourcePortRange :: Maybe Text
sourceCidrBlock :: Maybe Text
protocol :: Maybe Text
metaData :: Maybe TransitGatewayPolicyRuleMetaData
destinationPortRange :: Maybe Text
destinationCidrBlock :: Maybe Text
$sel:sourcePortRange:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
$sel:sourceCidrBlock:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
$sel:protocol:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
$sel:metaData:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe TransitGatewayPolicyRuleMetaData
$sel:destinationPortRange:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
$sel:destinationCidrBlock:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destinationCidrBlock
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destinationPortRange
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TransitGatewayPolicyRuleMetaData
metaData
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
protocol
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceCidrBlock
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourcePortRange

instance Prelude.NFData TransitGatewayPolicyRule where
  rnf :: TransitGatewayPolicyRule -> ()
rnf TransitGatewayPolicyRule' {Maybe Text
Maybe TransitGatewayPolicyRuleMetaData
sourcePortRange :: Maybe Text
sourceCidrBlock :: Maybe Text
protocol :: Maybe Text
metaData :: Maybe TransitGatewayPolicyRuleMetaData
destinationPortRange :: Maybe Text
destinationCidrBlock :: Maybe Text
$sel:sourcePortRange:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
$sel:sourceCidrBlock:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
$sel:protocol:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
$sel:metaData:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe TransitGatewayPolicyRuleMetaData
$sel:destinationPortRange:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
$sel:destinationCidrBlock:TransitGatewayPolicyRule' :: TransitGatewayPolicyRule -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destinationCidrBlock
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destinationPortRange
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TransitGatewayPolicyRuleMetaData
metaData
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
protocol
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceCidrBlock
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourcePortRange