Mercurial > public > src > rhodecode
annotate docs/api/api.rst @ 1895:203af05539e0 beta
implements #330 api method for listing nodes at particular revision
- improved filtering by files in file list
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 28 Dec 2011 04:12:27 +0200 |
parents | 631caf880b87 |
children | 320dec24fb9a |
rev | line source |
---|---|
1526 | 1 .. _api: |
2 | |
3 | |
4 API | |
5 === | |
6 | |
7 | |
8 Starting from RhodeCode version 1.2 a simple API was implemented. | |
1580 | 9 There's a single schema for calling all api methods. API is implemented |
1676 | 10 with JSON protocol both ways. An url to send API request in RhodeCode is |
1580 | 11 <your_server>/_admin/api |
1526 | 12 |
13 | |
1793
fee9895fa46e
changed API to match fully JSON-RPC specs
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
14 All clients are required to send JSON-RPC spec JSON data:: |
1526 | 15 |
1793
fee9895fa46e
changed API to match fully JSON-RPC specs
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
16 { |
fee9895fa46e
changed API to match fully JSON-RPC specs
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
17 "id:<id>, |
1526 | 18 "api_key":"<api_key>", |
19 "method":"<method_name>", | |
20 "args":{"<arg_key>":"<arg_val>"} | |
21 } | |
22 | |
1580 | 23 Example call for autopulling remotes repos using curl:: |
1793
fee9895fa46e
changed API to match fully JSON-RPC specs
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
24 curl https://server.com/_admin/api -X POST -H 'content-type:text/plain' --data-binary '{"id":1,"api_key":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull","args":{"repo":"CPython"}}' |
1580 | 25 |
1676 | 26 Simply provide |
1793
fee9895fa46e
changed API to match fully JSON-RPC specs
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
27 - *id* A value of any type, which is used to match the response with the request that it is replying to. |
1580 | 28 - *api_key* for access and permission validation. |
29 - *method* is name of method to call | |
30 - *args* is an key:value list of arguments to pass to method | |
1676 | 31 |
1526 | 32 .. note:: |
1676 | 33 |
34 api_key can be found in your user account page | |
35 | |
36 | |
1793
fee9895fa46e
changed API to match fully JSON-RPC specs
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
37 RhodeCode API will return always a JSON-RPC response:: |
1676 | 38 |
1793
fee9895fa46e
changed API to match fully JSON-RPC specs
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
39 { |
fee9895fa46e
changed API to match fully JSON-RPC specs
Marcin Kuzminski <marcin@python-works.com>
parents:
1676
diff
changeset
|
40 "id":<id>, |
1676 | 41 "result": "<result>", |
1526 | 42 "error": null |
43 } | |
44 | |
45 All responses from API will be `HTTP/1.0 200 OK`, if there's an error while | |
1676 | 46 calling api *error* key from response will contain failure description |
1526 | 47 and result will be null. |
48 | |
49 API METHODS | |
50 +++++++++++ | |
51 | |
1676 | 52 |
1526 | 53 pull |
54 ---- | |
55 | |
1676 | 56 Pulls given repo from remote location. Can be used to automatically keep |
57 remote repos up to date. This command can be executed only using api_key | |
1580 | 58 belonging to user with admin rights |
59 | |
60 INPUT:: | |
61 | |
1676 | 62 api_key : "<api_key>" |
63 method : "pull" | |
64 args : { | |
65 "repo" : "<repo_name>" | |
66 } | |
67 | |
68 OUTPUT:: | |
69 | |
70 result : "Pulled from <repo_name>" | |
71 error : null | |
72 | |
73 | |
74 get_users | |
75 --------- | |
76 | |
77 Lists all existing users. This command can be executed only using api_key | |
78 belonging to user with admin rights. | |
79 | |
80 INPUT:: | |
81 | |
82 api_key : "<api_key>" | |
83 method : "get_users" | |
84 args : { } | |
85 | |
86 OUTPUT:: | |
87 | |
88 result: [ | |
89 { | |
90 "id" : "<id>", | |
91 "username" : "<username>", | |
92 "firstname": "<firstname>", | |
93 "lastname" : "<lastname>", | |
94 "email" : "<email>", | |
95 "active" : "<bool>", | |
96 "admin" : "<bool>", | |
97 "ldap" : "<ldap_dn>" | |
98 }, | |
99 … | |
100 ] | |
101 error: null | |
102 | |
103 create_user | |
104 ----------- | |
105 | |
106 Creates new user in RhodeCode. This command can be executed only using api_key | |
107 belonging to user with admin rights. | |
108 | |
109 INPUT:: | |
110 | |
111 api_key : "<api_key>" | |
112 method : "create_user" | |
113 args : { | |
114 "username" : "<username>", | |
115 "password" : "<password>", | |
116 "firstname" : "<firstname>", | |
117 "lastname" : "<lastname>", | |
118 "email" : "<useremail>" | |
119 "active" : "<bool> = True", | |
120 "admin" : "<bool> = False", | |
121 "ldap_dn" : "<ldap_dn> = None" | |
122 } | |
1580 | 123 |
124 OUTPUT:: | |
125 | |
1676 | 126 result: { |
127 "msg" : "created new user <username>" | |
128 } | |
129 error: null | |
130 | |
131 get_users_groups | |
132 ---------------- | |
133 | |
134 Lists all existing users groups. This command can be executed only using api_key | |
135 belonging to user with admin rights. | |
136 | |
137 INPUT:: | |
138 | |
139 api_key : "<api_key>" | |
140 method : "get_users_groups" | |
141 args : { } | |
142 | |
143 OUTPUT:: | |
144 | |
145 result : [ | |
146 { | |
147 "id" : "<id>", | |
148 "name" : "<name>", | |
149 "active": "<bool>", | |
150 "members" : [ | |
151 { | |
152 "id" : "<userid>", | |
153 "username" : "<username>", | |
154 "firstname": "<firstname>", | |
155 "lastname" : "<lastname>", | |
156 "email" : "<email>", | |
157 "active" : "<bool>", | |
158 "admin" : "<bool>", | |
159 "ldap" : "<ldap_dn>" | |
160 }, | |
161 … | |
162 ] | |
163 } | |
164 ] | |
165 error : null | |
166 | |
167 get_users_group | |
168 --------------- | |
169 | |
170 Gets an existing users group. This command can be executed only using api_key | |
171 belonging to user with admin rights. | |
172 | |
173 INPUT:: | |
174 | |
175 api_key : "<api_key>" | |
176 method : "get_users_group" | |
177 args : { | |
178 "group_name" : "<name>" | |
179 } | |
180 | |
181 OUTPUT:: | |
182 | |
183 result : None if group not exist | |
184 { | |
185 "id" : "<id>", | |
186 "name" : "<name>", | |
187 "active": "<bool>", | |
188 "members" : [ | |
189 { "id" : "<userid>", | |
190 "username" : "<username>", | |
191 "firstname": "<firstname>", | |
192 "lastname" : "<lastname>", | |
193 "email" : "<email>", | |
194 "active" : "<bool>", | |
195 "admin" : "<bool>", | |
196 "ldap" : "<ldap_dn>" | |
197 }, | |
198 … | |
199 ] | |
200 } | |
201 error : null | |
202 | |
1580 | 203 create_users_group |
204 ------------------ | |
205 | |
1676 | 206 Creates new users group. This command can be executed only using api_key |
1580 | 207 belonging to user with admin rights |
208 | |
209 INPUT:: | |
210 | |
1676 | 211 api_key : "<api_key>" |
212 method : "create_users_group" | |
213 args: { | |
214 "name": "<name>", | |
215 "active":"<bool> = True" | |
216 } | |
217 | |
218 OUTPUT:: | |
219 | |
220 result: { | |
221 "id": "<newusersgroupid>", | |
222 "msg": "created new users group <name>" | |
223 } | |
224 error: null | |
225 | |
1878
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
226 add_user_to_users_group |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
227 ----------------------- |
1676 | 228 |
229 Adds a user to a users group. This command can be executed only using api_key | |
230 belonging to user with admin rights | |
231 | |
232 INPUT:: | |
233 | |
234 api_key : "<api_key>" | |
235 method : "add_user_users_group" | |
236 args: { | |
237 "group_name" : "<groupname>", | |
1895
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
238 "username" : "<username>" |
1676 | 239 } |
240 | |
241 OUTPUT:: | |
242 | |
243 result: { | |
244 "id": "<newusersgroupmemberid>", | |
245 "msg": "created new users group member" | |
246 } | |
247 error: null | |
248 | |
249 get_repos | |
250 --------- | |
251 | |
252 Lists all existing repositories. This command can be executed only using api_key | |
253 belonging to user with admin rights | |
254 | |
255 INPUT:: | |
256 | |
257 api_key : "<api_key>" | |
258 method : "get_repos" | |
259 args: { } | |
1580 | 260 |
261 OUTPUT:: | |
262 | |
1676 | 263 result: [ |
264 { | |
265 "id" : "<id>", | |
266 "name" : "<name>" | |
267 "type" : "<type>", | |
268 "description" : "<description>" | |
269 }, | |
270 … | |
271 ] | |
272 error: null | |
273 | |
274 get_repo | |
275 -------- | |
276 | |
277 Gets an existing repository. This command can be executed only using api_key | |
278 belonging to user with admin rights | |
279 | |
280 INPUT:: | |
281 | |
282 api_key : "<api_key>" | |
283 method : "get_repo" | |
284 args: { | |
285 "name" : "<name>" | |
286 } | |
287 | |
288 OUTPUT:: | |
289 | |
290 result: None if repository not exist | |
291 { | |
292 "id" : "<id>", | |
293 "name" : "<name>" | |
294 "type" : "<type>", | |
295 "description" : "<description>", | |
296 "members" : [ | |
297 { "id" : "<userid>", | |
298 "username" : "<username>", | |
299 "firstname": "<firstname>", | |
300 "lastname" : "<lastname>", | |
301 "email" : "<email>", | |
302 "active" : "<bool>", | |
303 "admin" : "<bool>", | |
304 "ldap" : "<ldap_dn>", | |
1878
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
305 "permission" : "repository.(read|write|admin)" |
1676 | 306 }, |
307 … | |
308 { | |
309 "id" : "<usersgroupid>", | |
310 "name" : "<usersgroupname>", | |
311 "active": "<bool>", | |
1878
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
312 "permission" : "repository.(read|write|admin)" |
1676 | 313 }, |
314 … | |
315 ] | |
316 } | |
317 error: null | |
318 | |
1895
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
319 get_repo_nodes |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
320 -------------- |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
321 |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
322 returns a list of nodes and it's children in a flat list for a given path |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
323 at given revision. It's possible to specify ret_type to show only files or |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
324 dirs. This command can be executed only using api_key belonging to user |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
325 with admin rights |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
326 |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
327 INPUT:: |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
328 |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
329 api_key : "<api_key>" |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
330 method : "get_repo_nodes" |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
331 args: { |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
332 "repo_name" : "<name>", |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
333 "revision" : "<revision>", |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
334 "root_path" : "<root_path>", |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
335 "ret_type" : "<ret_type>" = 'all' |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
336 } |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
337 |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
338 OUTPUT:: |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
339 |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
340 result: [ |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
341 { |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
342 "name" : "<name>" |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
343 "type" : "<type>", |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
344 }, |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
345 … |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
346 ] |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
347 error: null |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
348 |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
349 |
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
350 |
1676 | 351 create_repo |
352 ----------- | |
353 | |
354 Creates a repository. This command can be executed only using api_key | |
355 belonging to user with admin rights. | |
356 If repository name contains "/", all needed repository groups will be created. | |
357 For example "foo/bar/baz" will create groups "foo", "bar" (with "foo" as parent), | |
358 and create "baz" repository with "bar" as group. | |
359 | |
360 INPUT:: | |
361 | |
362 api_key : "<api_key>" | |
363 method : "create_repo" | |
364 args: { | |
365 "name" : "<name>", | |
366 "owner_name" : "<ownername>", | |
367 "description" : "<description> = ''", | |
368 "repo_type" : "<type> = 'hg'", | |
369 "private" : "<bool> = False" | |
370 } | |
371 | |
372 OUTPUT:: | |
373 | |
374 result: None | |
375 error: null | |
376 | |
377 add_user_to_repo | |
378 ---------------- | |
379 | |
380 Add a user to a repository. This command can be executed only using api_key | |
381 belonging to user with admin rights. | |
382 If "perm" is None, user will be removed from the repository. | |
383 | |
384 INPUT:: | |
385 | |
386 api_key : "<api_key>" | |
387 method : "add_user_to_repo" | |
388 args: { | |
389 "repo_name" : "<reponame>", | |
1895
203af05539e0
implements #330 api method for listing nodes at particular revision
Marcin Kuzminski <marcin@python-works.com>
parents:
1878
diff
changeset
|
390 "username" : "<username>", |
1878
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
391 "perm" : "(None|repository.(read|write|admin))", |
1676 | 392 } |
393 | |
394 OUTPUT:: | |
395 | |
396 result: None | |
397 error: null | |
1878
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
398 |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
399 add_users_group_to_repo |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
400 ----------------------- |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
401 |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
402 Add a users group to a repository. This command can be executed only using |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
403 api_key belonging to user with admin rights. If "perm" is None, group will |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
404 be removed from the repository. |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
405 |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
406 INPUT:: |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
407 |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
408 api_key : "<api_key>" |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
409 method : "add_users_group_to_repo" |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
410 args: { |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
411 "repo_name" : "<reponame>", |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
412 "group_name" : "<groupname>", |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
413 "perm" : "(None|repository.(read|write|admin))", |
631caf880b87
implements #329
Marcin Kuzminski <marcin@python-works.com>
parents:
1793
diff
changeset
|
414 } |