update scan tags api

This commit is contained in:
xiang.zhou
2026-02-11 15:03:50 +08:00
parent 75b37f891d
commit 3dc21e9248
7 changed files with 37 additions and 10 deletions
+1
View File
@@ -37,6 +37,7 @@ typedef struct {
char *node;
char *id;
char *ctx;
int load_index;
} neu_json_scan_tags_req_t;
int neu_json_decode_scan_tags_req(char *buf, neu_json_scan_tags_req_t **result);
+3
View File
@@ -1706,6 +1706,7 @@ typedef struct neu_req_scan_tags {
char driver[NEU_NODE_NAME_LEN];
char id[NEU_TAG_ADDRESS_LEN];
char ctx[NEU_VALUE_SIZE];
int load_index;
} neu_req_scan_tags_t;
typedef struct {
@@ -1722,6 +1723,8 @@ typedef struct {
neu_type_e type;
bool is_array;
char ctx[NEU_VALUE_SIZE];
int load_index;
int c_flag;
} neu_resp_scan_tags_t;
typedef struct {
+1 -1
View File
@@ -112,7 +112,7 @@ typedef struct neu_plugin_intf_funs {
int n_tag); // create tags by API
int (*del_tags)(neu_plugin_t *plugin, int n_tag);
int (*scan_tags)(neu_plugin_t *plugin, void *req, char *id,
char *ctx);
char *ctx, int load_index);
int (*test_read_tag)(neu_plugin_t *plugin, void *req,
neu_datatag_t tag);
int (*action)(neu_plugin_t *plugin, const char *action);
+2
View File
@@ -54,6 +54,8 @@ void handle_scan_tags(nng_aio *aio)
strcpy(cmd.ctx, req->ctx);
}
cmd.load_index = req->load_index;
if (0 != neu_plugin_op(plugin, header, &cmd)) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
neu_http_response(aio, NEU_ERR_IS_BUSY, result_error);
+2 -2
View File
@@ -3394,8 +3394,8 @@ void neu_adapter_driver_scan_tags(neu_adapter_driver_t *driver,
}
neu_req_scan_tags_t *cmd = (neu_req_scan_tags_t *) &req[1];
driver->adapter.module->intf_funs->driver.scan_tags(driver->adapter.plugin,
req, cmd->id, cmd->ctx);
driver->adapter.module->intf_funs->driver.scan_tags(
driver->adapter.plugin, req, cmd->id, cmd->ctx, cmd->load_index);
}
void neu_adapter_driver_test_read_tag(neu_adapter_driver_t *driver,
+25 -4
View File
@@ -64,6 +64,13 @@ int neu_json_decode_scan_tags_req(char *buf, neu_json_scan_tags_req_t **result)
},
};
neu_json_elem_t req_load_index_elems[] = {
{
.name = "load_index",
.t = NEU_JSON_INT,
},
};
if (0 !=
neu_json_decode_by_json(json_obj, NEU_JSON_ELEM_SIZE(req_node_elems),
req_node_elems)) {
@@ -78,10 +85,14 @@ int neu_json_decode_scan_tags_req(char *buf, neu_json_scan_tags_req_t **result)
neu_json_decode_by_json(json_obj, NEU_JSON_ELEM_SIZE(req_ctx_elems),
req_ctx_elems);
req->node = req_node_elems[0].v.val_str;
req->id = req_id_elems[0].v.val_str;
req->ctx = req_ctx_elems[0].v.val_str;
*result = req;
neu_json_decode_by_json(json_obj, NEU_JSON_ELEM_SIZE(req_load_index_elems),
req_load_index_elems);
req->node = req_node_elems[0].v.val_str;
req->id = req_id_elems[0].v.val_str;
req->ctx = req_ctx_elems[0].v.val_str;
req->load_index = req_load_index_elems[0].v.val_int;
*result = req;
neu_json_decode_free(json_obj);
return 0;
@@ -164,6 +175,16 @@ int neu_json_encode_scan_tags_resp(void *json_object, void *param)
.t = NEU_JSON_STR,
.v.val_str = resp->ctx,
},
{
.name = "load_index",
.t = NEU_JSON_INT,
.v.val_int = resp->load_index,
},
{
.name = "completed",
.t = NEU_JSON_INT,
.v.val_int = resp->c_flag,
},
{
.name = "tags",
.t = NEU_JSON_OBJECT,
+3 -3
View File
@@ -411,8 +411,8 @@ def get_nodes_disable_auth(type):
@gen_check
def scan_tags(node, id, ctx=""):
return requests.post(url=config.BASE_URL + "/api/v2/scan/tags", headers={"Authorization": config.default_jwt}, json={"node": node, "id": id, "ctx": ctx})
def scan_tags(node, id, ctx="", load_index=0):
return requests.post(url=config.BASE_URL + "/api/v2/scan/tags", headers={"Authorization": config.default_jwt}, json={"node": node, "id": id, "ctx": ctx, "load_index": load_index})
def otel_start(host, port):
@@ -587,4 +587,4 @@ def simulator_export(jwt=config.default_jwt):
def simulator_list_tags(jwt=config.default_jwt):
return requests.get(url=config.BASE_URL + "/api/v2/simulator/tags",
headers={"Authorization": jwt})
headers={"Authorization": jwt})