{-# 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.NetworkManager.DeleteGlobalNetwork
-- 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 an existing global network. You must first delete all global
-- network objects (devices, links, and sites) and deregister all transit
-- gateways.
module Amazonka.NetworkManager.DeleteGlobalNetwork
  ( -- * Creating a Request
    DeleteGlobalNetwork (..),
    newDeleteGlobalNetwork,

    -- * Request Lenses
    deleteGlobalNetwork_globalNetworkId,

    -- * Destructuring the Response
    DeleteGlobalNetworkResponse (..),
    newDeleteGlobalNetworkResponse,

    -- * Response Lenses
    deleteGlobalNetworkResponse_globalNetwork,
    deleteGlobalNetworkResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteGlobalNetwork' smart constructor.
data DeleteGlobalNetwork = DeleteGlobalNetwork'
  { -- | The ID of the global network.
    DeleteGlobalNetwork -> Text
globalNetworkId :: Prelude.Text
  }
  deriving (DeleteGlobalNetwork -> DeleteGlobalNetwork -> Bool
(DeleteGlobalNetwork -> DeleteGlobalNetwork -> Bool)
-> (DeleteGlobalNetwork -> DeleteGlobalNetwork -> Bool)
-> Eq DeleteGlobalNetwork
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteGlobalNetwork -> DeleteGlobalNetwork -> Bool
$c/= :: DeleteGlobalNetwork -> DeleteGlobalNetwork -> Bool
== :: DeleteGlobalNetwork -> DeleteGlobalNetwork -> Bool
$c== :: DeleteGlobalNetwork -> DeleteGlobalNetwork -> Bool
Prelude.Eq, ReadPrec [DeleteGlobalNetwork]
ReadPrec DeleteGlobalNetwork
Int -> ReadS DeleteGlobalNetwork
ReadS [DeleteGlobalNetwork]
(Int -> ReadS DeleteGlobalNetwork)
-> ReadS [DeleteGlobalNetwork]
-> ReadPrec DeleteGlobalNetwork
-> ReadPrec [DeleteGlobalNetwork]
-> Read DeleteGlobalNetwork
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteGlobalNetwork]
$creadListPrec :: ReadPrec [DeleteGlobalNetwork]
readPrec :: ReadPrec DeleteGlobalNetwork
$creadPrec :: ReadPrec DeleteGlobalNetwork
readList :: ReadS [DeleteGlobalNetwork]
$creadList :: ReadS [DeleteGlobalNetwork]
readsPrec :: Int -> ReadS DeleteGlobalNetwork
$creadsPrec :: Int -> ReadS DeleteGlobalNetwork
Prelude.Read, Int -> DeleteGlobalNetwork -> ShowS
[DeleteGlobalNetwork] -> ShowS
DeleteGlobalNetwork -> String
(Int -> DeleteGlobalNetwork -> ShowS)
-> (DeleteGlobalNetwork -> String)
-> ([DeleteGlobalNetwork] -> ShowS)
-> Show DeleteGlobalNetwork
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteGlobalNetwork] -> ShowS
$cshowList :: [DeleteGlobalNetwork] -> ShowS
show :: DeleteGlobalNetwork -> String
$cshow :: DeleteGlobalNetwork -> String
showsPrec :: Int -> DeleteGlobalNetwork -> ShowS
$cshowsPrec :: Int -> DeleteGlobalNetwork -> ShowS
Prelude.Show, (forall x. DeleteGlobalNetwork -> Rep DeleteGlobalNetwork x)
-> (forall x. Rep DeleteGlobalNetwork x -> DeleteGlobalNetwork)
-> Generic DeleteGlobalNetwork
forall x. Rep DeleteGlobalNetwork x -> DeleteGlobalNetwork
forall x. DeleteGlobalNetwork -> Rep DeleteGlobalNetwork x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteGlobalNetwork x -> DeleteGlobalNetwork
$cfrom :: forall x. DeleteGlobalNetwork -> Rep DeleteGlobalNetwork x
Prelude.Generic)

-- |
-- Create a value of 'DeleteGlobalNetwork' 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:
--
-- 'globalNetworkId', 'deleteGlobalNetwork_globalNetworkId' - The ID of the global network.
newDeleteGlobalNetwork ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  DeleteGlobalNetwork
newDeleteGlobalNetwork :: Text -> DeleteGlobalNetwork
newDeleteGlobalNetwork Text
pGlobalNetworkId_ =
  DeleteGlobalNetwork' :: Text -> DeleteGlobalNetwork
DeleteGlobalNetwork'
    { $sel:globalNetworkId:DeleteGlobalNetwork' :: Text
globalNetworkId =
        Text
pGlobalNetworkId_
    }

-- | The ID of the global network.
deleteGlobalNetwork_globalNetworkId :: Lens.Lens' DeleteGlobalNetwork Prelude.Text
deleteGlobalNetwork_globalNetworkId :: (Text -> f Text) -> DeleteGlobalNetwork -> f DeleteGlobalNetwork
deleteGlobalNetwork_globalNetworkId = (DeleteGlobalNetwork -> Text)
-> (DeleteGlobalNetwork -> Text -> DeleteGlobalNetwork)
-> Lens DeleteGlobalNetwork DeleteGlobalNetwork Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGlobalNetwork' {Text
globalNetworkId :: Text
$sel:globalNetworkId:DeleteGlobalNetwork' :: DeleteGlobalNetwork -> Text
globalNetworkId} -> Text
globalNetworkId) (\s :: DeleteGlobalNetwork
s@DeleteGlobalNetwork' {} Text
a -> DeleteGlobalNetwork
s {$sel:globalNetworkId:DeleteGlobalNetwork' :: Text
globalNetworkId = Text
a} :: DeleteGlobalNetwork)

instance Core.AWSRequest DeleteGlobalNetwork where
  type
    AWSResponse DeleteGlobalNetwork =
      DeleteGlobalNetworkResponse
  request :: DeleteGlobalNetwork -> Request DeleteGlobalNetwork
request = Service -> DeleteGlobalNetwork -> Request DeleteGlobalNetwork
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteGlobalNetwork
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteGlobalNetwork)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteGlobalNetwork))
-> Logger
-> Service
-> Proxy DeleteGlobalNetwork
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteGlobalNetwork)))
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 GlobalNetwork -> Int -> DeleteGlobalNetworkResponse
DeleteGlobalNetworkResponse'
            (Maybe GlobalNetwork -> Int -> DeleteGlobalNetworkResponse)
-> Either String (Maybe GlobalNetwork)
-> Either String (Int -> DeleteGlobalNetworkResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe GlobalNetwork)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GlobalNetwork")
            Either String (Int -> DeleteGlobalNetworkResponse)
-> Either String Int -> Either String DeleteGlobalNetworkResponse
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 DeleteGlobalNetwork

instance Prelude.NFData DeleteGlobalNetwork

instance Core.ToHeaders DeleteGlobalNetwork where
  toHeaders :: DeleteGlobalNetwork -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteGlobalNetwork -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DeleteGlobalNetwork where
  toPath :: DeleteGlobalNetwork -> ByteString
toPath DeleteGlobalNetwork' {Text
globalNetworkId :: Text
$sel:globalNetworkId:DeleteGlobalNetwork' :: DeleteGlobalNetwork -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/global-networks/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
globalNetworkId]

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

-- | /See:/ 'newDeleteGlobalNetworkResponse' smart constructor.
data DeleteGlobalNetworkResponse = DeleteGlobalNetworkResponse'
  { -- | Information about the global network.
    DeleteGlobalNetworkResponse -> Maybe GlobalNetwork
globalNetwork :: Prelude.Maybe GlobalNetwork,
    -- | The response's http status code.
    DeleteGlobalNetworkResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteGlobalNetworkResponse -> DeleteGlobalNetworkResponse -> Bool
(DeleteGlobalNetworkResponse
 -> DeleteGlobalNetworkResponse -> Bool)
-> (DeleteGlobalNetworkResponse
    -> DeleteGlobalNetworkResponse -> Bool)
-> Eq DeleteGlobalNetworkResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteGlobalNetworkResponse -> DeleteGlobalNetworkResponse -> Bool
$c/= :: DeleteGlobalNetworkResponse -> DeleteGlobalNetworkResponse -> Bool
== :: DeleteGlobalNetworkResponse -> DeleteGlobalNetworkResponse -> Bool
$c== :: DeleteGlobalNetworkResponse -> DeleteGlobalNetworkResponse -> Bool
Prelude.Eq, ReadPrec [DeleteGlobalNetworkResponse]
ReadPrec DeleteGlobalNetworkResponse
Int -> ReadS DeleteGlobalNetworkResponse
ReadS [DeleteGlobalNetworkResponse]
(Int -> ReadS DeleteGlobalNetworkResponse)
-> ReadS [DeleteGlobalNetworkResponse]
-> ReadPrec DeleteGlobalNetworkResponse
-> ReadPrec [DeleteGlobalNetworkResponse]
-> Read DeleteGlobalNetworkResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteGlobalNetworkResponse]
$creadListPrec :: ReadPrec [DeleteGlobalNetworkResponse]
readPrec :: ReadPrec DeleteGlobalNetworkResponse
$creadPrec :: ReadPrec DeleteGlobalNetworkResponse
readList :: ReadS [DeleteGlobalNetworkResponse]
$creadList :: ReadS [DeleteGlobalNetworkResponse]
readsPrec :: Int -> ReadS DeleteGlobalNetworkResponse
$creadsPrec :: Int -> ReadS DeleteGlobalNetworkResponse
Prelude.Read, Int -> DeleteGlobalNetworkResponse -> ShowS
[DeleteGlobalNetworkResponse] -> ShowS
DeleteGlobalNetworkResponse -> String
(Int -> DeleteGlobalNetworkResponse -> ShowS)
-> (DeleteGlobalNetworkResponse -> String)
-> ([DeleteGlobalNetworkResponse] -> ShowS)
-> Show DeleteGlobalNetworkResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteGlobalNetworkResponse] -> ShowS
$cshowList :: [DeleteGlobalNetworkResponse] -> ShowS
show :: DeleteGlobalNetworkResponse -> String
$cshow :: DeleteGlobalNetworkResponse -> String
showsPrec :: Int -> DeleteGlobalNetworkResponse -> ShowS
$cshowsPrec :: Int -> DeleteGlobalNetworkResponse -> ShowS
Prelude.Show, (forall x.
 DeleteGlobalNetworkResponse -> Rep DeleteGlobalNetworkResponse x)
-> (forall x.
    Rep DeleteGlobalNetworkResponse x -> DeleteGlobalNetworkResponse)
-> Generic DeleteGlobalNetworkResponse
forall x.
Rep DeleteGlobalNetworkResponse x -> DeleteGlobalNetworkResponse
forall x.
DeleteGlobalNetworkResponse -> Rep DeleteGlobalNetworkResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteGlobalNetworkResponse x -> DeleteGlobalNetworkResponse
$cfrom :: forall x.
DeleteGlobalNetworkResponse -> Rep DeleteGlobalNetworkResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteGlobalNetworkResponse' 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:
--
-- 'globalNetwork', 'deleteGlobalNetworkResponse_globalNetwork' - Information about the global network.
--
-- 'httpStatus', 'deleteGlobalNetworkResponse_httpStatus' - The response's http status code.
newDeleteGlobalNetworkResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteGlobalNetworkResponse
newDeleteGlobalNetworkResponse :: Int -> DeleteGlobalNetworkResponse
newDeleteGlobalNetworkResponse Int
pHttpStatus_ =
  DeleteGlobalNetworkResponse' :: Maybe GlobalNetwork -> Int -> DeleteGlobalNetworkResponse
DeleteGlobalNetworkResponse'
    { $sel:globalNetwork:DeleteGlobalNetworkResponse' :: Maybe GlobalNetwork
globalNetwork =
        Maybe GlobalNetwork
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteGlobalNetworkResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the global network.
deleteGlobalNetworkResponse_globalNetwork :: Lens.Lens' DeleteGlobalNetworkResponse (Prelude.Maybe GlobalNetwork)
deleteGlobalNetworkResponse_globalNetwork :: (Maybe GlobalNetwork -> f (Maybe GlobalNetwork))
-> DeleteGlobalNetworkResponse -> f DeleteGlobalNetworkResponse
deleteGlobalNetworkResponse_globalNetwork = (DeleteGlobalNetworkResponse -> Maybe GlobalNetwork)
-> (DeleteGlobalNetworkResponse
    -> Maybe GlobalNetwork -> DeleteGlobalNetworkResponse)
-> Lens
     DeleteGlobalNetworkResponse
     DeleteGlobalNetworkResponse
     (Maybe GlobalNetwork)
     (Maybe GlobalNetwork)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGlobalNetworkResponse' {Maybe GlobalNetwork
globalNetwork :: Maybe GlobalNetwork
$sel:globalNetwork:DeleteGlobalNetworkResponse' :: DeleteGlobalNetworkResponse -> Maybe GlobalNetwork
globalNetwork} -> Maybe GlobalNetwork
globalNetwork) (\s :: DeleteGlobalNetworkResponse
s@DeleteGlobalNetworkResponse' {} Maybe GlobalNetwork
a -> DeleteGlobalNetworkResponse
s {$sel:globalNetwork:DeleteGlobalNetworkResponse' :: Maybe GlobalNetwork
globalNetwork = Maybe GlobalNetwork
a} :: DeleteGlobalNetworkResponse)

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

instance Prelude.NFData DeleteGlobalNetworkResponse