{-# 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.DisassociateCustomerGateway
-- 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 customer gateway from a device and a link.
module Amazonka.NetworkManager.DisassociateCustomerGateway
  ( -- * Creating a Request
    DisassociateCustomerGateway (..),
    newDisassociateCustomerGateway,

    -- * Request Lenses
    disassociateCustomerGateway_globalNetworkId,
    disassociateCustomerGateway_customerGatewayArn,

    -- * Destructuring the Response
    DisassociateCustomerGatewayResponse (..),
    newDisassociateCustomerGatewayResponse,

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

-- |
-- Create a value of 'DisassociateCustomerGateway' 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', 'disassociateCustomerGateway_globalNetworkId' - The ID of the global network.
--
-- 'customerGatewayArn', 'disassociateCustomerGateway_customerGatewayArn' - The Amazon Resource Name (ARN) of the customer gateway.
newDisassociateCustomerGateway ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  -- | 'customerGatewayArn'
  Prelude.Text ->
  DisassociateCustomerGateway
newDisassociateCustomerGateway :: Text -> Text -> DisassociateCustomerGateway
newDisassociateCustomerGateway
  Text
pGlobalNetworkId_
  Text
pCustomerGatewayArn_ =
    DisassociateCustomerGateway'
      { $sel:globalNetworkId:DisassociateCustomerGateway' :: Text
globalNetworkId =
          Text
pGlobalNetworkId_,
        $sel:customerGatewayArn:DisassociateCustomerGateway' :: Text
customerGatewayArn = Text
pCustomerGatewayArn_
      }

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

-- | The Amazon Resource Name (ARN) of the customer gateway.
disassociateCustomerGateway_customerGatewayArn :: Lens.Lens' DisassociateCustomerGateway Prelude.Text
disassociateCustomerGateway_customerGatewayArn :: Lens' DisassociateCustomerGateway Text
disassociateCustomerGateway_customerGatewayArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateCustomerGateway' {Text
customerGatewayArn :: Text
$sel:customerGatewayArn:DisassociateCustomerGateway' :: DisassociateCustomerGateway -> Text
customerGatewayArn} -> Text
customerGatewayArn) (\s :: DisassociateCustomerGateway
s@DisassociateCustomerGateway' {} Text
a -> DisassociateCustomerGateway
s {$sel:customerGatewayArn:DisassociateCustomerGateway' :: Text
customerGatewayArn = Text
a} :: DisassociateCustomerGateway)

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

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

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

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

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

-- |
-- Create a value of 'DisassociateCustomerGatewayResponse' 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:
--
-- 'customerGatewayAssociation', 'disassociateCustomerGatewayResponse_customerGatewayAssociation' - Information about the customer gateway association.
--
-- 'httpStatus', 'disassociateCustomerGatewayResponse_httpStatus' - The response's http status code.
newDisassociateCustomerGatewayResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateCustomerGatewayResponse
newDisassociateCustomerGatewayResponse :: Int -> DisassociateCustomerGatewayResponse
newDisassociateCustomerGatewayResponse Int
pHttpStatus_ =
  DisassociateCustomerGatewayResponse'
    { $sel:customerGatewayAssociation:DisassociateCustomerGatewayResponse' :: Maybe CustomerGatewayAssociation
customerGatewayAssociation =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateCustomerGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the customer gateway association.
disassociateCustomerGatewayResponse_customerGatewayAssociation :: Lens.Lens' DisassociateCustomerGatewayResponse (Prelude.Maybe CustomerGatewayAssociation)
disassociateCustomerGatewayResponse_customerGatewayAssociation :: Lens'
  DisassociateCustomerGatewayResponse
  (Maybe CustomerGatewayAssociation)
disassociateCustomerGatewayResponse_customerGatewayAssociation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateCustomerGatewayResponse' {Maybe CustomerGatewayAssociation
customerGatewayAssociation :: Maybe CustomerGatewayAssociation
$sel:customerGatewayAssociation:DisassociateCustomerGatewayResponse' :: DisassociateCustomerGatewayResponse
-> Maybe CustomerGatewayAssociation
customerGatewayAssociation} -> Maybe CustomerGatewayAssociation
customerGatewayAssociation) (\s :: DisassociateCustomerGatewayResponse
s@DisassociateCustomerGatewayResponse' {} Maybe CustomerGatewayAssociation
a -> DisassociateCustomerGatewayResponse
s {$sel:customerGatewayAssociation:DisassociateCustomerGatewayResponse' :: Maybe CustomerGatewayAssociation
customerGatewayAssociation = Maybe CustomerGatewayAssociation
a} :: DisassociateCustomerGatewayResponse)

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

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