...
To create a new object. On success, the method always returns the internal object id of the newly created objectParameters:
{
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "attrs":{list of attribute value pairs} } |
...
| Code Block | ||||
|---|---|---|---|---|
|
...
{ |
...
"result":{"id":the id of the newly created object} |
...
} |
Examples:
Method:/user/create
| Code Block | ||||
|---|---|---|---|---|
|
...
{ |
...
"attrs": |
...
{ "domain.id":2, |
...
"name":"John Smith", |
...
"email":"js@acme.com" |
...
}
} |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "error":0, "result":{"id": |
...
"1234567890abcd"} |
...
} |
Method:/token/create
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"attrs":
{
"user.id":"user id",
"product.id":"product id"
}
} |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "error":0, "result":{"id": |
...
"1234567890abcd"} } |
| Anchor | ||||
|---|---|---|---|---|
|
| Anchor | ||||
|---|---|---|---|---|
|
To delete an object. The request parameter MUST be the internal id of the object to be deleted. On success the method returns error 0.
Parameters: {"id":the id of the object to be deleted}
Response: {"error":0}
Example:
Method:/user/deleteParameters: {
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "id": |
...
"1234567890abcd"
} |
| Code Block | ||||
|---|---|---|---|---|
|
...
{ "error":0 } |
| Anchor | ||||
|---|---|---|---|---|
|
| Anchor | ||||
|---|---|---|---|---|
|
To retrieve the object's attributes. The request must provide an array of attributes that are to be retrieved. On success the method returns a list of attribute value pairs.
Parameters:
\{
Wiki Markup
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "match": |
...
[array of expressions |
...
], "return": |
...
[array of attribute names |
...
]
|
...
} |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "result": |
...
{list of attribute pairs |
...
} |
...
} |
See /object/search for the description of match expression and conditions.
+Example:+ Method:/user/get Parameters: \{ "Match":\
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "match": [ ["id","=", |
...
"userid"] ], "return": |
...
["name","email","phone" |
...
]
|
...
} |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "error":0, "result": |
...
{ "name":"JohnSmith", "email":"js@acme.com", "phone":"442088654321" |
...
} |
...
} |
...
Notes:
...
To
...
return
...
all
...
simple
...
type
...
attributes,
...
use
...
"*"
...
in
...
the
...
return
...
array.
...
(Object
...
and
...
collection
...
attribute
...
has
...
to
...
be
...
specified
...
explicitly)
| Anchor | ||||
|---|---|---|---|---|
|
| Anchor | ||||
|---|---|---|---|---|
|
To set the object's attributes. The request must provide a list of attributes and values that are to be set. On success the method returns error 0.
| Code Block | ||||
|---|---|---|---|---|
|
...
{ |
...
"id":"the id of the object to be edited", |
...
"attrs":{list of attribute pairs} } |
...
| Code Block | ||||
|---|---|---|---|---|
|
...
{ "error":0 } |
Example:
Method:/user/set
| Code Block | ||||
|---|---|---|---|---|
|
...
{ |
...
"id": |
...
"user id", "attrs": |
...
{ "name":"John Smith", |
...
"email":"js@acme.com" |
...
}
} |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "error":0 } |
| Anchor | ||||
|---|---|---|---|---|
|
| Anchor | ||||
|---|---|---|---|---|
|
...
- the name of the attribute
- the operator
- the value to be matched
For example:
\Wiki Markup
["id","=",
...
2
...
]
Matching operators supported:
String
...
operators:
| Operator | Function |
|---|---|
| = | equals to |
| >> | starts with |
| << | ends with |
| ~= | like |
| like | like |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "match":[ ["firstName","=", "john" |
...
] |
...
, ["email","like", "j%acme.com" |
...
] ] } |
Integer
...
operators:
| Operator | Function |
|---|---|
| = | equals to |
| >= | greater than or equals to |
| <= | less than or equals to |
| > | greater than |
| < | less than |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"match":[
["failCount",">", "3"]
]
} |
Date operators:
| Operator | Function |
|---|---|
| = | equals to |
| > | after |
| < | before |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "match":[ ["lastChangePassword", "<", "2019-01-12T12:00:00Z" |
...
]
|
...
]
} |
Notes: all date value should be in ISO 8601 format.
Request parameters and response:
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "match": |
...
[list of attributes to be matched |
...
] "return": |
...
[array of attributes to be returned |
...
] "sort": attribute to be sorted by "order":"asc" | "desc" "max": the maximum numbers of records to return "offset": the offset |
...
} |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "error": 0, "result": |
...
[array of list of |
...
objects] |
...
} |
...
Example:
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "match": |
...
[ |
...
["domain.id", "=", |
...
"domain id"], |
...
[" |
...
lastName", "=", "smith" |
...
],
|
...
["email", " |
...
~=", " |
...
%@acme.com |
...
" |
...
], |
...
], "return": |
...
[" |
...
firstName", " |
...
lastName", "email", " |
...
telephone" |
...
], "sort":" |
...
lastName", "order":"asc", "max": 20, "offset": 10 |
...
} |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "error": 0, "result": |
...
{ "total": 20, "rows": |
...
[ |
...
{ |
...
"firstName":"John", |
...
"lastName":"Smith", "email":"js@acme.com", " |
...
telephone":"447974321234", |
...
}, |
...
{ "firstname":"David", "lastname":"Smith", "email":"ds@acme.com", |
...
"telephone":"447974234975", |
...
},
...
]
}
}
|
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "match": |
...
[ |
...
[" |
...
product.id", "=", |
...
"product id"] ], "return": |
...
["serial" |
...
], "sort": |
...
"serial" |
...
,
"order":"asc",
"max": 20,
"offset": 10
} |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "error": 0, "result": |
...
{ "total": |
...
20, "rows": |
...
[ {"serial":"77004155" |
...
},
|
...
{"serial":"77004245" |
...
},
|
...
{"serial":"77004266" |
...
},
|
...
{"serial":"77004321" |
...
},
|
...
...
]
}
}
|