{-# 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.DisassociateConnectPeer
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disassociates a core network Connect peer from a device and a link.
module Amazonka.NetworkManager.DisassociateConnectPeer
  ( -- * Creating a Request
    DisassociateConnectPeer (..),
    newDisassociateConnectPeer,

    -- * Request Lenses
    disassociateConnectPeer_globalNetworkId,
    disassociateConnectPeer_connectPeerId,

    -- * Destructuring the Response
    DisassociateConnectPeerResponse (..),
    newDisassociateConnectPeerResponse,

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

-- |
-- Create a value of 'DisassociateConnectPeer' 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', 'disassociateConnectPeer_globalNetworkId' - The ID of the global network.
--
-- 'connectPeerId', 'disassociateConnectPeer_connectPeerId' - The ID of the Connect peer to disassociate from a device.
newDisassociateConnectPeer ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  -- | 'connectPeerId'
  Prelude.Text ->
  DisassociateConnectPeer
newDisassociateConnectPeer :: Text -> Text -> DisassociateConnectPeer
newDisassociateConnectPeer
  Text
pGlobalNetworkId_
  Text
pConnectPeerId_ =
    DisassociateConnectPeer'
      { $sel:globalNetworkId:DisassociateConnectPeer' :: Text
globalNetworkId =
          Text
pGlobalNetworkId_,
        $sel:connectPeerId:DisassociateConnectPeer' :: Text
connectPeerId = Text
pConnectPeerId_
      }

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

-- | The ID of the Connect peer to disassociate from a device.
disassociateConnectPeer_connectPeerId :: Lens.Lens' DisassociateConnectPeer Prelude.Text
disassociateConnectPeer_connectPeerId :: Lens' DisassociateConnectPeer Text
disassociateConnectPeer_connectPeerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateConnectPeer' {Text
connectPeerId :: Text
$sel:connectPeerId:DisassociateConnectPeer' :: DisassociateConnectPeer -> Text
connectPeerId} -> Text
connectPeerId) (\s :: DisassociateConnectPeer
s@DisassociateConnectPeer' {} Text
a -> DisassociateConnectPeer
s {$sel:connectPeerId:DisassociateConnectPeer' :: Text
connectPeerId = Text
a} :: DisassociateConnectPeer)

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

instance Prelude.NFData DisassociateConnectPeer where
  rnf :: DisassociateConnectPeer -> ()
rnf DisassociateConnectPeer' {Text
connectPeerId :: Text
globalNetworkId :: Text
$sel:connectPeerId:DisassociateConnectPeer' :: DisassociateConnectPeer -> Text
$sel:globalNetworkId:DisassociateConnectPeer' :: DisassociateConnectPeer -> 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
connectPeerId

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

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

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

-- |
-- Create a value of 'DisassociateConnectPeerResponse' 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:
--
-- 'connectPeerAssociation', 'disassociateConnectPeerResponse_connectPeerAssociation' - Describes the Connect peer association.
--
-- 'httpStatus', 'disassociateConnectPeerResponse_httpStatus' - The response's http status code.
newDisassociateConnectPeerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateConnectPeerResponse
newDisassociateConnectPeerResponse :: Int -> DisassociateConnectPeerResponse
newDisassociateConnectPeerResponse Int
pHttpStatus_ =
  DisassociateConnectPeerResponse'
    { $sel:connectPeerAssociation:DisassociateConnectPeerResponse' :: Maybe ConnectPeerAssociation
connectPeerAssociation =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateConnectPeerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Describes the Connect peer association.
disassociateConnectPeerResponse_connectPeerAssociation :: Lens.Lens' DisassociateConnectPeerResponse (Prelude.Maybe ConnectPeerAssociation)
disassociateConnectPeerResponse_connectPeerAssociation :: Lens'
  DisassociateConnectPeerResponse (Maybe ConnectPeerAssociation)
disassociateConnectPeerResponse_connectPeerAssociation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateConnectPeerResponse' {Maybe ConnectPeerAssociation
connectPeerAssociation :: Maybe ConnectPeerAssociation
$sel:connectPeerAssociation:DisassociateConnectPeerResponse' :: DisassociateConnectPeerResponse -> Maybe ConnectPeerAssociation
connectPeerAssociation} -> Maybe ConnectPeerAssociation
connectPeerAssociation) (\s :: DisassociateConnectPeerResponse
s@DisassociateConnectPeerResponse' {} Maybe ConnectPeerAssociation
a -> DisassociateConnectPeerResponse
s {$sel:connectPeerAssociation:DisassociateConnectPeerResponse' :: Maybe ConnectPeerAssociation
connectPeerAssociation = Maybe ConnectPeerAssociation
a} :: DisassociateConnectPeerResponse)

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

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