README.md 2.49 KB
Newer Older
Mihkel Putrinš's avatar
Mihkel Putrinš committed
1
2
3
entulib
=======

Mihkel Putrinš's avatar
Mihkel Putrinš committed
4
Library for authenticated access to Entu database API
5

6
## 7 javascript (5 python) methods to please your application
Mihkel Putrinš's avatar
Mihkel Putrinš committed
7
8
9

### python 3
#### class EntuLib():
Mihkel Putrinš's avatar
Mihkel Putrinš committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
\__init__(self, entu_user_id, entu_user_key, entu_url):  
>
>  - def get_entity(self, entity_id):  
>    - on success return {result: entity, time: 0.009}
>    - else return {time: 0.009, error: "Entity with given ID is not found!"}
>  - def find_entity(self, definition, query, limit=1000000):
>    - on success return { count: count, result: [entitylist], time: 0.011}
>    - else return { count: 0, result: [], time: 0.086 }
>  - def create_entity(self, parent_id, definition, properties={}):
>    - on success return {result: { id: 685 }, time: 0.073}
>    - else return {time: 0.01, error: message}
>  - def add_properties(self, entity_id, definition, properties):
>    - on success return {result: { id: '686' }, time: 0.024}
>    - else return {time: 0.018, error: message}
>  - def add_file(self, entity_id, property_definition, abspath):
>    - on success return {time: 0.088}
>    - else return {time: 0.018, error: message}
Mihkel Putrinš's avatar
Mihkel Putrinš committed
27
28
29
30


### javascript
#### var EntuLib = function EntuLib(entu_user_id, entu_user_key, entu_url)
31
> - getEntity: function (entity_id, callback)
Mihkel Putrinš's avatar
Mihkel Putrinš committed
32
33
>    - on success callback ({result: entity, time: 0.009})
>    - else callback ({time: 0.009, error: "Entity with given ID is not found!"})
34
> - getChilds: function (entity_id, callback)
35
36
>    - on success callback ({count: count, result: {}, time: 0.097})
>    - else callback ({count: 0, result: {definition: {entities:[entities]}}, time: 0.094})
37
> - getReferrals: function (entity_id, callback)
38
39
>    - on success callback ({result: entity, time: 0.009})
>    - else callback ({count: 0, result: {definition: {entities:[entities]}}, time: 0.095})
40
> - findEntity: function (definition, query, limit, callback)
Mihkel Putrinš's avatar
Mihkel Putrinš committed
41
42
>    - on success callback ({ count: count, result: [entitylist], time: 0.011})
>    - else callback ({ count: 0, result: [], time: 0.086 })
43
> - createEntity: function (parent_id, definition, properties, callback)
Mihkel Putrinš's avatar
Mihkel Putrinš committed
44
45
>    - on success callback ({result: { id: 685 }, time: 0.073})
>    - else callback ({time: 0.01, error: message})
46
> - addProperties: function (entity_id, definition, properties, callback)
Mihkel Putrinš's avatar
Mihkel Putrinš committed
47
48
>    - on success callback ({result: { id: '686' }, time: 0.024})
>    - else callback ({time: 0.018, error: message})
49
> - addFile: function (entity_id, property_definition, abspath, callback)
Mihkel Putrinš's avatar
Mihkel Putrinš committed
50
51
>    - on success callback ({time: 0.088})
>    - else callback ({time: 0.018, error: message})