{-# 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.DeleteCoreNetwork
-- 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 core network along with all core network policies. This can
-- only be done if there are no attachments on a core network.
module Amazonka.NetworkManager.DeleteCoreNetwork
  ( -- * Creating a Request
    DeleteCoreNetwork (..),
    newDeleteCoreNetwork,

    -- * Request Lenses
    deleteCoreNetwork_coreNetworkId,

    -- * Destructuring the Response
    DeleteCoreNetworkResponse (..),
    newDeleteCoreNetworkResponse,

    -- * Response Lenses
    deleteCoreNetworkResponse_coreNetwork,
    deleteCoreNetworkResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DeleteCoreNetwork' 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:
--
-- 'coreNetworkId', 'deleteCoreNetwork_coreNetworkId' - The network ID of the deleted core network.
newDeleteCoreNetwork ::
  -- | 'coreNetworkId'
  Prelude.Text ->
  DeleteCoreNetwork
newDeleteCoreNetwork :: Text -> DeleteCoreNetwork
newDeleteCoreNetwork Text
pCoreNetworkId_ =
  DeleteCoreNetwork' {$sel:coreNetworkId:DeleteCoreNetwork' :: Text
coreNetworkId = Text
pCoreNetworkId_}

-- | The network ID of the deleted core network.
deleteCoreNetwork_coreNetworkId :: Lens.Lens' DeleteCoreNetwork Prelude.Text
deleteCoreNetwork_coreNetworkId :: Lens' DeleteCoreNetwork Text
deleteCoreNetwork_coreNetworkId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCoreNetwork' {Text
coreNetworkId :: Text
$sel:coreNetworkId:DeleteCoreNetwork' :: DeleteCoreNetwork -> Text
coreNetworkId} -> Text
coreNetworkId) (\s :: DeleteCoreNetwork
s@DeleteCoreNetwork' {} Text
a -> DeleteCoreNetwork
s {$sel:coreNetworkId:DeleteCoreNetwork' :: Text
coreNetworkId = Text
a} :: DeleteCoreNetwork)

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

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

instance Data.ToHeaders DeleteCoreNetwork where
  toHeaders :: DeleteCoreNetwork -> 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 DeleteCoreNetwork where
  toPath :: DeleteCoreNetwork -> ByteString
toPath DeleteCoreNetwork' {Text
coreNetworkId :: Text
$sel:coreNetworkId:DeleteCoreNetwork' :: DeleteCoreNetwork -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/core-networks/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
coreNetworkId]

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

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

-- |
-- Create a value of 'DeleteCoreNetworkResponse' 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:
--
-- 'coreNetwork', 'deleteCoreNetworkResponse_coreNetwork' - Information about the deleted core network.
--
-- 'httpStatus', 'deleteCoreNetworkResponse_httpStatus' - The response's http status code.
newDeleteCoreNetworkResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteCoreNetworkResponse
newDeleteCoreNetworkResponse :: Int -> DeleteCoreNetworkResponse
newDeleteCoreNetworkResponse Int
pHttpStatus_ =
  DeleteCoreNetworkResponse'
    { $sel:coreNetwork:DeleteCoreNetworkResponse' :: Maybe CoreNetwork
coreNetwork =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteCoreNetworkResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the deleted core network.
deleteCoreNetworkResponse_coreNetwork :: Lens.Lens' DeleteCoreNetworkResponse (Prelude.Maybe CoreNetwork)
deleteCoreNetworkResponse_coreNetwork :: Lens' DeleteCoreNetworkResponse (Maybe CoreNetwork)
deleteCoreNetworkResponse_coreNetwork = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCoreNetworkResponse' {Maybe CoreNetwork
coreNetwork :: Maybe CoreNetwork
$sel:coreNetwork:DeleteCoreNetworkResponse' :: DeleteCoreNetworkResponse -> Maybe CoreNetwork
coreNetwork} -> Maybe CoreNetwork
coreNetwork) (\s :: DeleteCoreNetworkResponse
s@DeleteCoreNetworkResponse' {} Maybe CoreNetwork
a -> DeleteCoreNetworkResponse
s {$sel:coreNetwork:DeleteCoreNetworkResponse' :: Maybe CoreNetwork
coreNetwork = Maybe CoreNetwork
a} :: DeleteCoreNetworkResponse)

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

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