Show More
@@ -1,942 +1,959 b'' | |||
|
1 | 1 | .. _api: |
|
2 | 2 | |
|
3 | 3 | === |
|
4 | 4 | API |
|
5 | 5 | === |
|
6 | 6 | |
|
7 | 7 | |
|
8 | 8 | Starting from RhodeCode version 1.2 a simple API was implemented. |
|
9 | 9 | There's a single schema for calling all api methods. API is implemented |
|
10 | 10 | with JSON protocol both ways. An url to send API request to RhodeCode is |
|
11 | 11 | <your_server>/_admin/api |
|
12 | 12 | |
|
13 | 13 | API ACCESS FOR WEB VIEWS |
|
14 | 14 | ++++++++++++++++++++++++ |
|
15 | 15 | |
|
16 | 16 | API access can also be turned on for each web view in RhodeCode that is |
|
17 | 17 | decorated with `@LoginRequired` decorator. To enable API access simple change |
|
18 | 18 | the standard login decorator to `@LoginRequired(api_access=True)`. |
|
19 | 19 | After this change, a rhodecode view can be accessed without login by adding a |
|
20 | 20 | GET parameter `?api_key=<api_key>` to url. By default this is only |
|
21 | 21 | enabled on RSS/ATOM feed views. |
|
22 | 22 | |
|
23 | 23 | |
|
24 | 24 | API ACCESS |
|
25 | 25 | ++++++++++ |
|
26 | 26 | |
|
27 | 27 | All clients are required to send JSON-RPC spec JSON data:: |
|
28 | 28 | |
|
29 | 29 | { |
|
30 | 30 | "id:"<id>", |
|
31 | 31 | "api_key":"<api_key>", |
|
32 | 32 | "method":"<method_name>", |
|
33 | 33 | "args":{"<arg_key>":"<arg_val>"} |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | Example call for autopulling remotes repos using curl:: |
|
37 | 37 | 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"}}' |
|
38 | 38 | |
|
39 | 39 | Simply provide |
|
40 | 40 | - *id* A value of any type, which is used to match the response with the request that it is replying to. |
|
41 | 41 | - *api_key* for access and permission validation. |
|
42 | 42 | - *method* is name of method to call |
|
43 | 43 | - *args* is an key:value list of arguments to pass to method |
|
44 | 44 | |
|
45 | 45 | .. note:: |
|
46 | 46 | |
|
47 | 47 | api_key can be found in your user account page |
|
48 | 48 | |
|
49 | 49 | |
|
50 | 50 | RhodeCode API will return always a JSON-RPC response:: |
|
51 | 51 | |
|
52 | 52 | { |
|
53 | 53 | "id":<id>, # matching id sent by request |
|
54 | 54 | "result": "<result>"|null, # JSON formatted result, null if any errors |
|
55 | 55 | "error": "null"|<error_message> # JSON formatted error (if any) |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | All responses from API will be `HTTP/1.0 200 OK`, if there's an error while |
|
59 | 59 | calling api *error* key from response will contain failure description |
|
60 | 60 | and result will be null. |
|
61 | 61 | |
|
62 | 62 | |
|
63 | 63 | API CLIENT |
|
64 | 64 | ++++++++++ |
|
65 | 65 | |
|
66 | 66 | From version 1.4 RhodeCode adds a script that allows to easily |
|
67 | 67 | communicate with API. After installing RhodeCode a `rhodecode-api` script |
|
68 | 68 | will be available. |
|
69 | 69 | |
|
70 | 70 | To get started quickly simply run:: |
|
71 | 71 | |
|
72 | 72 | rhodecode-api _create_config --apikey=<youapikey> --apihost=<rhodecode host> |
|
73 | 73 | |
|
74 | 74 | This will create a file named .config in the directory you executed it storing |
|
75 | 75 | json config file with credentials. You can skip this step and always provide |
|
76 | 76 | both of the arguments to be able to communicate with server |
|
77 | 77 | |
|
78 | 78 | |
|
79 | 79 | after that simply run any api command for example get_repo:: |
|
80 | 80 | |
|
81 | 81 | rhodecode-api get_repo |
|
82 | 82 | |
|
83 | 83 | calling {"api_key": "<apikey>", "id": 75, "args": {}, "method": "get_repo"} to http://127.0.0.1:5000 |
|
84 | 84 | rhodecode said: |
|
85 | 85 | {'error': 'Missing non optional `repoid` arg in JSON DATA', |
|
86 | 86 | 'id': 75, |
|
87 | 87 | 'result': None} |
|
88 | 88 | |
|
89 | 89 | Ups looks like we forgot to add an argument |
|
90 | 90 | |
|
91 | 91 | Let's try again now giving the repoid as parameters:: |
|
92 | 92 | |
|
93 | 93 | rhodecode-api get_repo repoid:rhodecode |
|
94 | 94 | |
|
95 | 95 | calling {"api_key": "<apikey>", "id": 39, "args": {"repoid": "rhodecode"}, "method": "get_repo"} to http://127.0.0.1:5000 |
|
96 | 96 | rhodecode said: |
|
97 | 97 | {'error': None, |
|
98 | 98 | 'id': 39, |
|
99 | 99 | 'result': <json data...>} |
|
100 | 100 | |
|
101 | 101 | |
|
102 | 102 | |
|
103 | 103 | API METHODS |
|
104 | 104 | +++++++++++ |
|
105 | 105 | |
|
106 | 106 | |
|
107 | 107 | pull |
|
108 | 108 | ---- |
|
109 | 109 | |
|
110 | 110 | Pulls given repo from remote location. Can be used to automatically keep |
|
111 | 111 | remote repos up to date. This command can be executed only using api_key |
|
112 | 112 | belonging to user with admin rights |
|
113 | 113 | |
|
114 | 114 | INPUT:: |
|
115 | 115 | |
|
116 | 116 | id : <id_for_response> |
|
117 | 117 | api_key : "<api_key>" |
|
118 | 118 | method : "pull" |
|
119 | 119 | args : { |
|
120 | 120 | "repoid" : "<reponame or repo_id>" |
|
121 | 121 | } |
|
122 | 122 | |
|
123 | 123 | OUTPUT:: |
|
124 | 124 | |
|
125 | 125 | id : <id_given_in_input> |
|
126 | 126 | result : "Pulled from `<reponame>`" |
|
127 | 127 | error : null |
|
128 | 128 | |
|
129 | 129 | |
|
130 | 130 | rescan_repos |
|
131 | 131 | ------------ |
|
132 | 132 | |
|
133 | 133 | Dispatch rescan repositories action. If remove_obsolete is set |
|
134 | 134 | RhodeCode will delete repos that are in database but not in the filesystem. |
|
135 | 135 | This command can be executed only using api_key belonging to user with admin |
|
136 | 136 | rights. |
|
137 | 137 | |
|
138 | 138 | INPUT:: |
|
139 | 139 | |
|
140 | 140 | id : <id_for_response> |
|
141 | 141 | api_key : "<api_key>" |
|
142 | 142 | method : "rescan_repos" |
|
143 | 143 | args : { |
|
144 | 144 | "remove_obsolete" : "<boolean = Optional(False)>" |
|
145 | 145 | } |
|
146 | 146 | |
|
147 | 147 | OUTPUT:: |
|
148 | 148 | |
|
149 | 149 | id : <id_given_in_input> |
|
150 | 150 | result : "{'added': [<list of names of added repos>], |
|
151 | 151 | 'removed': [<list of names of removed repos>]}" |
|
152 | 152 | error : null |
|
153 | 153 | |
|
154 | 154 | |
|
155 | 155 | lock |
|
156 | 156 | ---- |
|
157 | 157 | |
|
158 | 158 | Set locking state on given repository by given user. If userid param is skipped |
|
159 | 159 | , then it is set to id of user whos calling this method. |
|
160 | 160 | This command can be executed only using api_key belonging to user with admin |
|
161 | 161 | rights or regular user that have admin or write access to repository. |
|
162 | 162 | |
|
163 | 163 | INPUT:: |
|
164 | 164 | |
|
165 | 165 | id : <id_for_response> |
|
166 | 166 | api_key : "<api_key>" |
|
167 | 167 | method : "lock" |
|
168 | 168 | args : { |
|
169 | 169 | "repoid" : "<reponame or repo_id>" |
|
170 | 170 | "userid" : "<user_id or username = Optional(=apiuser)>", |
|
171 | 171 | "locked" : "<bool true|false>" |
|
172 | 172 | } |
|
173 | 173 | |
|
174 | 174 | OUTPUT:: |
|
175 | 175 | |
|
176 | 176 | id : <id_given_in_input> |
|
177 | 177 | result : "User `<username>` set lock state for repo `<reponame>` to `true|false`" |
|
178 | 178 | error : null |
|
179 | 179 | |
|
180 | 180 | |
|
181 | 181 | show_ip |
|
182 | 182 | ------- |
|
183 | 183 | |
|
184 | 184 | Shows IP address as seen from RhodeCode server, together with all |
|
185 | 185 | defined IP addresses for given user. |
|
186 | 186 | This command can be executed only using api_key belonging to user with admin |
|
187 | 187 | rights. |
|
188 | 188 | |
|
189 | 189 | INPUT:: |
|
190 | 190 | |
|
191 | 191 | id : <id_for_response> |
|
192 | 192 | api_key : "<api_key>" |
|
193 | 193 | method : "show_ip" |
|
194 | 194 | args : { |
|
195 | 195 | "userid" : "<user_id or username>", |
|
196 | 196 | } |
|
197 | 197 | |
|
198 | 198 | OUTPUT:: |
|
199 | 199 | |
|
200 | 200 | id : <id_given_in_input> |
|
201 | 201 | result : { |
|
202 | 202 | "ip_addr_server": <ip_from_clien>", |
|
203 | 203 | "user_ips": [ |
|
204 | 204 | { |
|
205 | 205 | "ip_addr": "<ip_with_mask>", |
|
206 | 206 | "ip_range": ["<start_ip>", "<end_ip>"], |
|
207 | 207 | }, |
|
208 | 208 | ... |
|
209 | 209 | ] |
|
210 | 210 | } |
|
211 | 211 | |
|
212 | 212 | error : null |
|
213 | 213 | |
|
214 | 214 | |
|
215 | 215 | get_user |
|
216 | 216 | -------- |
|
217 | 217 | |
|
218 | 218 | Get's an user by username or user_id, Returns empty result if user is not found. |
|
219 | 219 | If userid param is skipped it is set to id of user who is calling this method. |
|
220 | 220 | This command can be executed only using api_key belonging to user with admin |
|
221 | 221 | rights, or regular users that cannot specify different userid than theirs |
|
222 | 222 | |
|
223 | 223 | |
|
224 | 224 | INPUT:: |
|
225 | 225 | |
|
226 | 226 | id : <id_for_response> |
|
227 | 227 | api_key : "<api_key>" |
|
228 | 228 | method : "get_user" |
|
229 | 229 | args : { |
|
230 | 230 | "userid" : "<username or user_id Optional(=apiuser)>" |
|
231 | 231 | } |
|
232 | 232 | |
|
233 | 233 | OUTPUT:: |
|
234 | 234 | |
|
235 | 235 | id : <id_given_in_input> |
|
236 | 236 | result: None if user does not exist or |
|
237 | 237 | { |
|
238 | 238 | "user_id" : "<user_id>", |
|
239 | "api_key" : "<api_key>", | |
|
239 | 240 | "username" : "<username>", |
|
240 | 241 | "firstname": "<firstname>", |
|
241 | 242 | "lastname" : "<lastname>", |
|
242 | 243 | "email" : "<email>", |
|
243 | 244 | "emails": "<list_of_all_additional_emails>", |
|
244 | 245 | "ip_addresses": "<list_of_ip_addresses_for_user>", |
|
245 | 246 | "active" : "<bool>", |
|
246 | 247 | "admin" :Β "<bool>", |
|
247 | 248 | "ldap_dn" : "<ldap_dn>", |
|
248 | 249 | "last_login": "<last_login>", |
|
249 | 250 | "permissions": { |
|
250 | 251 | "global": ["hg.create.repository", |
|
251 | 252 | "repository.read", |
|
252 | 253 | "hg.register.manual_activate"], |
|
253 | 254 | "repositories": {"repo1": "repository.none"}, |
|
254 | 255 | "repositories_groups": {"Group1": "group.read"} |
|
255 | 256 | }, |
|
256 | 257 | } |
|
257 | 258 | |
|
258 | 259 | error: null |
|
259 | 260 | |
|
260 | 261 | |
|
261 | 262 | get_users |
|
262 | 263 | --------- |
|
263 | 264 | |
|
264 | 265 | Lists all existing users. This command can be executed only using api_key |
|
265 | 266 | belonging to user with admin rights. |
|
266 | 267 | |
|
267 | 268 | |
|
268 | 269 | INPUT:: |
|
269 | 270 | |
|
270 | 271 | id : <id_for_response> |
|
271 | 272 | api_key : "<api_key>" |
|
272 | 273 | method : "get_users" |
|
273 | 274 | args : { } |
|
274 | 275 | |
|
275 | 276 | OUTPUT:: |
|
276 | 277 | |
|
277 | 278 | id : <id_given_in_input> |
|
278 | 279 | result: [ |
|
279 | 280 | { |
|
280 | 281 | "user_id" : "<user_id>", |
|
281 | 282 | "username" : "<username>", |
|
282 | 283 | "firstname": "<firstname>", |
|
283 | 284 | "lastname" : "<lastname>", |
|
284 | 285 | "email" : "<email>", |
|
285 | 286 | "emails": "<list_of_all_additional_emails>", |
|
286 | 287 | "ip_addresses": "<list_of_ip_addresses_for_user>", |
|
287 | 288 | "active" : "<bool>", |
|
288 | 289 | "admin" :Β "<bool>", |
|
289 | 290 | "ldap_dn" : "<ldap_dn>", |
|
290 | 291 | "last_login": "<last_login>", |
|
291 | 292 | }, |
|
292 | 293 | β¦ |
|
293 | 294 | ] |
|
294 | 295 | error: null |
|
295 | 296 | |
|
296 | 297 | |
|
297 | 298 | create_user |
|
298 | 299 | ----------- |
|
299 | 300 | |
|
300 | 301 | Creates new user. This command can |
|
301 | 302 | be executed only using api_key belonging to user with admin rights. |
|
302 | 303 | |
|
303 | 304 | |
|
304 | 305 | INPUT:: |
|
305 | 306 | |
|
306 | 307 | id : <id_for_response> |
|
307 | 308 | api_key : "<api_key>" |
|
308 | 309 | method : "create_user" |
|
309 | 310 | args : { |
|
310 | 311 | "username" : "<username>", |
|
311 | 312 | "email" : "<useremail>", |
|
312 | 313 | "password" : "<password>", |
|
313 | 314 | "firstname" : "<firstname> = Optional(None)", |
|
314 | 315 | "lastname" : "<lastname> = Optional(None)", |
|
315 | 316 | "active" : "<bool> = Optional(True)", |
|
316 | 317 | "admin" : "<bool> = Optional(False)", |
|
317 | 318 | "ldap_dn" : "<ldap_dn> = Optional(None)" |
|
318 | 319 | } |
|
319 | 320 | |
|
320 | 321 | OUTPUT:: |
|
321 | 322 | |
|
322 | 323 | id : <id_given_in_input> |
|
323 | 324 | result: { |
|
324 | 325 | "msg" : "created new user `<username>`", |
|
325 | 326 | "user": { |
|
326 | 327 | "user_id" : "<user_id>", |
|
327 | 328 | "username" : "<username>", |
|
328 | 329 | "firstname": "<firstname>", |
|
329 | 330 | "lastname" : "<lastname>", |
|
330 | 331 | "email" : "<email>", |
|
331 | 332 | "emails": "<list_of_all_additional_emails>", |
|
332 | 333 | "active" : "<bool>", |
|
333 | 334 | "admin" :Β "<bool>", |
|
334 | 335 | "ldap_dn" : "<ldap_dn>", |
|
335 | 336 | "last_login": "<last_login>", |
|
336 | 337 | }, |
|
337 | 338 | } |
|
338 | 339 | error: null |
|
339 | 340 | |
|
340 | 341 | |
|
341 | 342 | update_user |
|
342 | 343 | ----------- |
|
343 | 344 | |
|
344 | 345 | updates given user if such user exists. This command can |
|
345 | 346 | be executed only using api_key belonging to user with admin rights. |
|
346 | 347 | |
|
347 | 348 | |
|
348 | 349 | INPUT:: |
|
349 | 350 | |
|
350 | 351 | id : <id_for_response> |
|
351 | 352 | api_key : "<api_key>" |
|
352 | 353 | method : "update_user" |
|
353 | 354 | args : { |
|
354 | 355 | "userid" : "<user_id or username>", |
|
355 | 356 | "username" : "<username> = Optional(None)", |
|
356 | 357 | "email" : "<useremail> = Optional(None)", |
|
357 | 358 | "password" : "<password> = Optional(None)", |
|
358 | 359 | "firstname" : "<firstname> = Optional(None)", |
|
359 | 360 | "lastname" : "<lastname> = Optional(None)", |
|
360 | 361 | "active" : "<bool> = Optional(None)", |
|
361 | 362 | "admin" : "<bool> = Optional(None)", |
|
362 | 363 | "ldap_dn" : "<ldap_dn> = Optional(None)" |
|
363 | 364 | } |
|
364 | 365 | |
|
365 | 366 | OUTPUT:: |
|
366 | 367 | |
|
367 | 368 | id : <id_given_in_input> |
|
368 | 369 | result: { |
|
369 | 370 | "msg" : "updated user ID:<userid> <username>", |
|
370 | 371 | "user": { |
|
371 | 372 | "user_id" : "<user_id>", |
|
372 | 373 | "username" : "<username>", |
|
373 | 374 | "firstname": "<firstname>", |
|
374 | 375 | "lastname" : "<lastname>", |
|
375 | 376 | "email" : "<email>", |
|
376 | 377 | "emails": "<list_of_all_additional_emails>", |
|
377 | 378 | "active" : "<bool>", |
|
378 | 379 | "admin" :Β "<bool>", |
|
379 | 380 | "ldap_dn" : "<ldap_dn>", |
|
380 | 381 | "last_login": "<last_login>", |
|
381 | 382 | }, |
|
382 | 383 | } |
|
383 | 384 | error: null |
|
384 | 385 | |
|
385 | 386 | |
|
386 | 387 | delete_user |
|
387 | 388 | ----------- |
|
388 | 389 | |
|
389 | 390 | |
|
390 | 391 | deletes givenuser if such user exists. This command can |
|
391 | 392 | be executed only using api_key belonging to user with admin rights. |
|
392 | 393 | |
|
393 | 394 | |
|
394 | 395 | INPUT:: |
|
395 | 396 | |
|
396 | 397 | id : <id_for_response> |
|
397 | 398 | api_key : "<api_key>" |
|
398 | 399 | method : "delete_user" |
|
399 | 400 | args : { |
|
400 | 401 | "userid" : "<user_id or username>", |
|
401 | 402 | } |
|
402 | 403 | |
|
403 | 404 | OUTPUT:: |
|
404 | 405 | |
|
405 | 406 | id : <id_given_in_input> |
|
406 | 407 | result: { |
|
407 | 408 | "msg" : "deleted user ID:<userid> <username>", |
|
408 | 409 | "user": null |
|
409 | 410 | } |
|
410 | 411 | error: null |
|
411 | 412 | |
|
412 | 413 | |
|
413 | 414 | get_users_group |
|
414 | 415 | --------------- |
|
415 | 416 | |
|
416 | 417 | Gets an existing users group. This command can be executed only using api_key |
|
417 | 418 | belonging to user with admin rights. |
|
418 | 419 | |
|
419 | 420 | |
|
420 | 421 | INPUT:: |
|
421 | 422 | |
|
422 | 423 | id : <id_for_response> |
|
423 | 424 | api_key : "<api_key>" |
|
424 | 425 | method : "get_users_group" |
|
425 | 426 | args : { |
|
426 | 427 | "usersgroupid" : "<users group id or name>" |
|
427 | 428 | } |
|
428 | 429 | |
|
429 | 430 | OUTPUT:: |
|
430 | 431 | |
|
431 | 432 | id : <id_given_in_input> |
|
432 | 433 | result : None if group not exist |
|
433 | 434 | { |
|
434 | 435 | "users_group_id" : "<id>", |
|
435 | 436 | "group_name" : "<groupname>", |
|
436 | 437 | "active": "<bool>", |
|
437 | 438 | "members" : [ |
|
438 | 439 | { |
|
439 | 440 | "user_id" : "<user_id>", |
|
440 | 441 | "username" : "<username>", |
|
441 | 442 | "firstname": "<firstname>", |
|
442 | 443 | "lastname" : "<lastname>", |
|
443 | 444 | "email" : "<email>", |
|
444 | 445 | "emails": "<list_of_all_additional_emails>", |
|
445 | 446 | "active" : "<bool>", |
|
446 | 447 | "admin" :Β "<bool>", |
|
447 | 448 | "ldap_dn" : "<ldap_dn>", |
|
448 | 449 | "last_login": "<last_login>", |
|
449 | 450 | }, |
|
450 | 451 | β¦ |
|
451 | 452 | ] |
|
452 | 453 | } |
|
453 | 454 | error : null |
|
454 | 455 | |
|
455 | 456 | |
|
456 | 457 | get_users_groups |
|
457 | 458 | ---------------- |
|
458 | 459 | |
|
459 | 460 | Lists all existing users groups. This command can be executed only using |
|
460 | 461 | api_key belonging to user with admin rights. |
|
461 | 462 | |
|
462 | 463 | |
|
463 | 464 | INPUT:: |
|
464 | 465 | |
|
465 | 466 | id : <id_for_response> |
|
466 | 467 | api_key : "<api_key>" |
|
467 | 468 | method : "get_users_groups" |
|
468 | 469 | args : { } |
|
469 | 470 | |
|
470 | 471 | OUTPUT:: |
|
471 | 472 | |
|
472 | 473 | id : <id_given_in_input> |
|
473 | 474 | result : [ |
|
474 | 475 | { |
|
475 | 476 | "users_group_id" : "<id>", |
|
476 | 477 | "group_name" : "<groupname>", |
|
477 | 478 | "active": "<bool>", |
|
478 | 479 | }, |
|
479 | 480 | β¦ |
|
480 | 481 | ] |
|
481 | 482 | error : null |
|
482 | 483 | |
|
483 | 484 | |
|
484 | 485 | create_users_group |
|
485 | 486 | ------------------ |
|
486 | 487 | |
|
487 | 488 | Creates new users group. This command can be executed only using api_key |
|
488 | 489 | belonging to user with admin rights |
|
489 | 490 | |
|
490 | 491 | |
|
491 | 492 | INPUT:: |
|
492 | 493 | |
|
493 | 494 | id : <id_for_response> |
|
494 | 495 | api_key : "<api_key>" |
|
495 | 496 | method : "create_users_group" |
|
496 | 497 | args: { |
|
497 | 498 | "group_name": "<groupname>", |
|
498 | 499 | "active":"<bool> = Optional(True)" |
|
499 | 500 | } |
|
500 | 501 | |
|
501 | 502 | OUTPUT:: |
|
502 | 503 | |
|
503 | 504 | id : <id_given_in_input> |
|
504 | 505 | result: { |
|
505 | 506 | "msg": "created new users group `<groupname>`", |
|
506 | 507 | "users_group": { |
|
507 | 508 | "users_group_id" : "<id>", |
|
508 | 509 | "group_name" : "<groupname>", |
|
509 | 510 | "active": "<bool>", |
|
510 | 511 | }, |
|
511 | 512 | } |
|
512 | 513 | error: null |
|
513 | 514 | |
|
514 | 515 | |
|
515 | 516 | add_user_to_users_group |
|
516 | 517 | ----------------------- |
|
517 | 518 | |
|
518 | 519 | Adds a user to a users group. If user exists in that group success will be |
|
519 | 520 | `false`. This command can be executed only using api_key |
|
520 | 521 | belonging to user with admin rights |
|
521 | 522 | |
|
522 | 523 | |
|
523 | 524 | INPUT:: |
|
524 | 525 | |
|
525 | 526 | id : <id_for_response> |
|
526 | 527 | api_key : "<api_key>" |
|
527 | 528 | method : "add_user_users_group" |
|
528 | 529 | args: { |
|
529 | 530 | "usersgroupid" : "<users group id or name>", |
|
530 | 531 | "userid" : "<user_id or username>", |
|
531 | 532 | } |
|
532 | 533 | |
|
533 | 534 | OUTPUT:: |
|
534 | 535 | |
|
535 | 536 | id : <id_given_in_input> |
|
536 | 537 | result: { |
|
537 | 538 | "success": True|False # depends on if member is in group |
|
538 | 539 | "msg": "added member `<username>` to users group `<groupname>` | |
|
539 | 540 | User is already in that group" |
|
540 | 541 | } |
|
541 | 542 | error: null |
|
542 | 543 | |
|
543 | 544 | |
|
544 | 545 | remove_user_from_users_group |
|
545 | 546 | ---------------------------- |
|
546 | 547 | |
|
547 | 548 | Removes a user from a users group. If user is not in given group success will |
|
548 | 549 | be `false`. This command can be executed only |
|
549 | 550 | using api_key belonging to user with admin rights |
|
550 | 551 | |
|
551 | 552 | |
|
552 | 553 | INPUT:: |
|
553 | 554 | |
|
554 | 555 | id : <id_for_response> |
|
555 | 556 | api_key : "<api_key>" |
|
556 | 557 | method : "remove_user_from_users_group" |
|
557 | 558 | args: { |
|
558 | 559 | "usersgroupid" : "<users group id or name>", |
|
559 | 560 | "userid" : "<user_id or username>", |
|
560 | 561 | } |
|
561 | 562 | |
|
562 | 563 | OUTPUT:: |
|
563 | 564 | |
|
564 | 565 | id : <id_given_in_input> |
|
565 | 566 | result: { |
|
566 | 567 | "success": True|False, # depends on if member is in group |
|
567 | 568 | "msg": "removed member <username> from users group <groupname> | |
|
568 | 569 | User wasn't in group" |
|
569 | 570 | } |
|
570 | 571 | error: null |
|
571 | 572 | |
|
572 | 573 | |
|
573 | 574 | get_repo |
|
574 | 575 | -------- |
|
575 | 576 | |
|
576 | 577 | Gets an existing repository by it's name or repository_id. Members will return |
|
577 | 578 | either users_group or user associated to that repository. This command can be |
|
578 | 579 | executed only using api_key belonging to user with admin |
|
579 | 580 | rights or regular user that have at least read access to repository. |
|
580 | 581 | |
|
581 | 582 | |
|
582 | 583 | INPUT:: |
|
583 | 584 | |
|
584 | 585 | id : <id_for_response> |
|
585 | 586 | api_key : "<api_key>" |
|
586 | 587 | method : "get_repo" |
|
587 | 588 | args: { |
|
588 | 589 | "repoid" : "<reponame or repo_id>" |
|
589 | 590 | } |
|
590 | 591 | |
|
591 | 592 | OUTPUT:: |
|
592 | 593 | |
|
593 | 594 | id : <id_given_in_input> |
|
594 | 595 | result: None if repository does not exist or |
|
595 | 596 | { |
|
596 | 597 | "repo_id" : "<repo_id>", |
|
597 | 598 | "repo_name" : "<reponame>" |
|
598 | 599 | "repo_type" : "<repo_type>", |
|
599 | 600 | "clone_uri" : "<clone_uri>", |
|
600 | 601 | "enable_downloads": "<bool>", |
|
601 | 602 | "enable_locking": "<bool>", |
|
602 | 603 | "enable_statistics": "<bool>", |
|
603 | 604 | "private": "<bool>", |
|
604 | 605 | "created_on" : "<date_time_created>", |
|
605 | 606 | "description" : "<description>", |
|
606 | 607 | "landing_rev": "<landing_rev>", |
|
607 | 608 | "last_changeset": { |
|
608 | 609 | "author": "<full_author>", |
|
609 | 610 | "date": "<date_time_of_commit>", |
|
610 | 611 | "message": "<commit_message>", |
|
611 | 612 | "raw_id": "<raw_id>", |
|
612 | 613 | "revision": "<numeric_revision>", |
|
613 | 614 | "short_id": "<short_id>" |
|
614 | 615 | } |
|
615 | 616 | "owner": "<repo_owner>", |
|
616 | 617 | "fork_of": "<name_of_fork_parent>", |
|
617 | 618 | "members" : [ |
|
618 | 619 | { |
|
619 | "type": "user", | |
|
620 | "type": "user", | |
|
620 | 621 | "user_id" : "<user_id>", |
|
621 | 622 | "username" : "<username>", |
|
622 | 623 | "firstname": "<firstname>", |
|
623 | 624 | "lastname" : "<lastname>", |
|
624 | 625 | "email" : "<email>", |
|
625 | 626 | "emails": "<list_of_all_additional_emails>", |
|
626 | 627 | "active" : "<bool>", |
|
627 | 628 | "admin" :Β "<bool>", |
|
628 | 629 | "ldap_dn" : "<ldap_dn>", |
|
629 | 630 | "last_login": "<last_login>", |
|
630 | 631 | "permission" : "repository.(read|write|admin)" |
|
631 | 632 | }, |
|
632 | 633 | β¦ |
|
633 | 634 | { |
|
634 | "type": "users_group", | |
|
635 | "type": "users_group", | |
|
635 | 636 | "id" : "<usersgroupid>", |
|
636 | 637 | "name" : "<usersgroupname>", |
|
637 | 638 | "active": "<bool>", |
|
638 | 639 | "permission" : "repository.(read|write|admin)" |
|
639 | 640 | }, |
|
640 | 641 | β¦ |
|
641 | 642 | ] |
|
643 | "followers": [ | |
|
644 | { | |
|
645 | "user_id" : "<user_id>", | |
|
646 | "username" : "<username>", | |
|
647 | "firstname": "<firstname>", | |
|
648 | "lastname" : "<lastname>", | |
|
649 | "email" : "<email>", | |
|
650 | "emails": "<list_of_all_additional_emails>", | |
|
651 | "ip_addresses": "<list_of_ip_addresses_for_user>", | |
|
652 | "active" : "<bool>", | |
|
653 | "admin" :Β "<bool>", | |
|
654 | "ldap_dn" : "<ldap_dn>", | |
|
655 | "last_login": "<last_login>", | |
|
656 | }, | |
|
657 | β¦ | |
|
658 | ] | |
|
642 | 659 | } |
|
643 | 660 | error: null |
|
644 | 661 | |
|
645 | 662 | |
|
646 | 663 | get_repos |
|
647 | 664 | --------- |
|
648 | 665 | |
|
649 | 666 | Lists all existing repositories. This command can be executed only using |
|
650 | 667 | api_key belonging to user with admin rights or regular user that have |
|
651 | 668 | admin, write or read access to repository. |
|
652 | 669 | |
|
653 | 670 | |
|
654 | 671 | INPUT:: |
|
655 | 672 | |
|
656 | 673 | id : <id_for_response> |
|
657 | 674 | api_key : "<api_key>" |
|
658 | 675 | method : "get_repos" |
|
659 | 676 | args: { } |
|
660 | 677 | |
|
661 | 678 | OUTPUT:: |
|
662 | 679 | |
|
663 | 680 | id : <id_given_in_input> |
|
664 | 681 | result: [ |
|
665 | 682 | { |
|
666 | 683 | "repo_id" : "<repo_id>", |
|
667 | 684 | "repo_name" : "<reponame>" |
|
668 | 685 | "repo_type" : "<repo_type>", |
|
669 | 686 | "clone_uri" : "<clone_uri>", |
|
670 | 687 | "private": : "<bool>", |
|
671 | 688 | "created_on" : "<datetimecreated>", |
|
672 | 689 | "description" : "<description>", |
|
673 | 690 | "landing_rev": "<landing_rev>", |
|
674 | 691 | "owner": "<repo_owner>", |
|
675 | 692 | "fork_of": "<name_of_fork_parent>", |
|
676 | 693 | "enable_downloads": "<bool>", |
|
677 | 694 | "enable_locking": "<bool>", |
|
678 | 695 | "enable_statistics": "<bool>", |
|
679 | 696 | }, |
|
680 | 697 | β¦ |
|
681 | 698 | ] |
|
682 | 699 | error: null |
|
683 | 700 | |
|
684 | 701 | |
|
685 | 702 | get_repo_nodes |
|
686 | 703 | -------------- |
|
687 | 704 | |
|
688 | 705 | returns a list of nodes and it's children in a flat list for a given path |
|
689 | 706 | at given revision. It's possible to specify ret_type to show only `files` or |
|
690 | 707 | `dirs`. This command can be executed only using api_key belonging to user |
|
691 | 708 | with admin rights |
|
692 | 709 | |
|
693 | 710 | |
|
694 | 711 | INPUT:: |
|
695 | 712 | |
|
696 | 713 | id : <id_for_response> |
|
697 | 714 | api_key : "<api_key>" |
|
698 | 715 | method : "get_repo_nodes" |
|
699 | 716 | args: { |
|
700 | 717 | "repoid" : "<reponame or repo_id>" |
|
701 | 718 | "revision" : "<revision>", |
|
702 | 719 | "root_path" : "<root_path>", |
|
703 | 720 | "ret_type" : "<ret_type> = Optional('all')" |
|
704 | 721 | } |
|
705 | 722 | |
|
706 | 723 | OUTPUT:: |
|
707 | 724 | |
|
708 | 725 | id : <id_given_in_input> |
|
709 | 726 | result: [ |
|
710 | 727 | { |
|
711 | 728 | "name" : "<name>" |
|
712 | 729 | "type" : "<type>", |
|
713 | 730 | }, |
|
714 | 731 | β¦ |
|
715 | 732 | ] |
|
716 | 733 | error: null |
|
717 | 734 | |
|
718 | 735 | |
|
719 | 736 | create_repo |
|
720 | 737 | ----------- |
|
721 | 738 | |
|
722 | 739 | Creates a repository. If repository name contains "/", all needed repository |
|
723 | 740 | groups will be created. For example "foo/bar/baz" will create groups |
|
724 | 741 | "foo", "bar" (with "foo" as parent), and create "baz" repository with |
|
725 | 742 | "bar" as group. This command can be executed only using api_key belonging to user with admin |
|
726 | 743 | rights or regular user that have create repository permission. Regular users |
|
727 | 744 | cannot specify owner parameter |
|
728 | 745 | |
|
729 | 746 | |
|
730 | 747 | INPUT:: |
|
731 | 748 | |
|
732 | 749 | id : <id_for_response> |
|
733 | 750 | api_key : "<api_key>" |
|
734 | 751 | method : "create_repo" |
|
735 | 752 | args: { |
|
736 | 753 | "repo_name" : "<reponame>", |
|
737 | 754 | "owner" : "<onwer_name_or_id = Optional(=apiuser)>", |
|
738 | 755 | "repo_type" : "<repo_type> = Optional('hg')", |
|
739 | 756 | "description" : "<description> = Optional('')", |
|
740 | 757 | "private" : "<bool> = Optional(False)", |
|
741 | 758 | "clone_uri" : "<clone_uri> = Optional(None)", |
|
742 | 759 | "landing_rev" : "<landing_rev> = Optional('tip')", |
|
743 | 760 | "enable_downloads": "<bool> = Optional(False)", |
|
744 | 761 | "enable_locking": "<bool> = Optional(False)", |
|
745 | 762 | "enable_statistics": "<bool> = Optional(False)", |
|
746 | 763 | } |
|
747 | 764 | |
|
748 | 765 | OUTPUT:: |
|
749 | 766 | |
|
750 | 767 | id : <id_given_in_input> |
|
751 | 768 | result: { |
|
752 | 769 | "msg": "Created new repository `<reponame>`", |
|
753 | 770 | "repo": { |
|
754 | 771 | "repo_id" : "<repo_id>", |
|
755 | 772 | "repo_name" : "<reponame>" |
|
756 | 773 | "repo_type" : "<repo_type>", |
|
757 | 774 | "clone_uri" : "<clone_uri>", |
|
758 | 775 | "private": : "<bool>", |
|
759 | 776 | "created_on" : "<datetimecreated>", |
|
760 | 777 | "description" : "<description>", |
|
761 | 778 | "landing_rev": "<landing_rev>", |
|
762 | 779 | "owner": "<username or user_id>", |
|
763 | 780 | "fork_of": "<name_of_fork_parent>", |
|
764 | 781 | "enable_downloads": "<bool>", |
|
765 | 782 | "enable_locking": "<bool>", |
|
766 | 783 | "enable_statistics": "<bool>", |
|
767 | 784 | }, |
|
768 | 785 | } |
|
769 | 786 | error: null |
|
770 | 787 | |
|
771 | 788 | |
|
772 | 789 | fork_repo |
|
773 | 790 | --------- |
|
774 | 791 | |
|
775 | 792 | Creates a fork of given repo. In case of using celery this will |
|
776 | 793 | immidiatelly return success message, while fork is going to be created |
|
777 | 794 | asynchronous. This command can be executed only using api_key belonging to |
|
778 | 795 | user with admin rights or regular user that have fork permission, and at least |
|
779 | 796 | read access to forking repository. Regular users cannot specify owner parameter. |
|
780 | 797 | |
|
781 | 798 | |
|
782 | 799 | INPUT:: |
|
783 | 800 | |
|
784 | 801 | id : <id_for_response> |
|
785 | 802 | api_key : "<api_key>" |
|
786 | 803 | method : "fork_repo" |
|
787 | 804 | args: { |
|
788 | 805 | "repoid" : "<reponame or repo_id>", |
|
789 | 806 | "fork_name": "<forkname>", |
|
790 | 807 | "owner": "<username or user_id = Optional(=apiuser)>", |
|
791 | 808 | "description": "<description>", |
|
792 | 809 | "copy_permissions": "<bool>", |
|
793 | 810 | "private": "<bool>", |
|
794 | 811 | "landing_rev": "<landing_rev>" |
|
795 | 812 | |
|
796 | 813 | } |
|
797 | 814 | |
|
798 | 815 | OUTPUT:: |
|
799 | 816 | |
|
800 | 817 | id : <id_given_in_input> |
|
801 | 818 | result: { |
|
802 | 819 | "msg": "Created fork of `<reponame>` as `<forkname>`", |
|
803 | 820 | "success": true |
|
804 | 821 | } |
|
805 | 822 | error: null |
|
806 | 823 | |
|
807 | 824 | |
|
808 | 825 | delete_repo |
|
809 | 826 | ----------- |
|
810 | 827 | |
|
811 | 828 | Deletes a repository. This command can be executed only using api_key belonging to user with admin |
|
812 | 829 | rights or regular user that have admin access to repository. |
|
813 | 830 | |
|
814 | 831 | |
|
815 | 832 | INPUT:: |
|
816 | 833 | |
|
817 | 834 | id : <id_for_response> |
|
818 | 835 | api_key : "<api_key>" |
|
819 | 836 | method : "delete_repo" |
|
820 | 837 | args: { |
|
821 | 838 | "repoid" : "<reponame or repo_id>" |
|
822 | 839 | } |
|
823 | 840 | |
|
824 | 841 | OUTPUT:: |
|
825 | 842 | |
|
826 | 843 | id : <id_given_in_input> |
|
827 | 844 | result: { |
|
828 | 845 | "msg": "Deleted repository `<reponame>`", |
|
829 | 846 | "success": true |
|
830 | 847 | } |
|
831 | 848 | error: null |
|
832 | 849 | |
|
833 | 850 | |
|
834 | 851 | grant_user_permission |
|
835 | 852 | --------------------- |
|
836 | 853 | |
|
837 | 854 | Grant permission for user on given repository, or update existing one |
|
838 | 855 | if found. This command can be executed only using api_key belonging to user |
|
839 | 856 | with admin rights. |
|
840 | 857 | |
|
841 | 858 | |
|
842 | 859 | INPUT:: |
|
843 | 860 | |
|
844 | 861 | id : <id_for_response> |
|
845 | 862 | api_key : "<api_key>" |
|
846 | 863 | method : "grant_user_permission" |
|
847 | 864 | args: { |
|
848 | 865 | "repoid" : "<reponame or repo_id>" |
|
849 | 866 | "userid" : "<username or user_id>" |
|
850 | 867 | "perm" : "(repository.(none|read|write|admin))", |
|
851 | 868 | } |
|
852 | 869 | |
|
853 | 870 | OUTPUT:: |
|
854 | 871 | |
|
855 | 872 | id : <id_given_in_input> |
|
856 | 873 | result: { |
|
857 | 874 | "msg" : "Granted perm: `<perm>` for user: `<username>` in repo: `<reponame>`", |
|
858 | 875 | "success": true |
|
859 | 876 | } |
|
860 | 877 | error: null |
|
861 | 878 | |
|
862 | 879 | |
|
863 | 880 | revoke_user_permission |
|
864 | 881 | ---------------------- |
|
865 | 882 | |
|
866 | 883 | Revoke permission for user on given repository. This command can be executed |
|
867 | 884 | only using api_key belonging to user with admin rights. |
|
868 | 885 | |
|
869 | 886 | |
|
870 | 887 | INPUT:: |
|
871 | 888 | |
|
872 | 889 | id : <id_for_response> |
|
873 | 890 | api_key : "<api_key>" |
|
874 | 891 | method : "revoke_user_permission" |
|
875 | 892 | args: { |
|
876 | 893 | "repoid" : "<reponame or repo_id>" |
|
877 | 894 | "userid" : "<username or user_id>" |
|
878 | 895 | } |
|
879 | 896 | |
|
880 | 897 | OUTPUT:: |
|
881 | 898 | |
|
882 | 899 | id : <id_given_in_input> |
|
883 | 900 | result: { |
|
884 | 901 | "msg" : "Revoked perm for user: `<username>` in repo: `<reponame>`", |
|
885 | 902 | "success": true |
|
886 | 903 | } |
|
887 | 904 | error: null |
|
888 | 905 | |
|
889 | 906 | |
|
890 | 907 | grant_users_group_permission |
|
891 | 908 | ---------------------------- |
|
892 | 909 | |
|
893 | 910 | Grant permission for users group on given repository, or update |
|
894 | 911 | existing one if found. This command can be executed only using |
|
895 | 912 | api_key belonging to user with admin rights. |
|
896 | 913 | |
|
897 | 914 | |
|
898 | 915 | INPUT:: |
|
899 | 916 | |
|
900 | 917 | id : <id_for_response> |
|
901 | 918 | api_key : "<api_key>" |
|
902 | 919 | method : "grant_users_group_permission" |
|
903 | 920 | args: { |
|
904 | 921 | "repoid" : "<reponame or repo_id>" |
|
905 | 922 | "usersgroupid" : "<users group id or name>" |
|
906 | 923 | "perm" : "(repository.(none|read|write|admin))", |
|
907 | 924 | } |
|
908 | 925 | |
|
909 | 926 | OUTPUT:: |
|
910 | 927 | |
|
911 | 928 | id : <id_given_in_input> |
|
912 | 929 | result: { |
|
913 | 930 | "msg" : "Granted perm: `<perm>` for group: `<usersgroupname>` in repo: `<reponame>`", |
|
914 | 931 | "success": true |
|
915 | 932 | } |
|
916 | 933 | error: null |
|
917 | 934 | |
|
918 | 935 | |
|
919 | 936 | revoke_users_group_permission |
|
920 | 937 | ----------------------------- |
|
921 | 938 | |
|
922 | 939 | Revoke permission for users group on given repository.This command can be |
|
923 | 940 | executed only using api_key belonging to user with admin rights. |
|
924 | 941 | |
|
925 | 942 | INPUT:: |
|
926 | 943 | |
|
927 | 944 | id : <id_for_response> |
|
928 | 945 | api_key : "<api_key>" |
|
929 | 946 | method : "revoke_users_group_permission" |
|
930 | 947 | args: { |
|
931 | 948 | "repoid" : "<reponame or repo_id>" |
|
932 | 949 | "usersgroupid" : "<users group id or name>" |
|
933 | 950 | } |
|
934 | 951 | |
|
935 | 952 | OUTPUT:: |
|
936 | 953 | |
|
937 | 954 | id : <id_given_in_input> |
|
938 | 955 | result: { |
|
939 | 956 | "msg" : "Revoked perm for group: `<usersgroupname>` in repo: `<reponame>`", |
|
940 | 957 | "success": true |
|
941 | 958 | } |
|
942 | 959 | error: null No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now