{-# 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.RouteTable
-- 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.RouteTable 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.PropagatingVgw
import Amazonka.EC2.Types.Route
import Amazonka.EC2.Types.RouteTableAssociation
import Amazonka.EC2.Types.Tag
import qualified Amazonka.Prelude as Prelude

-- | Describes a route table.
--
-- /See:/ 'newRouteTable' smart constructor.
data RouteTable = RouteTable'
  { -- | The associations between the route table and one or more subnets or a
    -- gateway.
    RouteTable -> Maybe [RouteTableAssociation]
associations :: Prelude.Maybe [RouteTableAssociation],
    -- | The ID of the Amazon Web Services account that owns the route table.
    RouteTable -> Maybe Text
ownerId :: Prelude.Maybe Prelude.Text,
    -- | Any virtual private gateway (VGW) propagating routes.
    RouteTable -> Maybe [PropagatingVgw]
propagatingVgws :: Prelude.Maybe [PropagatingVgw],
    -- | The ID of the route table.
    RouteTable -> Maybe Text
routeTableId :: Prelude.Maybe Prelude.Text,
    -- | The routes in the route table.
    RouteTable -> Maybe [Route]
routes :: Prelude.Maybe [Route],
    -- | Any tags assigned to the route table.
    RouteTable -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The ID of the VPC.
    RouteTable -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text
  }
  deriving (RouteTable -> RouteTable -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RouteTable -> RouteTable -> Bool
$c/= :: RouteTable -> RouteTable -> Bool
== :: RouteTable -> RouteTable -> Bool
$c== :: RouteTable -> RouteTable -> Bool
Prelude.Eq, ReadPrec [RouteTable]
ReadPrec RouteTable
Int -> ReadS RouteTable
ReadS [RouteTable]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RouteTable]
$creadListPrec :: ReadPrec [RouteTable]
readPrec :: ReadPrec RouteTable
$creadPrec :: ReadPrec RouteTable
readList :: ReadS [RouteTable]
$creadList :: ReadS [RouteTable]
readsPrec :: Int -> ReadS RouteTable
$creadsPrec :: Int -> ReadS RouteTable
Prelude.Read, Int -> RouteTable -> ShowS
[RouteTable] -> ShowS
RouteTable -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RouteTable] -> ShowS
$cshowList :: [RouteTable] -> ShowS
show :: RouteTable -> String
$cshow :: RouteTable -> String
showsPrec :: Int -> RouteTable -> ShowS
$cshowsPrec :: Int -> RouteTable -> ShowS
Prelude.Show, forall x. Rep RouteTable x -> RouteTable
forall x. RouteTable -> Rep RouteTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RouteTable x -> RouteTable
$cfrom :: forall x. RouteTable -> Rep RouteTable x
Prelude.Generic)

-- |
-- Create a value of 'RouteTable' 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:
--
-- 'associations', 'routeTable_associations' - The associations between the route table and one or more subnets or a
-- gateway.
--
-- 'ownerId', 'routeTable_ownerId' - The ID of the Amazon Web Services account that owns the route table.
--
-- 'propagatingVgws', 'routeTable_propagatingVgws' - Any virtual private gateway (VGW) propagating routes.
--
-- 'routeTableId', 'routeTable_routeTableId' - The ID of the route table.
--
-- 'routes', 'routeTable_routes' - The routes in the route table.
--
-- 'tags', 'routeTable_tags' - Any tags assigned to the route table.
--
-- 'vpcId', 'routeTable_vpcId' - The ID of the VPC.
newRouteTable ::
  RouteTable
newRouteTable :: RouteTable
newRouteTable =
  RouteTable'
    { $sel:associations:RouteTable' :: Maybe [RouteTableAssociation]
associations = forall a. Maybe a
Prelude.Nothing,
      $sel:ownerId:RouteTable' :: Maybe Text
ownerId = forall a. Maybe a
Prelude.Nothing,
      $sel:propagatingVgws:RouteTable' :: Maybe [PropagatingVgw]
propagatingVgws = forall a. Maybe a
Prelude.Nothing,
      $sel:routeTableId:RouteTable' :: Maybe Text
routeTableId = forall a. Maybe a
Prelude.Nothing,
      $sel:routes:RouteTable' :: Maybe [Route]
routes = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:RouteTable' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:RouteTable' :: Maybe Text
vpcId = forall a. Maybe a
Prelude.Nothing
    }

-- | The associations between the route table and one or more subnets or a
-- gateway.
routeTable_associations :: Lens.Lens' RouteTable (Prelude.Maybe [RouteTableAssociation])
routeTable_associations :: Lens' RouteTable (Maybe [RouteTableAssociation])
routeTable_associations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTable' {Maybe [RouteTableAssociation]
associations :: Maybe [RouteTableAssociation]
$sel:associations:RouteTable' :: RouteTable -> Maybe [RouteTableAssociation]
associations} -> Maybe [RouteTableAssociation]
associations) (\s :: RouteTable
s@RouteTable' {} Maybe [RouteTableAssociation]
a -> RouteTable
s {$sel:associations:RouteTable' :: Maybe [RouteTableAssociation]
associations = Maybe [RouteTableAssociation]
a} :: RouteTable) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the Amazon Web Services account that owns the route table.
routeTable_ownerId :: Lens.Lens' RouteTable (Prelude.Maybe Prelude.Text)
routeTable_ownerId :: Lens' RouteTable (Maybe Text)
routeTable_ownerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTable' {Maybe Text
ownerId :: Maybe Text
$sel:ownerId:RouteTable' :: RouteTable -> Maybe Text
ownerId} -> Maybe Text
ownerId) (\s :: RouteTable
s@RouteTable' {} Maybe Text
a -> RouteTable
s {$sel:ownerId:RouteTable' :: Maybe Text
ownerId = Maybe Text
a} :: RouteTable)

-- | Any virtual private gateway (VGW) propagating routes.
routeTable_propagatingVgws :: Lens.Lens' RouteTable (Prelude.Maybe [PropagatingVgw])
routeTable_propagatingVgws :: Lens' RouteTable (Maybe [PropagatingVgw])
routeTable_propagatingVgws = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTable' {Maybe [PropagatingVgw]
propagatingVgws :: Maybe [PropagatingVgw]
$sel:propagatingVgws:RouteTable' :: RouteTable -> Maybe [PropagatingVgw]
propagatingVgws} -> Maybe [PropagatingVgw]
propagatingVgws) (\s :: RouteTable
s@RouteTable' {} Maybe [PropagatingVgw]
a -> RouteTable
s {$sel:propagatingVgws:RouteTable' :: Maybe [PropagatingVgw]
propagatingVgws = Maybe [PropagatingVgw]
a} :: RouteTable) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the route table.
routeTable_routeTableId :: Lens.Lens' RouteTable (Prelude.Maybe Prelude.Text)
routeTable_routeTableId :: Lens' RouteTable (Maybe Text)
routeTable_routeTableId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTable' {Maybe Text
routeTableId :: Maybe Text
$sel:routeTableId:RouteTable' :: RouteTable -> Maybe Text
routeTableId} -> Maybe Text
routeTableId) (\s :: RouteTable
s@RouteTable' {} Maybe Text
a -> RouteTable
s {$sel:routeTableId:RouteTable' :: Maybe Text
routeTableId = Maybe Text
a} :: RouteTable)

-- | The routes in the route table.
routeTable_routes :: Lens.Lens' RouteTable (Prelude.Maybe [Route])
routeTable_routes :: Lens' RouteTable (Maybe [Route])
routeTable_routes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTable' {Maybe [Route]
routes :: Maybe [Route]
$sel:routes:RouteTable' :: RouteTable -> Maybe [Route]
routes} -> Maybe [Route]
routes) (\s :: RouteTable
s@RouteTable' {} Maybe [Route]
a -> RouteTable
s {$sel:routes:RouteTable' :: Maybe [Route]
routes = Maybe [Route]
a} :: RouteTable) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Any tags assigned to the route table.
routeTable_tags :: Lens.Lens' RouteTable (Prelude.Maybe [Tag])
routeTable_tags :: Lens' RouteTable (Maybe [Tag])
routeTable_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTable' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:RouteTable' :: RouteTable -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: RouteTable
s@RouteTable' {} Maybe [Tag]
a -> RouteTable
s {$sel:tags:RouteTable' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: RouteTable) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the VPC.
routeTable_vpcId :: Lens.Lens' RouteTable (Prelude.Maybe Prelude.Text)
routeTable_vpcId :: Lens' RouteTable (Maybe Text)
routeTable_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTable' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:RouteTable' :: RouteTable -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: RouteTable
s@RouteTable' {} Maybe Text
a -> RouteTable
s {$sel:vpcId:RouteTable' :: Maybe Text
vpcId = Maybe Text
a} :: RouteTable)

instance Data.FromXML RouteTable where
  parseXML :: [Node] -> Either String RouteTable
parseXML [Node]
x =
    Maybe [RouteTableAssociation]
-> Maybe Text
-> Maybe [PropagatingVgw]
-> Maybe Text
-> Maybe [Route]
-> Maybe [Tag]
-> Maybe Text
-> RouteTable
RouteTable'
      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
"associationSet"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )
      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
"ownerId")
      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
"propagatingVgwSet"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )
      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
"routeTableId")
      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
"routeSet"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )
      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
"tagSet"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )
      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
"vpcId")

instance Prelude.Hashable RouteTable where
  hashWithSalt :: Int -> RouteTable -> Int
hashWithSalt Int
_salt RouteTable' {Maybe [PropagatingVgw]
Maybe [Route]
Maybe [RouteTableAssociation]
Maybe [Tag]
Maybe Text
vpcId :: Maybe Text
tags :: Maybe [Tag]
routes :: Maybe [Route]
routeTableId :: Maybe Text
propagatingVgws :: Maybe [PropagatingVgw]
ownerId :: Maybe Text
associations :: Maybe [RouteTableAssociation]
$sel:vpcId:RouteTable' :: RouteTable -> Maybe Text
$sel:tags:RouteTable' :: RouteTable -> Maybe [Tag]
$sel:routes:RouteTable' :: RouteTable -> Maybe [Route]
$sel:routeTableId:RouteTable' :: RouteTable -> Maybe Text
$sel:propagatingVgws:RouteTable' :: RouteTable -> Maybe [PropagatingVgw]
$sel:ownerId:RouteTable' :: RouteTable -> Maybe Text
$sel:associations:RouteTable' :: RouteTable -> Maybe [RouteTableAssociation]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [RouteTableAssociation]
associations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ownerId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PropagatingVgw]
propagatingVgws
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
routeTableId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Route]
routes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcId

instance Prelude.NFData RouteTable where
  rnf :: RouteTable -> ()
rnf RouteTable' {Maybe [PropagatingVgw]
Maybe [Route]
Maybe [RouteTableAssociation]
Maybe [Tag]
Maybe Text
vpcId :: Maybe Text
tags :: Maybe [Tag]
routes :: Maybe [Route]
routeTableId :: Maybe Text
propagatingVgws :: Maybe [PropagatingVgw]
ownerId :: Maybe Text
associations :: Maybe [RouteTableAssociation]
$sel:vpcId:RouteTable' :: RouteTable -> Maybe Text
$sel:tags:RouteTable' :: RouteTable -> Maybe [Tag]
$sel:routes:RouteTable' :: RouteTable -> Maybe [Route]
$sel:routeTableId:RouteTable' :: RouteTable -> Maybe Text
$sel:propagatingVgws:RouteTable' :: RouteTable -> Maybe [PropagatingVgw]
$sel:ownerId:RouteTable' :: RouteTable -> Maybe Text
$sel:associations:RouteTable' :: RouteTable -> Maybe [RouteTableAssociation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [RouteTableAssociation]
associations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ownerId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [PropagatingVgw]
propagatingVgws
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
routeTableId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Route]
routes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcId