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