{-# 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.DeleteLink
-- 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 link. You must first disassociate the link from any
-- devices and customer gateways.
module Amazonka.NetworkManager.DeleteLink
  ( -- * Creating a Request
    DeleteLink (..),
    newDeleteLink,

    -- * Request Lenses
    deleteLink_globalNetworkId,
    deleteLink_linkId,

    -- * Destructuring the Response
    DeleteLinkResponse (..),
    newDeleteLinkResponse,

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

-- |
-- Create a value of 'DeleteLink' 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', 'deleteLink_globalNetworkId' - The ID of the global network.
--
-- 'linkId', 'deleteLink_linkId' - The ID of the link.
newDeleteLink ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  -- | 'linkId'
  Prelude.Text ->
  DeleteLink
newDeleteLink :: Text -> Text -> DeleteLink
newDeleteLink Text
pGlobalNetworkId_ Text
pLinkId_ =
  DeleteLink' :: Text -> Text -> DeleteLink
DeleteLink'
    { $sel:globalNetworkId:DeleteLink' :: Text
globalNetworkId = Text
pGlobalNetworkId_,
      $sel:linkId:DeleteLink' :: Text
linkId = Text
pLinkId_
    }

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

-- | The ID of the link.
deleteLink_linkId :: Lens.Lens' DeleteLink Prelude.Text
deleteLink_linkId :: (Text -> f Text) -> DeleteLink -> f DeleteLink
deleteLink_linkId = (DeleteLink -> Text)
-> (DeleteLink -> Text -> DeleteLink)
-> Lens DeleteLink DeleteLink Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLink' {Text
linkId :: Text
$sel:linkId:DeleteLink' :: DeleteLink -> Text
linkId} -> Text
linkId) (\s :: DeleteLink
s@DeleteLink' {} Text
a -> DeleteLink
s {$sel:linkId:DeleteLink' :: Text
linkId = Text
a} :: DeleteLink)

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

instance Prelude.NFData DeleteLink

instance Core.ToHeaders DeleteLink where
  toHeaders :: DeleteLink -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteLink -> 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 DeleteLink where
  toPath :: DeleteLink -> ByteString
toPath DeleteLink' {Text
linkId :: Text
globalNetworkId :: Text
$sel:linkId:DeleteLink' :: DeleteLink -> Text
$sel:globalNetworkId:DeleteLink' :: DeleteLink -> 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,
        ByteString
"/links/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
linkId
      ]

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

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

-- |
-- Create a value of 'DeleteLinkResponse' 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:
--
-- 'link', 'deleteLinkResponse_link' - Information about the link.
--
-- 'httpStatus', 'deleteLinkResponse_httpStatus' - The response's http status code.
newDeleteLinkResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteLinkResponse
newDeleteLinkResponse :: Int -> DeleteLinkResponse
newDeleteLinkResponse Int
pHttpStatus_ =
  DeleteLinkResponse' :: Maybe Link -> Int -> DeleteLinkResponse
DeleteLinkResponse'
    { $sel:link:DeleteLinkResponse' :: Maybe Link
link = Maybe Link
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteLinkResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the link.
deleteLinkResponse_link :: Lens.Lens' DeleteLinkResponse (Prelude.Maybe Link)
deleteLinkResponse_link :: (Maybe Link -> f (Maybe Link))
-> DeleteLinkResponse -> f DeleteLinkResponse
deleteLinkResponse_link = (DeleteLinkResponse -> Maybe Link)
-> (DeleteLinkResponse -> Maybe Link -> DeleteLinkResponse)
-> Lens
     DeleteLinkResponse DeleteLinkResponse (Maybe Link) (Maybe Link)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLinkResponse' {Maybe Link
link :: Maybe Link
$sel:link:DeleteLinkResponse' :: DeleteLinkResponse -> Maybe Link
link} -> Maybe Link
link) (\s :: DeleteLinkResponse
s@DeleteLinkResponse' {} Maybe Link
a -> DeleteLinkResponse
s {$sel:link:DeleteLinkResponse' :: Maybe Link
link = Maybe Link
a} :: DeleteLinkResponse)

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

instance Prelude.NFData DeleteLinkResponse