{-# 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.EC2.DetachVpnGateway
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Detaches a virtual private gateway from a VPC. You do this if you\'re
-- planning to turn off the VPC and not use it anymore. You can confirm a
-- virtual private gateway has been completely detached from a VPC by
-- describing the virtual private gateway (any attachments to the virtual
-- private gateway are also described).
--
-- You must wait for the attachment\'s state to switch to @detached@ before
-- you can delete the VPC or attach a different VPC to the virtual private
-- gateway.
module Amazonka.EC2.DetachVpnGateway
  ( -- * Creating a Request
    DetachVpnGateway (..),
    newDetachVpnGateway,

    -- * Request Lenses
    detachVpnGateway_dryRun,
    detachVpnGateway_vpcId,
    detachVpnGateway_vpnGatewayId,

    -- * Destructuring the Response
    DetachVpnGatewayResponse (..),
    newDetachVpnGatewayResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Contains the parameters for DetachVpnGateway.
--
-- /See:/ 'newDetachVpnGateway' smart constructor.
data DetachVpnGateway = DetachVpnGateway'
  { -- | Checks whether you have the required permissions for the action, without
    -- actually making the request, and provides an error response. If you have
    -- the required permissions, the error response is @DryRunOperation@.
    -- Otherwise, it is @UnauthorizedOperation@.
    DetachVpnGateway -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the VPC.
    DetachVpnGateway -> Text
vpcId :: Prelude.Text,
    -- | The ID of the virtual private gateway.
    DetachVpnGateway -> Text
vpnGatewayId :: Prelude.Text
  }
  deriving (DetachVpnGateway -> DetachVpnGateway -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachVpnGateway -> DetachVpnGateway -> Bool
$c/= :: DetachVpnGateway -> DetachVpnGateway -> Bool
== :: DetachVpnGateway -> DetachVpnGateway -> Bool
$c== :: DetachVpnGateway -> DetachVpnGateway -> Bool
Prelude.Eq, ReadPrec [DetachVpnGateway]
ReadPrec DetachVpnGateway
Int -> ReadS DetachVpnGateway
ReadS [DetachVpnGateway]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachVpnGateway]
$creadListPrec :: ReadPrec [DetachVpnGateway]
readPrec :: ReadPrec DetachVpnGateway
$creadPrec :: ReadPrec DetachVpnGateway
readList :: ReadS [DetachVpnGateway]
$creadList :: ReadS [DetachVpnGateway]
readsPrec :: Int -> ReadS DetachVpnGateway
$creadsPrec :: Int -> ReadS DetachVpnGateway
Prelude.Read, Int -> DetachVpnGateway -> ShowS
[DetachVpnGateway] -> ShowS
DetachVpnGateway -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachVpnGateway] -> ShowS
$cshowList :: [DetachVpnGateway] -> ShowS
show :: DetachVpnGateway -> String
$cshow :: DetachVpnGateway -> String
showsPrec :: Int -> DetachVpnGateway -> ShowS
$cshowsPrec :: Int -> DetachVpnGateway -> ShowS
Prelude.Show, forall x. Rep DetachVpnGateway x -> DetachVpnGateway
forall x. DetachVpnGateway -> Rep DetachVpnGateway x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetachVpnGateway x -> DetachVpnGateway
$cfrom :: forall x. DetachVpnGateway -> Rep DetachVpnGateway x
Prelude.Generic)

-- |
-- Create a value of 'DetachVpnGateway' 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:
--
-- 'dryRun', 'detachVpnGateway_dryRun' - Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
--
-- 'vpcId', 'detachVpnGateway_vpcId' - The ID of the VPC.
--
-- 'vpnGatewayId', 'detachVpnGateway_vpnGatewayId' - The ID of the virtual private gateway.
newDetachVpnGateway ::
  -- | 'vpcId'
  Prelude.Text ->
  -- | 'vpnGatewayId'
  Prelude.Text ->
  DetachVpnGateway
newDetachVpnGateway :: Text -> Text -> DetachVpnGateway
newDetachVpnGateway Text
pVpcId_ Text
pVpnGatewayId_ =
  DetachVpnGateway'
    { $sel:dryRun:DetachVpnGateway' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:DetachVpnGateway' :: Text
vpcId = Text
pVpcId_,
      $sel:vpnGatewayId:DetachVpnGateway' :: Text
vpnGatewayId = Text
pVpnGatewayId_
    }

-- | Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
detachVpnGateway_dryRun :: Lens.Lens' DetachVpnGateway (Prelude.Maybe Prelude.Bool)
detachVpnGateway_dryRun :: Lens' DetachVpnGateway (Maybe Bool)
detachVpnGateway_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachVpnGateway' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:DetachVpnGateway' :: DetachVpnGateway -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: DetachVpnGateway
s@DetachVpnGateway' {} Maybe Bool
a -> DetachVpnGateway
s {$sel:dryRun:DetachVpnGateway' :: Maybe Bool
dryRun = Maybe Bool
a} :: DetachVpnGateway)

-- | The ID of the VPC.
detachVpnGateway_vpcId :: Lens.Lens' DetachVpnGateway Prelude.Text
detachVpnGateway_vpcId :: Lens' DetachVpnGateway Text
detachVpnGateway_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachVpnGateway' {Text
vpcId :: Text
$sel:vpcId:DetachVpnGateway' :: DetachVpnGateway -> Text
vpcId} -> Text
vpcId) (\s :: DetachVpnGateway
s@DetachVpnGateway' {} Text
a -> DetachVpnGateway
s {$sel:vpcId:DetachVpnGateway' :: Text
vpcId = Text
a} :: DetachVpnGateway)

-- | The ID of the virtual private gateway.
detachVpnGateway_vpnGatewayId :: Lens.Lens' DetachVpnGateway Prelude.Text
detachVpnGateway_vpnGatewayId :: Lens' DetachVpnGateway Text
detachVpnGateway_vpnGatewayId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachVpnGateway' {Text
vpnGatewayId :: Text
$sel:vpnGatewayId:DetachVpnGateway' :: DetachVpnGateway -> Text
vpnGatewayId} -> Text
vpnGatewayId) (\s :: DetachVpnGateway
s@DetachVpnGateway' {} Text
a -> DetachVpnGateway
s {$sel:vpnGatewayId:DetachVpnGateway' :: Text
vpnGatewayId = Text
a} :: DetachVpnGateway)

instance Core.AWSRequest DetachVpnGateway where
  type
    AWSResponse DetachVpnGateway =
      DetachVpnGatewayResponse
  request :: (Service -> Service)
-> DetachVpnGateway -> Request DetachVpnGateway
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DetachVpnGateway
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetachVpnGateway)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DetachVpnGatewayResponse
DetachVpnGatewayResponse'

instance Prelude.Hashable DetachVpnGateway where
  hashWithSalt :: Int -> DetachVpnGateway -> Int
hashWithSalt Int
_salt DetachVpnGateway' {Maybe Bool
Text
vpnGatewayId :: Text
vpcId :: Text
dryRun :: Maybe Bool
$sel:vpnGatewayId:DetachVpnGateway' :: DetachVpnGateway -> Text
$sel:vpcId:DetachVpnGateway' :: DetachVpnGateway -> Text
$sel:dryRun:DetachVpnGateway' :: DetachVpnGateway -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
vpcId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
vpnGatewayId

instance Prelude.NFData DetachVpnGateway where
  rnf :: DetachVpnGateway -> ()
rnf DetachVpnGateway' {Maybe Bool
Text
vpnGatewayId :: Text
vpcId :: Text
dryRun :: Maybe Bool
$sel:vpnGatewayId:DetachVpnGateway' :: DetachVpnGateway -> Text
$sel:vpcId:DetachVpnGateway' :: DetachVpnGateway -> Text
$sel:dryRun:DetachVpnGateway' :: DetachVpnGateway -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
vpcId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
vpnGatewayId

instance Data.ToHeaders DetachVpnGateway where
  toHeaders :: DetachVpnGateway -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath DetachVpnGateway where
  toPath :: DetachVpnGateway -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery DetachVpnGateway where
  toQuery :: DetachVpnGateway -> QueryString
toQuery DetachVpnGateway' {Maybe Bool
Text
vpnGatewayId :: Text
vpcId :: Text
dryRun :: Maybe Bool
$sel:vpnGatewayId:DetachVpnGateway' :: DetachVpnGateway -> Text
$sel:vpcId:DetachVpnGateway' :: DetachVpnGateway -> Text
$sel:dryRun:DetachVpnGateway' :: DetachVpnGateway -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DetachVpnGateway" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun,
        ByteString
"VpcId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
vpcId,
        ByteString
"VpnGatewayId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
vpnGatewayId
      ]

-- | /See:/ 'newDetachVpnGatewayResponse' smart constructor.
data DetachVpnGatewayResponse = DetachVpnGatewayResponse'
  {
  }
  deriving (DetachVpnGatewayResponse -> DetachVpnGatewayResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachVpnGatewayResponse -> DetachVpnGatewayResponse -> Bool
$c/= :: DetachVpnGatewayResponse -> DetachVpnGatewayResponse -> Bool
== :: DetachVpnGatewayResponse -> DetachVpnGatewayResponse -> Bool
$c== :: DetachVpnGatewayResponse -> DetachVpnGatewayResponse -> Bool
Prelude.Eq, ReadPrec [DetachVpnGatewayResponse]
ReadPrec DetachVpnGatewayResponse
Int -> ReadS DetachVpnGatewayResponse
ReadS [DetachVpnGatewayResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachVpnGatewayResponse]
$creadListPrec :: ReadPrec [DetachVpnGatewayResponse]
readPrec :: ReadPrec DetachVpnGatewayResponse
$creadPrec :: ReadPrec DetachVpnGatewayResponse
readList :: ReadS [DetachVpnGatewayResponse]
$creadList :: ReadS [DetachVpnGatewayResponse]
readsPrec :: Int -> ReadS DetachVpnGatewayResponse
$creadsPrec :: Int -> ReadS DetachVpnGatewayResponse
Prelude.Read, Int -> DetachVpnGatewayResponse -> ShowS
[DetachVpnGatewayResponse] -> ShowS
DetachVpnGatewayResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachVpnGatewayResponse] -> ShowS
$cshowList :: [DetachVpnGatewayResponse] -> ShowS
show :: DetachVpnGatewayResponse -> String
$cshow :: DetachVpnGatewayResponse -> String
showsPrec :: Int -> DetachVpnGatewayResponse -> ShowS
$cshowsPrec :: Int -> DetachVpnGatewayResponse -> ShowS
Prelude.Show, forall x.
Rep DetachVpnGatewayResponse x -> DetachVpnGatewayResponse
forall x.
DetachVpnGatewayResponse -> Rep DetachVpnGatewayResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DetachVpnGatewayResponse x -> DetachVpnGatewayResponse
$cfrom :: forall x.
DetachVpnGatewayResponse -> Rep DetachVpnGatewayResponse x
Prelude.Generic)

-- |
-- Create a value of 'DetachVpnGatewayResponse' 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.
newDetachVpnGatewayResponse ::
  DetachVpnGatewayResponse
newDetachVpnGatewayResponse :: DetachVpnGatewayResponse
newDetachVpnGatewayResponse =
  DetachVpnGatewayResponse
DetachVpnGatewayResponse'

instance Prelude.NFData DetachVpnGatewayResponse where
  rnf :: DetachVpnGatewayResponse -> ()
rnf DetachVpnGatewayResponse
_ = ()