本OpenAPI为您提供根据上传文件创建标签的能力,当前暂不支持追加或修改已创建好的标签。
Path:/openapi/v1/app/{app_id}/tag
Method: POST
Content-type: application/json
Path-parameters: 参考公共参数即可
Body:
{ "name": "tag_test_tag", # "name" must start with "tag_" "show_name": "测试标签", "value_type": "string", "description": "", "create_type": "upload", "refresh_rule": "manual", "tag_rule": { "file": { "file_key": "tag_upload_uuid/164314/20220527/564b19debe5a448396504802ab5ea69a.json", # file_key 需要和上传标签数据得到的返回结果一致 "detail": { "name": "user_tag.csv" } } } }
字段含义说明
参数 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
name | string | 是 | true | 标签名称, 必须以"tag_"开头,应用内唯一。规则参考:用户标签 |
show_name | string | 是 | true | 标签展示名称,应用内唯一。 |
value_type | string | 是 | true | 值类型(枚举类型): int、string、float、datetime |
description | string | 否 | false | 描述,可为空 |
create_type | string | 是 | true | 创建类型,这里固定是 upload |
refresh_rule | string | 是 | true | 刷新类型: manual、daily, 上传文件固定刷新类型为 manual |
tag_rule.file.file_key | string | 否 | false | 系统的文件路径,需要和上传文件 API 得到的返回结果保持一致 |
tag_rule.file.detail.name | string | 否 | false | 文件名 |
Response:
{ "code": 200, "message": "success", "data": { "tag_name": "tag_test_tag" }, "total_execute_time": null }
字段含义说明
Field | Type | Description |
---|---|---|
code | int | 状态码 |
message | string | 返回message |
tag_name | string | 创建成功的标签名称 |
total_execute_time | int | 总的执行时间 |
bc
为创建的 RangersClient, 其初始化请参考使用说明, 各语言的 SDK 都提供了类似的接口
调用(Python):
method = 'POST' service_url = '/datatag/openapi/v1/app/164314/tag' body = { "name": "tag_test_tag", "show_name": "测试标签", "value_type": "string", "description": "", "create_type": "upload", "refresh_rule": "manual", "tag_rule": { "file": { "file_key": "tag_upload_uuid/164314/20220527/564b19debe5a448396504802ab5ea69a.json", "detail": { "name": "user_tag.csv" } } } } resp = bc.request(method=method, service_url=service_url, body=body) print(resp.content.decode('utf-8'))
调用(Java):
String method = "POST"; String serviceUrl = "/datatag/openapi/v1/app/164314/tag"; HashMap<String, String> headers = null; HashMap<String, String> params = null; String body = "{\n" + " \"name\": \"tag_test_tag\",\n" + " \"show_name\": \"测试标签\",\n" + " \"value_type\": \"string\",\n" + " \"description\": \"\",\n" + " \"create_type\": \"upload\",\n" + " \"refresh_rule\": \"manual\",\n" + " \"tag_rule\": {\n" + " \"file\": {\n" + " \"file_key\": \"tag_upload_uuid/164314/20220527/564b19debe5a448396504802ab5ea69a.json\",\n" + " \"detail\": {\n" + " \"name\": \"user_tag.csv\"\n" + " }\n" + " }\n" + " }\n" + "}"; String resp = bc.request(method, serviceUrl, headers, params, body); System.out.println(resp);
返回结果:
{ "code": 200, "message": "success", "data": { "tag_name": "tag_test_tag" }, "total_execute_time": null }