{-# 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-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 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 Amazonka.Glue.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:/ '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
(DeleteUserDefinedFunction -> DeleteUserDefinedFunction -> Bool)
-> (DeleteUserDefinedFunction -> DeleteUserDefinedFunction -> Bool)
-> Eq DeleteUserDefinedFunction
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]
(Int -> ReadS DeleteUserDefinedFunction)
-> ReadS [DeleteUserDefinedFunction]
-> ReadPrec DeleteUserDefinedFunction
-> ReadPrec [DeleteUserDefinedFunction]
-> Read 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
(Int -> DeleteUserDefinedFunction -> ShowS)
-> (DeleteUserDefinedFunction -> String)
-> ([DeleteUserDefinedFunction] -> ShowS)
-> Show DeleteUserDefinedFunction
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.
 DeleteUserDefinedFunction -> Rep DeleteUserDefinedFunction x)
-> (forall x.
    Rep DeleteUserDefinedFunction x -> DeleteUserDefinedFunction)
-> Generic DeleteUserDefinedFunction
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' :: Maybe Text -> Text -> Text -> DeleteUserDefinedFunction
DeleteUserDefinedFunction'
      { $sel:catalogId:DeleteUserDefinedFunction' :: Maybe Text
catalogId =
          Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteUserDefinedFunction -> f DeleteUserDefinedFunction
deleteUserDefinedFunction_catalogId = (DeleteUserDefinedFunction -> Maybe Text)
-> (DeleteUserDefinedFunction
    -> Maybe Text -> DeleteUserDefinedFunction)
-> Lens
     DeleteUserDefinedFunction
     DeleteUserDefinedFunction
     (Maybe Text)
     (Maybe Text)
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 :: (Text -> f Text)
-> DeleteUserDefinedFunction -> f DeleteUserDefinedFunction
deleteUserDefinedFunction_databaseName = (DeleteUserDefinedFunction -> Text)
-> (DeleteUserDefinedFunction -> Text -> DeleteUserDefinedFunction)
-> Lens
     DeleteUserDefinedFunction DeleteUserDefinedFunction Text Text
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 :: (Text -> f Text)
-> DeleteUserDefinedFunction -> f DeleteUserDefinedFunction
deleteUserDefinedFunction_functionName = (DeleteUserDefinedFunction -> Text)
-> (DeleteUserDefinedFunction -> Text -> DeleteUserDefinedFunction)
-> Lens
     DeleteUserDefinedFunction DeleteUserDefinedFunction Text Text
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 :: DeleteUserDefinedFunction -> Request DeleteUserDefinedFunction
request = Service
-> DeleteUserDefinedFunction -> Request DeleteUserDefinedFunction
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteUserDefinedFunction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteUserDefinedFunction)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteUserDefinedFunction))
-> Logger
-> Service
-> Proxy DeleteUserDefinedFunction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteUserDefinedFunction)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteUserDefinedFunctionResponse
DeleteUserDefinedFunctionResponse'
            (Int -> DeleteUserDefinedFunctionResponse)
-> Either String Int
-> Either String DeleteUserDefinedFunctionResponse
forall (f :: * -> *) a b. Functor 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 DeleteUserDefinedFunction

instance Prelude.NFData DeleteUserDefinedFunction

instance Core.ToHeaders DeleteUserDefinedFunction where
  toHeaders :: DeleteUserDefinedFunction -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteUserDefinedFunction -> 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
"AWSGlue.DeleteUserDefinedFunction" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CatalogId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
catalogId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DatabaseName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
databaseName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FunctionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
functionName)
          ]
      )

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

instance Core.ToQuery DeleteUserDefinedFunction where
  toQuery :: DeleteUserDefinedFunction -> QueryString
toQuery = QueryString -> DeleteUserDefinedFunction -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteUserDefinedFunctionResponse
 -> DeleteUserDefinedFunctionResponse -> Bool)
-> (DeleteUserDefinedFunctionResponse
    -> DeleteUserDefinedFunctionResponse -> Bool)
-> Eq DeleteUserDefinedFunctionResponse
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]
(Int -> ReadS DeleteUserDefinedFunctionResponse)
-> ReadS [DeleteUserDefinedFunctionResponse]
-> ReadPrec DeleteUserDefinedFunctionResponse
-> ReadPrec [DeleteUserDefinedFunctionResponse]
-> Read 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
(Int -> DeleteUserDefinedFunctionResponse -> ShowS)
-> (DeleteUserDefinedFunctionResponse -> String)
-> ([DeleteUserDefinedFunctionResponse] -> ShowS)
-> Show DeleteUserDefinedFunctionResponse
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.
 DeleteUserDefinedFunctionResponse
 -> Rep DeleteUserDefinedFunctionResponse x)
-> (forall x.
    Rep DeleteUserDefinedFunctionResponse x
    -> DeleteUserDefinedFunctionResponse)
-> Generic DeleteUserDefinedFunctionResponse
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' :: Int -> DeleteUserDefinedFunctionResponse
DeleteUserDefinedFunctionResponse'
    { $sel:httpStatus:DeleteUserDefinedFunctionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteUserDefinedFunctionResponse_httpStatus :: Lens.Lens' DeleteUserDefinedFunctionResponse Prelude.Int
deleteUserDefinedFunctionResponse_httpStatus :: (Int -> f Int)
-> DeleteUserDefinedFunctionResponse
-> f DeleteUserDefinedFunctionResponse
deleteUserDefinedFunctionResponse_httpStatus = (DeleteUserDefinedFunctionResponse -> Int)
-> (DeleteUserDefinedFunctionResponse
    -> Int -> DeleteUserDefinedFunctionResponse)
-> Lens
     DeleteUserDefinedFunctionResponse
     DeleteUserDefinedFunctionResponse
     Int
     Int
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