{-# 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.DMS.DeleteEndpoint
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified endpoint.
--
-- All tasks associated with the endpoint must be deleted before you can
-- delete the endpoint.
module Amazonka.DMS.DeleteEndpoint
  ( -- * Creating a Request
    DeleteEndpoint (..),
    newDeleteEndpoint,

    -- * Request Lenses
    deleteEndpoint_endpointArn,

    -- * Destructuring the Response
    DeleteEndpointResponse (..),
    newDeleteEndpointResponse,

    -- * Response Lenses
    deleteEndpointResponse_endpoint,
    deleteEndpointResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DMS.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- |
--
-- /See:/ 'newDeleteEndpoint' smart constructor.
data DeleteEndpoint = DeleteEndpoint'
  { -- | The Amazon Resource Name (ARN) string that uniquely identifies the
    -- endpoint.
    DeleteEndpoint -> Text
endpointArn :: Prelude.Text
  }
  deriving (DeleteEndpoint -> DeleteEndpoint -> Bool
(DeleteEndpoint -> DeleteEndpoint -> Bool)
-> (DeleteEndpoint -> DeleteEndpoint -> Bool) -> Eq DeleteEndpoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEndpoint -> DeleteEndpoint -> Bool
$c/= :: DeleteEndpoint -> DeleteEndpoint -> Bool
== :: DeleteEndpoint -> DeleteEndpoint -> Bool
$c== :: DeleteEndpoint -> DeleteEndpoint -> Bool
Prelude.Eq, ReadPrec [DeleteEndpoint]
ReadPrec DeleteEndpoint
Int -> ReadS DeleteEndpoint
ReadS [DeleteEndpoint]
(Int -> ReadS DeleteEndpoint)
-> ReadS [DeleteEndpoint]
-> ReadPrec DeleteEndpoint
-> ReadPrec [DeleteEndpoint]
-> Read DeleteEndpoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteEndpoint]
$creadListPrec :: ReadPrec [DeleteEndpoint]
readPrec :: ReadPrec DeleteEndpoint
$creadPrec :: ReadPrec DeleteEndpoint
readList :: ReadS [DeleteEndpoint]
$creadList :: ReadS [DeleteEndpoint]
readsPrec :: Int -> ReadS DeleteEndpoint
$creadsPrec :: Int -> ReadS DeleteEndpoint
Prelude.Read, Int -> DeleteEndpoint -> ShowS
[DeleteEndpoint] -> ShowS
DeleteEndpoint -> String
(Int -> DeleteEndpoint -> ShowS)
-> (DeleteEndpoint -> String)
-> ([DeleteEndpoint] -> ShowS)
-> Show DeleteEndpoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEndpoint] -> ShowS
$cshowList :: [DeleteEndpoint] -> ShowS
show :: DeleteEndpoint -> String
$cshow :: DeleteEndpoint -> String
showsPrec :: Int -> DeleteEndpoint -> ShowS
$cshowsPrec :: Int -> DeleteEndpoint -> ShowS
Prelude.Show, (forall x. DeleteEndpoint -> Rep DeleteEndpoint x)
-> (forall x. Rep DeleteEndpoint x -> DeleteEndpoint)
-> Generic DeleteEndpoint
forall x. Rep DeleteEndpoint x -> DeleteEndpoint
forall x. DeleteEndpoint -> Rep DeleteEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteEndpoint x -> DeleteEndpoint
$cfrom :: forall x. DeleteEndpoint -> Rep DeleteEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'DeleteEndpoint' 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:
--
-- 'endpointArn', 'deleteEndpoint_endpointArn' - The Amazon Resource Name (ARN) string that uniquely identifies the
-- endpoint.
newDeleteEndpoint ::
  -- | 'endpointArn'
  Prelude.Text ->
  DeleteEndpoint
newDeleteEndpoint :: Text -> DeleteEndpoint
newDeleteEndpoint Text
pEndpointArn_ =
  DeleteEndpoint' :: Text -> DeleteEndpoint
DeleteEndpoint' {$sel:endpointArn:DeleteEndpoint' :: Text
endpointArn = Text
pEndpointArn_}

-- | The Amazon Resource Name (ARN) string that uniquely identifies the
-- endpoint.
deleteEndpoint_endpointArn :: Lens.Lens' DeleteEndpoint Prelude.Text
deleteEndpoint_endpointArn :: (Text -> f Text) -> DeleteEndpoint -> f DeleteEndpoint
deleteEndpoint_endpointArn = (DeleteEndpoint -> Text)
-> (DeleteEndpoint -> Text -> DeleteEndpoint)
-> Lens DeleteEndpoint DeleteEndpoint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEndpoint' {Text
endpointArn :: Text
$sel:endpointArn:DeleteEndpoint' :: DeleteEndpoint -> Text
endpointArn} -> Text
endpointArn) (\s :: DeleteEndpoint
s@DeleteEndpoint' {} Text
a -> DeleteEndpoint
s {$sel:endpointArn:DeleteEndpoint' :: Text
endpointArn = Text
a} :: DeleteEndpoint)

instance Core.AWSRequest DeleteEndpoint where
  type
    AWSResponse DeleteEndpoint =
      DeleteEndpointResponse
  request :: DeleteEndpoint -> Request DeleteEndpoint
request = Service -> DeleteEndpoint -> Request DeleteEndpoint
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteEndpoint
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteEndpoint)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteEndpoint))
-> Logger
-> Service
-> Proxy DeleteEndpoint
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteEndpoint)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Endpoint -> Int -> DeleteEndpointResponse
DeleteEndpointResponse'
            (Maybe Endpoint -> Int -> DeleteEndpointResponse)
-> Either String (Maybe Endpoint)
-> Either String (Int -> DeleteEndpointResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Endpoint)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Endpoint")
            Either String (Int -> DeleteEndpointResponse)
-> Either String Int -> Either String DeleteEndpointResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteEndpoint

instance Prelude.NFData DeleteEndpoint

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

instance Core.ToJSON DeleteEndpoint where
  toJSON :: DeleteEndpoint -> Value
toJSON DeleteEndpoint' {Text
endpointArn :: Text
$sel:endpointArn:DeleteEndpoint' :: DeleteEndpoint -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EndpointArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
endpointArn)]
      )

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

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

-- |
--
-- /See:/ 'newDeleteEndpointResponse' smart constructor.
data DeleteEndpointResponse = DeleteEndpointResponse'
  { -- | The endpoint that was deleted.
    DeleteEndpointResponse -> Maybe Endpoint
endpoint :: Prelude.Maybe Endpoint,
    -- | The response's http status code.
    DeleteEndpointResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteEndpointResponse -> DeleteEndpointResponse -> Bool
(DeleteEndpointResponse -> DeleteEndpointResponse -> Bool)
-> (DeleteEndpointResponse -> DeleteEndpointResponse -> Bool)
-> Eq DeleteEndpointResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEndpointResponse -> DeleteEndpointResponse -> Bool
$c/= :: DeleteEndpointResponse -> DeleteEndpointResponse -> Bool
== :: DeleteEndpointResponse -> DeleteEndpointResponse -> Bool
$c== :: DeleteEndpointResponse -> DeleteEndpointResponse -> Bool
Prelude.Eq, Int -> DeleteEndpointResponse -> ShowS
[DeleteEndpointResponse] -> ShowS
DeleteEndpointResponse -> String
(Int -> DeleteEndpointResponse -> ShowS)
-> (DeleteEndpointResponse -> String)
-> ([DeleteEndpointResponse] -> ShowS)
-> Show DeleteEndpointResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEndpointResponse] -> ShowS
$cshowList :: [DeleteEndpointResponse] -> ShowS
show :: DeleteEndpointResponse -> String
$cshow :: DeleteEndpointResponse -> String
showsPrec :: Int -> DeleteEndpointResponse -> ShowS
$cshowsPrec :: Int -> DeleteEndpointResponse -> ShowS
Prelude.Show, (forall x. DeleteEndpointResponse -> Rep DeleteEndpointResponse x)
-> (forall x.
    Rep DeleteEndpointResponse x -> DeleteEndpointResponse)
-> Generic DeleteEndpointResponse
forall x. Rep DeleteEndpointResponse x -> DeleteEndpointResponse
forall x. DeleteEndpointResponse -> Rep DeleteEndpointResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteEndpointResponse x -> DeleteEndpointResponse
$cfrom :: forall x. DeleteEndpointResponse -> Rep DeleteEndpointResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteEndpointResponse' 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:
--
-- 'endpoint', 'deleteEndpointResponse_endpoint' - The endpoint that was deleted.
--
-- 'httpStatus', 'deleteEndpointResponse_httpStatus' - The response's http status code.
newDeleteEndpointResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteEndpointResponse
newDeleteEndpointResponse :: Int -> DeleteEndpointResponse
newDeleteEndpointResponse Int
pHttpStatus_ =
  DeleteEndpointResponse' :: Maybe Endpoint -> Int -> DeleteEndpointResponse
DeleteEndpointResponse'
    { $sel:endpoint:DeleteEndpointResponse' :: Maybe Endpoint
endpoint = Maybe Endpoint
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteEndpointResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The endpoint that was deleted.
deleteEndpointResponse_endpoint :: Lens.Lens' DeleteEndpointResponse (Prelude.Maybe Endpoint)
deleteEndpointResponse_endpoint :: (Maybe Endpoint -> f (Maybe Endpoint))
-> DeleteEndpointResponse -> f DeleteEndpointResponse
deleteEndpointResponse_endpoint = (DeleteEndpointResponse -> Maybe Endpoint)
-> (DeleteEndpointResponse
    -> Maybe Endpoint -> DeleteEndpointResponse)
-> Lens
     DeleteEndpointResponse
     DeleteEndpointResponse
     (Maybe Endpoint)
     (Maybe Endpoint)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEndpointResponse' {Maybe Endpoint
endpoint :: Maybe Endpoint
$sel:endpoint:DeleteEndpointResponse' :: DeleteEndpointResponse -> Maybe Endpoint
endpoint} -> Maybe Endpoint
endpoint) (\s :: DeleteEndpointResponse
s@DeleteEndpointResponse' {} Maybe Endpoint
a -> DeleteEndpointResponse
s {$sel:endpoint:DeleteEndpointResponse' :: Maybe Endpoint
endpoint = Maybe Endpoint
a} :: DeleteEndpointResponse)

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

instance Prelude.NFData DeleteEndpointResponse