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