Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 17 Current »

This API returns the details of the specified tag. User must specify the correct name for the tag_name variable.

HTTP Request

Parameters

Optional

Type

Description

Example

name

string

name of tag

?name=newtag01

Request Example

Response Example

Sample Code

In this sample, tag contains only sensor1, sensor2

 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_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%/tag"

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

:: CASE - Get Tag Information

set TAG_NAME=sensor1

curl -k -G %URL% -H %CONTENT_HEADER% -H %API_HEADER% \
    --data-urlencode "name=%TAG_NAME%"

:: Return Format / not exist tag name in lake
:: {
::     "success": true,
::     "reason": "get tag meta success",
::     "data": {"name": "sensor01"}
:: }


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

:: CASE - Get Tag Information when no exist tag name

set TAG_NAME=wrong_name

curl -k -G %URL% -H %CONTENT_HEADER% -H %API_HEADER% \
    --data-urlencode "name=%TAG_NAME%"

:: Return Format
:: status code : 400 Bad Request
:: {
::     "success": false,
::     "reason": "no such name : wrong_name"
:: }
 Linux(shell)

github

# Text Encoding to UTF-8 in CMD
# Example For Get Lake View API by using curl in shell script

API_KEY=$YOUR_API_KEY
LAKE_ID=$YOUR_LAKE_ID

CONTENT_HEADER="Content-Type:application/json"
API_HEADER="x-api-key:$API_KEY"

URL=https://api.machlake.com/v1/lakes/$LAKE_ID

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

# CASE - GET LAKE List

curl -k -X GET $URL -H $CONTENT_HEADER -H $API_HEADER

# Return Format
# {
#     "success":true,
#     "reason":"get lake info success",
#     "data":{
#         "lake_id":"xbcd0001",
#         "lake_info":{
#             "lake_name":"sample_lake",
#             "lake_plan":"basic",
#             "lake_type":"N",
#             "region":"aws1.kor",
#             "timezone":"America/Los_Angeles",
#             "create_time":"2021-09-30 10:30:05",
#             "update_time":"2021-10-01 14:59:12"
#         },
#         "lake_status":{
#             "count_of_tag":128,
#             "count_of_value":123456,
#             "query_call":0,
#             "traffic":4743829,
#             "storage":3032870912,
#             "state":"running" 
#         },
#         "plan_limit":{
#             "max_tag":1000,
#             "max_query":10000,
#             "max_disk":32212254720,
#             "max_concurrent":100000,
#             "limit_select_tag":1000,
#             "limit_select_value":100,
#             "limit_append_value":100,
#             "limit_append_tag":1000,
#             "default_tag_count":10000
#         },
#         "tag_schema":[
#             {
#                 "col_name":"name",
#                 "col_type":"varchar",
#                 "col_length":40
#             }
#         ],
#         "value_schema":[
#             {
#                 "col_name":"time",
#                 "col_type":"datetime"
#             },
#             {
#                 "col_name":"value",
#                 "col_type":"double"
#             }
#         ]
#     }
# }
 javacsript

github

// Example For Get Tag View API by using request in nodejs

// 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}/tag`;

var request = require('request');


/* ------------------------------------------------------------------------------------------------- */

// CASE - Get Tag Information

request.get({
    url: URL, 
    qs: {
        name: "sensor1"
    },
    headers: {
        "x-api-key": API_KEY
    }}, 
    function(error, response, body) {
        console.log(body);
        // Return Format
        // {
        //     "success": true,
        //     "reason": "get tag meta success",
        //     "data": {"name": "sensor01"}
        // }
    })

/* ------------------------------------------------------------------------------------------------- */

// CASE - Get Tag Information when no exist tag name

request.get({
    url: URL, 
    qs: {
        name: "wrong_name"
    },
    headers: {
        "x-api-key": API_KEY
    }}, 
    function(error, response, body) {
        console.log(body);
        // Return Format
        // status code : 400 Bad Request
        // {
        //     "success": false,
        //     "reason": "no such name : wrong_name"
        // }
    })
 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"}

  • No labels