{-# 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.AllocatePrivateVirtualInterface
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Provisions a private virtual interface to be owned by the specified
-- Amazon Web Services account.
--
-- Virtual interfaces created using this action must be confirmed by the
-- owner using ConfirmPrivateVirtualInterface. Until then, the virtual
-- interface is in the @Confirming@ state and is not available to handle
-- traffic.
module Amazonka.DirectConnect.AllocatePrivateVirtualInterface
  ( -- * Creating a Request
    AllocatePrivateVirtualInterface (..),
    newAllocatePrivateVirtualInterface,

    -- * Request Lenses
    allocatePrivateVirtualInterface_connectionId,
    allocatePrivateVirtualInterface_ownerAccount,
    allocatePrivateVirtualInterface_newPrivateVirtualInterfaceAllocation,

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

    -- * Response Lenses
    virtualInterface_addressFamily,
    virtualInterface_amazonAddress,
    virtualInterface_amazonSideAsn,
    virtualInterface_asn,
    virtualInterface_authKey,
    virtualInterface_awsDeviceV2,
    virtualInterface_awsLogicalDeviceId,
    virtualInterface_bgpPeers,
    virtualInterface_connectionId,
    virtualInterface_customerAddress,
    virtualInterface_customerRouterConfig,
    virtualInterface_directConnectGatewayId,
    virtualInterface_jumboFrameCapable,
    virtualInterface_location,
    virtualInterface_mtu,
    virtualInterface_ownerAccount,
    virtualInterface_region,
    virtualInterface_routeFilterPrefixes,
    virtualInterface_siteLinkEnabled,
    virtualInterface_tags,
    virtualInterface_virtualGatewayId,
    virtualInterface_virtualInterfaceId,
    virtualInterface_virtualInterfaceName,
    virtualInterface_virtualInterfaceState,
    virtualInterface_virtualInterfaceType,
    virtualInterface_vlan,
  )
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:/ 'newAllocatePrivateVirtualInterface' smart constructor.
data AllocatePrivateVirtualInterface = AllocatePrivateVirtualInterface'
  { -- | The ID of the connection on which the private virtual interface is
    -- provisioned.
    AllocatePrivateVirtualInterface -> Text
connectionId :: Prelude.Text,
    -- | The ID of the Amazon Web Services account that owns the virtual private
    -- interface.
    AllocatePrivateVirtualInterface -> Text
ownerAccount :: Prelude.Text,
    -- | Information about the private virtual interface.
    AllocatePrivateVirtualInterface
-> NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation' :: NewPrivateVirtualInterfaceAllocation
  }
  deriving (AllocatePrivateVirtualInterface
-> AllocatePrivateVirtualInterface -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllocatePrivateVirtualInterface
-> AllocatePrivateVirtualInterface -> Bool
$c/= :: AllocatePrivateVirtualInterface
-> AllocatePrivateVirtualInterface -> Bool
== :: AllocatePrivateVirtualInterface
-> AllocatePrivateVirtualInterface -> Bool
$c== :: AllocatePrivateVirtualInterface
-> AllocatePrivateVirtualInterface -> Bool
Prelude.Eq, ReadPrec [AllocatePrivateVirtualInterface]
ReadPrec AllocatePrivateVirtualInterface
Int -> ReadS AllocatePrivateVirtualInterface
ReadS [AllocatePrivateVirtualInterface]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AllocatePrivateVirtualInterface]
$creadListPrec :: ReadPrec [AllocatePrivateVirtualInterface]
readPrec :: ReadPrec AllocatePrivateVirtualInterface
$creadPrec :: ReadPrec AllocatePrivateVirtualInterface
readList :: ReadS [AllocatePrivateVirtualInterface]
$creadList :: ReadS [AllocatePrivateVirtualInterface]
readsPrec :: Int -> ReadS AllocatePrivateVirtualInterface
$creadsPrec :: Int -> ReadS AllocatePrivateVirtualInterface
Prelude.Read, Int -> AllocatePrivateVirtualInterface -> ShowS
[AllocatePrivateVirtualInterface] -> ShowS
AllocatePrivateVirtualInterface -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AllocatePrivateVirtualInterface] -> ShowS
$cshowList :: [AllocatePrivateVirtualInterface] -> ShowS
show :: AllocatePrivateVirtualInterface -> String
$cshow :: AllocatePrivateVirtualInterface -> String
showsPrec :: Int -> AllocatePrivateVirtualInterface -> ShowS
$cshowsPrec :: Int -> AllocatePrivateVirtualInterface -> ShowS
Prelude.Show, forall x.
Rep AllocatePrivateVirtualInterface x
-> AllocatePrivateVirtualInterface
forall x.
AllocatePrivateVirtualInterface
-> Rep AllocatePrivateVirtualInterface x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AllocatePrivateVirtualInterface x
-> AllocatePrivateVirtualInterface
$cfrom :: forall x.
AllocatePrivateVirtualInterface
-> Rep AllocatePrivateVirtualInterface x
Prelude.Generic)

-- |
-- Create a value of 'AllocatePrivateVirtualInterface' 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', 'allocatePrivateVirtualInterface_connectionId' - The ID of the connection on which the private virtual interface is
-- provisioned.
--
-- 'ownerAccount', 'allocatePrivateVirtualInterface_ownerAccount' - The ID of the Amazon Web Services account that owns the virtual private
-- interface.
--
-- 'newPrivateVirtualInterfaceAllocation'', 'allocatePrivateVirtualInterface_newPrivateVirtualInterfaceAllocation' - Information about the private virtual interface.
newAllocatePrivateVirtualInterface ::
  -- | 'connectionId'
  Prelude.Text ->
  -- | 'ownerAccount'
  Prelude.Text ->
  -- | 'newPrivateVirtualInterfaceAllocation''
  NewPrivateVirtualInterfaceAllocation ->
  AllocatePrivateVirtualInterface
newAllocatePrivateVirtualInterface :: Text
-> Text
-> NewPrivateVirtualInterfaceAllocation
-> AllocatePrivateVirtualInterface
newAllocatePrivateVirtualInterface
  Text
pConnectionId_
  Text
pOwnerAccount_
  NewPrivateVirtualInterfaceAllocation
pNewPrivateVirtualInterfaceAllocation_ =
    AllocatePrivateVirtualInterface'
      { $sel:connectionId:AllocatePrivateVirtualInterface' :: Text
connectionId =
          Text
pConnectionId_,
        $sel:ownerAccount:AllocatePrivateVirtualInterface' :: Text
ownerAccount = Text
pOwnerAccount_,
        $sel:newPrivateVirtualInterfaceAllocation':AllocatePrivateVirtualInterface' :: NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation' =
          NewPrivateVirtualInterfaceAllocation
pNewPrivateVirtualInterfaceAllocation_
      }

-- | The ID of the connection on which the private virtual interface is
-- provisioned.
allocatePrivateVirtualInterface_connectionId :: Lens.Lens' AllocatePrivateVirtualInterface Prelude.Text
allocatePrivateVirtualInterface_connectionId :: Lens' AllocatePrivateVirtualInterface Text
allocatePrivateVirtualInterface_connectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AllocatePrivateVirtualInterface' {Text
connectionId :: Text
$sel:connectionId:AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface -> Text
connectionId} -> Text
connectionId) (\s :: AllocatePrivateVirtualInterface
s@AllocatePrivateVirtualInterface' {} Text
a -> AllocatePrivateVirtualInterface
s {$sel:connectionId:AllocatePrivateVirtualInterface' :: Text
connectionId = Text
a} :: AllocatePrivateVirtualInterface)

-- | The ID of the Amazon Web Services account that owns the virtual private
-- interface.
allocatePrivateVirtualInterface_ownerAccount :: Lens.Lens' AllocatePrivateVirtualInterface Prelude.Text
allocatePrivateVirtualInterface_ownerAccount :: Lens' AllocatePrivateVirtualInterface Text
allocatePrivateVirtualInterface_ownerAccount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AllocatePrivateVirtualInterface' {Text
ownerAccount :: Text
$sel:ownerAccount:AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface -> Text
ownerAccount} -> Text
ownerAccount) (\s :: AllocatePrivateVirtualInterface
s@AllocatePrivateVirtualInterface' {} Text
a -> AllocatePrivateVirtualInterface
s {$sel:ownerAccount:AllocatePrivateVirtualInterface' :: Text
ownerAccount = Text
a} :: AllocatePrivateVirtualInterface)

-- | Information about the private virtual interface.
allocatePrivateVirtualInterface_newPrivateVirtualInterfaceAllocation :: Lens.Lens' AllocatePrivateVirtualInterface NewPrivateVirtualInterfaceAllocation
allocatePrivateVirtualInterface_newPrivateVirtualInterfaceAllocation :: Lens'
  AllocatePrivateVirtualInterface
  NewPrivateVirtualInterfaceAllocation
allocatePrivateVirtualInterface_newPrivateVirtualInterfaceAllocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AllocatePrivateVirtualInterface' {NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation' :: NewPrivateVirtualInterfaceAllocation
$sel:newPrivateVirtualInterfaceAllocation':AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface
-> NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation'} -> NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation') (\s :: AllocatePrivateVirtualInterface
s@AllocatePrivateVirtualInterface' {} NewPrivateVirtualInterfaceAllocation
a -> AllocatePrivateVirtualInterface
s {$sel:newPrivateVirtualInterfaceAllocation':AllocatePrivateVirtualInterface' :: NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation' = NewPrivateVirtualInterfaceAllocation
a} :: AllocatePrivateVirtualInterface)

instance
  Core.AWSRequest
    AllocatePrivateVirtualInterface
  where
  type
    AWSResponse AllocatePrivateVirtualInterface =
      VirtualInterface
  request :: (Service -> Service)
-> AllocatePrivateVirtualInterface
-> Request AllocatePrivateVirtualInterface
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 AllocatePrivateVirtualInterface
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AllocatePrivateVirtualInterface)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance
  Prelude.Hashable
    AllocatePrivateVirtualInterface
  where
  hashWithSalt :: Int -> AllocatePrivateVirtualInterface -> Int
hashWithSalt
    Int
_salt
    AllocatePrivateVirtualInterface' {Text
NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation' :: NewPrivateVirtualInterfaceAllocation
ownerAccount :: Text
connectionId :: Text
$sel:newPrivateVirtualInterfaceAllocation':AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface
-> NewPrivateVirtualInterfaceAllocation
$sel:ownerAccount:AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface -> Text
$sel:connectionId:AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ownerAccount
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation'

instance
  Prelude.NFData
    AllocatePrivateVirtualInterface
  where
  rnf :: AllocatePrivateVirtualInterface -> ()
rnf AllocatePrivateVirtualInterface' {Text
NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation' :: NewPrivateVirtualInterfaceAllocation
ownerAccount :: Text
connectionId :: Text
$sel:newPrivateVirtualInterfaceAllocation':AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface
-> NewPrivateVirtualInterfaceAllocation
$sel:ownerAccount:AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface -> Text
$sel:connectionId:AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface -> 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 Text
ownerAccount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation'

instance
  Data.ToHeaders
    AllocatePrivateVirtualInterface
  where
  toHeaders :: AllocatePrivateVirtualInterface -> 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.AllocatePrivateVirtualInterface" ::
                          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 AllocatePrivateVirtualInterface where
  toJSON :: AllocatePrivateVirtualInterface -> Value
toJSON AllocatePrivateVirtualInterface' {Text
NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation' :: NewPrivateVirtualInterfaceAllocation
ownerAccount :: Text
connectionId :: Text
$sel:newPrivateVirtualInterfaceAllocation':AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface
-> NewPrivateVirtualInterfaceAllocation
$sel:ownerAccount:AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface -> Text
$sel:connectionId:AllocatePrivateVirtualInterface' :: AllocatePrivateVirtualInterface -> 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
"ownerAccount" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
ownerAccount),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"newPrivateVirtualInterfaceAllocation"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NewPrivateVirtualInterfaceAllocation
newPrivateVirtualInterfaceAllocation'
              )
          ]
      )

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

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