You are viewing an old version of this content. View the current version.
Compare with Current
View Version History
« Previous
Version 2
Next »
Tag_name 변수에 지정한 tag에 대한 자세한 정보를 반환한다. tag_name변수에 적절한 값을 반드시 설정해야 한다.
HTTP Request
GET https://${CloudVendor}.${CountryCode}.machlake.com/lakes/${lake_id}/tag
Content-Type: application/json; charset=utf8
x-api-key: {API Key}
Parameters
Optional | Type | Description | Example |
---|
name | string | name of tag | ?name=newtag01 |
Request Example
GET https://aws1.us.machlake.com/lakes/xbacd1234/tag?name=newtag01
Content-Type: application/json; charset=utf8
x-api-key: {API Key}
Response Example
Status 200
{
"status": "success",
"data": {
"name": "newtag01"
}
}
Sample Code
이 예제코드는 Tag name이 ‘sensor1’인 tag 정보를 얻는다.
window(batch)
github
chcp 65001
:: Text Encoding to UTF-8 in CMD
:: Example For Get Tag View 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/tag
:: ------------------------------------------------------------------------------------------------- ::
:: CASE - Get Tag Information
set TAG_NAME=sensor
curl -k -G %URL% -H %CONTENT_HEADER% -H %API_HEADER% --data-urlencode "name=%TAG_NAME%"
:: Return Format / not exist tag name in lake
:: {"message":"no such name : sensor","status":"error"}
set TAG_NAME=sensor1
curl -k -G %URL% -H %CONTENT_HEADER% -H %API_HEADER% --data-urlencode "name=%TAG_NAME%"
:: Return Format
:: {"data":{"name":"sensor1"},"status":"success"}
:: ------------------------------------------------------------------------------------------------- ::
Linux(shell)
github
# Text Encoding to UTF-8 in CMD
# Example For Get Tag View 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/tag
# ------------------------------------------------------------------------------------------------- #
# CASE - Get Tag Information
TAG_NAME=sensor
curl -k -G $URL -H $CONTENT_HEADER -H $API_HEADER --data-urlencode "name=$TAG_NAME"
# Return Format / not exist tag name in lake
# {"message":"no such name : sensor","status":"error"}
TAG_NAME=sensor1
curl -k -G $URL -H $CONTENT_HEADER -H $API_HEADER --data-urlencode "name=$TAG_NAME"
# Return Format
# {"data":{"name":"sensor1"},"status":"success"}
# ------------------------------------------------------------------------------------------------- #
javacsript
github
// Example For Get Tag View 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/tag";
// CASE - Get Tag Information
app.get(
'/get_tag_view_no_tag_name', function(req, res) {
var request = require('request');
const QueryParams = new URLSearchParams()
QueryParams.set("name", "sensor")
var option = {
url: URL + "?" + QueryParams.toString(),
headers: {
'Content-Type': 'application/json',
'x-api-key': API_KEY
},
};
request.get(option, function(error, response, body) {
if (!error && response.statusCode === 200) {
res.writeHead(200);
res.end(body);
console.log(body)
} else {
console.log('error');
console.log(error, response)
if (response !== undefined) {
res.writeHead(200);
res.end(body);
console.log(body) // {"message":"no such name : sensor","status":"error"}
}
}
})
}
)
// CASE - Get Tag Information
app.get(
'/get_tag_view_tag_name', function(req, res) {
var request = require('request');
const QueryParams = new URLSearchParams()
QueryParams.set("name", "sensor1")
var option = {
url: URL + "?" + QueryParams.toString(),
headers: {
'Content-Type': 'application/json',
'x-api-key': API_KEY
},
};
request.get(option, function(error, response, body) {
if (!error && response.statusCode === 200) {
res.writeHead(200);
res.end(body);
console.log(body)
} else {
console.log('error');
console.log(error, response)
if (response !== undefined) {
res.writeHead(200);
res.end(body);
console.log(body) // {"data":{"name":"sensor1"},"status":"success"}
}
}
})
}
)
app.listen(8888, function() {
console.log('http://127.0.0.1:8888/get_tag_view_no_tag_name is result for tag name not exist in lake')
console.log('http://127.0.0.1:8888/get_tag_view_tag_name is result for tag name exsit in lake')
})
python
github
"""
Example For Get Tag View 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"
URL = f"https://{LAKE_ID}.machlake.com/lakes/tag"
headers = {
'Content-Type': 'application/json',
'x-api-key': API_KEY
}
# CASE - Get Tag Information
params = {
'name': 'sensor'
}
response = requests.get(URL, headers=headers, params=params, verify=False)
print(response.content.decode('utf-8')) # {"message":"no such name : sensor","status":"error"}
# CASE - Get Tag Information
params = {
'name': 'sensor1'
}
response = requests.get(URL, headers=headers, params=params, verify=False)
print(response.content.decode('utf-8')) # {"data":{"name":"sensor1"},"status":"success"}