{-# 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.DeleteConnection
-- 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 connection in your global network.
module Amazonka.NetworkManager.DeleteConnection
  ( -- * Creating a Request
    DeleteConnection (..),
    newDeleteConnection,

    -- * Request Lenses
    deleteConnection_globalNetworkId,
    deleteConnection_connectionId,

    -- * Destructuring the Response
    DeleteConnectionResponse (..),
    newDeleteConnectionResponse,

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

-- |
-- Create a value of 'DeleteConnection' 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', 'deleteConnection_globalNetworkId' - The ID of the global network.
--
-- 'connectionId', 'deleteConnection_connectionId' - The ID of the connection.
newDeleteConnection ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  -- | 'connectionId'
  Prelude.Text ->
  DeleteConnection
newDeleteConnection :: Text -> Text -> DeleteConnection
newDeleteConnection Text
pGlobalNetworkId_ Text
pConnectionId_ =
  DeleteConnection'
    { $sel:globalNetworkId:DeleteConnection' :: Text
globalNetworkId =
        Text
pGlobalNetworkId_,
      $sel:connectionId:DeleteConnection' :: Text
connectionId = Text
pConnectionId_
    }

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

-- | The ID of the connection.
deleteConnection_connectionId :: Lens.Lens' DeleteConnection Prelude.Text
deleteConnection_connectionId :: Lens' DeleteConnection Text
deleteConnection_connectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteConnection' {Text
connectionId :: Text
$sel:connectionId:DeleteConnection' :: DeleteConnection -> Text
connectionId} -> Text
connectionId) (\s :: DeleteConnection
s@DeleteConnection' {} Text
a -> DeleteConnection
s {$sel:connectionId:DeleteConnection' :: Text
connectionId = Text
a} :: DeleteConnection)

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

instance Prelude.NFData DeleteConnection where
  rnf :: DeleteConnection -> ()
rnf DeleteConnection' {Text
connectionId :: Text
globalNetworkId :: Text
$sel:connectionId:DeleteConnection' :: DeleteConnection -> Text
$sel:globalNetworkId:DeleteConnection' :: DeleteConnection -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
globalNetworkId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
connectionId

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

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

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

-- |
-- Create a value of 'DeleteConnectionResponse' 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:
--
-- 'connection', 'deleteConnectionResponse_connection' - Information about the connection.
--
-- 'httpStatus', 'deleteConnectionResponse_httpStatus' - The response's http status code.
newDeleteConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteConnectionResponse
newDeleteConnectionResponse :: Int -> DeleteConnectionResponse
newDeleteConnectionResponse Int
pHttpStatus_ =
  DeleteConnectionResponse'
    { $sel:connection:DeleteConnectionResponse' :: Maybe Connection
connection =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteConnectionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the connection.
deleteConnectionResponse_connection :: Lens.Lens' DeleteConnectionResponse (Prelude.Maybe Connection)
deleteConnectionResponse_connection :: Lens' DeleteConnectionResponse (Maybe Connection)
deleteConnectionResponse_connection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteConnectionResponse' {Maybe Connection
connection :: Maybe Connection
$sel:connection:DeleteConnectionResponse' :: DeleteConnectionResponse -> Maybe Connection
connection} -> Maybe Connection
connection) (\s :: DeleteConnectionResponse
s@DeleteConnectionResponse' {} Maybe Connection
a -> DeleteConnectionResponse
s {$sel:connection:DeleteConnectionResponse' :: Maybe Connection
connection = Maybe Connection
a} :: DeleteConnectionResponse)

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

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