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