{-# 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.ConfirmPublicVirtualInterface
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Accepts ownership of a public virtual interface created by another
-- Amazon Web Services account.
--
-- After the virtual interface owner makes this call, the specified virtual
-- interface is created and made available to handle traffic.
module Amazonka.DirectConnect.ConfirmPublicVirtualInterface
  ( -- * Creating a Request
    ConfirmPublicVirtualInterface (..),
    newConfirmPublicVirtualInterface,

    -- * Request Lenses
    confirmPublicVirtualInterface_virtualInterfaceId,

    -- * Destructuring the Response
    ConfirmPublicVirtualInterfaceResponse (..),
    newConfirmPublicVirtualInterfaceResponse,

    -- * Response Lenses
    confirmPublicVirtualInterfaceResponse_virtualInterfaceState,
    confirmPublicVirtualInterfaceResponse_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:/ 'newConfirmPublicVirtualInterface' smart constructor.
data ConfirmPublicVirtualInterface = ConfirmPublicVirtualInterface'
  { -- | The ID of the virtual interface.
    ConfirmPublicVirtualInterface -> Text
virtualInterfaceId :: Prelude.Text
  }
  deriving (ConfirmPublicVirtualInterface
-> ConfirmPublicVirtualInterface -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfirmPublicVirtualInterface
-> ConfirmPublicVirtualInterface -> Bool
$c/= :: ConfirmPublicVirtualInterface
-> ConfirmPublicVirtualInterface -> Bool
== :: ConfirmPublicVirtualInterface
-> ConfirmPublicVirtualInterface -> Bool
$c== :: ConfirmPublicVirtualInterface
-> ConfirmPublicVirtualInterface -> Bool
Prelude.Eq, ReadPrec [ConfirmPublicVirtualInterface]
ReadPrec ConfirmPublicVirtualInterface
Int -> ReadS ConfirmPublicVirtualInterface
ReadS [ConfirmPublicVirtualInterface]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfirmPublicVirtualInterface]
$creadListPrec :: ReadPrec [ConfirmPublicVirtualInterface]
readPrec :: ReadPrec ConfirmPublicVirtualInterface
$creadPrec :: ReadPrec ConfirmPublicVirtualInterface
readList :: ReadS [ConfirmPublicVirtualInterface]
$creadList :: ReadS [ConfirmPublicVirtualInterface]
readsPrec :: Int -> ReadS ConfirmPublicVirtualInterface
$creadsPrec :: Int -> ReadS ConfirmPublicVirtualInterface
Prelude.Read, Int -> ConfirmPublicVirtualInterface -> ShowS
[ConfirmPublicVirtualInterface] -> ShowS
ConfirmPublicVirtualInterface -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfirmPublicVirtualInterface] -> ShowS
$cshowList :: [ConfirmPublicVirtualInterface] -> ShowS
show :: ConfirmPublicVirtualInterface -> String
$cshow :: ConfirmPublicVirtualInterface -> String
showsPrec :: Int -> ConfirmPublicVirtualInterface -> ShowS
$cshowsPrec :: Int -> ConfirmPublicVirtualInterface -> ShowS
Prelude.Show, forall x.
Rep ConfirmPublicVirtualInterface x
-> ConfirmPublicVirtualInterface
forall x.
ConfirmPublicVirtualInterface
-> Rep ConfirmPublicVirtualInterface x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfirmPublicVirtualInterface x
-> ConfirmPublicVirtualInterface
$cfrom :: forall x.
ConfirmPublicVirtualInterface
-> Rep ConfirmPublicVirtualInterface x
Prelude.Generic)

-- |
-- Create a value of 'ConfirmPublicVirtualInterface' 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:
--
-- 'virtualInterfaceId', 'confirmPublicVirtualInterface_virtualInterfaceId' - The ID of the virtual interface.
newConfirmPublicVirtualInterface ::
  -- | 'virtualInterfaceId'
  Prelude.Text ->
  ConfirmPublicVirtualInterface
newConfirmPublicVirtualInterface :: Text -> ConfirmPublicVirtualInterface
newConfirmPublicVirtualInterface Text
pVirtualInterfaceId_ =
  ConfirmPublicVirtualInterface'
    { $sel:virtualInterfaceId:ConfirmPublicVirtualInterface' :: Text
virtualInterfaceId =
        Text
pVirtualInterfaceId_
    }

-- | The ID of the virtual interface.
confirmPublicVirtualInterface_virtualInterfaceId :: Lens.Lens' ConfirmPublicVirtualInterface Prelude.Text
confirmPublicVirtualInterface_virtualInterfaceId :: Lens' ConfirmPublicVirtualInterface Text
confirmPublicVirtualInterface_virtualInterfaceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmPublicVirtualInterface' {Text
virtualInterfaceId :: Text
$sel:virtualInterfaceId:ConfirmPublicVirtualInterface' :: ConfirmPublicVirtualInterface -> Text
virtualInterfaceId} -> Text
virtualInterfaceId) (\s :: ConfirmPublicVirtualInterface
s@ConfirmPublicVirtualInterface' {} Text
a -> ConfirmPublicVirtualInterface
s {$sel:virtualInterfaceId:ConfirmPublicVirtualInterface' :: Text
virtualInterfaceId = Text
a} :: ConfirmPublicVirtualInterface)

instance
  Core.AWSRequest
    ConfirmPublicVirtualInterface
  where
  type
    AWSResponse ConfirmPublicVirtualInterface =
      ConfirmPublicVirtualInterfaceResponse
  request :: (Service -> Service)
-> ConfirmPublicVirtualInterface
-> Request ConfirmPublicVirtualInterface
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 ConfirmPublicVirtualInterface
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ConfirmPublicVirtualInterface)))
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 VirtualInterfaceState
-> Int -> ConfirmPublicVirtualInterfaceResponse
ConfirmPublicVirtualInterfaceResponse'
            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
"virtualInterfaceState")
            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
    ConfirmPublicVirtualInterface
  where
  hashWithSalt :: Int -> ConfirmPublicVirtualInterface -> Int
hashWithSalt Int
_salt ConfirmPublicVirtualInterface' {Text
virtualInterfaceId :: Text
$sel:virtualInterfaceId:ConfirmPublicVirtualInterface' :: ConfirmPublicVirtualInterface -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
virtualInterfaceId

instance Prelude.NFData ConfirmPublicVirtualInterface where
  rnf :: ConfirmPublicVirtualInterface -> ()
rnf ConfirmPublicVirtualInterface' {Text
virtualInterfaceId :: Text
$sel:virtualInterfaceId:ConfirmPublicVirtualInterface' :: ConfirmPublicVirtualInterface -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
virtualInterfaceId

instance Data.ToHeaders ConfirmPublicVirtualInterface where
  toHeaders :: ConfirmPublicVirtualInterface -> 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.ConfirmPublicVirtualInterface" ::
                          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 ConfirmPublicVirtualInterface where
  toJSON :: ConfirmPublicVirtualInterface -> Value
toJSON ConfirmPublicVirtualInterface' {Text
virtualInterfaceId :: Text
$sel:virtualInterfaceId:ConfirmPublicVirtualInterface' :: ConfirmPublicVirtualInterface -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"virtualInterfaceId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
virtualInterfaceId)
          ]
      )

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

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

-- | /See:/ 'newConfirmPublicVirtualInterfaceResponse' smart constructor.
data ConfirmPublicVirtualInterfaceResponse = ConfirmPublicVirtualInterfaceResponse'
  { -- | The state of the virtual interface. The following are the possible
    -- values:
    --
    -- -   @confirming@: The creation of the virtual interface is pending
    --     confirmation from the virtual interface owner. If the owner of the
    --     virtual interface is different from the owner of the connection on
    --     which it is provisioned, then the virtual interface will remain in
    --     this state until it is confirmed by the virtual interface owner.
    --
    -- -   @verifying@: This state only applies to public virtual interfaces.
    --     Each public virtual interface needs validation before the virtual
    --     interface can be created.
    --
    -- -   @pending@: A virtual interface is in this state from the time that
    --     it is created until the virtual interface is ready to forward
    --     traffic.
    --
    -- -   @available@: A virtual interface that is able to forward traffic.
    --
    -- -   @down@: A virtual interface that is BGP down.
    --
    -- -   @deleting@: A virtual interface is in this state immediately after
    --     calling DeleteVirtualInterface until it can no longer forward
    --     traffic.
    --
    -- -   @deleted@: A virtual interface that cannot forward traffic.
    --
    -- -   @rejected@: The virtual interface owner has declined creation of the
    --     virtual interface. If a virtual interface in the @Confirming@ state
    --     is deleted by the virtual interface owner, the virtual interface
    --     enters the @Rejected@ state.
    --
    -- -   @unknown@: The state of the virtual interface is not available.
    ConfirmPublicVirtualInterfaceResponse
-> Maybe VirtualInterfaceState
virtualInterfaceState :: Prelude.Maybe VirtualInterfaceState,
    -- | The response's http status code.
    ConfirmPublicVirtualInterfaceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ConfirmPublicVirtualInterfaceResponse
-> ConfirmPublicVirtualInterfaceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfirmPublicVirtualInterfaceResponse
-> ConfirmPublicVirtualInterfaceResponse -> Bool
$c/= :: ConfirmPublicVirtualInterfaceResponse
-> ConfirmPublicVirtualInterfaceResponse -> Bool
== :: ConfirmPublicVirtualInterfaceResponse
-> ConfirmPublicVirtualInterfaceResponse -> Bool
$c== :: ConfirmPublicVirtualInterfaceResponse
-> ConfirmPublicVirtualInterfaceResponse -> Bool
Prelude.Eq, ReadPrec [ConfirmPublicVirtualInterfaceResponse]
ReadPrec ConfirmPublicVirtualInterfaceResponse
Int -> ReadS ConfirmPublicVirtualInterfaceResponse
ReadS [ConfirmPublicVirtualInterfaceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfirmPublicVirtualInterfaceResponse]
$creadListPrec :: ReadPrec [ConfirmPublicVirtualInterfaceResponse]
readPrec :: ReadPrec ConfirmPublicVirtualInterfaceResponse
$creadPrec :: ReadPrec ConfirmPublicVirtualInterfaceResponse
readList :: ReadS [ConfirmPublicVirtualInterfaceResponse]
$creadList :: ReadS [ConfirmPublicVirtualInterfaceResponse]
readsPrec :: Int -> ReadS ConfirmPublicVirtualInterfaceResponse
$creadsPrec :: Int -> ReadS ConfirmPublicVirtualInterfaceResponse
Prelude.Read, Int -> ConfirmPublicVirtualInterfaceResponse -> ShowS
[ConfirmPublicVirtualInterfaceResponse] -> ShowS
ConfirmPublicVirtualInterfaceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfirmPublicVirtualInterfaceResponse] -> ShowS
$cshowList :: [ConfirmPublicVirtualInterfaceResponse] -> ShowS
show :: ConfirmPublicVirtualInterfaceResponse -> String
$cshow :: ConfirmPublicVirtualInterfaceResponse -> String
showsPrec :: Int -> ConfirmPublicVirtualInterfaceResponse -> ShowS
$cshowsPrec :: Int -> ConfirmPublicVirtualInterfaceResponse -> ShowS
Prelude.Show, forall x.
Rep ConfirmPublicVirtualInterfaceResponse x
-> ConfirmPublicVirtualInterfaceResponse
forall x.
ConfirmPublicVirtualInterfaceResponse
-> Rep ConfirmPublicVirtualInterfaceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfirmPublicVirtualInterfaceResponse x
-> ConfirmPublicVirtualInterfaceResponse
$cfrom :: forall x.
ConfirmPublicVirtualInterfaceResponse
-> Rep ConfirmPublicVirtualInterfaceResponse x
Prelude.Generic)

-- |
-- Create a value of 'ConfirmPublicVirtualInterfaceResponse' 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:
--
-- 'virtualInterfaceState', 'confirmPublicVirtualInterfaceResponse_virtualInterfaceState' - The state of the virtual interface. The following are the possible
-- values:
--
-- -   @confirming@: The creation of the virtual interface is pending
--     confirmation from the virtual interface owner. If the owner of the
--     virtual interface is different from the owner of the connection on
--     which it is provisioned, then the virtual interface will remain in
--     this state until it is confirmed by the virtual interface owner.
--
-- -   @verifying@: This state only applies to public virtual interfaces.
--     Each public virtual interface needs validation before the virtual
--     interface can be created.
--
-- -   @pending@: A virtual interface is in this state from the time that
--     it is created until the virtual interface is ready to forward
--     traffic.
--
-- -   @available@: A virtual interface that is able to forward traffic.
--
-- -   @down@: A virtual interface that is BGP down.
--
-- -   @deleting@: A virtual interface is in this state immediately after
--     calling DeleteVirtualInterface until it can no longer forward
--     traffic.
--
-- -   @deleted@: A virtual interface that cannot forward traffic.
--
-- -   @rejected@: The virtual interface owner has declined creation of the
--     virtual interface. If a virtual interface in the @Confirming@ state
--     is deleted by the virtual interface owner, the virtual interface
--     enters the @Rejected@ state.
--
-- -   @unknown@: The state of the virtual interface is not available.
--
-- 'httpStatus', 'confirmPublicVirtualInterfaceResponse_httpStatus' - The response's http status code.
newConfirmPublicVirtualInterfaceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ConfirmPublicVirtualInterfaceResponse
newConfirmPublicVirtualInterfaceResponse :: Int -> ConfirmPublicVirtualInterfaceResponse
newConfirmPublicVirtualInterfaceResponse Int
pHttpStatus_ =
  ConfirmPublicVirtualInterfaceResponse'
    { $sel:virtualInterfaceState:ConfirmPublicVirtualInterfaceResponse' :: Maybe VirtualInterfaceState
virtualInterfaceState =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ConfirmPublicVirtualInterfaceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The state of the virtual interface. The following are the possible
-- values:
--
-- -   @confirming@: The creation of the virtual interface is pending
--     confirmation from the virtual interface owner. If the owner of the
--     virtual interface is different from the owner of the connection on
--     which it is provisioned, then the virtual interface will remain in
--     this state until it is confirmed by the virtual interface owner.
--
-- -   @verifying@: This state only applies to public virtual interfaces.
--     Each public virtual interface needs validation before the virtual
--     interface can be created.
--
-- -   @pending@: A virtual interface is in this state from the time that
--     it is created until the virtual interface is ready to forward
--     traffic.
--
-- -   @available@: A virtual interface that is able to forward traffic.
--
-- -   @down@: A virtual interface that is BGP down.
--
-- -   @deleting@: A virtual interface is in this state immediately after
--     calling DeleteVirtualInterface until it can no longer forward
--     traffic.
--
-- -   @deleted@: A virtual interface that cannot forward traffic.
--
-- -   @rejected@: The virtual interface owner has declined creation of the
--     virtual interface. If a virtual interface in the @Confirming@ state
--     is deleted by the virtual interface owner, the virtual interface
--     enters the @Rejected@ state.
--
-- -   @unknown@: The state of the virtual interface is not available.
confirmPublicVirtualInterfaceResponse_virtualInterfaceState :: Lens.Lens' ConfirmPublicVirtualInterfaceResponse (Prelude.Maybe VirtualInterfaceState)
confirmPublicVirtualInterfaceResponse_virtualInterfaceState :: Lens'
  ConfirmPublicVirtualInterfaceResponse (Maybe VirtualInterfaceState)
confirmPublicVirtualInterfaceResponse_virtualInterfaceState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmPublicVirtualInterfaceResponse' {Maybe VirtualInterfaceState
virtualInterfaceState :: Maybe VirtualInterfaceState
$sel:virtualInterfaceState:ConfirmPublicVirtualInterfaceResponse' :: ConfirmPublicVirtualInterfaceResponse
-> Maybe VirtualInterfaceState
virtualInterfaceState} -> Maybe VirtualInterfaceState
virtualInterfaceState) (\s :: ConfirmPublicVirtualInterfaceResponse
s@ConfirmPublicVirtualInterfaceResponse' {} Maybe VirtualInterfaceState
a -> ConfirmPublicVirtualInterfaceResponse
s {$sel:virtualInterfaceState:ConfirmPublicVirtualInterfaceResponse' :: Maybe VirtualInterfaceState
virtualInterfaceState = Maybe VirtualInterfaceState
a} :: ConfirmPublicVirtualInterfaceResponse)

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

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