{-# 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.RouteTableAssociation
-- 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.RouteTableAssociation 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.RouteTableAssociationState
import qualified Amazonka.Prelude as Prelude

-- | Describes an association between a route table and a subnet or gateway.
--
-- /See:/ 'newRouteTableAssociation' smart constructor.
data RouteTableAssociation = RouteTableAssociation'
  { -- | The state of the association.
    RouteTableAssociation -> Maybe RouteTableAssociationState
associationState :: Prelude.Maybe RouteTableAssociationState,
    -- | The ID of the internet gateway or virtual private gateway.
    RouteTableAssociation -> Maybe Text
gatewayId :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether this is the main route table.
    RouteTableAssociation -> Maybe Bool
main :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the association.
    RouteTableAssociation -> Maybe Text
routeTableAssociationId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the route table.
    RouteTableAssociation -> Maybe Text
routeTableId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the subnet. A subnet ID is not returned for an implicit
    -- association.
    RouteTableAssociation -> Maybe Text
subnetId :: Prelude.Maybe Prelude.Text
  }
  deriving (RouteTableAssociation -> RouteTableAssociation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RouteTableAssociation -> RouteTableAssociation -> Bool
$c/= :: RouteTableAssociation -> RouteTableAssociation -> Bool
== :: RouteTableAssociation -> RouteTableAssociation -> Bool
$c== :: RouteTableAssociation -> RouteTableAssociation -> Bool
Prelude.Eq, ReadPrec [RouteTableAssociation]
ReadPrec RouteTableAssociation
Int -> ReadS RouteTableAssociation
ReadS [RouteTableAssociation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RouteTableAssociation]
$creadListPrec :: ReadPrec [RouteTableAssociation]
readPrec :: ReadPrec RouteTableAssociation
$creadPrec :: ReadPrec RouteTableAssociation
readList :: ReadS [RouteTableAssociation]
$creadList :: ReadS [RouteTableAssociation]
readsPrec :: Int -> ReadS RouteTableAssociation
$creadsPrec :: Int -> ReadS RouteTableAssociation
Prelude.Read, Int -> RouteTableAssociation -> ShowS
[RouteTableAssociation] -> ShowS
RouteTableAssociation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RouteTableAssociation] -> ShowS
$cshowList :: [RouteTableAssociation] -> ShowS
show :: RouteTableAssociation -> String
$cshow :: RouteTableAssociation -> String
showsPrec :: Int -> RouteTableAssociation -> ShowS
$cshowsPrec :: Int -> RouteTableAssociation -> ShowS
Prelude.Show, forall x. Rep RouteTableAssociation x -> RouteTableAssociation
forall x. RouteTableAssociation -> Rep RouteTableAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RouteTableAssociation x -> RouteTableAssociation
$cfrom :: forall x. RouteTableAssociation -> Rep RouteTableAssociation x
Prelude.Generic)

-- |
-- Create a value of 'RouteTableAssociation' 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:
--
-- 'associationState', 'routeTableAssociation_associationState' - The state of the association.
--
-- 'gatewayId', 'routeTableAssociation_gatewayId' - The ID of the internet gateway or virtual private gateway.
--
-- 'main', 'routeTableAssociation_main' - Indicates whether this is the main route table.
--
-- 'routeTableAssociationId', 'routeTableAssociation_routeTableAssociationId' - The ID of the association.
--
-- 'routeTableId', 'routeTableAssociation_routeTableId' - The ID of the route table.
--
-- 'subnetId', 'routeTableAssociation_subnetId' - The ID of the subnet. A subnet ID is not returned for an implicit
-- association.
newRouteTableAssociation ::
  RouteTableAssociation
newRouteTableAssociation :: RouteTableAssociation
newRouteTableAssociation =
  RouteTableAssociation'
    { $sel:associationState:RouteTableAssociation' :: Maybe RouteTableAssociationState
associationState =
        forall a. Maybe a
Prelude.Nothing,
      $sel:gatewayId:RouteTableAssociation' :: Maybe Text
gatewayId = forall a. Maybe a
Prelude.Nothing,
      $sel:main:RouteTableAssociation' :: Maybe Bool
main = forall a. Maybe a
Prelude.Nothing,
      $sel:routeTableAssociationId:RouteTableAssociation' :: Maybe Text
routeTableAssociationId = forall a. Maybe a
Prelude.Nothing,
      $sel:routeTableId:RouteTableAssociation' :: Maybe Text
routeTableId = forall a. Maybe a
Prelude.Nothing,
      $sel:subnetId:RouteTableAssociation' :: Maybe Text
subnetId = forall a. Maybe a
Prelude.Nothing
    }

-- | The state of the association.
routeTableAssociation_associationState :: Lens.Lens' RouteTableAssociation (Prelude.Maybe RouteTableAssociationState)
routeTableAssociation_associationState :: Lens' RouteTableAssociation (Maybe RouteTableAssociationState)
routeTableAssociation_associationState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTableAssociation' {Maybe RouteTableAssociationState
associationState :: Maybe RouteTableAssociationState
$sel:associationState:RouteTableAssociation' :: RouteTableAssociation -> Maybe RouteTableAssociationState
associationState} -> Maybe RouteTableAssociationState
associationState) (\s :: RouteTableAssociation
s@RouteTableAssociation' {} Maybe RouteTableAssociationState
a -> RouteTableAssociation
s {$sel:associationState:RouteTableAssociation' :: Maybe RouteTableAssociationState
associationState = Maybe RouteTableAssociationState
a} :: RouteTableAssociation)

-- | The ID of the internet gateway or virtual private gateway.
routeTableAssociation_gatewayId :: Lens.Lens' RouteTableAssociation (Prelude.Maybe Prelude.Text)
routeTableAssociation_gatewayId :: Lens' RouteTableAssociation (Maybe Text)
routeTableAssociation_gatewayId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTableAssociation' {Maybe Text
gatewayId :: Maybe Text
$sel:gatewayId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
gatewayId} -> Maybe Text
gatewayId) (\s :: RouteTableAssociation
s@RouteTableAssociation' {} Maybe Text
a -> RouteTableAssociation
s {$sel:gatewayId:RouteTableAssociation' :: Maybe Text
gatewayId = Maybe Text
a} :: RouteTableAssociation)

-- | Indicates whether this is the main route table.
routeTableAssociation_main :: Lens.Lens' RouteTableAssociation (Prelude.Maybe Prelude.Bool)
routeTableAssociation_main :: Lens' RouteTableAssociation (Maybe Bool)
routeTableAssociation_main = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTableAssociation' {Maybe Bool
main :: Maybe Bool
$sel:main:RouteTableAssociation' :: RouteTableAssociation -> Maybe Bool
main} -> Maybe Bool
main) (\s :: RouteTableAssociation
s@RouteTableAssociation' {} Maybe Bool
a -> RouteTableAssociation
s {$sel:main:RouteTableAssociation' :: Maybe Bool
main = Maybe Bool
a} :: RouteTableAssociation)

-- | The ID of the association.
routeTableAssociation_routeTableAssociationId :: Lens.Lens' RouteTableAssociation (Prelude.Maybe Prelude.Text)
routeTableAssociation_routeTableAssociationId :: Lens' RouteTableAssociation (Maybe Text)
routeTableAssociation_routeTableAssociationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTableAssociation' {Maybe Text
routeTableAssociationId :: Maybe Text
$sel:routeTableAssociationId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
routeTableAssociationId} -> Maybe Text
routeTableAssociationId) (\s :: RouteTableAssociation
s@RouteTableAssociation' {} Maybe Text
a -> RouteTableAssociation
s {$sel:routeTableAssociationId:RouteTableAssociation' :: Maybe Text
routeTableAssociationId = Maybe Text
a} :: RouteTableAssociation)

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

-- | The ID of the subnet. A subnet ID is not returned for an implicit
-- association.
routeTableAssociation_subnetId :: Lens.Lens' RouteTableAssociation (Prelude.Maybe Prelude.Text)
routeTableAssociation_subnetId :: Lens' RouteTableAssociation (Maybe Text)
routeTableAssociation_subnetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteTableAssociation' {Maybe Text
subnetId :: Maybe Text
$sel:subnetId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
subnetId} -> Maybe Text
subnetId) (\s :: RouteTableAssociation
s@RouteTableAssociation' {} Maybe Text
a -> RouteTableAssociation
s {$sel:subnetId:RouteTableAssociation' :: Maybe Text
subnetId = Maybe Text
a} :: RouteTableAssociation)

instance Data.FromXML RouteTableAssociation where
  parseXML :: [Node] -> Either String RouteTableAssociation
parseXML [Node]
x =
    Maybe RouteTableAssociationState
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> RouteTableAssociation
RouteTableAssociation'
      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
"associationState")
      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
"gatewayId")
      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
"main")
      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
"routeTableAssociationId")
      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
"subnetId")

instance Prelude.Hashable RouteTableAssociation where
  hashWithSalt :: Int -> RouteTableAssociation -> Int
hashWithSalt Int
_salt RouteTableAssociation' {Maybe Bool
Maybe Text
Maybe RouteTableAssociationState
subnetId :: Maybe Text
routeTableId :: Maybe Text
routeTableAssociationId :: Maybe Text
main :: Maybe Bool
gatewayId :: Maybe Text
associationState :: Maybe RouteTableAssociationState
$sel:subnetId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
$sel:routeTableId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
$sel:routeTableAssociationId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
$sel:main:RouteTableAssociation' :: RouteTableAssociation -> Maybe Bool
$sel:gatewayId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
$sel:associationState:RouteTableAssociation' :: RouteTableAssociation -> Maybe RouteTableAssociationState
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RouteTableAssociationState
associationState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
gatewayId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
main
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
routeTableAssociationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
routeTableId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
subnetId

instance Prelude.NFData RouteTableAssociation where
  rnf :: RouteTableAssociation -> ()
rnf RouteTableAssociation' {Maybe Bool
Maybe Text
Maybe RouteTableAssociationState
subnetId :: Maybe Text
routeTableId :: Maybe Text
routeTableAssociationId :: Maybe Text
main :: Maybe Bool
gatewayId :: Maybe Text
associationState :: Maybe RouteTableAssociationState
$sel:subnetId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
$sel:routeTableId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
$sel:routeTableAssociationId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
$sel:main:RouteTableAssociation' :: RouteTableAssociation -> Maybe Bool
$sel:gatewayId:RouteTableAssociation' :: RouteTableAssociation -> Maybe Text
$sel:associationState:RouteTableAssociation' :: RouteTableAssociation -> Maybe RouteTableAssociationState
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RouteTableAssociationState
associationState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
gatewayId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
main
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
routeTableAssociationId
      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 Text
subnetId