Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel7
typeflat

지정한 tag정보와 등록된 모든 데이터를 삭제한다. Tag_name 매개변수는 반드시 지정해야 한다.

...

Code Block
Status 200

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

Sample Code

In this sample, tag contains sensor1, sensor2, so if that not contains then result should be different

Expand
titlewindow(batch)

github

Code Block
chcp 65001 
:: Text Encoding to UTF-8 in CMD
:: Example For Delete 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 - delete error when no exist tag name

set TAG_NAME=sensor

curl -k -X DELETE %URL% -H %CONTENT_HEADER% -H %API_HEADER% -d "{\"name\": \"%TAG_NAME%\"}"

:: Return Format / Example for tag name does not exist in lake
:: {"message":"no such name : sensor","status":"error"}

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

:: CASE - delete tag

set TAG_NAME=sensor1

curl -k -X DELETE %URL% -H %CONTENT_HEADER% -H %API_HEADER% -d "{\"name\": \"%TAG_NAME%\"}"

:: Return Format / Example for delete tag
:: {"data":{},"status":"success"}

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

:: CASE - delete tag

set TAG_NAME=sensor2

curl -k -X DELETE %URL% -H %CONTENT_HEADER% -H %API_HEADER% -d "{\"name\": \"%TAG_NAME%\"}"

:: Return Format / Example for delete tag
:: {"data":{},"status":"success"}

Expand
titlelinux(shell)

github

Code Block
# Text Encoding to UTF-8 in CMD
# Example For Delete Tag API by using curl in ubuntu
# written by yeony kim
# sensor1, sensor2 is applied in lake

API_KEY=YOUR_API_TOKEN

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

# ------------------------------------------------------------------------------------------------- #

# CASE - delete error when no exist tag name

TAG_NAME=sensor

curl -k -X DELETE $URL -H $CONTENT_HEADER -H $API_HEADER -d "{\"name\": \"$TAG_NAME\"}"

# Return Format / Example for tag name does not exist in lake
# {"message":"no such name : sensor","status":"error"}

# ------------------------------------------------------------------------------------------------- #

# CASE - delete tag

TAG_NAME=sensor1

curl -k -X DELETE $URL -H $CONTENT_HEADER -H $API_HEADER -d "{\"name\": \"$TAG_NAME\"}"

# Return Format / Example for delete tag
# {"data":{},"status":"success"}

# ------------------------------------------------------------------------------------------------- #

# CASE - delete tag

TAG_NAME=sensor2

curl -k -X DELETE $URL -H $CONTENT_HEADER -H $API_HEADER -d "{\"name\": \"$TAG_NAME\"}"

# Return Format / Example for delete tag
# {"data":{},"status":"success"}
Expand
titlejavascript

github

Code Block
// Example For Delete Tag API by using request in nodejs
// written by yeony kim
// sensor1, sensor2 is applied in lake

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

const express = require('express');
const app = express();
const API_KEY = "YOUR_API_TOKEN";
const LAKE_ID = "YOUR_LAKE_ID"
const URL = "https://" + LAKE_ID + ".machlake.com/lakes/tags";

// CASE - delete error when no exist tag name

app.get(
    '/delete_tag_name_sensor', function(req, res) {
        const Data = {
            name: 'sensor',
        }
        var request = require('request');
        var option = {
            url: URL,
            headers: {
                'Content-Type': 'application/json',
                'x-api-key': API_KEY
            },
            body: JSON.stringify(Data)
        };
        request.delete( option, function(error, response, body) {
            if (!error) {
                res.writeHead(200);
                res.end(body);
                console.log(body) // {"data":{},"status":"success"} or {"message":"no such name : sensor1","status":"error"}
            } else {
                console.log(error)
            }
        })
    }
)

// CASE - delete tag

app.get(
    '/delete_tag_name_sensor1', function(req, res) {
        const Data = {
            name: 'sensor1',
        }
        var request = require('request');
        var option = {
            url: URL,
            headers: {
                'Content-Type': 'application/json',
                'x-api-key': API_KEY
            },
            body: JSON.stringify(Data)
        };
        request.delete( option, function(error, response, body) {
            if (!error) {
                res.writeHead(200);
                res.end(body);
                console.log(body) // {"data":{},"status":"success"} or {"message":"no such name : sensor1","status":"error"}
            } else {
                console.log(error)
            }
        })
    }
)

// CASE - delete tag

app.get(
    '/delete_tag_name_sensor2', function(req, res) {
        const Data = {
            name: 'sensor2',
        }
        var request = require('request');
        var option = {
            url: URL,
            headers: {
                'Content-Type': 'application/json',
                'x-api-key': API_KEY
            },
            body: JSON.stringify(Data)
        };
        request.delete( option, function(error, response, body) {
            if (!error) {
                res.writeHead(200);
                res.end(body);
                console.log(body) // {"data":{},"status":"success"} or {"message":"no such name : sensor1","status":"error"}
            } else {
                console.log(error)
            }
        })
    }
)

app.listen(8888, function() {
    console.log('http://127.0.0.1:8888/delete_tag_name_sensor is result for delete sensor tag (error)')
    console.log('http://127.0.0.1:8888/delete_tag_name_sensor1 is result for delete sensor1 tag')
    console.log('http://127.0.0.1:8888/delete_tag_name_sensor1 is result for delete sensor2 tag')
})

...

titlepython

github

...

이 예제에서, sensor1, sensor2의 tag가 사전에 생성되어 있는 것을 가정한다. 해당 tag가 없으면 오류로 처리된다.