{-# 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.Glue.DeleteUserDefinedFunction
-- 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 existing function definition from the Data Catalog.
module Amazonka.Glue.DeleteUserDefinedFunction
  ( -- * Creating a Request
    DeleteUserDefinedFunction (..),
    newDeleteUserDefinedFunction,

    -- * Request Lenses
    deleteUserDefinedFunction_catalogId,
    deleteUserDefinedFunction_databaseName,
    deleteUserDefinedFunction_functionName,

    -- * Destructuring the Response
    DeleteUserDefinedFunctionResponse (..),
    newDeleteUserDefinedFunctionResponse,

    -- * Response Lenses
    deleteUserDefinedFunctionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteUserDefinedFunction' smart constructor.
data DeleteUserDefinedFunction = DeleteUserDefinedFunction'
  { -- | The ID of the Data Catalog where the function to be deleted is located.
    -- If none is supplied, the Amazon Web Services account ID is used by
    -- default.
    DeleteUserDefinedFunction -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The name of the catalog database where the function is located.
    DeleteUserDefinedFunction -> Text
databaseName :: Prelude.Text,
    -- | The name of the function definition to be deleted.
    DeleteUserDefinedFunction -> Text
functionName :: Prelude.Text
  }
  deriving (DeleteUserDefinedFunction -> DeleteUserDefinedFunction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteUserDefinedFunction -> DeleteUserDefinedFunction -> Bool
$c/= :: DeleteUserDefinedFunction -> DeleteUserDefinedFunction -> Bool
== :: DeleteUserDefinedFunction -> DeleteUserDefinedFunction -> Bool
$c== :: DeleteUserDefinedFunction -> DeleteUserDefinedFunction -> Bool
Prelude.Eq, ReadPrec [DeleteUserDefinedFunction]
ReadPrec DeleteUserDefinedFunction
Int -> ReadS DeleteUserDefinedFunction
ReadS [DeleteUserDefinedFunction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteUserDefinedFunction]
$creadListPrec :: ReadPrec [DeleteUserDefinedFunction]
readPrec :: ReadPrec DeleteUserDefinedFunction
$creadPrec :: ReadPrec DeleteUserDefinedFunction
readList :: ReadS [DeleteUserDefinedFunction]
$creadList :: ReadS [DeleteUserDefinedFunction]
readsPrec :: Int -> ReadS DeleteUserDefinedFunction
$creadsPrec :: Int -> ReadS DeleteUserDefinedFunction
Prelude.Read, Int -> DeleteUserDefinedFunction -> ShowS
[DeleteUserDefinedFunction] -> ShowS
DeleteUserDefinedFunction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteUserDefinedFunction] -> ShowS
$cshowList :: [DeleteUserDefinedFunction] -> ShowS
show :: DeleteUserDefinedFunction -> String
$cshow :: DeleteUserDefinedFunction -> String
showsPrec :: Int -> DeleteUserDefinedFunction -> ShowS
$cshowsPrec :: Int -> DeleteUserDefinedFunction -> ShowS
Prelude.Show, forall x.
Rep DeleteUserDefinedFunction x -> DeleteUserDefinedFunction
forall x.
DeleteUserDefinedFunction -> Rep DeleteUserDefinedFunction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteUserDefinedFunction x -> DeleteUserDefinedFunction
$cfrom :: forall x.
DeleteUserDefinedFunction -> Rep DeleteUserDefinedFunction x
Prelude.Generic)

-- |
-- Create a value of 'DeleteUserDefinedFunction' 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:
--
-- 'catalogId', 'deleteUserDefinedFunction_catalogId' - The ID of the Data Catalog where the function to be deleted is located.
-- If none is supplied, the Amazon Web Services account ID is used by
-- default.
--
-- 'databaseName', 'deleteUserDefinedFunction_databaseName' - The name of the catalog database where the function is located.
--
-- 'functionName', 'deleteUserDefinedFunction_functionName' - The name of the function definition to be deleted.
newDeleteUserDefinedFunction ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'functionName'
  Prelude.Text ->
  DeleteUserDefinedFunction
newDeleteUserDefinedFunction :: Text -> Text -> DeleteUserDefinedFunction
newDeleteUserDefinedFunction
  Text
pDatabaseName_
  Text
pFunctionName_ =
    DeleteUserDefinedFunction'
      { $sel:catalogId:DeleteUserDefinedFunction' :: Maybe Text
catalogId =
          forall a. Maybe a
Prelude.Nothing,
        $sel:databaseName:DeleteUserDefinedFunction' :: Text
databaseName = Text
pDatabaseName_,
        $sel:functionName:DeleteUserDefinedFunction' :: Text
functionName = Text
pFunctionName_
      }

-- | The ID of the Data Catalog where the function to be deleted is located.
-- If none is supplied, the Amazon Web Services account ID is used by
-- default.
deleteUserDefinedFunction_catalogId :: Lens.Lens' DeleteUserDefinedFunction (Prelude.Maybe Prelude.Text)
deleteUserDefinedFunction_catalogId :: Lens' DeleteUserDefinedFunction (Maybe Text)
deleteUserDefinedFunction_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUserDefinedFunction' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: DeleteUserDefinedFunction
s@DeleteUserDefinedFunction' {} Maybe Text
a -> DeleteUserDefinedFunction
s {$sel:catalogId:DeleteUserDefinedFunction' :: Maybe Text
catalogId = Maybe Text
a} :: DeleteUserDefinedFunction)

-- | The name of the catalog database where the function is located.
deleteUserDefinedFunction_databaseName :: Lens.Lens' DeleteUserDefinedFunction Prelude.Text
deleteUserDefinedFunction_databaseName :: Lens' DeleteUserDefinedFunction Text
deleteUserDefinedFunction_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUserDefinedFunction' {Text
databaseName :: Text
$sel:databaseName:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Text
databaseName} -> Text
databaseName) (\s :: DeleteUserDefinedFunction
s@DeleteUserDefinedFunction' {} Text
a -> DeleteUserDefinedFunction
s {$sel:databaseName:DeleteUserDefinedFunction' :: Text
databaseName = Text
a} :: DeleteUserDefinedFunction)

-- | The name of the function definition to be deleted.
deleteUserDefinedFunction_functionName :: Lens.Lens' DeleteUserDefinedFunction Prelude.Text
deleteUserDefinedFunction_functionName :: Lens' DeleteUserDefinedFunction Text
deleteUserDefinedFunction_functionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUserDefinedFunction' {Text
functionName :: Text
$sel:functionName:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Text
functionName} -> Text
functionName) (\s :: DeleteUserDefinedFunction
s@DeleteUserDefinedFunction' {} Text
a -> DeleteUserDefinedFunction
s {$sel:functionName:DeleteUserDefinedFunction' :: Text
functionName = Text
a} :: DeleteUserDefinedFunction)

instance Core.AWSRequest DeleteUserDefinedFunction where
  type
    AWSResponse DeleteUserDefinedFunction =
      DeleteUserDefinedFunctionResponse
  request :: (Service -> Service)
-> DeleteUserDefinedFunction -> Request DeleteUserDefinedFunction
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 DeleteUserDefinedFunction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteUserDefinedFunction)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteUserDefinedFunctionResponse
DeleteUserDefinedFunctionResponse'
            forall (f :: * -> *) a b. Functor 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 DeleteUserDefinedFunction where
  hashWithSalt :: Int -> DeleteUserDefinedFunction -> Int
hashWithSalt Int
_salt DeleteUserDefinedFunction' {Maybe Text
Text
functionName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:functionName:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Text
$sel:databaseName:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Text
$sel:catalogId:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
catalogId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
functionName

instance Prelude.NFData DeleteUserDefinedFunction where
  rnf :: DeleteUserDefinedFunction -> ()
rnf DeleteUserDefinedFunction' {Maybe Text
Text
functionName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:functionName:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Text
$sel:databaseName:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Text
$sel:catalogId:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
catalogId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
databaseName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
functionName

instance Data.ToHeaders DeleteUserDefinedFunction where
  toHeaders :: DeleteUserDefinedFunction -> 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
"AWSGlue.DeleteUserDefinedFunction" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteUserDefinedFunction where
  toJSON :: DeleteUserDefinedFunction -> Value
toJSON DeleteUserDefinedFunction' {Maybe Text
Text
functionName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:functionName:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Text
$sel:databaseName:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Text
$sel:catalogId:DeleteUserDefinedFunction' :: DeleteUserDefinedFunction -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CatalogId" 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
catalogId,
            forall a. a -> Maybe a
Prelude.Just (Key
"DatabaseName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
databaseName),
            forall a. a -> Maybe a
Prelude.Just (Key
"FunctionName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
functionName)
          ]
      )

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

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

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

-- |
-- Create a value of 'DeleteUserDefinedFunctionResponse' 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:
--
-- 'httpStatus', 'deleteUserDefinedFunctionResponse_httpStatus' - The response's http status code.
newDeleteUserDefinedFunctionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteUserDefinedFunctionResponse
newDeleteUserDefinedFunctionResponse :: Int -> DeleteUserDefinedFunctionResponse
newDeleteUserDefinedFunctionResponse Int
pHttpStatus_ =
  DeleteUserDefinedFunctionResponse'
    { $sel:httpStatus:DeleteUserDefinedFunctionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    DeleteUserDefinedFunctionResponse
  where
  rnf :: DeleteUserDefinedFunctionResponse -> ()
rnf DeleteUserDefinedFunctionResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteUserDefinedFunctionResponse' :: DeleteUserDefinedFunctionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus