Versions Compared

Key

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

...

Paste code macro
languagehttp
themeSunburst
GET https://${CloudVendor}.${CountryCode}.machlake.com/v1/lakes/${lake_id}/tag
Content-Type: application/json; charset=utf8
x-api-key: {API Key}

...

Paste code macro
languagehttp
themeSunburst
GET https://${CloudVendor}.${CountryCode}aws1.us.machlake.com/v1/lakes/${lake_id}xbacd1234/tag?name=newtag01
Content-Type: application/json; charset=utf8
x-api-key: {API Key}

...

Paste code macro
languagejson
themeSunburst
Status 200
 
{
    "status"success": true,
    "reason": "get tag meta success",
    "data": {
        "name": "newtag01"
    }
}

...

Expand
titlewindow(batch)

github

Code Block
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
KEY
set LAKE_ID=YOUR_LAKE_ID
set CONTENTCLOUD_HEADER="Content-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 LAKE_ID=YOUR_LAKE_ID
set URL="https://%LAKE_ID%%CLOUD_VENDOR%.%CLOUD_REGION%.machlake.com/v1/lakes/%LAKE_ID%/tag"

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

:: CASE - Get Tag Information

set TAG_NAME=sensorsensor1

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"}
::     "success": true,
::     "reason": "get tag meta success",
::     "data": {"name": "sensor01"}
:: }


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

::
Expand
titleLinux(shell)

github

Code Block
# 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"}

#  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"
:: }
Expand
titleLinux(shell)

github

Code Block
languagebash
# 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 -------------------------- #
Expand
titlejavacsript

github

Code Block
languagejs
// 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) {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",
#           var request = require('request'); "lake_plan":"basic",
#             const QueryParams = new URLSearchParams()"lake_type":"N",
#             QueryParams.set("nameregion", "sensor")
:"aws1.kor",
#        var option = {             url: URL + "?" + QueryParams.toString(),"timezone":"America/Los_Angeles",
#              headers: {"create_time":"2021-09-30 10:30:05",
#                 'Content-Type': 'application/json',"update_time":"2021-10-01 14:59:12"
#         },
#         'x-api-key': API_KEY"lake_status":{
#             }"count_of_tag":128,
#        };         request.get(option, function(error, response, body) {"count_of_value":123456,
#             "query_call":0,
#     if (!error && response.statusCode === 200) {   "traffic":4743829,
#             res.writeHead(200);
"storage":3032870912,
#             "state":"running" 
# res.end(body);        },
#        console.log(body)
  "plan_limit":{
#           } else {
 "max_tag":1000,
#                console.log('error');
"max_query":10000,
#                console.log(error, response)"max_disk":32212254720,
#             "max_concurrent":100000,
#   if (response !== undefined) {      "limit_select_tag":1000,
#              res.writeHead(200);"limit_select_value":100,
#             "limit_append_value":100,
#       res.end(body);      "limit_append_tag":1000,
#              console.log(body) // {"message":"no such name : sensor","status":"error"}
"default_tag_count":10000
#         },
#         "tag_schema":[
#      }       {
#     }         })   "col_name":"name",
# } )  // CASE - Get Tag  Information  app.get(     '/get_tag_view_tag_name', function(req, res) {"col_type":"varchar",
#           var request = require('request');   "col_length":40
#     const QueryParams = new URLSearchParams()    }
#     QueryParams.set("name", "sensor1")    ],
#      var  option = { "value_schema":[
#             url:{
URL# + "?" + QueryParams.toString(),             headers: {"col_name":"time",
#                 'Content-Type': 'application/json',"col_type":"datetime"
#             },
#   'x-api-key': API_KEY         {
#   },         };     "col_name":"value",
#   request.get(option, function(error, response, body) {          "col_type":"double"
#  if (!error && response.statusCode === 200) {     }
#         ]
# res.writeHead(200);    }
# }
Expand
titlejavacsript

github

Code Block
languagejs
// Example For Get Tag View API by using request  res.end(body);in nodejs

// process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;

const API_KEY = "YOUR_API_TOKEN";
const LAKE_ID = "YOUR_LAKE_ID";
const  console.log(body)
            } else {
                console.log('errorCLOUD_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');


              console.log(error, response)
                if (response !== undefined) {
            /* ------------------------------------------------------------------------------------------------- */

// CASE - Get Tag Information

request.get({
    url: URL, 
    qs: {
res.writeHead(200);        name: "sensor1"
    },
    headers: {
res.end(body);        "x-api-key": API_KEY
    }}, 
     console.log(function(error, response, body) // {"data":{"name":"sensor1"},"status":"success"}{
        console.log(body);
        }// Return Format
        // {
}        // })     }
)"success": true,
   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')"reason": "get tag meta success",
    console.log('http://127.0.0.1:8888/get_tag_view_tag_name is result for tag name exsit in lake')
})
Expand
titlepython

github

Code Block
languagepy
"""
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
}    //     "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"
        // }
    })
Expand
titlepython

github

Code Block
languagepy
"""
Example For Get Tag View API by using requests in python
written by yeony kim
"""

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}/tag"

headers = {
    "Content-Type": "application/json",
    "x-api-key": API_KEY
}


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

# CASE - Get Tag Information

params = {
    "name": "sensor1"
}

response = requests.get(URL, headers=headers,  params=params, verify=False)
print(response.content.decode("utf-8"))

# Return Format
# {
#     "success": true,
#     "reason": "get tag meta success",
#     "data": {"name": "sensor01"}
# }


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

# CASE - Get Tag Information when no exist tag name

params = {
    '"name'": 'sensor'"wrong_name"
}

response = requests.get(URL, headers=headers,  params=params, verify=False)
print(response.content.decode('utf-8'))  # {"message":"no such name : sensor","status":"error"}.content.decode("utf-8"))

# CASEReturn -Format
Get# Tagstatus Informationcode : params400 =Bad {Request
#    'name': 'sensor1'
}

response = requests.get(URL, headers=headers,  params=params, verify=False)
print(response.content.decode('utf-8'))  # {"data":{"name":"sensor1"},"status":"success"}{
#     "success": false,
#     "reason": "no such name : wrong_name"
# }