{-# 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.DirectConnect.CreateTransitVirtualInterface
-- 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 transit virtual interface. A transit virtual interface should
-- be used to access one or more transit gateways associated with Direct
-- Connect gateways. A transit virtual interface enables the connection of
-- multiple VPCs attached to a transit gateway to a Direct Connect gateway.
--
-- If you associate your transit gateway with one or more Direct Connect
-- gateways, the Autonomous System Number (ASN) used by the transit gateway
-- and the Direct Connect gateway must be different. For example, if you
-- use the default ASN 64512 for both your the transit gateway and Direct
-- Connect gateway, the association request fails.
--
-- Setting the MTU of a virtual interface to 8500 (jumbo frames) can cause
-- an update to the underlying physical connection if it wasn\'t updated to
-- support jumbo frames. Updating the connection disrupts network
-- connectivity for all virtual interfaces associated with the connection
-- for up to 30 seconds. To check whether your connection supports jumbo
-- frames, call DescribeConnections. To check whether your virtual
-- interface supports jumbo frames, call DescribeVirtualInterfaces.
module Amazonka.DirectConnect.CreateTransitVirtualInterface
  ( -- * Creating a Request
    CreateTransitVirtualInterface (..),
    newCreateTransitVirtualInterface,

    -- * Request Lenses
    createTransitVirtualInterface_connectionId,
    createTransitVirtualInterface_newTransitVirtualInterface,

    -- * Destructuring the Response
    CreateTransitVirtualInterfaceResponse (..),
    newCreateTransitVirtualInterfaceResponse,

    -- * Response Lenses
    createTransitVirtualInterfaceResponse_virtualInterface,
    createTransitVirtualInterfaceResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateTransitVirtualInterface' smart constructor.
data CreateTransitVirtualInterface = CreateTransitVirtualInterface'
  { -- | The ID of the connection.
    CreateTransitVirtualInterface -> Text
connectionId :: Prelude.Text,
    -- | Information about the transit virtual interface.
    CreateTransitVirtualInterface -> NewTransitVirtualInterface
newTransitVirtualInterface' :: NewTransitVirtualInterface
  }
  deriving (CreateTransitVirtualInterface
-> CreateTransitVirtualInterface -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTransitVirtualInterface
-> CreateTransitVirtualInterface -> Bool
$c/= :: CreateTransitVirtualInterface
-> CreateTransitVirtualInterface -> Bool
== :: CreateTransitVirtualInterface
-> CreateTransitVirtualInterface -> Bool
$c== :: CreateTransitVirtualInterface
-> CreateTransitVirtualInterface -> Bool
Prelude.Eq, ReadPrec [CreateTransitVirtualInterface]
ReadPrec CreateTransitVirtualInterface
Int -> ReadS CreateTransitVirtualInterface
ReadS [CreateTransitVirtualInterface]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTransitVirtualInterface]
$creadListPrec :: ReadPrec [CreateTransitVirtualInterface]
readPrec :: ReadPrec CreateTransitVirtualInterface
$creadPrec :: ReadPrec CreateTransitVirtualInterface
readList :: ReadS [CreateTransitVirtualInterface]
$creadList :: ReadS [CreateTransitVirtualInterface]
readsPrec :: Int -> ReadS CreateTransitVirtualInterface
$creadsPrec :: Int -> ReadS CreateTransitVirtualInterface
Prelude.Read, Int -> CreateTransitVirtualInterface -> ShowS
[CreateTransitVirtualInterface] -> ShowS
CreateTransitVirtualInterface -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTransitVirtualInterface] -> ShowS
$cshowList :: [CreateTransitVirtualInterface] -> ShowS
show :: CreateTransitVirtualInterface -> String
$cshow :: CreateTransitVirtualInterface -> String
showsPrec :: Int -> CreateTransitVirtualInterface -> ShowS
$cshowsPrec :: Int -> CreateTransitVirtualInterface -> ShowS
Prelude.Show, forall x.
Rep CreateTransitVirtualInterface x
-> CreateTransitVirtualInterface
forall x.
CreateTransitVirtualInterface
-> Rep CreateTransitVirtualInterface x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateTransitVirtualInterface x
-> CreateTransitVirtualInterface
$cfrom :: forall x.
CreateTransitVirtualInterface
-> Rep CreateTransitVirtualInterface x
Prelude.Generic)

-- |
-- Create a value of 'CreateTransitVirtualInterface' 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:
--
-- 'connectionId', 'createTransitVirtualInterface_connectionId' - The ID of the connection.
--
-- 'newTransitVirtualInterface'', 'createTransitVirtualInterface_newTransitVirtualInterface' - Information about the transit virtual interface.
newCreateTransitVirtualInterface ::
  -- | 'connectionId'
  Prelude.Text ->
  -- | 'newTransitVirtualInterface''
  NewTransitVirtualInterface ->
  CreateTransitVirtualInterface
newCreateTransitVirtualInterface :: Text -> NewTransitVirtualInterface -> CreateTransitVirtualInterface
newCreateTransitVirtualInterface
  Text
pConnectionId_
  NewTransitVirtualInterface
pNewTransitVirtualInterface_ =
    CreateTransitVirtualInterface'
      { $sel:connectionId:CreateTransitVirtualInterface' :: Text
connectionId =
          Text
pConnectionId_,
        $sel:newTransitVirtualInterface':CreateTransitVirtualInterface' :: NewTransitVirtualInterface
newTransitVirtualInterface' =
          NewTransitVirtualInterface
pNewTransitVirtualInterface_
      }

-- | The ID of the connection.
createTransitVirtualInterface_connectionId :: Lens.Lens' CreateTransitVirtualInterface Prelude.Text
createTransitVirtualInterface_connectionId :: Lens' CreateTransitVirtualInterface Text
createTransitVirtualInterface_connectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTransitVirtualInterface' {Text
connectionId :: Text
$sel:connectionId:CreateTransitVirtualInterface' :: CreateTransitVirtualInterface -> Text
connectionId} -> Text
connectionId) (\s :: CreateTransitVirtualInterface
s@CreateTransitVirtualInterface' {} Text
a -> CreateTransitVirtualInterface
s {$sel:connectionId:CreateTransitVirtualInterface' :: Text
connectionId = Text
a} :: CreateTransitVirtualInterface)

-- | Information about the transit virtual interface.
createTransitVirtualInterface_newTransitVirtualInterface :: Lens.Lens' CreateTransitVirtualInterface NewTransitVirtualInterface
createTransitVirtualInterface_newTransitVirtualInterface :: Lens' CreateTransitVirtualInterface NewTransitVirtualInterface
createTransitVirtualInterface_newTransitVirtualInterface = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTransitVirtualInterface' {NewTransitVirtualInterface
newTransitVirtualInterface' :: NewTransitVirtualInterface
$sel:newTransitVirtualInterface':CreateTransitVirtualInterface' :: CreateTransitVirtualInterface -> NewTransitVirtualInterface
newTransitVirtualInterface'} -> NewTransitVirtualInterface
newTransitVirtualInterface') (\s :: CreateTransitVirtualInterface
s@CreateTransitVirtualInterface' {} NewTransitVirtualInterface
a -> CreateTransitVirtualInterface
s {$sel:newTransitVirtualInterface':CreateTransitVirtualInterface' :: NewTransitVirtualInterface
newTransitVirtualInterface' = NewTransitVirtualInterface
a} :: CreateTransitVirtualInterface)

instance
  Core.AWSRequest
    CreateTransitVirtualInterface
  where
  type
    AWSResponse CreateTransitVirtualInterface =
      CreateTransitVirtualInterfaceResponse
  request :: (Service -> Service)
-> CreateTransitVirtualInterface
-> Request CreateTransitVirtualInterface
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateTransitVirtualInterface
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateTransitVirtualInterface)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe VirtualInterface
-> Int -> CreateTransitVirtualInterfaceResponse
CreateTransitVirtualInterfaceResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"virtualInterface")
            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
    CreateTransitVirtualInterface
  where
  hashWithSalt :: Int -> CreateTransitVirtualInterface -> Int
hashWithSalt Int
_salt CreateTransitVirtualInterface' {Text
NewTransitVirtualInterface
newTransitVirtualInterface' :: NewTransitVirtualInterface
connectionId :: Text
$sel:newTransitVirtualInterface':CreateTransitVirtualInterface' :: CreateTransitVirtualInterface -> NewTransitVirtualInterface
$sel:connectionId:CreateTransitVirtualInterface' :: CreateTransitVirtualInterface -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NewTransitVirtualInterface
newTransitVirtualInterface'

instance Prelude.NFData CreateTransitVirtualInterface where
  rnf :: CreateTransitVirtualInterface -> ()
rnf CreateTransitVirtualInterface' {Text
NewTransitVirtualInterface
newTransitVirtualInterface' :: NewTransitVirtualInterface
connectionId :: Text
$sel:newTransitVirtualInterface':CreateTransitVirtualInterface' :: CreateTransitVirtualInterface -> NewTransitVirtualInterface
$sel:connectionId:CreateTransitVirtualInterface' :: CreateTransitVirtualInterface -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
connectionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NewTransitVirtualInterface
newTransitVirtualInterface'

instance Data.ToHeaders CreateTransitVirtualInterface where
  toHeaders :: CreateTransitVirtualInterface -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"OvertureService.CreateTransitVirtualInterface" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateTransitVirtualInterface where
  toJSON :: CreateTransitVirtualInterface -> Value
toJSON CreateTransitVirtualInterface' {Text
NewTransitVirtualInterface
newTransitVirtualInterface' :: NewTransitVirtualInterface
connectionId :: Text
$sel:newTransitVirtualInterface':CreateTransitVirtualInterface' :: CreateTransitVirtualInterface -> NewTransitVirtualInterface
$sel:connectionId:CreateTransitVirtualInterface' :: CreateTransitVirtualInterface -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"connectionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
connectionId),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"newTransitVirtualInterface"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NewTransitVirtualInterface
newTransitVirtualInterface'
              )
          ]
      )

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

instance Data.ToQuery CreateTransitVirtualInterface where
  toQuery :: CreateTransitVirtualInterface -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'CreateTransitVirtualInterfaceResponse' 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:
--
-- 'virtualInterface', 'createTransitVirtualInterfaceResponse_virtualInterface' - Undocumented member.
--
-- 'httpStatus', 'createTransitVirtualInterfaceResponse_httpStatus' - The response's http status code.
newCreateTransitVirtualInterfaceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateTransitVirtualInterfaceResponse
newCreateTransitVirtualInterfaceResponse :: Int -> CreateTransitVirtualInterfaceResponse
newCreateTransitVirtualInterfaceResponse Int
pHttpStatus_ =
  CreateTransitVirtualInterfaceResponse'
    { $sel:virtualInterface:CreateTransitVirtualInterfaceResponse' :: Maybe VirtualInterface
virtualInterface =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateTransitVirtualInterfaceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
createTransitVirtualInterfaceResponse_virtualInterface :: Lens.Lens' CreateTransitVirtualInterfaceResponse (Prelude.Maybe VirtualInterface)
createTransitVirtualInterfaceResponse_virtualInterface :: Lens'
  CreateTransitVirtualInterfaceResponse (Maybe VirtualInterface)
createTransitVirtualInterfaceResponse_virtualInterface = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTransitVirtualInterfaceResponse' {Maybe VirtualInterface
virtualInterface :: Maybe VirtualInterface
$sel:virtualInterface:CreateTransitVirtualInterfaceResponse' :: CreateTransitVirtualInterfaceResponse -> Maybe VirtualInterface
virtualInterface} -> Maybe VirtualInterface
virtualInterface) (\s :: CreateTransitVirtualInterfaceResponse
s@CreateTransitVirtualInterfaceResponse' {} Maybe VirtualInterface
a -> CreateTransitVirtualInterfaceResponse
s {$sel:virtualInterface:CreateTransitVirtualInterfaceResponse' :: Maybe VirtualInterface
virtualInterface = Maybe VirtualInterface
a} :: CreateTransitVirtualInterfaceResponse)

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

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