Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
Status 200

{
    "status": "success",
    "data": {
        "name": "changetag01"
    }
}

Sample Code

in this sample, try to update sensor1 to sensor10 and recover sensor10 to sensor1이 예제는 sensor1 tag를 sensor10으로 변경했다가 다시 sensor1로 변경하는것을 보여준다.

Expand
titlewindow(batch)

github

Code Block
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_TOKEN

set CONTENT_HEADER="Content-Type: application/json"
set API_HEADER="x-api-key: %API_KEY%"
set LAKE_ID=YOUR_LAKE_ID
set URL=https://%LAKE_ID%.machlake.com/lakes/tags

:: ------------------------------------------------------------------------------------------------- ::

:: CASE - Tag Name Change SRC to TAR

set SRC_TAG_NAME=sensor1
set TAR_TAG_NAME=sensor10

curl -k -X PUT %URL% -H %CONTENT_HEADER% -H %API_HEADER%  -d "{\"name\": \"%SRC_TAG_NAME%\", \"columns\": [{\"col_name\": \"name\", \"value\": \"%TAR_TAG_NAME%\"}]}"

:: Return Format
:: {"data":{"name":"sensor10"},"status":"success"}

:: ------------------------------------------------------------------------------------------------- ::

:: CASE - Tag Name Change Error when Not exist

curl -k -X PUT %URL% -H %CONTENT_HEADER% -H %API_HEADER%  -d "{\"name\": \"%SRC_TAG_NAME%\", \"columns\": [{\"col_name\": \"name\", \"value\": \"%TAR_TAG_NAME%\"}]}"

:: Return Format / SRC_TAG_NAME이 존재 하지 않는 경우 예시
:: {"message":"no such name : sensor1","status":"error"}

:: ------------------------------------------------------------------------------------------------- ::

:: CASE - Tag Name Change SRC to TAR

set SRC_TAG_NAME=sensor10
set TAR_TAG_NAME=sensor1

curl -k -X PUT %URL% -H %CONTENT_HEADER% -H %API_HEADER%  -d "{\"name\": \"%SRC_TAG_NAME%\", \"columns\": [{\"col_name\": \"name\", \"value\": \"%TAR_TAG_NAME%\"}]}"

:: Return Format
:: {"data":{"name":"sensor1"},"status":"success"}

:: ------------------------------------------------------------------------------------------------- ::

...