Info |
---|
실제 개발자들이 default 가 아닌 확장 컬럼을 사용할 수 도 있을 것 같습니다. 그래서, 별도로 본인들의 lake를 구성할 수 있는 여지를 줘야합니다. |
Image Added
note
This API creates a data lake for the user to use. Define the Tag of the data lake to be created, its extended columns and Values, and its definite columns. And, don't forget to design well in advance because the data structure determined in this way cannot be changed. The last created Data Lake incurs an immediate cost, so call it with caution.
This API creates a data lake for the user to use. Define the Tag of the data lake to be created, its extended columns and Values, and its definite columns. And, don't forget to design well in advance because the data structure determined in this way cannot be changed. The last created Data Lake incurs an immediate cost, so call it with caution.
HTTP Request
Code Block |
---|
POST https://${CloudVendor}.${CountryCode}.machlake.com/lakes
Content-Type: application/json; charset=utf8
x-api-key: {API Key}
{
"lake_info" : {
"lake_name" : "{lake_name}",
"lake_plan" : "{lake_plan}",
"owner" : "{owner}",
"region" : "{region}",
"timezone" : "{timezone}",
"storage_size" : "{storage size}"
},
"tag_schema" : [
{
"col_name" : "{column name}",
"col_type" : "{column type}",
"col_length" : "{column length}"
},
......
],
"value_schema" : [
{
"col_name" : "{column name}",
"col_type" : "{column type}",
"col_length" : "{column length}"
},
......
]
} |
|
Parameters
Prerequisites |
---|
Key | Type | Description |
---|
lake_name | string | lake name |
lake_plan | string | tiny / basic / business/ enterprise |
owner | string | Lake's Owner (When omitted, the user who calls the API) |
region | string | AWS region name |
timezone | string | Timezone name |
storage_size | int | Storage size |
tag_schema | JSON | Columns for this lake's Tag meta. Each column have the three sub component: col_name, col_type, col_length. col_name : column name col_type : column type “short” : fixed integer value (2 byte length) “int” : fixed integer value (4 byte) “long” : fixed integer value (8 byte) “float” : floating point value (4 byte) “double” : floating point value(8 byte) “datetime” : time data to nano precision (8 byte) “varchar” : string type
col_length : if varchar type, assign the max length of column Code Block |
---|
{'col_name': "name", 'col_type': "varchar", 'col_length': 40} |
The data type of the first column , “col_type” must be “varchar”. But, additional meta column can have any data type. |
value_schema | JSON | Columns for this lake’s values. In this field, you have to assign two essential columns for time and default value. The first column datatype must be “datetime”. The second column datatype must be “double” keeping numeric data as default. Code Block |
---|
{'col_name': "time", 'col_type': "datetime"},
{'col_name': "value",'col_type': "double"} |
However, beginning with the third column information, you can have the option of specifying additional column information. |
Request Example
Code Block |
---|
POST https://aws1.us.machlake.com/lakes
Content-Type: application/json; charset=utf8
x-api-key: {API Key}
{
"lake_info" : {
"lake_name" : "My Lake",
"lake_plan" : "basic",
"owner" : "user01",
"region" : "us-east-1",
"timezone" : "America/Los_Angeles",
"storage_size" : 60
},
"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"
}
]
} |
|
Response Example
Code Block |
---|
Status 200
{
"status": true,
"data" : {lake id}
} |
|
Sample Code
github Code Block |
---|
chcp 65001
:: Text Encoding to UTF-8 in CMD
:: Example For Create Lake API by using curl in window script
:: written by yeony kim
set API_KEY=YOUR_API_TOKEN
set CONTENT_HEADER="Content-Type: application/json"
set API_HEADER="x-api-key: %API_KEY%"
set URL=https://api.machlake.com/lakes
:: ------------------------------------------------------------------------------------------------- ::
:: CASE - create LAKE
curl -k -X POST %URL% -H %CONTENT_HEADER% -H %API_HEADER% --data "{\"lake_id\":\"\",\"lake_info\":{\"lake_name\":\"sample_lake\",\"lake_plan\":\"basic\",\"owner\":\"YOUR_MACHLAKE_ID\",\"region\":\"ap-northeast-2\",\"timezone\":\"Asia/Seoul\",\"storage_size\":20},\"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\"}]}"
:: Return Format
:: {"data":"YOUR_LAKE_ID","status":"success"} |
|
github Code Block |
---|
# Text Encoding to UTF-8 in CMD
# Example For Create Lake API by using curl in shell script
# written by yeony kim
API_KEY=YOUR_API_TOKEN
CONTENT_HEADER=Content-Type:application/json
API_HEADER=x-api-key:$API_KEY
URL=https://api.machlake.com/lakes
# ------------------------------------------------------------------------------------------------- #
# CASE - create LAKE
curl -k -X POST $URL -H $CONTENT_HEADER -H $API_HEADER --data "{\"lake_id\":\"\",\"lake_info\":{\"lake_name\":\"sample_lake\",\"lake_plan\":\"basic\",\"owner\":\"YOUR_MACHLAKE_ID\",\"region\":\"ap-northeast-2\",\"timezone\":\"Asia/Seoul\",\"storage_size\":20},\"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\"}]}"
# Return Format
# {"data":"YOUR_LAKE_ID","status":"success"}
# ------------------------------------------------------------------------------------------------- # |
|
github Code Block |
---|
// Example For Create LAKE API by using request in nodejs
// written by yeony kim
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
const express = require('express');
const app = express();
const API_KEY = "YOUR_API_TOKEN";
const URL = "https://api.machlake.com/lakes";
// CASE - create LAKE
app.get(
'/create_lake', function(req, res) {
const Data = {
lake_id:"",
lake_info:{
lake_name:"sample_lake",
lake_plan:"basic",
owner:"YOUR_MACHLAKE_ID",
region:"ap-northeast-2",
timezone:"Asia/Seoul",
storage_size:20
},
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"}
]
}
var request = require('request');
var option = {
url: URL,
headers: {
'Content-Type': 'application/json',
'x-api-key': API_KEY
},
body: JSON.stringify(Data)
};
request.post( option, function(error, response, body) {
if (!error) {
res.writeHead(200);
res.end(body);
console.log(body) // {"data":"YOUR_LAKE_ID","status":"success"}
} else {
console.log(error)
}
})
}
)
app.listen(8888, function() {
console.log('http://127.0.0.1:8888/create_lake is result for create LAKE')
}) |
|
github Code Block |
---|
"""
Example For Create LAKE API by using request in python
written by yeony kim
"""
import requests
API_KEY = "YOUR_API_TOKEN"
URL = f"https://api.machlake.com/lakes"
# CASE - CASE - create LAKE
headers = {
'Content-Type': 'application/json',
'x-api-key': API_KEY
}
params = {
'lake_id': "",
'lake_info': {
'lake_name': "sample_lake",
'lake_plan': "basic",
'owner': "YOUR_MACHLAKE_ID",
'region': "ap-northeast-2",
'timezone': "Asia/Seoul",
'storage_size': 20
},
'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"}
]
}
response = requests.post(URL, headers=headers, json=params, verify=False)
print(response.content.decode('utf-8')) # {"data":"YOUR_LAKE_ID","status":"success"} |
|