{-# 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.DeleteVirtualInterface
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a virtual interface.
module Amazonka.DirectConnect.DeleteVirtualInterface
  ( -- * Creating a Request
    DeleteVirtualInterface (..),
    newDeleteVirtualInterface,

    -- * Request Lenses
    deleteVirtualInterface_virtualInterfaceId,

    -- * Destructuring the Response
    DeleteVirtualInterfaceResponse (..),
    newDeleteVirtualInterfaceResponse,

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

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

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

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

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

instance Data.ToHeaders DeleteVirtualInterface where
  toHeaders :: DeleteVirtualInterface -> 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.DeleteVirtualInterface" ::
                          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 DeleteVirtualInterface where
  toJSON :: DeleteVirtualInterface -> Value
toJSON DeleteVirtualInterface' {Text
virtualInterfaceId :: Text
$sel:virtualInterfaceId:DeleteVirtualInterface' :: DeleteVirtualInterface -> 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 DeleteVirtualInterface where
  toPath :: DeleteVirtualInterface -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DeleteVirtualInterfaceResponse' 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', 'deleteVirtualInterfaceResponse_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', 'deleteVirtualInterfaceResponse_httpStatus' - The response's http status code.
newDeleteVirtualInterfaceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteVirtualInterfaceResponse
newDeleteVirtualInterfaceResponse :: Int -> DeleteVirtualInterfaceResponse
newDeleteVirtualInterfaceResponse Int
pHttpStatus_ =
  DeleteVirtualInterfaceResponse'
    { $sel:virtualInterfaceState:DeleteVirtualInterfaceResponse' :: Maybe VirtualInterfaceState
virtualInterfaceState =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteVirtualInterfaceResponse' :: 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.
deleteVirtualInterfaceResponse_virtualInterfaceState :: Lens.Lens' DeleteVirtualInterfaceResponse (Prelude.Maybe VirtualInterfaceState)
deleteVirtualInterfaceResponse_virtualInterfaceState :: Lens' DeleteVirtualInterfaceResponse (Maybe VirtualInterfaceState)
deleteVirtualInterfaceResponse_virtualInterfaceState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVirtualInterfaceResponse' {Maybe VirtualInterfaceState
virtualInterfaceState :: Maybe VirtualInterfaceState
$sel:virtualInterfaceState:DeleteVirtualInterfaceResponse' :: DeleteVirtualInterfaceResponse -> Maybe VirtualInterfaceState
virtualInterfaceState} -> Maybe VirtualInterfaceState
virtualInterfaceState) (\s :: DeleteVirtualInterfaceResponse
s@DeleteVirtualInterfaceResponse' {} Maybe VirtualInterfaceState
a -> DeleteVirtualInterfaceResponse
s {$sel:virtualInterfaceState:DeleteVirtualInterfaceResponse' :: Maybe VirtualInterfaceState
virtualInterfaceState = Maybe VirtualInterfaceState
a} :: DeleteVirtualInterfaceResponse)

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

instance
  Prelude.NFData
    DeleteVirtualInterfaceResponse
  where
  rnf :: DeleteVirtualInterfaceResponse -> ()
rnf DeleteVirtualInterfaceResponse' {Int
Maybe VirtualInterfaceState
httpStatus :: Int
virtualInterfaceState :: Maybe VirtualInterfaceState
$sel:httpStatus:DeleteVirtualInterfaceResponse' :: DeleteVirtualInterfaceResponse -> Int
$sel:virtualInterfaceState:DeleteVirtualInterfaceResponse' :: DeleteVirtualInterfaceResponse -> 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