{-# 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.OpenSearchServerless.DeleteVpcEndpoint
-- 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 an OpenSearch Serverless-managed interface endpoint. For more
-- information, see
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless-vpc.html Access Amazon OpenSearch Serverless using an interface endpoint>.
module Amazonka.OpenSearchServerless.DeleteVpcEndpoint
  ( -- * Creating a Request
    DeleteVpcEndpoint (..),
    newDeleteVpcEndpoint,

    -- * Request Lenses
    deleteVpcEndpoint_clientToken,
    deleteVpcEndpoint_id,

    -- * Destructuring the Response
    DeleteVpcEndpointResponse (..),
    newDeleteVpcEndpointResponse,

    -- * Response Lenses
    deleteVpcEndpointResponse_deleteVpcEndpointDetail,
    deleteVpcEndpointResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteVpcEndpoint' smart constructor.
data DeleteVpcEndpoint = DeleteVpcEndpoint'
  { -- | Unique, case-sensitive identifier to ensure idempotency of the request.
    DeleteVpcEndpoint -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The VPC endpoint identifier.
    DeleteVpcEndpoint -> Text
id :: Prelude.Text
  }
  deriving (DeleteVpcEndpoint -> DeleteVpcEndpoint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteVpcEndpoint -> DeleteVpcEndpoint -> Bool
$c/= :: DeleteVpcEndpoint -> DeleteVpcEndpoint -> Bool
== :: DeleteVpcEndpoint -> DeleteVpcEndpoint -> Bool
$c== :: DeleteVpcEndpoint -> DeleteVpcEndpoint -> Bool
Prelude.Eq, ReadPrec [DeleteVpcEndpoint]
ReadPrec DeleteVpcEndpoint
Int -> ReadS DeleteVpcEndpoint
ReadS [DeleteVpcEndpoint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteVpcEndpoint]
$creadListPrec :: ReadPrec [DeleteVpcEndpoint]
readPrec :: ReadPrec DeleteVpcEndpoint
$creadPrec :: ReadPrec DeleteVpcEndpoint
readList :: ReadS [DeleteVpcEndpoint]
$creadList :: ReadS [DeleteVpcEndpoint]
readsPrec :: Int -> ReadS DeleteVpcEndpoint
$creadsPrec :: Int -> ReadS DeleteVpcEndpoint
Prelude.Read, Int -> DeleteVpcEndpoint -> ShowS
[DeleteVpcEndpoint] -> ShowS
DeleteVpcEndpoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteVpcEndpoint] -> ShowS
$cshowList :: [DeleteVpcEndpoint] -> ShowS
show :: DeleteVpcEndpoint -> String
$cshow :: DeleteVpcEndpoint -> String
showsPrec :: Int -> DeleteVpcEndpoint -> ShowS
$cshowsPrec :: Int -> DeleteVpcEndpoint -> ShowS
Prelude.Show, forall x. Rep DeleteVpcEndpoint x -> DeleteVpcEndpoint
forall x. DeleteVpcEndpoint -> Rep DeleteVpcEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteVpcEndpoint x -> DeleteVpcEndpoint
$cfrom :: forall x. DeleteVpcEndpoint -> Rep DeleteVpcEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'DeleteVpcEndpoint' 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:
--
-- 'clientToken', 'deleteVpcEndpoint_clientToken' - Unique, case-sensitive identifier to ensure idempotency of the request.
--
-- 'id', 'deleteVpcEndpoint_id' - The VPC endpoint identifier.
newDeleteVpcEndpoint ::
  -- | 'id'
  Prelude.Text ->
  DeleteVpcEndpoint
newDeleteVpcEndpoint :: Text -> DeleteVpcEndpoint
newDeleteVpcEndpoint Text
pId_ =
  DeleteVpcEndpoint'
    { $sel:clientToken:DeleteVpcEndpoint' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeleteVpcEndpoint' :: Text
id = Text
pId_
    }

-- | Unique, case-sensitive identifier to ensure idempotency of the request.
deleteVpcEndpoint_clientToken :: Lens.Lens' DeleteVpcEndpoint (Prelude.Maybe Prelude.Text)
deleteVpcEndpoint_clientToken :: Lens' DeleteVpcEndpoint (Maybe Text)
deleteVpcEndpoint_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVpcEndpoint' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DeleteVpcEndpoint' :: DeleteVpcEndpoint -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DeleteVpcEndpoint
s@DeleteVpcEndpoint' {} Maybe Text
a -> DeleteVpcEndpoint
s {$sel:clientToken:DeleteVpcEndpoint' :: Maybe Text
clientToken = Maybe Text
a} :: DeleteVpcEndpoint)

-- | The VPC endpoint identifier.
deleteVpcEndpoint_id :: Lens.Lens' DeleteVpcEndpoint Prelude.Text
deleteVpcEndpoint_id :: Lens' DeleteVpcEndpoint Text
deleteVpcEndpoint_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVpcEndpoint' {Text
id :: Text
$sel:id:DeleteVpcEndpoint' :: DeleteVpcEndpoint -> Text
id} -> Text
id) (\s :: DeleteVpcEndpoint
s@DeleteVpcEndpoint' {} Text
a -> DeleteVpcEndpoint
s {$sel:id:DeleteVpcEndpoint' :: Text
id = Text
a} :: DeleteVpcEndpoint)

instance Core.AWSRequest DeleteVpcEndpoint where
  type
    AWSResponse DeleteVpcEndpoint =
      DeleteVpcEndpointResponse
  request :: (Service -> Service)
-> DeleteVpcEndpoint -> Request DeleteVpcEndpoint
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteVpcEndpoint
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteVpcEndpoint)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DeleteVpcEndpointDetail -> Int -> DeleteVpcEndpointResponse
DeleteVpcEndpointResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"deleteVpcEndpointDetail")
            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 DeleteVpcEndpoint where
  hashWithSalt :: Int -> DeleteVpcEndpoint -> Int
hashWithSalt Int
_salt DeleteVpcEndpoint' {Maybe Text
Text
id :: Text
clientToken :: Maybe Text
$sel:id:DeleteVpcEndpoint' :: DeleteVpcEndpoint -> Text
$sel:clientToken:DeleteVpcEndpoint' :: DeleteVpcEndpoint -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData DeleteVpcEndpoint where
  rnf :: DeleteVpcEndpoint -> ()
rnf DeleteVpcEndpoint' {Maybe Text
Text
id :: Text
clientToken :: Maybe Text
$sel:id:DeleteVpcEndpoint' :: DeleteVpcEndpoint -> Text
$sel:clientToken:DeleteVpcEndpoint' :: DeleteVpcEndpoint -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToHeaders DeleteVpcEndpoint where
  toHeaders :: DeleteVpcEndpoint -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"OpenSearchServerless.DeleteVpcEndpoint" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteVpcEndpoint where
  toJSON :: DeleteVpcEndpoint -> Value
toJSON DeleteVpcEndpoint' {Maybe Text
Text
id :: Text
clientToken :: Maybe Text
$sel:id:DeleteVpcEndpoint' :: DeleteVpcEndpoint -> Text
$sel:clientToken:DeleteVpcEndpoint' :: DeleteVpcEndpoint -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"clientToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)
          ]
      )

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

instance Data.ToQuery DeleteVpcEndpoint where
  toQuery :: DeleteVpcEndpoint -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'DeleteVpcEndpointResponse' 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:
--
-- 'deleteVpcEndpointDetail', 'deleteVpcEndpointResponse_deleteVpcEndpointDetail' - Details about the deleted endpoint.
--
-- 'httpStatus', 'deleteVpcEndpointResponse_httpStatus' - The response's http status code.
newDeleteVpcEndpointResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteVpcEndpointResponse
newDeleteVpcEndpointResponse :: Int -> DeleteVpcEndpointResponse
newDeleteVpcEndpointResponse Int
pHttpStatus_ =
  DeleteVpcEndpointResponse'
    { $sel:deleteVpcEndpointDetail:DeleteVpcEndpointResponse' :: Maybe DeleteVpcEndpointDetail
deleteVpcEndpointDetail =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteVpcEndpointResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Details about the deleted endpoint.
deleteVpcEndpointResponse_deleteVpcEndpointDetail :: Lens.Lens' DeleteVpcEndpointResponse (Prelude.Maybe DeleteVpcEndpointDetail)
deleteVpcEndpointResponse_deleteVpcEndpointDetail :: Lens' DeleteVpcEndpointResponse (Maybe DeleteVpcEndpointDetail)
deleteVpcEndpointResponse_deleteVpcEndpointDetail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVpcEndpointResponse' {Maybe DeleteVpcEndpointDetail
deleteVpcEndpointDetail :: Maybe DeleteVpcEndpointDetail
$sel:deleteVpcEndpointDetail:DeleteVpcEndpointResponse' :: DeleteVpcEndpointResponse -> Maybe DeleteVpcEndpointDetail
deleteVpcEndpointDetail} -> Maybe DeleteVpcEndpointDetail
deleteVpcEndpointDetail) (\s :: DeleteVpcEndpointResponse
s@DeleteVpcEndpointResponse' {} Maybe DeleteVpcEndpointDetail
a -> DeleteVpcEndpointResponse
s {$sel:deleteVpcEndpointDetail:DeleteVpcEndpointResponse' :: Maybe DeleteVpcEndpointDetail
deleteVpcEndpointDetail = Maybe DeleteVpcEndpointDetail
a} :: DeleteVpcEndpointResponse)

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

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