/
Update Tag

Update Tag

This API modifies the details of the registered tag. The name of the tag to be modified is entered in the name field, and the name of the column to be modified and the modified value of the corresponding tag are entered in “col_name” and “value” in the columns, respectively, and input in the form of a json array to request.

HTTP Request

Parameters

no parameters

Request Example

Response Example

Sample Code

in this sample, try to update sensor1 to sensor10 and recover sensor10 to sensor1

github

chcp 65001 :: Text Encoding to UTF-8 in CMD :: Example For Update Tag API by using curl in window script :: written by yeony kim :: sensor1, sensor2 is applied in lake set API_KEY=YOUR_API_KEY set LAKE_ID=YOUR_LAKE_ID set CLOUD_VENDOR=YOUR_CLOUD_VENDOR set CLOUD_REGION=YOUR_CLOUD_REGION set CONTENT_HEADER="Content-Type: application/json" set API_HEADER="x-api-key: %API_KEY%" set URL="https://%CLOUD_VENDOR%.%CLOUD_REGION%.machlake.com/v1/lakes/%LAKE_ID%/tags" :: ------------------------------------------------------------------------------------------------- :: :: CASE - Update Tag Name set SRC_TAG_NAME=sensor1 set TAR_TAG_NAME=sensor10 set VALUES="{\"name\": \"%SRC_TAG_NAME%\", \"columns\": [{\"col_name\": \"name\", \"value\": \"%TAR_TAG_NAME%\"}]}" curl -k -X PUT %URL% -H %CONTENT_HEADER% -H %API_HEADER% -d %VALUES% :: Return Format :: { :: "success": true, :: "reason": "update tag meta success", :: "data":{"name":"sensor10"} :: } :: ------------------------------------------------------------------------------------------------- :: :: CASE - Update Tag additional column :: columns :: name (varchar, 80), location (varchar, 40) set SRC_TAG_NAME=sensor02 set ADD_COLUMN=4F-101 set VALUES="{\"name\": \"%SRC_TAG_NAME%\", \"columns\": [{\"col_name\": \"location\", \"value\": \"%ADD_COLUMN%\"}]}" curl -k -X PUT %URL% -H %CONTENT_HEADER% -H %API_HEADER% -d %VALUES% :: Return Format :: { :: "success": true, :: "reason": "update tag meta success", :: "data": { :: "location": "4F-101", :: "name": "sensor02" :: } :: } :: ------------------------------------------------------------------------------------------------- :: :: CASE - Update Tag when not exist tag set SRC_TAG_NAME=wrong_name set ADD_COLUMN=4F-101 set VALUES="{\"name\": \"%SRC_TAG_NAME%\", \"columns\": [{\"col_name\": \"location\", \"value\": \"%ADD_COLUMN%\"}]}" curl -k -X PUT %URL% -H %CONTENT_HEADER% -H %API_HEADER% -d %VALUES% :: Return Format :: status code : 400 Bad Request :: { :: "success": false, :: "reason": "no such name : wrong_name" :: }

github

# Text Encoding to UTF-8 in CMD # Example For Update Tag API by using curl in ubuntu LAKE_ID=$YOUR_LAKE_ID API_KEY=$YOUR_API_KEY CLOUD_VENDOR=$YOUR_CLOUD_VENDOR CLOUD_REGION=$YOUR_CLOUD_REGION CONTENT_HEADER=Content-Type:application/json API_HEADER=x-api-key:$API_KEY URL=https://${CLOUD_VENDOR}.${CLOUD_REGION}.machlake.com/v1/lakes/${LAKE_ID}/tags # ------------------------------------------------------------------------------------------------- # # CASE - Update Tag Name SRC_TAG_NAME=sensor1 TAR_TAG_NAME=sensor10 VALUES="{\"name\": \"$SRC_TAG_NAME\", \"columns\": [{\"col_name\": \"name\", \"value\": \"$TAR_TAG_NAME\"}]}" curl -k -X PUT $URL -H $CONTENT_HEADER -H $API_HEADER -d $VALUES # Return Format # { # "success": true, # "reason": "update tag meta success", # "data":{"name":"sensor10"} # } # ------------------------------------------------------------------------------------------------- # # CASE - Update Tag additional column # columns # name (varchar, 80), location (varchar, 40) SRC_TAG_NAME=sensor02 ADD_COLUMN="4F-101" VALUES="{\"name\": \"$SRC_TAG_NAME\", \"columns\": [{\"col_name\": \"location\", \"value\": \"$ADD_COLUMN\"}]}" curl -k -X PUT $URL -H $CONTENT_HEADER -H $API_HEADER -d $VALUES # Return Format # { # "success": true, # "reason": "update tag meta success", # "data": { # "location": "4F-101", # "name": "sensor02" # } # } # ------------------------------------------------------------------------------------------------- # # CASE - Update Tag when not exist tag SRC_TAG_NAME=wrong_name ADD_COLUMN="4F-101" VALUES="{\"name\": \"$SRC_TAG_NAME\", \"columns\": [{\"col_name\": \"location\", \"value\": \"$ADD_COLUMN\"}]}" curl -k -X PUT $URL -H $CONTENT_HEADER -H $API_HEADER -d $VALUES # Return Format # status code : 400 Bad Request # { # "success": false, # "reason": "no such name : wrong_name" # }

github

// Example For Update Tag API by using request in nodejs // sensor1, sensor2 is applied in lake // process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; const API_KEY = "YOUR_API_TOKEN"; const LAKE_ID = "YOUR_LAKE_ID" const CLOUD_VENDOR="CLOUD_VENDOR"; const CLOUD_REGION="CLOUD_REGION"; const URL = `https://${CLOUD_VENDOR}.${CLOUD_REGION}.machlake.com/v1/lakes/${LAKE_ID}/tags`; var request = require('request'); /* ------------------------------------------------------------------------------------------------- */ // CASE - Update Tag Name var Data = { name: "sensor1", columns: [ {col_name: "name", value: "sensor10"} ] } request.put({ url: URL, headers: { "Content-Type": "application/json", "x-api-key": API_KEY }, body: JSON.stringify(Data) }, function(error, response, body) { console.log(body); // Return Format // { // "success": true, // "reason": "update tag meta success", // "data":{"name":"sensor10"} // } }) /* ------------------------------------------------------------------------------------------------- */ // CASE - Update Tag additional column // columns // name (varchar, 80), location (varchar, 40) var Data = { name: "sensor2", columns: [ {col_name: "location", value: "4F-101"} ] } request.put({ url: URL, headers: { "Content-Type": "application/json", "x-api-key": API_KEY }, body: JSON.stringify(Data) }, function(error, response, body) { console.log(body); // Return Format // { // "success": true, // "reason": "update tag meta success", // "data": { // "location": "4F-101", // "name": "sensor02" // } // } }) /* ------------------------------------------------------------------------------------------------- */ // CASE - Update Tag when not exist tag var Data = { name: "wrong_name", columns: [ {col_name: "location", value: "4F-102"} ] } request.put({ url: URL, headers: { "Content-Type": "application/json", "x-api-key": API_KEY }, body: JSON.stringify(Data) }, function(error, response, body) { console.log(body); // Return Format // status code : 400 Bad Request // { // "success": false, // "reason": "no such name : wrong_name" // } })

github

""" Example For Update Tag API by using requests in python written by yeony kim sensor1, sensor2 is applied in lake """ import requests API_KEY = "YOUR_API_TOKEN" LAKE_ID = "YOUR_LAKE_ID" CLOUD_VENDOR="CLOUD_VENDOR" CLOUD_REGION="CLOUD_REGION" URL = f"https://{CLOUD_VENDOR}.{CLOUD_REGION}.machlake.com/v1/lakes/{LAKE_ID}/tags" headers = { "Content-Type": "application/json", "x-api-key": API_KEY } # ------------------------------------------------------------------------------------------------- # # CASE - Update Tag Name params = { "name": "sensor1", "columns": [ {"col_name": "name", "value": "sensor10"} ] } response = requests.put(URL, headers=headers, json=params, verify=False) print(response.content.decode("utf-8")) # Return Format # { # "success": true, # "reason": "update tag meta success", # "data":{"name":"sensor10"} # } # ------------------------------------------------------------------------------------------------- # # CASE - Update Tag additional column # columns # name (varchar, 80), location (varchar, 40) params = { "name": "sensor2", "columns": [ {"col_name": "location", "value": "4F-101"} ] } response = requests.put(URL, headers=headers, json=params, verify=False) print(response.content.decode("utf-8")) # Return Format # { # "success": true, # "reason": "update tag meta success", # "data": { # "location": "4F-101", # "name": "sensor02" # } # } # ------------------------------------------------------------------------------------------------- # # CASE - Update Tag when not exist tag params = { "name": "wrong_name", "columns": [ {"col_name": "location", "value": "4F-102"} ] } response = requests.put(URL, headers=headers, json=params, verify=False) print(response.content.decode("utf-8")) # Return Format # status code : 400 Bad Request # { # "success": false, # "reason": "no such name : wrong_name" # }