函数
更新时间:2024-12-13
函数管理
函数信息
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
functionName | String | 是 | 函数名,长度不大于32个字符 |
databaseName | String | 是 | 函数隶属数据库名,长度不大于32个字符 |
className | String | 是 | 函数类名 |
functionType | Integer | 是 | 函数类型,(JAVA(1) |
resourceUris | List<ResourceUri> | 是 | 函数资源 |
creator | String | 否 | 创建者 |
createTime | String | 否 | 创建时间 |
modifyTime | String | 否 | 修改时间 |
description | String | 否 | 描述信息,长度不大于1024个字符 |
ResourceUri对象:
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
resourceType | Integer | 是 | 函数资源类型,(JAR(1),FILE(2),ARCHIVE(3) |
resourceUri | String | 否 | 函数资源路径 |
ListFunctions
接口说明
获取函数信息列表
请求原型
Plain Text
1GET /v1/database?function
请求参数
字段 | 类型 | 位置 | 是否必须 | 描述 |
---|---|---|---|---|
pageNo | Integer | URL | 否 | 页码 |
pageSize | Integer | URL | 否 | 每页查询记录数 |
database | String | URL | 否 | 按数据库名过滤 |
namePattern | String | URL | 否 | 用户定义函数名的正则匹配表达式 |
creator | String | URL | 否 | 按函数创建者过滤 |
响应参数
名称 | 类型 | 描述 |
---|---|---|
pageNo | Integer | 当前页数 |
pageSize | Integer | 每页条数 |
totalCount | Integer | 总数 |
result | List<Function> | 函数详情列表 |
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1GET /v1/database?function&pageNo=1&pageSize=10 HTTP/1.1
2
3Host: edap.bj.baidubce.com
4
5Content-Length: 0
响应示例
Plain Text
1HTTP/1.1 200 OK
2
3Content-Length: xxxx
4
5Content-Type: application/json
6{
7 "pageNo": 1,
8 "pageSize": 10,
9 "totalCount": 1,
10 "result": [
11 {
12 "functionName": "count",
13 "database": "db_01",
14 "className": "com.baidu.edap.CountUDF",
15 "functionType": 1,
16 "resourceUris": [
17 {
18 "resourceType": 1,
19 "resourceUri": "bos://abc/a.jar"
20 },
21 {
22 "resourceType": 1,
23 "resourceUri": "bos://abc/a.txt"
24 }
25 ],
26 "createTime": "2019-06-01T23:00:10Z",
27 "modifyTime": "2019-07-01T23:00:10Z",
28 "description": "count tow numbers",
29 "creator": "root"
30 }
31 ]
32}
GetFunction
接口说明
获取函数详情
请求原型
Plain Text
1GET /v1/database/${databaseName}/function/${functionName}
请求参数
名称 | 类型 | 位置 | 必须 | 说明 |
---|---|---|---|---|
databaseName | String | URL | 是 | 数据库名 |
functionName | String | URL | 是 | 函数名 |
响应参数
参见Function对象说明
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
FunctionNotFound | Function not found. | 404 | 函数不存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1GET /v1/database/db_01/function/count HTTP/1.1
2
3Host: edap.bj.baidubce.com
4
5Content-Length: 0
响应示例
Plain Text
1HTTP/1.1 200 OK
2
3Content-Length: xxxx
4
5Content-Type: application/json
6{
7 "functionName": "count",
8 "database": "db_01",
9 "className": "com.baidu.edap.CountUDF",
10 "functionType": 1,
11 "resourceUris": [
12 {
13 "resourceType": 1,
14 "resourceUri": "bos://abc/a.jar"
15 },
16 {
17 "resourceType": 1,
18 "resourceUri": "bos://abc/a.txt"
19 }
20 ],
21 "createTime": "2019-06-01T23:00:10Z",
22 "modifyTime": "2019-07-01T23:00:10Z",
23 "description": "count tow numbers",
24 "creator": "root"
25}
CreateFunction
接口说明
在指定数据库下创建函数,库下唯一,不能创建同名函数
请求原型
Plain Text
1POST /v1/database/${databaseName}/function
请求参数
字段 | 类型 | 位置 | 是否必须 | 描述 |
---|---|---|---|---|
databaseName | String | URL | 是 | 数据库名 |
functionName | String | Body | 是 | 函数名 |
database | String | Body | 是 | 函数隶属数据库名 |
className | String | Body | 是 | 函数类名 |
functionType | Integer | Body | 是 | 函数类型(JAVA(1) |
resourceUris | List<ResourceUri> | Body | 是 | 函数资源 |
description | String | Body | 是 | 描述信息 长度不大于1024个字符 |
响应参数
除公共响应参数外,无特殊响应。
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
BadRequest | Bad request, please check your request | 400 | 请求体规则校验错误 |
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
FunctionAlreadyExist | Functionalready exist. | 409 | 数据库已存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1POST /v1/database/bd_01/function HTTP/1.1
2
3Content-Length: xxx
4
5Content-Type: application/json
6{
7 "functionName": "count",
8 "database": "db_01",
9 "className": "com.baidu.edap.CountUDF",
10 "functionType": 1,
11 "resourceUris": [
12 {
13 "resourceType": 1,
14 "resourceUri": "bos://abc/a.jar"
15 },
16 {
17 "resourceType": 1,
18 "resourceUri": "bos://abc/a.txt"
19 }
20 ],
21 "description": "count tow numbers"
22}
响应示例
Plain Text
1HTTP/1.1 204 No Content
2
3Content-Length: 0
UpdateFunction
接口说明
更新函数信息, 除绑定的数据库和函数名不能更新,其余数据字段都可更新
请求原型
Plain Text
1PUT /v1/database/${databaseName}/function/${functionName}
请求参数
字段 | 类型 | 位置 | 是否必须 | 描述 |
---|---|---|---|---|
databaseName | String | URL | 是 | 数据库名 |
functionName | String | URL | 是 | 函数名 |
className | String | Body | 是 | 函数类名 |
resourceUris | List | Body | 是 | 函数资源 |
description | String | Body | 是 | 描述信息 长度不大于1024个字符 |
响应参数
除公共响应参数外,无特殊响应。
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
BadRequest | Bad request, please check your request | 400 | 请求体规则校验错误 |
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
FunctionNotFound | Function not found. | 404 | 函数不存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1PUT /v1/database/bd_01/function/count HTTP/1.1
2
3Host: edap.bj.baidubce.com
4
5Content-Length: xxxx
6
7Content-Type: application/json
8{
9 "className": "com.baidu.edap.Count",
10 "resourceUris": [
11 {
12 "resourceType": 1,
13 "resourceUri": "bos://abc/ax.jar"
14 },
15 {
16 "resourceType": 1,
17 "resourceUri": "bos://abc/a.txt"
18 }
19 ],
20 "description": "count tow numbers"
21}
响应示例
Plain Text
1HTTP/1.1 204 No Content
2
3Content-Length: 0
DeleteFunction
接口说明
删除函数
请求原型
Plain Text
1DELETE /v1/database/${databaseName}/function/${functionName}
请求参数
字段 | 类型 | 位置 | 是否必须 | 描述 |
---|---|---|---|---|
databaseName | String | URL | 是 | 数据库名 |
functionName | String | URL | 是 | 函数名 |
响应参数
除公共响应参数外,无特殊响应。
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
FunctionNotFound | Function not found. | 404 | 函数不存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1DELETE /v1/database/db_01/function/count HTTP/1.1
2
3Host: edap.bj.baidubce.com
4
5Content-Length: 0
响应示例
Plain Text
1HTTP/1.1 204 No Content
2
3Content-Length: 0