{-# 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.DeleteCarrierGateway
-- 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 a carrier gateway.
--
-- If you do not delete the route that contains the carrier gateway as the
-- Target, the route is a blackhole route. For information about how to
-- delete a route, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DeleteRoute.html DeleteRoute>.
module Amazonka.EC2.DeleteCarrierGateway
  ( -- * Creating a Request
    DeleteCarrierGateway (..),
    newDeleteCarrierGateway,

    -- * Request Lenses
    deleteCarrierGateway_dryRun,
    deleteCarrierGateway_carrierGatewayId,

    -- * Destructuring the Response
    DeleteCarrierGatewayResponse (..),
    newDeleteCarrierGatewayResponse,

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

-- |
-- Create a value of 'DeleteCarrierGateway' 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', 'deleteCarrierGateway_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@.
--
-- 'carrierGatewayId', 'deleteCarrierGateway_carrierGatewayId' - The ID of the carrier gateway.
newDeleteCarrierGateway ::
  -- | 'carrierGatewayId'
  Prelude.Text ->
  DeleteCarrierGateway
newDeleteCarrierGateway :: Text -> DeleteCarrierGateway
newDeleteCarrierGateway Text
pCarrierGatewayId_ =
  DeleteCarrierGateway'
    { $sel:dryRun:DeleteCarrierGateway' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:carrierGatewayId:DeleteCarrierGateway' :: Text
carrierGatewayId = Text
pCarrierGatewayId_
    }

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

-- | The ID of the carrier gateway.
deleteCarrierGateway_carrierGatewayId :: Lens.Lens' DeleteCarrierGateway Prelude.Text
deleteCarrierGateway_carrierGatewayId :: Lens' DeleteCarrierGateway Text
deleteCarrierGateway_carrierGatewayId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCarrierGateway' {Text
carrierGatewayId :: Text
$sel:carrierGatewayId:DeleteCarrierGateway' :: DeleteCarrierGateway -> Text
carrierGatewayId} -> Text
carrierGatewayId) (\s :: DeleteCarrierGateway
s@DeleteCarrierGateway' {} Text
a -> DeleteCarrierGateway
s {$sel:carrierGatewayId:DeleteCarrierGateway' :: Text
carrierGatewayId = Text
a} :: DeleteCarrierGateway)

instance Core.AWSRequest DeleteCarrierGateway where
  type
    AWSResponse DeleteCarrierGateway =
      DeleteCarrierGatewayResponse
  request :: (Service -> Service)
-> DeleteCarrierGateway -> Request DeleteCarrierGateway
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 DeleteCarrierGateway
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCarrierGateway)))
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 CarrierGateway -> Int -> DeleteCarrierGatewayResponse
DeleteCarrierGatewayResponse'
            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
"carrierGateway")
            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 DeleteCarrierGateway where
  hashWithSalt :: Int -> DeleteCarrierGateway -> Int
hashWithSalt Int
_salt DeleteCarrierGateway' {Maybe Bool
Text
carrierGatewayId :: Text
dryRun :: Maybe Bool
$sel:carrierGatewayId:DeleteCarrierGateway' :: DeleteCarrierGateway -> Text
$sel:dryRun:DeleteCarrierGateway' :: DeleteCarrierGateway -> 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
carrierGatewayId

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

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

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

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

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

-- |
-- Create a value of 'DeleteCarrierGatewayResponse' 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:
--
-- 'carrierGateway', 'deleteCarrierGatewayResponse_carrierGateway' - Information about the carrier gateway.
--
-- 'httpStatus', 'deleteCarrierGatewayResponse_httpStatus' - The response's http status code.
newDeleteCarrierGatewayResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteCarrierGatewayResponse
newDeleteCarrierGatewayResponse :: Int -> DeleteCarrierGatewayResponse
newDeleteCarrierGatewayResponse Int
pHttpStatus_ =
  DeleteCarrierGatewayResponse'
    { $sel:carrierGateway:DeleteCarrierGatewayResponse' :: Maybe CarrierGateway
carrierGateway =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteCarrierGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the carrier gateway.
deleteCarrierGatewayResponse_carrierGateway :: Lens.Lens' DeleteCarrierGatewayResponse (Prelude.Maybe CarrierGateway)
deleteCarrierGatewayResponse_carrierGateway :: Lens' DeleteCarrierGatewayResponse (Maybe CarrierGateway)
deleteCarrierGatewayResponse_carrierGateway = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCarrierGatewayResponse' {Maybe CarrierGateway
carrierGateway :: Maybe CarrierGateway
$sel:carrierGateway:DeleteCarrierGatewayResponse' :: DeleteCarrierGatewayResponse -> Maybe CarrierGateway
carrierGateway} -> Maybe CarrierGateway
carrierGateway) (\s :: DeleteCarrierGatewayResponse
s@DeleteCarrierGatewayResponse' {} Maybe CarrierGateway
a -> DeleteCarrierGatewayResponse
s {$sel:carrierGateway:DeleteCarrierGatewayResponse' :: Maybe CarrierGateway
carrierGateway = Maybe CarrierGateway
a} :: DeleteCarrierGatewayResponse)

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

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