{-# 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.DeleteVpcEndpoints
-- 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 one or more specified VPC endpoints. You can delete any of the
-- following types of VPC endpoints.
--
-- -   Gateway endpoint,
--
-- -   Gateway Load Balancer endpoint,
--
-- -   Interface endpoint
--
-- The following rules apply when you delete a VPC endpoint:
--
-- -   When you delete a gateway endpoint, we delete the endpoint routes in
--     the route tables that are associated with the endpoint.
--
-- -   When you delete a Gateway Load Balancer endpoint, we delete the
--     endpoint network interfaces.
--
--     You can only delete Gateway Load Balancer endpoints when the routes
--     that are associated with the endpoint are deleted.
--
-- -   When you delete an interface endpoint, we delete the endpoint
--     network interfaces.
module Amazonka.EC2.DeleteVpcEndpoints
  ( -- * Creating a Request
    DeleteVpcEndpoints (..),
    newDeleteVpcEndpoints,

    -- * Request Lenses
    deleteVpcEndpoints_dryRun,
    deleteVpcEndpoints_vpcEndpointIds,

    -- * Destructuring the Response
    DeleteVpcEndpointsResponse (..),
    newDeleteVpcEndpointsResponse,

    -- * Response Lenses
    deleteVpcEndpointsResponse_unsuccessful,
    deleteVpcEndpointsResponse_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

-- | Contains the parameters for DeleteVpcEndpoints.
--
-- /See:/ 'newDeleteVpcEndpoints' smart constructor.
data DeleteVpcEndpoints = DeleteVpcEndpoints'
  { -- | 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@.
    DeleteVpcEndpoints -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | One or more VPC endpoint IDs.
    DeleteVpcEndpoints -> [Text]
vpcEndpointIds :: [Prelude.Text]
  }
  deriving (DeleteVpcEndpoints -> DeleteVpcEndpoints -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteVpcEndpoints -> DeleteVpcEndpoints -> Bool
$c/= :: DeleteVpcEndpoints -> DeleteVpcEndpoints -> Bool
== :: DeleteVpcEndpoints -> DeleteVpcEndpoints -> Bool
$c== :: DeleteVpcEndpoints -> DeleteVpcEndpoints -> Bool
Prelude.Eq, ReadPrec [DeleteVpcEndpoints]
ReadPrec DeleteVpcEndpoints
Int -> ReadS DeleteVpcEndpoints
ReadS [DeleteVpcEndpoints]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteVpcEndpoints]
$creadListPrec :: ReadPrec [DeleteVpcEndpoints]
readPrec :: ReadPrec DeleteVpcEndpoints
$creadPrec :: ReadPrec DeleteVpcEndpoints
readList :: ReadS [DeleteVpcEndpoints]
$creadList :: ReadS [DeleteVpcEndpoints]
readsPrec :: Int -> ReadS DeleteVpcEndpoints
$creadsPrec :: Int -> ReadS DeleteVpcEndpoints
Prelude.Read, Int -> DeleteVpcEndpoints -> ShowS
[DeleteVpcEndpoints] -> ShowS
DeleteVpcEndpoints -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteVpcEndpoints] -> ShowS
$cshowList :: [DeleteVpcEndpoints] -> ShowS
show :: DeleteVpcEndpoints -> String
$cshow :: DeleteVpcEndpoints -> String
showsPrec :: Int -> DeleteVpcEndpoints -> ShowS
$cshowsPrec :: Int -> DeleteVpcEndpoints -> ShowS
Prelude.Show, forall x. Rep DeleteVpcEndpoints x -> DeleteVpcEndpoints
forall x. DeleteVpcEndpoints -> Rep DeleteVpcEndpoints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteVpcEndpoints x -> DeleteVpcEndpoints
$cfrom :: forall x. DeleteVpcEndpoints -> Rep DeleteVpcEndpoints x
Prelude.Generic)

-- |
-- Create a value of 'DeleteVpcEndpoints' 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', 'deleteVpcEndpoints_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@.
--
-- 'vpcEndpointIds', 'deleteVpcEndpoints_vpcEndpointIds' - One or more VPC endpoint IDs.
newDeleteVpcEndpoints ::
  DeleteVpcEndpoints
newDeleteVpcEndpoints :: DeleteVpcEndpoints
newDeleteVpcEndpoints =
  DeleteVpcEndpoints'
    { $sel:dryRun:DeleteVpcEndpoints' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcEndpointIds:DeleteVpcEndpoints' :: [Text]
vpcEndpointIds = forall a. Monoid a => a
Prelude.mempty
    }

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

-- | One or more VPC endpoint IDs.
deleteVpcEndpoints_vpcEndpointIds :: Lens.Lens' DeleteVpcEndpoints [Prelude.Text]
deleteVpcEndpoints_vpcEndpointIds :: Lens' DeleteVpcEndpoints [Text]
deleteVpcEndpoints_vpcEndpointIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVpcEndpoints' {[Text]
vpcEndpointIds :: [Text]
$sel:vpcEndpointIds:DeleteVpcEndpoints' :: DeleteVpcEndpoints -> [Text]
vpcEndpointIds} -> [Text]
vpcEndpointIds) (\s :: DeleteVpcEndpoints
s@DeleteVpcEndpoints' {} [Text]
a -> DeleteVpcEndpoints
s {$sel:vpcEndpointIds:DeleteVpcEndpoints' :: [Text]
vpcEndpointIds = [Text]
a} :: DeleteVpcEndpoints) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest DeleteVpcEndpoints where
  type
    AWSResponse DeleteVpcEndpoints =
      DeleteVpcEndpointsResponse
  request :: (Service -> Service)
-> DeleteVpcEndpoints -> Request DeleteVpcEndpoints
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 DeleteVpcEndpoints
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteVpcEndpoints)))
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 [UnsuccessfulItem] -> Int -> DeleteVpcEndpointsResponse
DeleteVpcEndpointsResponse'
            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
"unsuccessful"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                        )
            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 DeleteVpcEndpoints where
  hashWithSalt :: Int -> DeleteVpcEndpoints -> Int
hashWithSalt Int
_salt DeleteVpcEndpoints' {[Text]
Maybe Bool
vpcEndpointIds :: [Text]
dryRun :: Maybe Bool
$sel:vpcEndpointIds:DeleteVpcEndpoints' :: DeleteVpcEndpoints -> [Text]
$sel:dryRun:DeleteVpcEndpoints' :: DeleteVpcEndpoints -> 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]
vpcEndpointIds

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

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

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

instance Data.ToQuery DeleteVpcEndpoints where
  toQuery :: DeleteVpcEndpoints -> QueryString
toQuery DeleteVpcEndpoints' {[Text]
Maybe Bool
vpcEndpointIds :: [Text]
dryRun :: Maybe Bool
$sel:vpcEndpointIds:DeleteVpcEndpoints' :: DeleteVpcEndpoints -> [Text]
$sel:dryRun:DeleteVpcEndpoints' :: DeleteVpcEndpoints -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteVpcEndpoints" :: 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,
        forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"VpcEndpointId" [Text]
vpcEndpointIds
      ]

-- | Contains the output of DeleteVpcEndpoints.
--
-- /See:/ 'newDeleteVpcEndpointsResponse' smart constructor.
data DeleteVpcEndpointsResponse = DeleteVpcEndpointsResponse'
  { -- | Information about the VPC endpoints that were not successfully deleted.
    DeleteVpcEndpointsResponse -> Maybe [UnsuccessfulItem]
unsuccessful :: Prelude.Maybe [UnsuccessfulItem],
    -- | The response's http status code.
    DeleteVpcEndpointsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteVpcEndpointsResponse -> DeleteVpcEndpointsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteVpcEndpointsResponse -> DeleteVpcEndpointsResponse -> Bool
$c/= :: DeleteVpcEndpointsResponse -> DeleteVpcEndpointsResponse -> Bool
== :: DeleteVpcEndpointsResponse -> DeleteVpcEndpointsResponse -> Bool
$c== :: DeleteVpcEndpointsResponse -> DeleteVpcEndpointsResponse -> Bool
Prelude.Eq, ReadPrec [DeleteVpcEndpointsResponse]
ReadPrec DeleteVpcEndpointsResponse
Int -> ReadS DeleteVpcEndpointsResponse
ReadS [DeleteVpcEndpointsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteVpcEndpointsResponse]
$creadListPrec :: ReadPrec [DeleteVpcEndpointsResponse]
readPrec :: ReadPrec DeleteVpcEndpointsResponse
$creadPrec :: ReadPrec DeleteVpcEndpointsResponse
readList :: ReadS [DeleteVpcEndpointsResponse]
$creadList :: ReadS [DeleteVpcEndpointsResponse]
readsPrec :: Int -> ReadS DeleteVpcEndpointsResponse
$creadsPrec :: Int -> ReadS DeleteVpcEndpointsResponse
Prelude.Read, Int -> DeleteVpcEndpointsResponse -> ShowS
[DeleteVpcEndpointsResponse] -> ShowS
DeleteVpcEndpointsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteVpcEndpointsResponse] -> ShowS
$cshowList :: [DeleteVpcEndpointsResponse] -> ShowS
show :: DeleteVpcEndpointsResponse -> String
$cshow :: DeleteVpcEndpointsResponse -> String
showsPrec :: Int -> DeleteVpcEndpointsResponse -> ShowS
$cshowsPrec :: Int -> DeleteVpcEndpointsResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteVpcEndpointsResponse x -> DeleteVpcEndpointsResponse
forall x.
DeleteVpcEndpointsResponse -> Rep DeleteVpcEndpointsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteVpcEndpointsResponse x -> DeleteVpcEndpointsResponse
$cfrom :: forall x.
DeleteVpcEndpointsResponse -> Rep DeleteVpcEndpointsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteVpcEndpointsResponse' 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:
--
-- 'unsuccessful', 'deleteVpcEndpointsResponse_unsuccessful' - Information about the VPC endpoints that were not successfully deleted.
--
-- 'httpStatus', 'deleteVpcEndpointsResponse_httpStatus' - The response's http status code.
newDeleteVpcEndpointsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteVpcEndpointsResponse
newDeleteVpcEndpointsResponse :: Int -> DeleteVpcEndpointsResponse
newDeleteVpcEndpointsResponse Int
pHttpStatus_ =
  DeleteVpcEndpointsResponse'
    { $sel:unsuccessful:DeleteVpcEndpointsResponse' :: Maybe [UnsuccessfulItem]
unsuccessful =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteVpcEndpointsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the VPC endpoints that were not successfully deleted.
deleteVpcEndpointsResponse_unsuccessful :: Lens.Lens' DeleteVpcEndpointsResponse (Prelude.Maybe [UnsuccessfulItem])
deleteVpcEndpointsResponse_unsuccessful :: Lens' DeleteVpcEndpointsResponse (Maybe [UnsuccessfulItem])
deleteVpcEndpointsResponse_unsuccessful = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVpcEndpointsResponse' {Maybe [UnsuccessfulItem]
unsuccessful :: Maybe [UnsuccessfulItem]
$sel:unsuccessful:DeleteVpcEndpointsResponse' :: DeleteVpcEndpointsResponse -> Maybe [UnsuccessfulItem]
unsuccessful} -> Maybe [UnsuccessfulItem]
unsuccessful) (\s :: DeleteVpcEndpointsResponse
s@DeleteVpcEndpointsResponse' {} Maybe [UnsuccessfulItem]
a -> DeleteVpcEndpointsResponse
s {$sel:unsuccessful:DeleteVpcEndpointsResponse' :: Maybe [UnsuccessfulItem]
unsuccessful = Maybe [UnsuccessfulItem]
a} :: DeleteVpcEndpointsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeleteVpcEndpointsResponse where
  rnf :: DeleteVpcEndpointsResponse -> ()
rnf DeleteVpcEndpointsResponse' {Int
Maybe [UnsuccessfulItem]
httpStatus :: Int
unsuccessful :: Maybe [UnsuccessfulItem]
$sel:httpStatus:DeleteVpcEndpointsResponse' :: DeleteVpcEndpointsResponse -> Int
$sel:unsuccessful:DeleteVpcEndpointsResponse' :: DeleteVpcEndpointsResponse -> Maybe [UnsuccessfulItem]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [UnsuccessfulItem]
unsuccessful
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus