rhosync_api 0.0.6 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -2
- data/LICENSE +3 -3
- data/README +125 -29
- data/lib/rho-api-connect.rb +535 -0
- data/lib/rho-sources.rb +97 -0
- data/lib/rhosync_api.rb +61 -343
- metadata +71 -40
data/History.txt
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
version 0.0.1 - 5 August 2011 - firts test of the gem
|
3
3
|
version 0.0.2 - 5 August 2011 - fixing methods
|
4
4
|
version 0.0.3 - 5 August 2011 - added new api methods
|
5
|
-
version 0.0.4 - 6 August 2011 - error
|
5
|
+
version 0.0.4 - 6 August 2011 - error, this version is not working at all.
|
6
6
|
version 0.0.5 - 6 August 2011 - firts stable release
|
7
|
-
|
7
|
+
version 0.0.6 - 7 August 2001 - added README file and changed class RhosyncApi to module RhosyncApi
|
8
|
+
|
9
|
+
version 0.1.0 - 27 August 2011 - Gem name was changed from Rhosync_Api to RhoApi due conflicts with RhosyncApi module
|
10
|
+
- Added methods find, create, delete, delete_all
|
11
|
+
- Added methods push_objects and push_deletes, update_user
|
data/LICENSE
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
Created by Raul Mantilla Assia (2011)
|
1
|
+
Created by Raul Mantilla Assia (2011)
|
2
|
+
Any comments or questions to rmantilla26@hotmail.com
|
2
3
|
|
3
|
-
Based on the rhomobile documentation
|
4
4
|
|
5
|
-
|
5
|
+
Based on the rhomobile documentation
|
6
6
|
|
7
7
|
http://docs.rhomobile.com/rhosync/rest-api
|
8
8
|
|
data/README
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
|
1
|
+
Created by Raul Mantilla Assia (2011)
|
2
|
+
Any comments or questions to rmantilla26@hotmail.com
|
3
|
+
|
4
|
+
Based on the rhomobile documentation
|
5
|
+
|
6
|
+
http://docs.rhomobile.com/rhosync/rest-api
|
7
|
+
|
8
|
+
=rhosync_api
|
2
9
|
|
3
10
|
With this gem you can connect to the rhosync API very easy.
|
4
11
|
|
@@ -8,10 +15,60 @@ With this gem you can connect to the rhosync API very easy.
|
|
8
15
|
|
9
16
|
=HOW TO
|
10
17
|
|
11
|
-
require "rubygems"
|
12
|
-
require "rhosync_api"
|
18
|
+
require "rubygems"
|
19
|
+
require "rhosync_api"
|
20
|
+
|
21
|
+
RhoApi."method"
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
=SIMULATING ACTIVERECORD (Beta version, not completed)
|
26
|
+
A new feature was added to this gem, after the login method, the gem will get all the source adapters
|
27
|
+
and simulate a rails active record.
|
28
|
+
that means that we can do simples find, create, delete methods like:
|
29
|
+
|
30
|
+
RhoApi.Contacts.find("Test_user",:conditions=>{:object=>"0001"})
|
31
|
+
RhoApi.Contacts.create("Test_user",{ "0001"=>{"name"=>"Raul","lastname"=>"Mantilla"} } )
|
32
|
+
RhoApi.Contacts.delete("Test_user","0003")
|
33
|
+
RhoApi.Contacts.delete_all("Test_user")
|
34
|
+
|
35
|
+
|
36
|
+
=FIND
|
37
|
+
with this method you can search data inside a source adapter, right now is only avaliable to search by "object id"
|
38
|
+
or using AND conditionals, in the future will be OR, ORDER, and more conditions.
|
39
|
+
<source_name> = is the Source name, should be the same name in the rhosync setting.yml file
|
40
|
+
<user_id> = is the User name or login ID.
|
41
|
+
|
42
|
+
RhoApi.<source_name>.find("<user_id>",:conditions=>{:object=>"0001"})
|
43
|
+
RhoApi.<source_name>.find("<user_id>",:conditions=>{"field1"=>"value1","field2"=>"value2"})
|
44
|
+
|
45
|
+
|
46
|
+
=CREATE
|
47
|
+
with the create method you can insert new records into a given source adapter. and user id
|
48
|
+
<source_name> = is the Source name, should be the same name in the rhosync setting.yml file
|
49
|
+
<user_id> = is the User name or login ID.
|
50
|
+
DATA : Data should be a hash of hashes. {"0001"=>{"field1"=>"value","field2"=>"value2"},.....}
|
51
|
+
you can insert multiple record in the same query.
|
52
|
+
|
53
|
+
RhoApi.<source_name>.create("<user_id>",data)
|
54
|
+
|
55
|
+
=DELETE
|
56
|
+
with the delete method you can delete records from a given source adapter and user id
|
57
|
+
<source_name> = is the Source name, should be the same name in the rhosync setting.yml file
|
58
|
+
<user_id> = is the User name or login ID.
|
59
|
+
OBJECTS ID : Data should be an Array of objects IDs ["0001","0002"]
|
60
|
+
could be also a string "0001" if you want to delete only one value
|
61
|
+
|
62
|
+
RhoApi.<source_name>.delete("<user_id>",objects)
|
63
|
+
|
64
|
+
=DELETE_ALL
|
65
|
+
with this method you can delete all the data in a given source adapter and user id
|
66
|
+
<source_name> = is the Source name, should be the same name in the rhosync setting.yml file
|
67
|
+
<user_id> = is the User name or login ID.
|
68
|
+
|
69
|
+
RhoApi.<source_name>.delete_all("<user_id>")
|
70
|
+
|
13
71
|
|
14
|
-
RhosyncApi."method"
|
15
72
|
|
16
73
|
=METHODS
|
17
74
|
|
@@ -23,6 +80,7 @@ RhosyncApi."method"
|
|
23
80
|
- ping
|
24
81
|
- list_users
|
25
82
|
- create_user
|
83
|
+
- update_user
|
26
84
|
- delete_user
|
27
85
|
- list_clients
|
28
86
|
- create_client
|
@@ -41,7 +99,7 @@ RhosyncApi."method"
|
|
41
99
|
=LOGIN
|
42
100
|
this method is used to authenticate with rhosync server
|
43
101
|
|
44
|
-
|
102
|
+
RhoApi.login("http://localhost:3000","rhoadmin","")
|
45
103
|
|
46
104
|
params:
|
47
105
|
- RHOSYNC URL
|
@@ -53,12 +111,12 @@ RhosyncApi."method"
|
|
53
111
|
|
54
112
|
=LOGOUT
|
55
113
|
This method set token variable to nil
|
56
|
-
|
114
|
+
RhoApi.logout
|
57
115
|
|
58
116
|
|
59
117
|
=GET_API_TOKEN
|
60
118
|
|
61
|
-
|
119
|
+
RhoApi.get_api_token
|
62
120
|
|
63
121
|
return:
|
64
122
|
this method returns the rhosync token, with this token you can authenticate to rhosync
|
@@ -66,21 +124,21 @@ RhosyncApi."method"
|
|
66
124
|
|
67
125
|
=GET_LICENSE_INFO
|
68
126
|
|
69
|
-
|
127
|
+
RhoApi.get_license_info
|
70
128
|
|
71
129
|
return:
|
72
130
|
this method returns all the information about the rhosync license
|
73
131
|
|
74
132
|
=RESET
|
75
133
|
|
76
|
-
|
134
|
+
RhoApi.reset
|
77
135
|
|
78
136
|
this method will reset all the redis information in rhosync
|
79
137
|
|
80
138
|
=PING
|
81
139
|
this method is used to send alerts to devices using rhosync settings
|
82
140
|
|
83
|
-
|
141
|
+
RhoApi.ping(user_id,ping_params)
|
84
142
|
|
85
143
|
params
|
86
144
|
- USER_ID
|
@@ -96,7 +154,7 @@ RhosyncApi."method"
|
|
96
154
|
|
97
155
|
=LIST_USERS
|
98
156
|
|
99
|
-
|
157
|
+
RhoApi.list_users
|
100
158
|
|
101
159
|
return:
|
102
160
|
this method returns an ARRAY of users ID.
|
@@ -104,7 +162,7 @@ RhosyncApi."method"
|
|
104
162
|
=CREATE_USER
|
105
163
|
with this method you can create a new user in rhosync
|
106
164
|
|
107
|
-
|
165
|
+
RhoApi.create_user("username","password")
|
108
166
|
|
109
167
|
params:
|
110
168
|
- USERNAME
|
@@ -112,10 +170,23 @@ RhosyncApi."method"
|
|
112
170
|
return:
|
113
171
|
this method will return nil if it fails
|
114
172
|
|
173
|
+
=UPDATE_USER
|
174
|
+
with this method you can update the user password, be careful this method will change the Admin password, so keep it in mind.
|
175
|
+
tested in rhosync 2.1.6: for some reason went i changed the password the admin password was changed too, i think is a bug in this rhosync version.
|
176
|
+
|
177
|
+
RhoApi.update_user("username","new password")
|
178
|
+
|
179
|
+
params:
|
180
|
+
- USERNAME : any user ID
|
181
|
+
- NEW PASSWORD : thi will be the new password
|
182
|
+
return:
|
183
|
+
this method will return nil if it fails
|
184
|
+
|
185
|
+
|
115
186
|
=DELETE_USER
|
116
187
|
with this method you can delete an existing user in rhosync
|
117
188
|
|
118
|
-
|
189
|
+
RhoApi.delete_user("user_id")
|
119
190
|
|
120
191
|
params:
|
121
192
|
- USERID
|
@@ -125,7 +196,7 @@ RhosyncApi."method"
|
|
125
196
|
=LIST_CLIENTS
|
126
197
|
this method returns a list of devices for a given user ID
|
127
198
|
|
128
|
-
|
199
|
+
RhoApi.list_clients("user_id")
|
129
200
|
|
130
201
|
params:
|
131
202
|
- USERID
|
@@ -135,7 +206,7 @@ RhosyncApi."method"
|
|
135
206
|
=CREATE_CLIENT
|
136
207
|
this method create a device for a given user ID
|
137
208
|
|
138
|
-
|
209
|
+
RhoApi.create_client("user_id")
|
139
210
|
|
140
211
|
params:
|
141
212
|
- USERID
|
@@ -145,7 +216,7 @@ RhosyncApi."method"
|
|
145
216
|
=DELETE_CLIENT
|
146
217
|
this method deletes a device for a given user ID and device ID
|
147
218
|
|
148
|
-
|
219
|
+
RhoApi.delete_client("user_id","device_id")
|
149
220
|
|
150
221
|
params:
|
151
222
|
- USERID
|
@@ -156,7 +227,7 @@ RhosyncApi."method"
|
|
156
227
|
=GET_CLIENT_PARAMS
|
157
228
|
this method returns the attributes of a given device ID, such as device_type, device_pin, device_port.
|
158
229
|
|
159
|
-
|
230
|
+
RhoApi.get_client_params("device_id")
|
160
231
|
|
161
232
|
params:
|
162
233
|
- DEVICE_ID
|
@@ -167,8 +238,8 @@ RhosyncApi."method"
|
|
167
238
|
=LIST_SOURCES
|
168
239
|
this method returns a list rhosync source adapters for a given partition
|
169
240
|
|
170
|
-
|
171
|
-
|
241
|
+
RhoApi.list_sources("partition")
|
242
|
+
RhoApi.list_sources
|
172
243
|
|
173
244
|
params:
|
174
245
|
- PARTITION : this could be "user" or "app" by default if use "user" partition
|
@@ -179,7 +250,7 @@ RhosyncApi."method"
|
|
179
250
|
this method returns the attributes of a given source adapter
|
180
251
|
such as name, poll_interval, partition_type, sync_type, queue, query_queue, cud_queue
|
181
252
|
|
182
|
-
|
253
|
+
RhoApi.get_source_params("source name")
|
183
254
|
|
184
255
|
params:
|
185
256
|
- SOURCE NAME
|
@@ -190,7 +261,7 @@ RhosyncApi."method"
|
|
190
261
|
this method returns a list of document keys associated with given source and user.
|
191
262
|
such as md, md_size, md_copy, errors
|
192
263
|
|
193
|
-
|
264
|
+
RhoApi.list_source_docs("user_id","source_name")
|
194
265
|
|
195
266
|
params:
|
196
267
|
- USER ID
|
@@ -201,8 +272,8 @@ RhosyncApi."method"
|
|
201
272
|
=GET_DB_DOC
|
202
273
|
this method returns the content of a given document key.
|
203
274
|
|
204
|
-
|
205
|
-
|
275
|
+
RhoApi.get_db_doc("document key","data_type")
|
276
|
+
RhoApi.get_db_doc("document key")
|
206
277
|
|
207
278
|
params:
|
208
279
|
- DOCUMENT KEY : this is the document key listed in the LIST_SOURCE_DOCS method
|
@@ -213,8 +284,8 @@ RhosyncApi."method"
|
|
213
284
|
=SET_DB_DOC
|
214
285
|
this method set content of a given document key
|
215
286
|
|
216
|
-
|
217
|
-
|
287
|
+
RhoApi.set_db_doc("document key","data","data_type")
|
288
|
+
RhoApi.set_db_doc("document key","data")
|
218
289
|
|
219
290
|
params:
|
220
291
|
- DOCUMENT KEY : this is the document key listed in the LIST_SOURCE_DOCS method
|
@@ -226,7 +297,7 @@ RhosyncApi."method"
|
|
226
297
|
=LIST_CLIENT_DOC
|
227
298
|
this method returns a list of document keys associated with particular device.
|
228
299
|
|
229
|
-
|
300
|
+
RhoApi.list_client_docs("device_id","source_name")
|
230
301
|
|
231
302
|
params:
|
232
303
|
- DEVICE_ID :
|
@@ -237,7 +308,7 @@ RhosyncApi."method"
|
|
237
308
|
=GET_DB_DOC_BY_TYPE
|
238
309
|
this method returns the content of a given document user and source name.
|
239
310
|
|
240
|
-
|
311
|
+
RhoApi.get_db_doc_by_type("user_id","source_name","type_doc")
|
241
312
|
|
242
313
|
params:
|
243
314
|
- USER ID :
|
@@ -249,7 +320,7 @@ RhosyncApi."method"
|
|
249
320
|
=SET_DB_DOC_BY_TYPE
|
250
321
|
this method set content of a given user id and source name
|
251
322
|
|
252
|
-
|
323
|
+
RhoApi.set_db_doc_by_type("user_id","source_name","data","type_doc")
|
253
324
|
|
254
325
|
params:
|
255
326
|
- USER ID :
|
@@ -258,4 +329,29 @@ RhosyncApi."method"
|
|
258
329
|
- TYPE DOC : such as md, md_size, md_copy, errors
|
259
330
|
return:
|
260
331
|
this method will return nil if it fails
|
261
|
-
|
332
|
+
|
333
|
+
|
334
|
+
=PUSH_OBJECTS
|
335
|
+
this method save data into a given user id and source name
|
336
|
+
|
337
|
+
RhoApi.push_objects("user_id","source_name","data")
|
338
|
+
|
339
|
+
params:
|
340
|
+
- USER ID :
|
341
|
+
- SOURCE NAME:
|
342
|
+
- DATA : Data should be a hash of hashes. {"0001"=>{"field1"=>"value","field2"=>"value2"},.....}
|
343
|
+
return:
|
344
|
+
this method will return nil if it fails
|
345
|
+
|
346
|
+
=PUSH_DELETES
|
347
|
+
this method deletes records in a given user id and source name
|
348
|
+
|
349
|
+
RhoApi.push_deletes("user_id","source_name","data")
|
350
|
+
|
351
|
+
params:
|
352
|
+
- USER ID :
|
353
|
+
- SOURCE NAME:
|
354
|
+
- DATA : Data should be an Array of objects IDs ["0001","0002"], could be also a string "0001"
|
355
|
+
return:
|
356
|
+
this method will return nil if it fails
|
357
|
+
|