{-# 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.PrivateNetworks.DeleteNetwork
-- 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 the specified network. You must delete network sites before you
-- delete the network. For more information, see
-- <https://docs.aws.amazon.com/private-networks/latest/APIReference/API_DeleteNetworkSite.html DeleteNetworkSite>
-- in the /API Reference for Amazon Web Services Private 5G/.
module Amazonka.PrivateNetworks.DeleteNetwork
  ( -- * Creating a Request
    DeleteNetwork (..),
    newDeleteNetwork,

    -- * Request Lenses
    deleteNetwork_clientToken,
    deleteNetwork_networkArn,

    -- * Destructuring the Response
    DeleteNetworkResponse (..),
    newDeleteNetworkResponse,

    -- * Response Lenses
    deleteNetworkResponse_httpStatus,
    deleteNetworkResponse_network,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.PrivateNetworks.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteNetwork' smart constructor.
data DeleteNetwork = DeleteNetwork'
  { -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. For more information, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html How to ensure idempotency>.
    DeleteNetwork -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the network.
    DeleteNetwork -> Text
networkArn :: Prelude.Text
  }
  deriving (DeleteNetwork -> DeleteNetwork -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteNetwork -> DeleteNetwork -> Bool
$c/= :: DeleteNetwork -> DeleteNetwork -> Bool
== :: DeleteNetwork -> DeleteNetwork -> Bool
$c== :: DeleteNetwork -> DeleteNetwork -> Bool
Prelude.Eq, ReadPrec [DeleteNetwork]
ReadPrec DeleteNetwork
Int -> ReadS DeleteNetwork
ReadS [DeleteNetwork]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteNetwork]
$creadListPrec :: ReadPrec [DeleteNetwork]
readPrec :: ReadPrec DeleteNetwork
$creadPrec :: ReadPrec DeleteNetwork
readList :: ReadS [DeleteNetwork]
$creadList :: ReadS [DeleteNetwork]
readsPrec :: Int -> ReadS DeleteNetwork
$creadsPrec :: Int -> ReadS DeleteNetwork
Prelude.Read, Int -> DeleteNetwork -> ShowS
[DeleteNetwork] -> ShowS
DeleteNetwork -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteNetwork] -> ShowS
$cshowList :: [DeleteNetwork] -> ShowS
show :: DeleteNetwork -> String
$cshow :: DeleteNetwork -> String
showsPrec :: Int -> DeleteNetwork -> ShowS
$cshowsPrec :: Int -> DeleteNetwork -> ShowS
Prelude.Show, forall x. Rep DeleteNetwork x -> DeleteNetwork
forall x. DeleteNetwork -> Rep DeleteNetwork x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteNetwork x -> DeleteNetwork
$cfrom :: forall x. DeleteNetwork -> Rep DeleteNetwork x
Prelude.Generic)

-- |
-- Create a value of 'DeleteNetwork' 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:
--
-- 'clientToken', 'deleteNetwork_clientToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html How to ensure idempotency>.
--
-- 'networkArn', 'deleteNetwork_networkArn' - The Amazon Resource Name (ARN) of the network.
newDeleteNetwork ::
  -- | 'networkArn'
  Prelude.Text ->
  DeleteNetwork
newDeleteNetwork :: Text -> DeleteNetwork
newDeleteNetwork Text
pNetworkArn_ =
  DeleteNetwork'
    { $sel:clientToken:DeleteNetwork' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:networkArn:DeleteNetwork' :: Text
networkArn = Text
pNetworkArn_
    }

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html How to ensure idempotency>.
deleteNetwork_clientToken :: Lens.Lens' DeleteNetwork (Prelude.Maybe Prelude.Text)
deleteNetwork_clientToken :: Lens' DeleteNetwork (Maybe Text)
deleteNetwork_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNetwork' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DeleteNetwork' :: DeleteNetwork -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DeleteNetwork
s@DeleteNetwork' {} Maybe Text
a -> DeleteNetwork
s {$sel:clientToken:DeleteNetwork' :: Maybe Text
clientToken = Maybe Text
a} :: DeleteNetwork)

-- | The Amazon Resource Name (ARN) of the network.
deleteNetwork_networkArn :: Lens.Lens' DeleteNetwork Prelude.Text
deleteNetwork_networkArn :: Lens' DeleteNetwork Text
deleteNetwork_networkArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNetwork' {Text
networkArn :: Text
$sel:networkArn:DeleteNetwork' :: DeleteNetwork -> Text
networkArn} -> Text
networkArn) (\s :: DeleteNetwork
s@DeleteNetwork' {} Text
a -> DeleteNetwork
s {$sel:networkArn:DeleteNetwork' :: Text
networkArn = Text
a} :: DeleteNetwork)

instance Core.AWSRequest DeleteNetwork where
  type
    AWSResponse DeleteNetwork =
      DeleteNetworkResponse
  request :: (Service -> Service) -> DeleteNetwork -> Request DeleteNetwork
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteNetwork
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteNetwork)))
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 ->
          Int -> Network -> DeleteNetworkResponse
DeleteNetworkResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"network")
      )

instance Prelude.Hashable DeleteNetwork where
  hashWithSalt :: Int -> DeleteNetwork -> Int
hashWithSalt Int
_salt DeleteNetwork' {Maybe Text
Text
networkArn :: Text
clientToken :: Maybe Text
$sel:networkArn:DeleteNetwork' :: DeleteNetwork -> Text
$sel:clientToken:DeleteNetwork' :: DeleteNetwork -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
networkArn

instance Prelude.NFData DeleteNetwork where
  rnf :: DeleteNetwork -> ()
rnf DeleteNetwork' {Maybe Text
Text
networkArn :: Text
clientToken :: Maybe Text
$sel:networkArn:DeleteNetwork' :: DeleteNetwork -> Text
$sel:clientToken:DeleteNetwork' :: DeleteNetwork -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
networkArn

instance Data.ToHeaders DeleteNetwork where
  toHeaders :: DeleteNetwork -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath DeleteNetwork where
  toPath :: DeleteNetwork -> ByteString
toPath DeleteNetwork' {Maybe Text
Text
networkArn :: Text
clientToken :: Maybe Text
$sel:networkArn:DeleteNetwork' :: DeleteNetwork -> Text
$sel:clientToken:DeleteNetwork' :: DeleteNetwork -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/networks/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
networkArn]

instance Data.ToQuery DeleteNetwork where
  toQuery :: DeleteNetwork -> QueryString
toQuery DeleteNetwork' {Maybe Text
Text
networkArn :: Text
clientToken :: Maybe Text
$sel:networkArn:DeleteNetwork' :: DeleteNetwork -> Text
$sel:clientToken:DeleteNetwork' :: DeleteNetwork -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"clientToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
clientToken]

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

-- |
-- Create a value of 'DeleteNetworkResponse' 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:
--
-- 'httpStatus', 'deleteNetworkResponse_httpStatus' - The response's http status code.
--
-- 'network', 'deleteNetworkResponse_network' - Information about the network.
newDeleteNetworkResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'network'
  Network ->
  DeleteNetworkResponse
newDeleteNetworkResponse :: Int -> Network -> DeleteNetworkResponse
newDeleteNetworkResponse Int
pHttpStatus_ Network
pNetwork_ =
  DeleteNetworkResponse'
    { $sel:httpStatus:DeleteNetworkResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:network:DeleteNetworkResponse' :: Network
network = Network
pNetwork_
    }

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

-- | Information about the network.
deleteNetworkResponse_network :: Lens.Lens' DeleteNetworkResponse Network
deleteNetworkResponse_network :: Lens' DeleteNetworkResponse Network
deleteNetworkResponse_network = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNetworkResponse' {Network
network :: Network
$sel:network:DeleteNetworkResponse' :: DeleteNetworkResponse -> Network
network} -> Network
network) (\s :: DeleteNetworkResponse
s@DeleteNetworkResponse' {} Network
a -> DeleteNetworkResponse
s {$sel:network:DeleteNetworkResponse' :: Network
network = Network
a} :: DeleteNetworkResponse)

instance Prelude.NFData DeleteNetworkResponse where
  rnf :: DeleteNetworkResponse -> ()
rnf DeleteNetworkResponse' {Int
Network
network :: Network
httpStatus :: Int
$sel:network:DeleteNetworkResponse' :: DeleteNetworkResponse -> Network
$sel:httpStatus:DeleteNetworkResponse' :: DeleteNetworkResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Network
network