INFO-调用中台open API
更新时间: 2024-07-09 08:01:55
阅读 5151
INFO-调用中台open API(仅内部使用)
适用模块
离线开发
具体说明
open api调用mammut平台任务
使用示例
1、获取平台信息(需要平台管理员执行下列请求,email可以是普通具备执行任务的用户)
http://easydemo-workbench.163yun.com/api/user/apikey/set?email=用户账号 (需要在平台中的账户名,影响用户的权限等)
如:
http://easydemo-workbench.163yun.com/api/user/apikey/set?email=bigdata-test@163.com.cn
得到如下:
{"msg":"success","result":{"apikey":"7c419a6f-ec9e-49b3-92cc-434ec6e6aff5","masterkey":"2a9bc117-068e-4d99-b88d-d49d850d4a79","email":"bigdata-test@163.com.cn"},"code":200,"cost":9,"reqId":"dfa17f5c9f1a44b3972dd1836472a601"}
如下图所示:
2、获取token信息(工程见附件)
更改下列参数运行即可得到所需token (java代码如下)注:token 需要masterkey和url计算获得
package com.netease.hangkong;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
public class EncryptUtil {
public static String md5(String msg) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(msg.getBytes(StandardCharsets.UTF_8));
byte[] digest = md.digest();
return Base64.getEncoder().encodeToString(digest);
}
public static void main(String[] args) throws Exception {
String master_key = "1d2cf5f0-b336-462c-acf1-e5202b9a95ce";
String url = "/v1/openapi/etl/task/execute";
String token = URLEncoder
.encode(EncryptUtil.md5(master_key + url), "utf-8");
System.out.println(token);
}
}
public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException {
mammutOpenApi api = new mammutOpenApi();
//api.test("/v1/openapi/etl/task/schedule");
System.out.println(api.getToken("/v2/lineage/batch/table/task/writer")); (换接口)
3、根据mammut.pdf接口信息执行请求
例如跑某个离线开发任务:请求字段参照pdf说明(pdf见附件)
以postman为调试工具
post请求:http://easydemo-workbench.163yun.com/v1/openapi/etl/task/execute
添加headers:
Content-Type=applications/json
body添加如下
{
"apiKey": "5586b36a-b4a4-48a6-a96a-418757d1f772",
"token": "T2ngUN7fOWb1GG%2BwcAzX7A%3D%3D",
"product": "ebd_user",
"clusterId": "easyops-cluster",
"taskName": "ppack_transmit_kafka_service_v2",
"flowName": "ppack_transmit_kafka_service_v2",
"email": "admin.mammut@163.com",
"disables": [],
"doneNotify": false,
"execSettings":{
"concurrentOption": "skip",
"failureAction": "finishPossible",
"execQueue": "root.yq_ebd_user.default",
"execpros": [
{
"key": "mapreduce.job.queuename",
"value": "root.yq_ebd_user.default"
},
{
"key": "yarnid",
"value": "default"
}
]
}
}
返回
{
"result": {
"message": "Execution submitted successfully with exec id 23736",
"execid": 23736
},
"code": 200
}
运行的结果可在离线开发-运行结果查询
openApi接口规范文档:https://study.sf.163.com/documents/read/easyopenapi/openapi_list.md
作者:林帅
文档反馈
以上内容对您是否有帮助?