{-# 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.DeleteNatGateway
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified NAT gateway. Deleting a public NAT gateway
-- disassociates its Elastic IP address, but does not release the address
-- from your account. Deleting a NAT gateway does not delete any NAT
-- gateway routes in your route tables.
module Amazonka.EC2.DeleteNatGateway
  ( -- * Creating a Request
    DeleteNatGateway (..),
    newDeleteNatGateway,

    -- * Request Lenses
    deleteNatGateway_dryRun,
    deleteNatGateway_natGatewayId,

    -- * Destructuring the Response
    DeleteNatGatewayResponse (..),
    newDeleteNatGatewayResponse,

    -- * Response Lenses
    deleteNatGatewayResponse_natGatewayId,
    deleteNatGatewayResponse_httpStatus,
  )
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

-- | /See:/ 'newDeleteNatGateway' smart constructor.
data DeleteNatGateway = DeleteNatGateway'
  { -- | 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@.
    DeleteNatGateway -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the NAT gateway.
    DeleteNatGateway -> Text
natGatewayId :: Prelude.Text
  }
  deriving (DeleteNatGateway -> DeleteNatGateway -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteNatGateway -> DeleteNatGateway -> Bool
$c/= :: DeleteNatGateway -> DeleteNatGateway -> Bool
== :: DeleteNatGateway -> DeleteNatGateway -> Bool
$c== :: DeleteNatGateway -> DeleteNatGateway -> Bool
Prelude.Eq, ReadPrec [DeleteNatGateway]
ReadPrec DeleteNatGateway
Int -> ReadS DeleteNatGateway
ReadS [DeleteNatGateway]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteNatGateway]
$creadListPrec :: ReadPrec [DeleteNatGateway]
readPrec :: ReadPrec DeleteNatGateway
$creadPrec :: ReadPrec DeleteNatGateway
readList :: ReadS [DeleteNatGateway]
$creadList :: ReadS [DeleteNatGateway]
readsPrec :: Int -> ReadS DeleteNatGateway
$creadsPrec :: Int -> ReadS DeleteNatGateway
Prelude.Read, Int -> DeleteNatGateway -> ShowS
[DeleteNatGateway] -> ShowS
DeleteNatGateway -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteNatGateway] -> ShowS
$cshowList :: [DeleteNatGateway] -> ShowS
show :: DeleteNatGateway -> String
$cshow :: DeleteNatGateway -> String
showsPrec :: Int -> DeleteNatGateway -> ShowS
$cshowsPrec :: Int -> DeleteNatGateway -> ShowS
Prelude.Show, forall x. Rep DeleteNatGateway x -> DeleteNatGateway
forall x. DeleteNatGateway -> Rep DeleteNatGateway x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteNatGateway x -> DeleteNatGateway
$cfrom :: forall x. DeleteNatGateway -> Rep DeleteNatGateway x
Prelude.Generic)

-- |
-- Create a value of 'DeleteNatGateway' 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', 'deleteNatGateway_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@.
--
-- 'natGatewayId', 'deleteNatGateway_natGatewayId' - The ID of the NAT gateway.
newDeleteNatGateway ::
  -- | 'natGatewayId'
  Prelude.Text ->
  DeleteNatGateway
newDeleteNatGateway :: Text -> DeleteNatGateway
newDeleteNatGateway Text
pNatGatewayId_ =
  DeleteNatGateway'
    { $sel:dryRun:DeleteNatGateway' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:natGatewayId:DeleteNatGateway' :: Text
natGatewayId = Text
pNatGatewayId_
    }

-- | 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@.
deleteNatGateway_dryRun :: Lens.Lens' DeleteNatGateway (Prelude.Maybe Prelude.Bool)
deleteNatGateway_dryRun :: Lens' DeleteNatGateway (Maybe Bool)
deleteNatGateway_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNatGateway' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:DeleteNatGateway' :: DeleteNatGateway -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: DeleteNatGateway
s@DeleteNatGateway' {} Maybe Bool
a -> DeleteNatGateway
s {$sel:dryRun:DeleteNatGateway' :: Maybe Bool
dryRun = Maybe Bool
a} :: DeleteNatGateway)

-- | The ID of the NAT gateway.
deleteNatGateway_natGatewayId :: Lens.Lens' DeleteNatGateway Prelude.Text
deleteNatGateway_natGatewayId :: Lens' DeleteNatGateway Text
deleteNatGateway_natGatewayId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNatGateway' {Text
natGatewayId :: Text
$sel:natGatewayId:DeleteNatGateway' :: DeleteNatGateway -> Text
natGatewayId} -> Text
natGatewayId) (\s :: DeleteNatGateway
s@DeleteNatGateway' {} Text
a -> DeleteNatGateway
s {$sel:natGatewayId:DeleteNatGateway' :: Text
natGatewayId = Text
a} :: DeleteNatGateway)

instance Core.AWSRequest DeleteNatGateway where
  type
    AWSResponse DeleteNatGateway =
      DeleteNatGatewayResponse
  request :: (Service -> Service)
-> DeleteNatGateway -> Request DeleteNatGateway
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 DeleteNatGateway
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteNatGateway)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Int -> DeleteNatGatewayResponse
DeleteNatGatewayResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"natGatewayId")
            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 DeleteNatGateway where
  hashWithSalt :: Int -> DeleteNatGateway -> Int
hashWithSalt Int
_salt DeleteNatGateway' {Maybe Bool
Text
natGatewayId :: Text
dryRun :: Maybe Bool
$sel:natGatewayId:DeleteNatGateway' :: DeleteNatGateway -> Text
$sel:dryRun:DeleteNatGateway' :: DeleteNatGateway -> 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
natGatewayId

instance Prelude.NFData DeleteNatGateway where
  rnf :: DeleteNatGateway -> ()
rnf DeleteNatGateway' {Maybe Bool
Text
natGatewayId :: Text
dryRun :: Maybe Bool
$sel:natGatewayId:DeleteNatGateway' :: DeleteNatGateway -> Text
$sel:dryRun:DeleteNatGateway' :: DeleteNatGateway -> 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
natGatewayId

instance Data.ToHeaders DeleteNatGateway where
  toHeaders :: DeleteNatGateway -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery DeleteNatGateway where
  toQuery :: DeleteNatGateway -> QueryString
toQuery DeleteNatGateway' {Maybe Bool
Text
natGatewayId :: Text
dryRun :: Maybe Bool
$sel:natGatewayId:DeleteNatGateway' :: DeleteNatGateway -> Text
$sel:dryRun:DeleteNatGateway' :: DeleteNatGateway -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteNatGateway" :: 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
"NatGatewayId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
natGatewayId
      ]

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

-- |
-- Create a value of 'DeleteNatGatewayResponse' 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:
--
-- 'natGatewayId', 'deleteNatGatewayResponse_natGatewayId' - The ID of the NAT gateway.
--
-- 'httpStatus', 'deleteNatGatewayResponse_httpStatus' - The response's http status code.
newDeleteNatGatewayResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteNatGatewayResponse
newDeleteNatGatewayResponse :: Int -> DeleteNatGatewayResponse
newDeleteNatGatewayResponse Int
pHttpStatus_ =
  DeleteNatGatewayResponse'
    { $sel:natGatewayId:DeleteNatGatewayResponse' :: Maybe Text
natGatewayId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteNatGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID of the NAT gateway.
deleteNatGatewayResponse_natGatewayId :: Lens.Lens' DeleteNatGatewayResponse (Prelude.Maybe Prelude.Text)
deleteNatGatewayResponse_natGatewayId :: Lens' DeleteNatGatewayResponse (Maybe Text)
deleteNatGatewayResponse_natGatewayId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNatGatewayResponse' {Maybe Text
natGatewayId :: Maybe Text
$sel:natGatewayId:DeleteNatGatewayResponse' :: DeleteNatGatewayResponse -> Maybe Text
natGatewayId} -> Maybe Text
natGatewayId) (\s :: DeleteNatGatewayResponse
s@DeleteNatGatewayResponse' {} Maybe Text
a -> DeleteNatGatewayResponse
s {$sel:natGatewayId:DeleteNatGatewayResponse' :: Maybe Text
natGatewayId = Maybe Text
a} :: DeleteNatGatewayResponse)

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

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