{-# 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.TransitGatewayAssociation
-- 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.TransitGatewayAssociation 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.TransitGatewayAssociationState
import Amazonka.EC2.Types.TransitGatewayAttachmentResourceType
import qualified Amazonka.Prelude as Prelude

-- | Describes an association between a resource attachment and a transit
-- gateway route table.
--
-- /See:/ 'newTransitGatewayAssociation' smart constructor.
data TransitGatewayAssociation = TransitGatewayAssociation'
  { -- | The ID of the resource.
    TransitGatewayAssociation -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | The resource type. Note that the @tgw-peering@ resource type has been
    -- deprecated.
    TransitGatewayAssociation
-> Maybe TransitGatewayAttachmentResourceType
resourceType :: Prelude.Maybe TransitGatewayAttachmentResourceType,
    -- | The state of the association.
    TransitGatewayAssociation -> Maybe TransitGatewayAssociationState
state :: Prelude.Maybe TransitGatewayAssociationState,
    -- | The ID of the attachment.
    TransitGatewayAssociation -> Maybe Text
transitGatewayAttachmentId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the transit gateway route table.
    TransitGatewayAssociation -> Maybe Text
transitGatewayRouteTableId :: Prelude.Maybe Prelude.Text
  }
  deriving (TransitGatewayAssociation -> TransitGatewayAssociation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransitGatewayAssociation -> TransitGatewayAssociation -> Bool
$c/= :: TransitGatewayAssociation -> TransitGatewayAssociation -> Bool
== :: TransitGatewayAssociation -> TransitGatewayAssociation -> Bool
$c== :: TransitGatewayAssociation -> TransitGatewayAssociation -> Bool
Prelude.Eq, ReadPrec [TransitGatewayAssociation]
ReadPrec TransitGatewayAssociation
Int -> ReadS TransitGatewayAssociation
ReadS [TransitGatewayAssociation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TransitGatewayAssociation]
$creadListPrec :: ReadPrec [TransitGatewayAssociation]
readPrec :: ReadPrec TransitGatewayAssociation
$creadPrec :: ReadPrec TransitGatewayAssociation
readList :: ReadS [TransitGatewayAssociation]
$creadList :: ReadS [TransitGatewayAssociation]
readsPrec :: Int -> ReadS TransitGatewayAssociation
$creadsPrec :: Int -> ReadS TransitGatewayAssociation
Prelude.Read, Int -> TransitGatewayAssociation -> ShowS
[TransitGatewayAssociation] -> ShowS
TransitGatewayAssociation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransitGatewayAssociation] -> ShowS
$cshowList :: [TransitGatewayAssociation] -> ShowS
show :: TransitGatewayAssociation -> String
$cshow :: TransitGatewayAssociation -> String
showsPrec :: Int -> TransitGatewayAssociation -> ShowS
$cshowsPrec :: Int -> TransitGatewayAssociation -> ShowS
Prelude.Show, forall x.
Rep TransitGatewayAssociation x -> TransitGatewayAssociation
forall x.
TransitGatewayAssociation -> Rep TransitGatewayAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TransitGatewayAssociation x -> TransitGatewayAssociation
$cfrom :: forall x.
TransitGatewayAssociation -> Rep TransitGatewayAssociation x
Prelude.Generic)

-- |
-- Create a value of 'TransitGatewayAssociation' 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:
--
-- 'resourceId', 'transitGatewayAssociation_resourceId' - The ID of the resource.
--
-- 'resourceType', 'transitGatewayAssociation_resourceType' - The resource type. Note that the @tgw-peering@ resource type has been
-- deprecated.
--
-- 'state', 'transitGatewayAssociation_state' - The state of the association.
--
-- 'transitGatewayAttachmentId', 'transitGatewayAssociation_transitGatewayAttachmentId' - The ID of the attachment.
--
-- 'transitGatewayRouteTableId', 'transitGatewayAssociation_transitGatewayRouteTableId' - The ID of the transit gateway route table.
newTransitGatewayAssociation ::
  TransitGatewayAssociation
newTransitGatewayAssociation :: TransitGatewayAssociation
newTransitGatewayAssociation =
  TransitGatewayAssociation'
    { $sel:resourceId:TransitGatewayAssociation' :: Maybe Text
resourceId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:TransitGatewayAssociation' :: Maybe TransitGatewayAttachmentResourceType
resourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:state:TransitGatewayAssociation' :: Maybe TransitGatewayAssociationState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:transitGatewayAttachmentId:TransitGatewayAssociation' :: Maybe Text
transitGatewayAttachmentId = forall a. Maybe a
Prelude.Nothing,
      $sel:transitGatewayRouteTableId:TransitGatewayAssociation' :: Maybe Text
transitGatewayRouteTableId = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the resource.
transitGatewayAssociation_resourceId :: Lens.Lens' TransitGatewayAssociation (Prelude.Maybe Prelude.Text)
transitGatewayAssociation_resourceId :: Lens' TransitGatewayAssociation (Maybe Text)
transitGatewayAssociation_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitGatewayAssociation' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: TransitGatewayAssociation
s@TransitGatewayAssociation' {} Maybe Text
a -> TransitGatewayAssociation
s {$sel:resourceId:TransitGatewayAssociation' :: Maybe Text
resourceId = Maybe Text
a} :: TransitGatewayAssociation)

-- | The resource type. Note that the @tgw-peering@ resource type has been
-- deprecated.
transitGatewayAssociation_resourceType :: Lens.Lens' TransitGatewayAssociation (Prelude.Maybe TransitGatewayAttachmentResourceType)
transitGatewayAssociation_resourceType :: Lens'
  TransitGatewayAssociation
  (Maybe TransitGatewayAttachmentResourceType)
transitGatewayAssociation_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitGatewayAssociation' {Maybe TransitGatewayAttachmentResourceType
resourceType :: Maybe TransitGatewayAttachmentResourceType
$sel:resourceType:TransitGatewayAssociation' :: TransitGatewayAssociation
-> Maybe TransitGatewayAttachmentResourceType
resourceType} -> Maybe TransitGatewayAttachmentResourceType
resourceType) (\s :: TransitGatewayAssociation
s@TransitGatewayAssociation' {} Maybe TransitGatewayAttachmentResourceType
a -> TransitGatewayAssociation
s {$sel:resourceType:TransitGatewayAssociation' :: Maybe TransitGatewayAttachmentResourceType
resourceType = Maybe TransitGatewayAttachmentResourceType
a} :: TransitGatewayAssociation)

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

-- | The ID of the attachment.
transitGatewayAssociation_transitGatewayAttachmentId :: Lens.Lens' TransitGatewayAssociation (Prelude.Maybe Prelude.Text)
transitGatewayAssociation_transitGatewayAttachmentId :: Lens' TransitGatewayAssociation (Maybe Text)
transitGatewayAssociation_transitGatewayAttachmentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitGatewayAssociation' {Maybe Text
transitGatewayAttachmentId :: Maybe Text
$sel:transitGatewayAttachmentId:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe Text
transitGatewayAttachmentId} -> Maybe Text
transitGatewayAttachmentId) (\s :: TransitGatewayAssociation
s@TransitGatewayAssociation' {} Maybe Text
a -> TransitGatewayAssociation
s {$sel:transitGatewayAttachmentId:TransitGatewayAssociation' :: Maybe Text
transitGatewayAttachmentId = Maybe Text
a} :: TransitGatewayAssociation)

-- | The ID of the transit gateway route table.
transitGatewayAssociation_transitGatewayRouteTableId :: Lens.Lens' TransitGatewayAssociation (Prelude.Maybe Prelude.Text)
transitGatewayAssociation_transitGatewayRouteTableId :: Lens' TransitGatewayAssociation (Maybe Text)
transitGatewayAssociation_transitGatewayRouteTableId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitGatewayAssociation' {Maybe Text
transitGatewayRouteTableId :: Maybe Text
$sel:transitGatewayRouteTableId:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe Text
transitGatewayRouteTableId} -> Maybe Text
transitGatewayRouteTableId) (\s :: TransitGatewayAssociation
s@TransitGatewayAssociation' {} Maybe Text
a -> TransitGatewayAssociation
s {$sel:transitGatewayRouteTableId:TransitGatewayAssociation' :: Maybe Text
transitGatewayRouteTableId = Maybe Text
a} :: TransitGatewayAssociation)

instance Data.FromXML TransitGatewayAssociation where
  parseXML :: [Node] -> Either String TransitGatewayAssociation
parseXML [Node]
x =
    Maybe Text
-> Maybe TransitGatewayAttachmentResourceType
-> Maybe TransitGatewayAssociationState
-> Maybe Text
-> Maybe Text
-> TransitGatewayAssociation
TransitGatewayAssociation'
      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
"resourceId")
      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
"resourceType")
      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
"state")
      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
"transitGatewayAttachmentId")
      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
"transitGatewayRouteTableId")

instance Prelude.Hashable TransitGatewayAssociation where
  hashWithSalt :: Int -> TransitGatewayAssociation -> Int
hashWithSalt Int
_salt TransitGatewayAssociation' {Maybe Text
Maybe TransitGatewayAssociationState
Maybe TransitGatewayAttachmentResourceType
transitGatewayRouteTableId :: Maybe Text
transitGatewayAttachmentId :: Maybe Text
state :: Maybe TransitGatewayAssociationState
resourceType :: Maybe TransitGatewayAttachmentResourceType
resourceId :: Maybe Text
$sel:transitGatewayRouteTableId:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe Text
$sel:transitGatewayAttachmentId:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe Text
$sel:state:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe TransitGatewayAssociationState
$sel:resourceType:TransitGatewayAssociation' :: TransitGatewayAssociation
-> Maybe TransitGatewayAttachmentResourceType
$sel:resourceId:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TransitGatewayAttachmentResourceType
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TransitGatewayAssociationState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
transitGatewayAttachmentId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
transitGatewayRouteTableId

instance Prelude.NFData TransitGatewayAssociation where
  rnf :: TransitGatewayAssociation -> ()
rnf TransitGatewayAssociation' {Maybe Text
Maybe TransitGatewayAssociationState
Maybe TransitGatewayAttachmentResourceType
transitGatewayRouteTableId :: Maybe Text
transitGatewayAttachmentId :: Maybe Text
state :: Maybe TransitGatewayAssociationState
resourceType :: Maybe TransitGatewayAttachmentResourceType
resourceId :: Maybe Text
$sel:transitGatewayRouteTableId:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe Text
$sel:transitGatewayAttachmentId:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe Text
$sel:state:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe TransitGatewayAssociationState
$sel:resourceType:TransitGatewayAssociation' :: TransitGatewayAssociation
-> Maybe TransitGatewayAttachmentResourceType
$sel:resourceId:TransitGatewayAssociation' :: TransitGatewayAssociation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TransitGatewayAttachmentResourceType
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TransitGatewayAssociationState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
transitGatewayAttachmentId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
transitGatewayRouteTableId