OmniThings API 使用文件
https://tsdbase02.asuswebstorage.com/tsdbase/entry
,由 request header
X-Omni-Action
指定操作動作。型態 | 說明 |
---|---|
DateTime | 時間字串,格式
yyyy-MM-dd HH:mm:ss 。 |
HASH | 數值字串,僅允許作為 KEY 使用 |
RANGE | 有限長度字串,僅允許作為 KEY 使用 |
Number | 數值字串,僅允許作為 Attribute 使用 |
String | 有限長度字串 |
Boolean | 布林值,
true |
false ,僅允許作為 Attribute 使用 |
Integer | 4bytes 整數,範圍 -2147483648 ~ 2147483647 |
Unsigned Integer | 4bytes 無號整數,範圍 0 ~ 2147483647 |
Long | 長整數,範圍 -9223372036854775807 ~ 9223372036854775807 |
Unsigned Long | 8bytes 無號長整數,範圍 0 ~ 9223372036854775807 |
Double | 浮點數,範圍 -1.7976931348623158E+308 ~ 1.7976931348623158+308,僅允許作為 Attribute 使用 |
Unsigned Double | 無號浮點數,範圍 0 ~ 1.7976931348623158E+308,僅允許作為 Attribute 使用 |
名稱 | 必要性 | 說明 |
---|---|---|
X-Omni-Sid | YES | OmiStor Security ID |
Authorization | YES | 驗證 SID 是否合法,產生過程需與帶入 SID 匹配 |
X-Omni-Action | YES | 欲執行的動作 |
X-Omni-Service | YES | Service Name |
X-Forwarded-For | Log Option | 提供 Logger 紀錄操作 IP,若是未帶入則使用 remote IP |
X-Omni-CV | Log Option | 提供 Logger 記錄 Client Version |
X-Omni-OV | Log Option | 提供 Logger 記錄 OS version |
X-Omni-CT | Log Option | 提供 Logger 記錄 Client Type |
X-Omni-Req-Encoding | Optional |
gzip : 宣告 request payload 使用 gzip 壓縮 |
X-Omni-Resp-Encoding | Optional |
gzip : 要求 response payload 使用 gzip 壓縮 |
X-Omni-Encoding | Optional |
gzip : 指定 request 及 response payload 皆使用 gzip 壓縮 |
Origin | Optional | CORS 呼叫時,傳入呼叫方 domain |
名稱 | 必要性 | 說明 |
---|---|---|
X-Omni-RequestId | YES | 該次 API 呼叫所對應之 UUID |
X-Omni-Status | YES | 執行狀態 |
X-Omni-Status-Message | YES | 執行狀態說明 |
X-Omni-Message | Optional | 當有發生錯時會回傳錯誤說明 |
Content-Encoding | Optional |
gzip : response payload 使用 gzip 壓縮時傳回 |
X-Content-Type-Options | Optional |
nosniff : 當為 CORS 時傳回 |
Access-Control-Allow-Credentials | Optional |
rue : 當 CORS 時傳回 |
Access-Control-Allow-Methods | Optional |
OPTIONS ,
HEAD ,
GET ,
POST ,
PUT : 當 CORS 時傳回 |
Access-Control-Expose-Headers | Optional |
Status ,
X-Omni-RequestId ,
X-Omni-Status ,
X-Omni-Status-Message ,
X-Omni-Message ,
Content-Encoding : 當 CORS 時傳回 |
Access-Control-Allow-Origin | Optional |
* : 當 CORS 時傳回 |
運算條件 | 說明 | 值域型態 |
---|---|---|
= | 等於,型態需與設定欄位相同 | 單一值 |
BETWEEN | 範圍查詢,包含前後值,型態需與設定欄位相同 | LIST,size 為 2 |
<> | 不等於,同部分 SQL 版本支援之
!=
|
單一值 |
> | 大於,型態需與設定欄位相同 | 單一值 |
< | 小於,型態需與設定欄位相同 | 單一值 |
>= | 不小於(大於或等於),型態需與設定欄位相同 | 單一值 |
<= | 不大於(小於或等於),型態需與設定欄位相同 | 單一值 |
LIKE | 查詢某種 pattern,需用
% 至於前或後或是同時 |
單一值 |
IN | 查詢內容於列表內 | List (1至多個) |
NOT IN | 查詢內容不在列表內 | List (1至多個) |
{ "schemaname": "schema_template", "keyconditions" : [ [ "time", "BETWEEN", [ "2016-02-23 14:15:17", "2016-02-23 14:15:18" ] ], [ "name", "=", "tsdBtestAccount" ], [ "status", "IN", ["OPEN","INIT"], [ "alias", "<>", " "] ] ] }
POST / HTTP/1.1 X-Omni-Sid: {SID} X-Omni-Action: PutEntries X-Omni-Service: {Service Name} Authorization: {Authorization String} { "schemaname": "schema_template", "entries": [{"number":"123","ulong":9223372036854775807,"deleted":true,"test":"2017-11-09 10:10:26","uinteger":2147483647,"double":-1.7976931348623157,"udouble":1.7976931348623157,"integer":-2147483648,"time":"2017-11-09 10:10:26","value":"abc123","long":-9223372036854775807}] }
HTTP/1.1 200 X-Omni-RequestId:826c8c47b4765eb2b7abb8b553a5a13d X-Omni-Status:0 X-Omni-Status-Message:SUCCESS {}
attrubute_name
,
query_operator
,
query_value
]
Query Operator
單元。=
指定要某一 attribute (通常為 deviceid, asusaccount 或是 userid),或以 query operator
BETWEEN
指定查詢時間範圍。POST / HTTP/1.1 X-Omni-Sid: {SID} X-Omni-Action: Query X-Omni-Service: {Service Name} Authorization: {Authorization String} { "schemaname": "test", "limit" : 100, "query_attributes" : ["deleted","time","integer","uinteger","long","ulong","double","udouble","number"], "keyconditions" : [["time","BETWEEN",["2016-10-01 00:00:00","2017-11-09 10:34:26"]]] }
HTTP/1.1 200 X-Omni-RequestId: 961da734cef9dd53856b308c083e1a21 X-Omni-Status: 0 X-Omni-Status-Message: SUCCESS { "schemaname": "test", "entries": [{"number":"123","ulong":9223372036854775807,"deleted":true,"uinteger":2147483647,"double":-1.7976931348623157,"udouble":1.7976931348623157,"integer":-2147483648,",time":"2017-11-09 10:10:26","long":-9223372036854775807}] }
Java
Status Code | Description |
---|---|
0 | Success |
2 | Authentication Fail |
5 | Authorization Fail |
6 | Encoding Not Support |
201 | AUTH Input Data FAIL |
280 | AUTH Unauthorized |
281 | scope privilege violation on destination |
282 | scope privilege violation on source |
283 | client id not match original request |
300 | Stream Exception |
301 | Xml Stream Exception |
302 | JSON Stream Exception |
310 | Required Field Validator Exception |
311 | Field Format Exception |
312 | Empty Input Exception |
313 | ServiceName Validation Exception |
314 | SchemaName Validation Exception |
315 | AttributeName Validation Exception |
316 | AttributeType NOT SET Exception |
317 | AttributeType Validation Exception |
318 | SucKey Is Duplicatecess |
319 | Attribute Is Duplicate |
320 | SID Is Duplicate |
350 | X Omni Action NOT SET |
351 | X Omni Service NOT SET |
352 | Schemaname NOT SET |
353 | Schema Sids NOT SET |
354 | SidControl SID NOT SET |
355 | SidControl Role NOT SET |
356 | SidControl SID NOT VALIDATE |
357 | Schema Key Schema NOT SET |
358 | Schema Key Schema Size NOT Allow |
359 | Schema Key Schema Setting NOT Allow |
360 | Schema Key Schema Range NOT Allow |
361 | Schema Key Schema S NOT Allow |
370 | Query Condition Format Exception |
371 | Query Conditionin Is Duplicate |
372 | Query Conditionin Is Not Setting In Schema |
373 | Query Conditionin ASUSACCOUNT Is Duplicate |
374 | Query Conditionin ASUSACCOUNT Operator Is Not Validate |
375 | Query Conditionin Input Is Not Validate |
376 | Query Conditionin Not Include Any Key |
391 | Query Attributes Is not Validate |
392 | Query Return Is not Validate |
393 | Query NumberFormatException |
394 | Query Funcs Is not Validate |
395 | Query Funcs Format Exception |
396 | Query Funcs Column Is not Validate |
397 | Query Limit not Validate |
404 | Schema Not Found |
405 | SCHEMA ACTION NOT SUPPORT |
410 | SERVICE NOT EXIST |
411 | X Omni Action NOT SUPPORT |
440 | Table Not Found |
501 | SID NOT Authorize |
502 | SID CHECK ACL FAIL |
600 | SERVICE ISEXISTED |
601 | SCHEMA ISEXISTED |
700 | ADVANCEDQUERY NOTSUPPORT |
701 | Advanced Query Not Support Change Schema |
900 | System Error |
901 | Need Retry Error |
980 | System TimeOut |
999 | A general error |