{-# 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.UpdateUserDefinedFunction
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates an existing function definition in the Data Catalog.
module Amazonka.Glue.UpdateUserDefinedFunction
  ( -- * Creating a Request
    UpdateUserDefinedFunction (..),
    newUpdateUserDefinedFunction,

    -- * Request Lenses
    updateUserDefinedFunction_catalogId,
    updateUserDefinedFunction_databaseName,
    updateUserDefinedFunction_functionName,
    updateUserDefinedFunction_functionInput,

    -- * Destructuring the Response
    UpdateUserDefinedFunctionResponse (..),
    newUpdateUserDefinedFunctionResponse,

    -- * Response Lenses
    updateUserDefinedFunctionResponse_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:/ 'newUpdateUserDefinedFunction' smart constructor.
data UpdateUserDefinedFunction = UpdateUserDefinedFunction'
  { -- | The ID of the Data Catalog where the function to be updated is located.
    -- If none is provided, the Amazon Web Services account ID is used by
    -- default.
    UpdateUserDefinedFunction -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The name of the catalog database where the function to be updated is
    -- located.
    UpdateUserDefinedFunction -> Text
databaseName :: Prelude.Text,
    -- | The name of the function.
    UpdateUserDefinedFunction -> Text
functionName :: Prelude.Text,
    -- | A @FunctionInput@ object that redefines the function in the Data
    -- Catalog.
    UpdateUserDefinedFunction -> UserDefinedFunctionInput
functionInput :: UserDefinedFunctionInput
  }
  deriving (UpdateUserDefinedFunction -> UpdateUserDefinedFunction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateUserDefinedFunction -> UpdateUserDefinedFunction -> Bool
$c/= :: UpdateUserDefinedFunction -> UpdateUserDefinedFunction -> Bool
== :: UpdateUserDefinedFunction -> UpdateUserDefinedFunction -> Bool
$c== :: UpdateUserDefinedFunction -> UpdateUserDefinedFunction -> Bool
Prelude.Eq, ReadPrec [UpdateUserDefinedFunction]
ReadPrec UpdateUserDefinedFunction
Int -> ReadS UpdateUserDefinedFunction
ReadS [UpdateUserDefinedFunction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateUserDefinedFunction]
$creadListPrec :: ReadPrec [UpdateUserDefinedFunction]
readPrec :: ReadPrec UpdateUserDefinedFunction
$creadPrec :: ReadPrec UpdateUserDefinedFunction
readList :: ReadS [UpdateUserDefinedFunction]
$creadList :: ReadS [UpdateUserDefinedFunction]
readsPrec :: Int -> ReadS UpdateUserDefinedFunction
$creadsPrec :: Int -> ReadS UpdateUserDefinedFunction
Prelude.Read, Int -> UpdateUserDefinedFunction -> ShowS
[UpdateUserDefinedFunction] -> ShowS
UpdateUserDefinedFunction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateUserDefinedFunction] -> ShowS
$cshowList :: [UpdateUserDefinedFunction] -> ShowS
show :: UpdateUserDefinedFunction -> String
$cshow :: UpdateUserDefinedFunction -> String
showsPrec :: Int -> UpdateUserDefinedFunction -> ShowS
$cshowsPrec :: Int -> UpdateUserDefinedFunction -> ShowS
Prelude.Show, forall x.
Rep UpdateUserDefinedFunction x -> UpdateUserDefinedFunction
forall x.
UpdateUserDefinedFunction -> Rep UpdateUserDefinedFunction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateUserDefinedFunction x -> UpdateUserDefinedFunction
$cfrom :: forall x.
UpdateUserDefinedFunction -> Rep UpdateUserDefinedFunction x
Prelude.Generic)

-- |
-- Create a value of 'UpdateUserDefinedFunction' 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', 'updateUserDefinedFunction_catalogId' - The ID of the Data Catalog where the function to be updated is located.
-- If none is provided, the Amazon Web Services account ID is used by
-- default.
--
-- 'databaseName', 'updateUserDefinedFunction_databaseName' - The name of the catalog database where the function to be updated is
-- located.
--
-- 'functionName', 'updateUserDefinedFunction_functionName' - The name of the function.
--
-- 'functionInput', 'updateUserDefinedFunction_functionInput' - A @FunctionInput@ object that redefines the function in the Data
-- Catalog.
newUpdateUserDefinedFunction ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'functionName'
  Prelude.Text ->
  -- | 'functionInput'
  UserDefinedFunctionInput ->
  UpdateUserDefinedFunction
newUpdateUserDefinedFunction :: Text
-> Text -> UserDefinedFunctionInput -> UpdateUserDefinedFunction
newUpdateUserDefinedFunction
  Text
pDatabaseName_
  Text
pFunctionName_
  UserDefinedFunctionInput
pFunctionInput_ =
    UpdateUserDefinedFunction'
      { $sel:catalogId:UpdateUserDefinedFunction' :: Maybe Text
catalogId =
          forall a. Maybe a
Prelude.Nothing,
        $sel:databaseName:UpdateUserDefinedFunction' :: Text
databaseName = Text
pDatabaseName_,
        $sel:functionName:UpdateUserDefinedFunction' :: Text
functionName = Text
pFunctionName_,
        $sel:functionInput:UpdateUserDefinedFunction' :: UserDefinedFunctionInput
functionInput = UserDefinedFunctionInput
pFunctionInput_
      }

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

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

-- | The name of the function.
updateUserDefinedFunction_functionName :: Lens.Lens' UpdateUserDefinedFunction Prelude.Text
updateUserDefinedFunction_functionName :: Lens' UpdateUserDefinedFunction Text
updateUserDefinedFunction_functionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserDefinedFunction' {Text
functionName :: Text
$sel:functionName:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> Text
functionName} -> Text
functionName) (\s :: UpdateUserDefinedFunction
s@UpdateUserDefinedFunction' {} Text
a -> UpdateUserDefinedFunction
s {$sel:functionName:UpdateUserDefinedFunction' :: Text
functionName = Text
a} :: UpdateUserDefinedFunction)

-- | A @FunctionInput@ object that redefines the function in the Data
-- Catalog.
updateUserDefinedFunction_functionInput :: Lens.Lens' UpdateUserDefinedFunction UserDefinedFunctionInput
updateUserDefinedFunction_functionInput :: Lens' UpdateUserDefinedFunction UserDefinedFunctionInput
updateUserDefinedFunction_functionInput = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserDefinedFunction' {UserDefinedFunctionInput
functionInput :: UserDefinedFunctionInput
$sel:functionInput:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> UserDefinedFunctionInput
functionInput} -> UserDefinedFunctionInput
functionInput) (\s :: UpdateUserDefinedFunction
s@UpdateUserDefinedFunction' {} UserDefinedFunctionInput
a -> UpdateUserDefinedFunction
s {$sel:functionInput:UpdateUserDefinedFunction' :: UserDefinedFunctionInput
functionInput = UserDefinedFunctionInput
a} :: UpdateUserDefinedFunction)

instance Core.AWSRequest UpdateUserDefinedFunction where
  type
    AWSResponse UpdateUserDefinedFunction =
      UpdateUserDefinedFunctionResponse
  request :: (Service -> Service)
-> UpdateUserDefinedFunction -> Request UpdateUserDefinedFunction
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 UpdateUserDefinedFunction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateUserDefinedFunction)))
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 -> UpdateUserDefinedFunctionResponse
UpdateUserDefinedFunctionResponse'
            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 UpdateUserDefinedFunction where
  hashWithSalt :: Int -> UpdateUserDefinedFunction -> Int
hashWithSalt Int
_salt UpdateUserDefinedFunction' {Maybe Text
Text
UserDefinedFunctionInput
functionInput :: UserDefinedFunctionInput
functionName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:functionInput:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> UserDefinedFunctionInput
$sel:functionName:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> Text
$sel:databaseName:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> Text
$sel:catalogId:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> 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
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` UserDefinedFunctionInput
functionInput

instance Prelude.NFData UpdateUserDefinedFunction where
  rnf :: UpdateUserDefinedFunction -> ()
rnf UpdateUserDefinedFunction' {Maybe Text
Text
UserDefinedFunctionInput
functionInput :: UserDefinedFunctionInput
functionName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:functionInput:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> UserDefinedFunctionInput
$sel:functionName:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> Text
$sel:databaseName:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> Text
$sel:catalogId:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf UserDefinedFunctionInput
functionInput

instance Data.ToHeaders UpdateUserDefinedFunction where
  toHeaders :: UpdateUserDefinedFunction -> 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.UpdateUserDefinedFunction" ::
                          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 UpdateUserDefinedFunction where
  toJSON :: UpdateUserDefinedFunction -> Value
toJSON UpdateUserDefinedFunction' {Maybe Text
Text
UserDefinedFunctionInput
functionInput :: UserDefinedFunctionInput
functionName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:functionInput:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> UserDefinedFunctionInput
$sel:functionName:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> Text
$sel:databaseName:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> Text
$sel:catalogId:UpdateUserDefinedFunction' :: UpdateUserDefinedFunction -> 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),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"FunctionInput" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= UserDefinedFunctionInput
functionInput)
          ]
      )

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

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

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

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

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

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