{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateRouteTable
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a route table for the specified VPC. After you create a route
-- table, you can add routes and associate the table with a subnet.
--
-- For more information, see
-- <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html Route tables>
-- in the /Amazon Virtual Private Cloud User Guide/.
module Amazonka.EC2.CreateRouteTable
  ( -- * Creating a Request
    CreateRouteTable (..),
    newCreateRouteTable,

    -- * Request Lenses
    createRouteTable_dryRun,
    createRouteTable_tagSpecifications,
    createRouteTable_vpcId,

    -- * Destructuring the Response
    CreateRouteTableResponse (..),
    newCreateRouteTableResponse,

    -- * Response Lenses
    createRouteTableResponse_routeTable,
    createRouteTableResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateRouteTable' smart constructor.
data CreateRouteTable = CreateRouteTable'
  { -- | Checks whether you have the required permissions for the action, without
    -- actually making the request, and provides an error response. If you have
    -- the required permissions, the error response is @DryRunOperation@.
    -- Otherwise, it is @UnauthorizedOperation@.
    CreateRouteTable -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The tags to assign to the route table.
    CreateRouteTable -> Maybe [TagSpecification]
tagSpecifications :: Prelude.Maybe [TagSpecification],
    -- | The ID of the VPC.
    CreateRouteTable -> Text
vpcId :: Prelude.Text
  }
  deriving (CreateRouteTable -> CreateRouteTable -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRouteTable -> CreateRouteTable -> Bool
$c/= :: CreateRouteTable -> CreateRouteTable -> Bool
== :: CreateRouteTable -> CreateRouteTable -> Bool
$c== :: CreateRouteTable -> CreateRouteTable -> Bool
Prelude.Eq, ReadPrec [CreateRouteTable]
ReadPrec CreateRouteTable
Int -> ReadS CreateRouteTable
ReadS [CreateRouteTable]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRouteTable]
$creadListPrec :: ReadPrec [CreateRouteTable]
readPrec :: ReadPrec CreateRouteTable
$creadPrec :: ReadPrec CreateRouteTable
readList :: ReadS [CreateRouteTable]
$creadList :: ReadS [CreateRouteTable]
readsPrec :: Int -> ReadS CreateRouteTable
$creadsPrec :: Int -> ReadS CreateRouteTable
Prelude.Read, Int -> CreateRouteTable -> ShowS
[CreateRouteTable] -> ShowS
CreateRouteTable -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRouteTable] -> ShowS
$cshowList :: [CreateRouteTable] -> ShowS
show :: CreateRouteTable -> String
$cshow :: CreateRouteTable -> String
showsPrec :: Int -> CreateRouteTable -> ShowS
$cshowsPrec :: Int -> CreateRouteTable -> ShowS
Prelude.Show, forall x. Rep CreateRouteTable x -> CreateRouteTable
forall x. CreateRouteTable -> Rep CreateRouteTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRouteTable x -> CreateRouteTable
$cfrom :: forall x. CreateRouteTable -> Rep CreateRouteTable x
Prelude.Generic)

-- |
-- Create a value of 'CreateRouteTable' 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:
--
-- 'dryRun', 'createRouteTable_dryRun' - Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
--
-- 'tagSpecifications', 'createRouteTable_tagSpecifications' - The tags to assign to the route table.
--
-- 'vpcId', 'createRouteTable_vpcId' - The ID of the VPC.
newCreateRouteTable ::
  -- | 'vpcId'
  Prelude.Text ->
  CreateRouteTable
newCreateRouteTable :: Text -> CreateRouteTable
newCreateRouteTable Text
pVpcId_ =
  CreateRouteTable'
    { $sel:dryRun:CreateRouteTable' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:tagSpecifications:CreateRouteTable' :: Maybe [TagSpecification]
tagSpecifications = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:CreateRouteTable' :: Text
vpcId = Text
pVpcId_
    }

-- | Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
createRouteTable_dryRun :: Lens.Lens' CreateRouteTable (Prelude.Maybe Prelude.Bool)
createRouteTable_dryRun :: Lens' CreateRouteTable (Maybe Bool)
createRouteTable_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRouteTable' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:CreateRouteTable' :: CreateRouteTable -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: CreateRouteTable
s@CreateRouteTable' {} Maybe Bool
a -> CreateRouteTable
s {$sel:dryRun:CreateRouteTable' :: Maybe Bool
dryRun = Maybe Bool
a} :: CreateRouteTable)

-- | The tags to assign to the route table.
createRouteTable_tagSpecifications :: Lens.Lens' CreateRouteTable (Prelude.Maybe [TagSpecification])
createRouteTable_tagSpecifications :: Lens' CreateRouteTable (Maybe [TagSpecification])
createRouteTable_tagSpecifications = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRouteTable' {Maybe [TagSpecification]
tagSpecifications :: Maybe [TagSpecification]
$sel:tagSpecifications:CreateRouteTable' :: CreateRouteTable -> Maybe [TagSpecification]
tagSpecifications} -> Maybe [TagSpecification]
tagSpecifications) (\s :: CreateRouteTable
s@CreateRouteTable' {} Maybe [TagSpecification]
a -> CreateRouteTable
s {$sel:tagSpecifications:CreateRouteTable' :: Maybe [TagSpecification]
tagSpecifications = Maybe [TagSpecification]
a} :: CreateRouteTable) 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.
createRouteTable_vpcId :: Lens.Lens' CreateRouteTable Prelude.Text
createRouteTable_vpcId :: Lens' CreateRouteTable Text
createRouteTable_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRouteTable' {Text
vpcId :: Text
$sel:vpcId:CreateRouteTable' :: CreateRouteTable -> Text
vpcId} -> Text
vpcId) (\s :: CreateRouteTable
s@CreateRouteTable' {} Text
a -> CreateRouteTable
s {$sel:vpcId:CreateRouteTable' :: Text
vpcId = Text
a} :: CreateRouteTable)

instance Core.AWSRequest CreateRouteTable where
  type
    AWSResponse CreateRouteTable =
      CreateRouteTableResponse
  request :: (Service -> Service)
-> CreateRouteTable -> Request CreateRouteTable
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateRouteTable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRouteTable)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe RouteTable -> Int -> CreateRouteTableResponse
CreateRouteTableResponse'
            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
"routeTable")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateRouteTable where
  hashWithSalt :: Int -> CreateRouteTable -> Int
hashWithSalt Int
_salt CreateRouteTable' {Maybe Bool
Maybe [TagSpecification]
Text
vpcId :: Text
tagSpecifications :: Maybe [TagSpecification]
dryRun :: Maybe Bool
$sel:vpcId:CreateRouteTable' :: CreateRouteTable -> Text
$sel:tagSpecifications:CreateRouteTable' :: CreateRouteTable -> Maybe [TagSpecification]
$sel:dryRun:CreateRouteTable' :: CreateRouteTable -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [TagSpecification]
tagSpecifications
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
vpcId

instance Prelude.NFData CreateRouteTable where
  rnf :: CreateRouteTable -> ()
rnf CreateRouteTable' {Maybe Bool
Maybe [TagSpecification]
Text
vpcId :: Text
tagSpecifications :: Maybe [TagSpecification]
dryRun :: Maybe Bool
$sel:vpcId:CreateRouteTable' :: CreateRouteTable -> Text
$sel:tagSpecifications:CreateRouteTable' :: CreateRouteTable -> Maybe [TagSpecification]
$sel:dryRun:CreateRouteTable' :: CreateRouteTable -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [TagSpecification]
tagSpecifications
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
vpcId

instance Data.ToHeaders CreateRouteTable where
  toHeaders :: CreateRouteTable -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath CreateRouteTable where
  toPath :: CreateRouteTable -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery CreateRouteTable where
  toQuery :: CreateRouteTable -> QueryString
toQuery CreateRouteTable' {Maybe Bool
Maybe [TagSpecification]
Text
vpcId :: Text
tagSpecifications :: Maybe [TagSpecification]
dryRun :: Maybe Bool
$sel:vpcId:CreateRouteTable' :: CreateRouteTable -> Text
$sel:tagSpecifications:CreateRouteTable' :: CreateRouteTable -> Maybe [TagSpecification]
$sel:dryRun:CreateRouteTable' :: CreateRouteTable -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"CreateRouteTable" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun,
        forall a. ToQuery a => a -> QueryString
Data.toQuery
          ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"TagSpecification"
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TagSpecification]
tagSpecifications
          ),
        ByteString
"VpcId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
vpcId
      ]

-- | /See:/ 'newCreateRouteTableResponse' smart constructor.
data CreateRouteTableResponse = CreateRouteTableResponse'
  { -- | Information about the route table.
    CreateRouteTableResponse -> Maybe RouteTable
routeTable :: Prelude.Maybe RouteTable,
    -- | The response's http status code.
    CreateRouteTableResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateRouteTableResponse -> CreateRouteTableResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRouteTableResponse -> CreateRouteTableResponse -> Bool
$c/= :: CreateRouteTableResponse -> CreateRouteTableResponse -> Bool
== :: CreateRouteTableResponse -> CreateRouteTableResponse -> Bool
$c== :: CreateRouteTableResponse -> CreateRouteTableResponse -> Bool
Prelude.Eq, ReadPrec [CreateRouteTableResponse]
ReadPrec CreateRouteTableResponse
Int -> ReadS CreateRouteTableResponse
ReadS [CreateRouteTableResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRouteTableResponse]
$creadListPrec :: ReadPrec [CreateRouteTableResponse]
readPrec :: ReadPrec CreateRouteTableResponse
$creadPrec :: ReadPrec CreateRouteTableResponse
readList :: ReadS [CreateRouteTableResponse]
$creadList :: ReadS [CreateRouteTableResponse]
readsPrec :: Int -> ReadS CreateRouteTableResponse
$creadsPrec :: Int -> ReadS CreateRouteTableResponse
Prelude.Read, Int -> CreateRouteTableResponse -> ShowS
[CreateRouteTableResponse] -> ShowS
CreateRouteTableResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRouteTableResponse] -> ShowS
$cshowList :: [CreateRouteTableResponse] -> ShowS
show :: CreateRouteTableResponse -> String
$cshow :: CreateRouteTableResponse -> String
showsPrec :: Int -> CreateRouteTableResponse -> ShowS
$cshowsPrec :: Int -> CreateRouteTableResponse -> ShowS
Prelude.Show, forall x.
Rep CreateRouteTableResponse x -> CreateRouteTableResponse
forall x.
CreateRouteTableResponse -> Rep CreateRouteTableResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateRouteTableResponse x -> CreateRouteTableResponse
$cfrom :: forall x.
CreateRouteTableResponse -> Rep CreateRouteTableResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateRouteTableResponse' 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:
--
-- 'routeTable', 'createRouteTableResponse_routeTable' - Information about the route table.
--
-- 'httpStatus', 'createRouteTableResponse_httpStatus' - The response's http status code.
newCreateRouteTableResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateRouteTableResponse
newCreateRouteTableResponse :: Int -> CreateRouteTableResponse
newCreateRouteTableResponse Int
pHttpStatus_ =
  CreateRouteTableResponse'
    { $sel:routeTable:CreateRouteTableResponse' :: Maybe RouteTable
routeTable =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateRouteTableResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the route table.
createRouteTableResponse_routeTable :: Lens.Lens' CreateRouteTableResponse (Prelude.Maybe RouteTable)
createRouteTableResponse_routeTable :: Lens' CreateRouteTableResponse (Maybe RouteTable)
createRouteTableResponse_routeTable = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRouteTableResponse' {Maybe RouteTable
routeTable :: Maybe RouteTable
$sel:routeTable:CreateRouteTableResponse' :: CreateRouteTableResponse -> Maybe RouteTable
routeTable} -> Maybe RouteTable
routeTable) (\s :: CreateRouteTableResponse
s@CreateRouteTableResponse' {} Maybe RouteTable
a -> CreateRouteTableResponse
s {$sel:routeTable:CreateRouteTableResponse' :: Maybe RouteTable
routeTable = Maybe RouteTable
a} :: CreateRouteTableResponse)

-- | The response's http status code.
createRouteTableResponse_httpStatus :: Lens.Lens' CreateRouteTableResponse Prelude.Int
createRouteTableResponse_httpStatus :: Lens' CreateRouteTableResponse Int
createRouteTableResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRouteTableResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateRouteTableResponse' :: CreateRouteTableResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateRouteTableResponse
s@CreateRouteTableResponse' {} Int
a -> CreateRouteTableResponse
s {$sel:httpStatus:CreateRouteTableResponse' :: Int
httpStatus = Int
a} :: CreateRouteTableResponse)

instance Prelude.NFData CreateRouteTableResponse where
  rnf :: CreateRouteTableResponse -> ()
rnf CreateRouteTableResponse' {Int
Maybe RouteTable
httpStatus :: Int
routeTable :: Maybe RouteTable
$sel:httpStatus:CreateRouteTableResponse' :: CreateRouteTableResponse -> Int
$sel:routeTable:CreateRouteTableResponse' :: CreateRouteTableResponse -> Maybe RouteTable
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RouteTable
routeTable
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus