{-# 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.CreatePrivateVirtualInterface
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a private virtual interface. A virtual interface is the VLAN
-- that transports Direct Connect traffic. A private virtual interface can
-- be connected to either a Direct Connect gateway or a Virtual Private
-- Gateway (VGW). Connecting the private virtual interface to a Direct
-- Connect gateway enables the possibility for connecting to multiple VPCs,
-- including VPCs in different Amazon Web Services Regions. Connecting the
-- private virtual interface to a VGW only provides access to a single VPC
-- within the same Region.
--
-- Setting the MTU of a virtual interface to 9001 (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.CreatePrivateVirtualInterface
  ( -- * Creating a Request
    CreatePrivateVirtualInterface (..),
    newCreatePrivateVirtualInterface,

    -- * Request Lenses
    createPrivateVirtualInterface_connectionId,
    createPrivateVirtualInterface_newPrivateVirtualInterface,

    -- * Destructuring the Response
    VirtualInterface (..),
    newVirtualInterface,

    -- * Response Lenses
    virtualInterface_bgpPeers,
    virtualInterface_virtualGatewayId,
    virtualInterface_mtu,
    virtualInterface_routeFilterPrefixes,
    virtualInterface_customerAddress,
    virtualInterface_vlan,
    virtualInterface_location,
    virtualInterface_amazonAddress,
    virtualInterface_addressFamily,
    virtualInterface_virtualInterfaceState,
    virtualInterface_connectionId,
    virtualInterface_awsLogicalDeviceId,
    virtualInterface_directConnectGatewayId,
    virtualInterface_amazonSideAsn,
    virtualInterface_virtualInterfaceType,
    virtualInterface_asn,
    virtualInterface_authKey,
    virtualInterface_jumboFrameCapable,
    virtualInterface_customerRouterConfig,
    virtualInterface_ownerAccount,
    virtualInterface_region,
    virtualInterface_virtualInterfaceName,
    virtualInterface_awsDeviceV2,
    virtualInterface_virtualInterfaceId,
    virtualInterface_tags,
  )
where

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

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

-- |
-- Create a value of 'CreatePrivateVirtualInterface' 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', 'createPrivateVirtualInterface_connectionId' - The ID of the connection.
--
-- 'newPrivateVirtualInterface'', 'createPrivateVirtualInterface_newPrivateVirtualInterface' - Information about the private virtual interface.
newCreatePrivateVirtualInterface ::
  -- | 'connectionId'
  Prelude.Text ->
  -- | 'newPrivateVirtualInterface''
  NewPrivateVirtualInterface ->
  CreatePrivateVirtualInterface
newCreatePrivateVirtualInterface :: Text -> NewPrivateVirtualInterface -> CreatePrivateVirtualInterface
newCreatePrivateVirtualInterface
  Text
pConnectionId_
  NewPrivateVirtualInterface
pNewPrivateVirtualInterface_ =
    CreatePrivateVirtualInterface' :: Text -> NewPrivateVirtualInterface -> CreatePrivateVirtualInterface
CreatePrivateVirtualInterface'
      { $sel:connectionId:CreatePrivateVirtualInterface' :: Text
connectionId =
          Text
pConnectionId_,
        $sel:newPrivateVirtualInterface':CreatePrivateVirtualInterface' :: NewPrivateVirtualInterface
newPrivateVirtualInterface' =
          NewPrivateVirtualInterface
pNewPrivateVirtualInterface_
      }

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

-- | Information about the private virtual interface.
createPrivateVirtualInterface_newPrivateVirtualInterface :: Lens.Lens' CreatePrivateVirtualInterface NewPrivateVirtualInterface
createPrivateVirtualInterface_newPrivateVirtualInterface :: (NewPrivateVirtualInterface -> f NewPrivateVirtualInterface)
-> CreatePrivateVirtualInterface -> f CreatePrivateVirtualInterface
createPrivateVirtualInterface_newPrivateVirtualInterface = (CreatePrivateVirtualInterface -> NewPrivateVirtualInterface)
-> (CreatePrivateVirtualInterface
    -> NewPrivateVirtualInterface -> CreatePrivateVirtualInterface)
-> Lens
     CreatePrivateVirtualInterface
     CreatePrivateVirtualInterface
     NewPrivateVirtualInterface
     NewPrivateVirtualInterface
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePrivateVirtualInterface' {NewPrivateVirtualInterface
newPrivateVirtualInterface' :: NewPrivateVirtualInterface
$sel:newPrivateVirtualInterface':CreatePrivateVirtualInterface' :: CreatePrivateVirtualInterface -> NewPrivateVirtualInterface
newPrivateVirtualInterface'} -> NewPrivateVirtualInterface
newPrivateVirtualInterface') (\s :: CreatePrivateVirtualInterface
s@CreatePrivateVirtualInterface' {} NewPrivateVirtualInterface
a -> CreatePrivateVirtualInterface
s {$sel:newPrivateVirtualInterface':CreatePrivateVirtualInterface' :: NewPrivateVirtualInterface
newPrivateVirtualInterface' = NewPrivateVirtualInterface
a} :: CreatePrivateVirtualInterface)

instance
  Core.AWSRequest
    CreatePrivateVirtualInterface
  where
  type
    AWSResponse CreatePrivateVirtualInterface =
      VirtualInterface
  request :: CreatePrivateVirtualInterface
-> Request CreatePrivateVirtualInterface
request = Service
-> CreatePrivateVirtualInterface
-> Request CreatePrivateVirtualInterface
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreatePrivateVirtualInterface
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreatePrivateVirtualInterface)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreatePrivateVirtualInterface))
-> Logger
-> Service
-> Proxy CreatePrivateVirtualInterface
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreatePrivateVirtualInterface)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String VirtualInterface
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance
  Prelude.Hashable
    CreatePrivateVirtualInterface

instance Prelude.NFData CreatePrivateVirtualInterface

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

instance Core.ToJSON CreatePrivateVirtualInterface where
  toJSON :: CreatePrivateVirtualInterface -> Value
toJSON CreatePrivateVirtualInterface' {Text
NewPrivateVirtualInterface
newPrivateVirtualInterface' :: NewPrivateVirtualInterface
connectionId :: Text
$sel:newPrivateVirtualInterface':CreatePrivateVirtualInterface' :: CreatePrivateVirtualInterface -> NewPrivateVirtualInterface
$sel:connectionId:CreatePrivateVirtualInterface' :: CreatePrivateVirtualInterface -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"connectionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
connectionId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"newPrivateVirtualInterface"
                  Text -> NewPrivateVirtualInterface -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NewPrivateVirtualInterface
newPrivateVirtualInterface'
              )
          ]
      )

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

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