{-# 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.DeleteDirectConnectGateway
-- 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)
--
-- Deletes the specified Direct Connect gateway. You must first delete all
-- virtual interfaces that are attached to the Direct Connect gateway and
-- disassociate all virtual private gateways associated with the Direct
-- Connect gateway.
module Amazonka.DirectConnect.DeleteDirectConnectGateway
  ( -- * Creating a Request
    DeleteDirectConnectGateway (..),
    newDeleteDirectConnectGateway,

    -- * Request Lenses
    deleteDirectConnectGateway_directConnectGatewayId,

    -- * Destructuring the Response
    DeleteDirectConnectGatewayResponse (..),
    newDeleteDirectConnectGatewayResponse,

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

-- |
-- Create a value of 'DeleteDirectConnectGateway' 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:
--
-- 'directConnectGatewayId', 'deleteDirectConnectGateway_directConnectGatewayId' - The ID of the Direct Connect gateway.
newDeleteDirectConnectGateway ::
  -- | 'directConnectGatewayId'
  Prelude.Text ->
  DeleteDirectConnectGateway
newDeleteDirectConnectGateway :: Text -> DeleteDirectConnectGateway
newDeleteDirectConnectGateway
  Text
pDirectConnectGatewayId_ =
    DeleteDirectConnectGateway' :: Text -> DeleteDirectConnectGateway
DeleteDirectConnectGateway'
      { $sel:directConnectGatewayId:DeleteDirectConnectGateway' :: Text
directConnectGatewayId =
          Text
pDirectConnectGatewayId_
      }

-- | The ID of the Direct Connect gateway.
deleteDirectConnectGateway_directConnectGatewayId :: Lens.Lens' DeleteDirectConnectGateway Prelude.Text
deleteDirectConnectGateway_directConnectGatewayId :: (Text -> f Text)
-> DeleteDirectConnectGateway -> f DeleteDirectConnectGateway
deleteDirectConnectGateway_directConnectGatewayId = (DeleteDirectConnectGateway -> Text)
-> (DeleteDirectConnectGateway
    -> Text -> DeleteDirectConnectGateway)
-> Lens
     DeleteDirectConnectGateway DeleteDirectConnectGateway Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDirectConnectGateway' {Text
directConnectGatewayId :: Text
$sel:directConnectGatewayId:DeleteDirectConnectGateway' :: DeleteDirectConnectGateway -> Text
directConnectGatewayId} -> Text
directConnectGatewayId) (\s :: DeleteDirectConnectGateway
s@DeleteDirectConnectGateway' {} Text
a -> DeleteDirectConnectGateway
s {$sel:directConnectGatewayId:DeleteDirectConnectGateway' :: Text
directConnectGatewayId = Text
a} :: DeleteDirectConnectGateway)

instance Core.AWSRequest DeleteDirectConnectGateway where
  type
    AWSResponse DeleteDirectConnectGateway =
      DeleteDirectConnectGatewayResponse
  request :: DeleteDirectConnectGateway -> Request DeleteDirectConnectGateway
request = Service
-> DeleteDirectConnectGateway -> Request DeleteDirectConnectGateway
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDirectConnectGateway
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDirectConnectGateway)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteDirectConnectGateway))
-> Logger
-> Service
-> Proxy DeleteDirectConnectGateway
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDirectConnectGateway)))
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 ->
          Maybe DirectConnectGateway
-> Int -> DeleteDirectConnectGatewayResponse
DeleteDirectConnectGatewayResponse'
            (Maybe DirectConnectGateway
 -> Int -> DeleteDirectConnectGatewayResponse)
-> Either String (Maybe DirectConnectGateway)
-> Either String (Int -> DeleteDirectConnectGatewayResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DirectConnectGateway)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"directConnectGateway")
            Either String (Int -> DeleteDirectConnectGatewayResponse)
-> Either String Int
-> Either String DeleteDirectConnectGatewayResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteDirectConnectGateway

instance Prelude.NFData DeleteDirectConnectGateway

instance Core.ToHeaders DeleteDirectConnectGateway where
  toHeaders :: DeleteDirectConnectGateway -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteDirectConnectGateway -> 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.DeleteDirectConnectGateway" ::
                          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 DeleteDirectConnectGateway where
  toJSON :: DeleteDirectConnectGateway -> Value
toJSON DeleteDirectConnectGateway' {Text
directConnectGatewayId :: Text
$sel:directConnectGatewayId:DeleteDirectConnectGateway' :: DeleteDirectConnectGateway -> 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
"directConnectGatewayId"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
directConnectGatewayId
              )
          ]
      )

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

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

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

-- |
-- Create a value of 'DeleteDirectConnectGatewayResponse' 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:
--
-- 'directConnectGateway', 'deleteDirectConnectGatewayResponse_directConnectGateway' - The Direct Connect gateway.
--
-- 'httpStatus', 'deleteDirectConnectGatewayResponse_httpStatus' - The response's http status code.
newDeleteDirectConnectGatewayResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteDirectConnectGatewayResponse
newDeleteDirectConnectGatewayResponse :: Int -> DeleteDirectConnectGatewayResponse
newDeleteDirectConnectGatewayResponse Int
pHttpStatus_ =
  DeleteDirectConnectGatewayResponse' :: Maybe DirectConnectGateway
-> Int -> DeleteDirectConnectGatewayResponse
DeleteDirectConnectGatewayResponse'
    { $sel:directConnectGateway:DeleteDirectConnectGatewayResponse' :: Maybe DirectConnectGateway
directConnectGateway =
        Maybe DirectConnectGateway
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteDirectConnectGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Direct Connect gateway.
deleteDirectConnectGatewayResponse_directConnectGateway :: Lens.Lens' DeleteDirectConnectGatewayResponse (Prelude.Maybe DirectConnectGateway)
deleteDirectConnectGatewayResponse_directConnectGateway :: (Maybe DirectConnectGateway -> f (Maybe DirectConnectGateway))
-> DeleteDirectConnectGatewayResponse
-> f DeleteDirectConnectGatewayResponse
deleteDirectConnectGatewayResponse_directConnectGateway = (DeleteDirectConnectGatewayResponse -> Maybe DirectConnectGateway)
-> (DeleteDirectConnectGatewayResponse
    -> Maybe DirectConnectGateway
    -> DeleteDirectConnectGatewayResponse)
-> Lens
     DeleteDirectConnectGatewayResponse
     DeleteDirectConnectGatewayResponse
     (Maybe DirectConnectGateway)
     (Maybe DirectConnectGateway)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDirectConnectGatewayResponse' {Maybe DirectConnectGateway
directConnectGateway :: Maybe DirectConnectGateway
$sel:directConnectGateway:DeleteDirectConnectGatewayResponse' :: DeleteDirectConnectGatewayResponse -> Maybe DirectConnectGateway
directConnectGateway} -> Maybe DirectConnectGateway
directConnectGateway) (\s :: DeleteDirectConnectGatewayResponse
s@DeleteDirectConnectGatewayResponse' {} Maybe DirectConnectGateway
a -> DeleteDirectConnectGatewayResponse
s {$sel:directConnectGateway:DeleteDirectConnectGatewayResponse' :: Maybe DirectConnectGateway
directConnectGateway = Maybe DirectConnectGateway
a} :: DeleteDirectConnectGatewayResponse)

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

instance
  Prelude.NFData
    DeleteDirectConnectGatewayResponse