{-# 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.DisassociateLink
-- 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)
--
-- Disassociates an existing device from a link. You must first
-- disassociate any customer gateways that are associated with the link.
module Amazonka.NetworkManager.DisassociateLink
  ( -- * Creating a Request
    DisassociateLink (..),
    newDisassociateLink,

    -- * Request Lenses
    disassociateLink_globalNetworkId,
    disassociateLink_deviceId,
    disassociateLink_linkId,

    -- * Destructuring the Response
    DisassociateLinkResponse (..),
    newDisassociateLinkResponse,

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

-- |
-- Create a value of 'DisassociateLink' 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', 'disassociateLink_globalNetworkId' - The ID of the global network.
--
-- 'deviceId', 'disassociateLink_deviceId' - The ID of the device.
--
-- 'linkId', 'disassociateLink_linkId' - The ID of the link.
newDisassociateLink ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  -- | 'deviceId'
  Prelude.Text ->
  -- | 'linkId'
  Prelude.Text ->
  DisassociateLink
newDisassociateLink :: Text -> Text -> Text -> DisassociateLink
newDisassociateLink
  Text
pGlobalNetworkId_
  Text
pDeviceId_
  Text
pLinkId_ =
    DisassociateLink' :: Text -> Text -> Text -> DisassociateLink
DisassociateLink'
      { $sel:globalNetworkId:DisassociateLink' :: Text
globalNetworkId =
          Text
pGlobalNetworkId_,
        $sel:deviceId:DisassociateLink' :: Text
deviceId = Text
pDeviceId_,
        $sel:linkId:DisassociateLink' :: Text
linkId = Text
pLinkId_
      }

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

-- | The ID of the device.
disassociateLink_deviceId :: Lens.Lens' DisassociateLink Prelude.Text
disassociateLink_deviceId :: (Text -> f Text) -> DisassociateLink -> f DisassociateLink
disassociateLink_deviceId = (DisassociateLink -> Text)
-> (DisassociateLink -> Text -> DisassociateLink)
-> Lens DisassociateLink DisassociateLink Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateLink' {Text
deviceId :: Text
$sel:deviceId:DisassociateLink' :: DisassociateLink -> Text
deviceId} -> Text
deviceId) (\s :: DisassociateLink
s@DisassociateLink' {} Text
a -> DisassociateLink
s {$sel:deviceId:DisassociateLink' :: Text
deviceId = Text
a} :: DisassociateLink)

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

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

instance Prelude.NFData DisassociateLink

instance Core.ToHeaders DisassociateLink where
  toHeaders :: DisassociateLink -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateLink -> 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 DisassociateLink where
  toPath :: DisassociateLink -> ByteString
toPath DisassociateLink' {Text
linkId :: Text
deviceId :: Text
globalNetworkId :: Text
$sel:linkId:DisassociateLink' :: DisassociateLink -> Text
$sel:deviceId:DisassociateLink' :: DisassociateLink -> Text
$sel:globalNetworkId:DisassociateLink' :: DisassociateLink -> 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
"/link-associations"
      ]

instance Core.ToQuery DisassociateLink where
  toQuery :: DisassociateLink -> QueryString
toQuery DisassociateLink' {Text
linkId :: Text
deviceId :: Text
globalNetworkId :: Text
$sel:linkId:DisassociateLink' :: DisassociateLink -> Text
$sel:deviceId:DisassociateLink' :: DisassociateLink -> Text
$sel:globalNetworkId:DisassociateLink' :: DisassociateLink -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"deviceId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
deviceId,
        ByteString
"linkId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
linkId
      ]

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

-- |
-- Create a value of 'DisassociateLinkResponse' 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:
--
-- 'linkAssociation', 'disassociateLinkResponse_linkAssociation' - Information about the link association.
--
-- 'httpStatus', 'disassociateLinkResponse_httpStatus' - The response's http status code.
newDisassociateLinkResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateLinkResponse
newDisassociateLinkResponse :: Int -> DisassociateLinkResponse
newDisassociateLinkResponse Int
pHttpStatus_ =
  DisassociateLinkResponse' :: Maybe LinkAssociation -> Int -> DisassociateLinkResponse
DisassociateLinkResponse'
    { $sel:linkAssociation:DisassociateLinkResponse' :: Maybe LinkAssociation
linkAssociation =
        Maybe LinkAssociation
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateLinkResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the link association.
disassociateLinkResponse_linkAssociation :: Lens.Lens' DisassociateLinkResponse (Prelude.Maybe LinkAssociation)
disassociateLinkResponse_linkAssociation :: (Maybe LinkAssociation -> f (Maybe LinkAssociation))
-> DisassociateLinkResponse -> f DisassociateLinkResponse
disassociateLinkResponse_linkAssociation = (DisassociateLinkResponse -> Maybe LinkAssociation)
-> (DisassociateLinkResponse
    -> Maybe LinkAssociation -> DisassociateLinkResponse)
-> Lens
     DisassociateLinkResponse
     DisassociateLinkResponse
     (Maybe LinkAssociation)
     (Maybe LinkAssociation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateLinkResponse' {Maybe LinkAssociation
linkAssociation :: Maybe LinkAssociation
$sel:linkAssociation:DisassociateLinkResponse' :: DisassociateLinkResponse -> Maybe LinkAssociation
linkAssociation} -> Maybe LinkAssociation
linkAssociation) (\s :: DisassociateLinkResponse
s@DisassociateLinkResponse' {} Maybe LinkAssociation
a -> DisassociateLinkResponse
s {$sel:linkAssociation:DisassociateLinkResponse' :: Maybe LinkAssociation
linkAssociation = Maybe LinkAssociation
a} :: DisassociateLinkResponse)

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

instance Prelude.NFData DisassociateLinkResponse