{-# 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-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 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.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:/ '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. For more
    -- information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazonec2.html#amazonec2-resources-for-iam-policies Resources Defined by Amazon EC2>.
    DisassociateCustomerGateway -> Text
customerGatewayArn :: Prelude.Text
  }
  deriving (DisassociateCustomerGateway -> DisassociateCustomerGateway -> Bool
(DisassociateCustomerGateway
 -> DisassociateCustomerGateway -> Bool)
-> (DisassociateCustomerGateway
    -> DisassociateCustomerGateway -> Bool)
-> Eq DisassociateCustomerGateway
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]
(Int -> ReadS DisassociateCustomerGateway)
-> ReadS [DisassociateCustomerGateway]
-> ReadPrec DisassociateCustomerGateway
-> ReadPrec [DisassociateCustomerGateway]
-> Read 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
(Int -> DisassociateCustomerGateway -> ShowS)
-> (DisassociateCustomerGateway -> String)
-> ([DisassociateCustomerGateway] -> ShowS)
-> Show DisassociateCustomerGateway
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.
 DisassociateCustomerGateway -> Rep DisassociateCustomerGateway x)
-> (forall x.
    Rep DisassociateCustomerGateway x -> DisassociateCustomerGateway)
-> Generic DisassociateCustomerGateway
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. For more
-- information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazonec2.html#amazonec2-resources-for-iam-policies Resources Defined by Amazon EC2>.
newDisassociateCustomerGateway ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  -- | 'customerGatewayArn'
  Prelude.Text ->
  DisassociateCustomerGateway
newDisassociateCustomerGateway :: Text -> Text -> DisassociateCustomerGateway
newDisassociateCustomerGateway
  Text
pGlobalNetworkId_
  Text
pCustomerGatewayArn_ =
    DisassociateCustomerGateway' :: Text -> Text -> DisassociateCustomerGateway
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 :: (Text -> f Text)
-> DisassociateCustomerGateway -> f DisassociateCustomerGateway
disassociateCustomerGateway_globalNetworkId = (DisassociateCustomerGateway -> Text)
-> (DisassociateCustomerGateway
    -> Text -> DisassociateCustomerGateway)
-> Lens
     DisassociateCustomerGateway DisassociateCustomerGateway Text Text
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. For more
-- information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazonec2.html#amazonec2-resources-for-iam-policies Resources Defined by Amazon EC2>.
disassociateCustomerGateway_customerGatewayArn :: Lens.Lens' DisassociateCustomerGateway Prelude.Text
disassociateCustomerGateway_customerGatewayArn :: (Text -> f Text)
-> DisassociateCustomerGateway -> f DisassociateCustomerGateway
disassociateCustomerGateway_customerGatewayArn = (DisassociateCustomerGateway -> Text)
-> (DisassociateCustomerGateway
    -> Text -> DisassociateCustomerGateway)
-> Lens
     DisassociateCustomerGateway DisassociateCustomerGateway Text Text
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 :: DisassociateCustomerGateway -> Request DisassociateCustomerGateway
request = Service
-> DisassociateCustomerGateway
-> Request DisassociateCustomerGateway
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateCustomerGateway
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateCustomerGateway)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DisassociateCustomerGateway))
-> Logger
-> Service
-> Proxy DisassociateCustomerGateway
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateCustomerGateway)))
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 CustomerGatewayAssociation
-> Int -> DisassociateCustomerGatewayResponse
DisassociateCustomerGatewayResponse'
            (Maybe CustomerGatewayAssociation
 -> Int -> DisassociateCustomerGatewayResponse)
-> Either String (Maybe CustomerGatewayAssociation)
-> Either String (Int -> DisassociateCustomerGatewayResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe CustomerGatewayAssociation)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CustomerGatewayAssociation")
            Either String (Int -> DisassociateCustomerGatewayResponse)
-> Either String Int
-> Either String DisassociateCustomerGatewayResponse
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 DisassociateCustomerGateway

instance Prelude.NFData DisassociateCustomerGateway

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

instance Core.ToQuery DisassociateCustomerGateway where
  toQuery :: DisassociateCustomerGateway -> QueryString
toQuery = QueryString -> DisassociateCustomerGateway -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DisassociateCustomerGatewayResponse
 -> DisassociateCustomerGatewayResponse -> Bool)
-> (DisassociateCustomerGatewayResponse
    -> DisassociateCustomerGatewayResponse -> Bool)
-> Eq DisassociateCustomerGatewayResponse
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]
(Int -> ReadS DisassociateCustomerGatewayResponse)
-> ReadS [DisassociateCustomerGatewayResponse]
-> ReadPrec DisassociateCustomerGatewayResponse
-> ReadPrec [DisassociateCustomerGatewayResponse]
-> Read 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
(Int -> DisassociateCustomerGatewayResponse -> ShowS)
-> (DisassociateCustomerGatewayResponse -> String)
-> ([DisassociateCustomerGatewayResponse] -> ShowS)
-> Show DisassociateCustomerGatewayResponse
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.
 DisassociateCustomerGatewayResponse
 -> Rep DisassociateCustomerGatewayResponse x)
-> (forall x.
    Rep DisassociateCustomerGatewayResponse x
    -> DisassociateCustomerGatewayResponse)
-> Generic DisassociateCustomerGatewayResponse
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' :: Maybe CustomerGatewayAssociation
-> Int -> DisassociateCustomerGatewayResponse
DisassociateCustomerGatewayResponse'
    { $sel:customerGatewayAssociation:DisassociateCustomerGatewayResponse' :: Maybe CustomerGatewayAssociation
customerGatewayAssociation =
        Maybe 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 :: (Maybe CustomerGatewayAssociation
 -> f (Maybe CustomerGatewayAssociation))
-> DisassociateCustomerGatewayResponse
-> f DisassociateCustomerGatewayResponse
disassociateCustomerGatewayResponse_customerGatewayAssociation = (DisassociateCustomerGatewayResponse
 -> Maybe CustomerGatewayAssociation)
-> (DisassociateCustomerGatewayResponse
    -> Maybe CustomerGatewayAssociation
    -> DisassociateCustomerGatewayResponse)
-> Lens
     DisassociateCustomerGatewayResponse
     DisassociateCustomerGatewayResponse
     (Maybe CustomerGatewayAssociation)
     (Maybe 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 :: (Int -> f Int)
-> DisassociateCustomerGatewayResponse
-> f DisassociateCustomerGatewayResponse
disassociateCustomerGatewayResponse_httpStatus = (DisassociateCustomerGatewayResponse -> Int)
-> (DisassociateCustomerGatewayResponse
    -> Int -> DisassociateCustomerGatewayResponse)
-> Lens
     DisassociateCustomerGatewayResponse
     DisassociateCustomerGatewayResponse
     Int
     Int
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