##// END OF EJS Templates
docs: fix curl example
Mads Kiilerich -
r7777:ae155f6a default
parent child Browse files
Show More
@@ -1,1251 +1,1251 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 12 API keys
13 13 --------
14 14
15 15 Every Kallithea user automatically receives an API key, which they can
16 16 view under "My Account". On this page, API keys can also be revoked, and
17 17 additional API keys can be generated.
18 18
19 19
20 20 API access
21 21 ----------
22 22
23 23 Clients must send JSON encoded JSON-RPC requests::
24 24
25 25 {
26 26 "id: "<id>",
27 27 "api_key": "<api_key>",
28 28 "method": "<method_name>",
29 29 "args": {"<arg_key>": "<arg_val>"}
30 30 }
31 31
32 32 For example, to pull to a local "CPython" mirror using curl::
33 33
34 34 curl https://kallithea.example.com/_admin/api -X POST -H 'content-type:text/plain' \
35 --data-binary '{"id":1,"api_key":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull","args":{"repo":"CPython"}}'
35 --data-binary '{"id":1,"api_key":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull","args":{"repoid":"CPython"}}'
36 36
37 37 In general, provide
38 38 - *id*, a value of any type, can be used to match the response with the request that it is replying to.
39 39 - *api_key*, for authentication and permission validation.
40 40 - *method*, the name of the method to call -- a list of available methods can be found below.
41 41 - *args*, the arguments to pass to the method.
42 42
43 43 .. note::
44 44
45 45 api_key can be found or set on the user account page.
46 46
47 47 The response to the JSON-RPC API call will always be a JSON structure::
48 48
49 49 {
50 50 "id": <id>, # the id that was used in the request
51 51 "result": <result>|null, # JSON formatted result (null on error)
52 52 "error": null|<error_message> # JSON formatted error (null on success)
53 53 }
54 54
55 55 All responses from the API will be ``HTTP/1.0 200 OK``. If an error occurs,
56 56 the reponse will have a failure description in *error* and
57 57 *result* will be null.
58 58
59 59
60 60 API client
61 61 ----------
62 62
63 63 Kallithea comes with a ``kallithea-api`` command line tool, providing a convenient
64 64 way to call the JSON-RPC API.
65 65
66 66 For example, to call ``get_repo``::
67 67
68 68 kallithea-api --apihost=<Kallithea URL> --apikey=<API key> get_repo
69 69
70 70 Calling method get_repo => <Kallithea URL>
71 71 Server response
72 72 ERROR:"Missing non optional `repoid` arg in JSON DATA"
73 73
74 74 Oops, looks like we forgot to add an argument. Let's try again, now
75 75 providing the ``repoid`` as a parameter::
76 76
77 77 kallithea-api --apihost=<Kallithea URL> --apikey=<API key> get_repo repoid:myrepo
78 78
79 79 Calling method get_repo => <Kallithea URL>
80 80 Server response
81 81 {
82 82 "clone_uri": null,
83 83 "created_on": "2015-08-31T14:55:19.042",
84 84 ...
85 85
86 86 To avoid specifying ``apihost`` and ``apikey`` every time, run::
87 87
88 88 kallithea-api --save-config --apihost=<Kallithea URL> --apikey=<API key>
89 89
90 90 This will create a ``~/.config/kallithea`` with the specified URL and API key
91 91 so you don't have to specify them every time.
92 92
93 93
94 94 API methods
95 95 -----------
96 96
97 97
98 98 pull
99 99 ^^^^
100 100
101 101 Pull the given repo from remote location. Can be used to automatically keep
102 102 remote repos up to date.
103 103 This command can only be executed using the api_key of a user with admin rights.
104 104
105 105 INPUT::
106 106
107 107 id : <id_for_response>
108 108 api_key : "<api_key>"
109 109 method : "pull"
110 110 args : {
111 111 "repoid" : "<reponame or repo_id>"
112 112 }
113 113
114 114 OUTPUT::
115 115
116 116 id : <id_given_in_input>
117 117 result : "Pulled from `<reponame>`"
118 118 error : null
119 119
120 120 rescan_repos
121 121 ^^^^^^^^^^^^
122 122
123 123 Rescan repositories. If ``remove_obsolete`` is set,
124 124 Kallithea will delete repos that are in the database but not in the filesystem.
125 125 This command can only be executed using the api_key of a user with admin rights.
126 126
127 127 INPUT::
128 128
129 129 id : <id_for_response>
130 130 api_key : "<api_key>"
131 131 method : "rescan_repos"
132 132 args : {
133 133 "remove_obsolete" : "<boolean = Optional(False)>"
134 134 }
135 135
136 136 OUTPUT::
137 137
138 138 id : <id_given_in_input>
139 139 result : "{'added': [<list of names of added repos>],
140 140 'removed': [<list of names of removed repos>]}"
141 141 error : null
142 142
143 143 invalidate_cache
144 144 ^^^^^^^^^^^^^^^^
145 145
146 146 Invalidate the cache for a repository.
147 147 This command can only be executed using the api_key of a user with admin rights,
148 148 or that of a regular user with admin or write access to the repository.
149 149
150 150 INPUT::
151 151
152 152 id : <id_for_response>
153 153 api_key : "<api_key>"
154 154 method : "invalidate_cache"
155 155 args : {
156 156 "repoid" : "<reponame or repo_id>"
157 157 }
158 158
159 159 OUTPUT::
160 160
161 161 id : <id_given_in_input>
162 162 result : "Caches of repository `<reponame>`"
163 163 error : null
164 164
165 165 get_ip
166 166 ^^^^^^
167 167
168 168 Return IP address as seen from Kallithea server, together with all
169 169 defined IP addresses for given user.
170 170 This command can only be executed using the api_key of a user with admin rights.
171 171
172 172 INPUT::
173 173
174 174 id : <id_for_response>
175 175 api_key : "<api_key>"
176 176 method : "get_ip"
177 177 args : {
178 178 "userid" : "<user_id or username>",
179 179 }
180 180
181 181 OUTPUT::
182 182
183 183 id : <id_given_in_input>
184 184 result : {
185 185 "ip_addr_server": <ip_from_clien>",
186 186 "user_ips": [
187 187 {
188 188 "ip_addr": "<ip_with_mask>",
189 189 "ip_range": ["<start_ip>", "<end_ip>"],
190 190 },
191 191 ...
192 192 ]
193 193 }
194 194
195 195 error : null
196 196
197 197 get_user
198 198 ^^^^^^^^
199 199
200 200 Get a user by username or userid. The result is empty if user can't be found.
201 201 If userid param is skipped, it is set to id of user who is calling this method.
202 202 Any userid can be specified when the command is executed using the api_key of a user with admin rights.
203 203 Regular users can only specify their own userid.
204 204
205 205 INPUT::
206 206
207 207 id : <id_for_response>
208 208 api_key : "<api_key>"
209 209 method : "get_user"
210 210 args : {
211 211 "userid" : "<username or user_id Optional(=apiuser)>"
212 212 }
213 213
214 214 OUTPUT::
215 215
216 216 id : <id_given_in_input>
217 217 result: None if user does not exist or
218 218 {
219 219 "user_id" : "<user_id>",
220 220 "api_key" : "<api_key>",
221 221 "username" : "<username>",
222 222 "firstname": "<firstname>",
223 223 "lastname" : "<lastname>",
224 224 "email" : "<email>",
225 225 "emails": "<list_of_all_additional_emails>",
226 226 "ip_addresses": "<list_of_ip_addresses_for_user>",
227 227 "active" : "<bool>",
228 228 "admin" :Β  "<bool>",
229 229 "ldap_dn" : "<ldap_dn>",
230 230 "last_login": "<last_login>",
231 231 "permissions": {
232 232 "global": ["hg.create.repository",
233 233 "repository.read",
234 234 "hg.register.manual_activate"],
235 235 "repositories": {"repo1": "repository.none"},
236 236 "repositories_groups": {"Group1": "group.read"}
237 237 },
238 238 }
239 239 error: null
240 240
241 241 get_users
242 242 ^^^^^^^^^
243 243
244 244 List all existing users.
245 245 This command can only be executed using the api_key of a user with admin rights.
246 246
247 247 INPUT::
248 248
249 249 id : <id_for_response>
250 250 api_key : "<api_key>"
251 251 method : "get_users"
252 252 args : { }
253 253
254 254 OUTPUT::
255 255
256 256 id : <id_given_in_input>
257 257 result: [
258 258 {
259 259 "user_id" : "<user_id>",
260 260 "api_key" : "<api_key>",
261 261 "username" : "<username>",
262 262 "firstname": "<firstname>",
263 263 "lastname" : "<lastname>",
264 264 "email" : "<email>",
265 265 "emails": "<list_of_all_additional_emails>",
266 266 "ip_addresses": "<list_of_ip_addresses_for_user>",
267 267 "active" : "<bool>",
268 268 "admin" :Β  "<bool>",
269 269 "ldap_dn" : "<ldap_dn>",
270 270 "last_login": "<last_login>",
271 271 },
272 272 …
273 273 ]
274 274 error: null
275 275
276 276 .. _create-user:
277 277
278 278 create_user
279 279 ^^^^^^^^^^^
280 280
281 281 Create new user.
282 282 This command can only be executed using the api_key of a user with admin rights.
283 283
284 284 INPUT::
285 285
286 286 id : <id_for_response>
287 287 api_key : "<api_key>"
288 288 method : "create_user"
289 289 args : {
290 290 "username" : "<username>",
291 291 "email" : "<useremail>",
292 292 "password" : "<password = Optional(None)>",
293 293 "firstname" : "<firstname> = Optional(None)",
294 294 "lastname" : "<lastname> = Optional(None)",
295 295 "active" : "<bool> = Optional(True)",
296 296 "admin" : "<bool> = Optional(False)",
297 297 "ldap_dn" : "<ldap_dn> = Optional(None)"
298 298 }
299 299
300 300 OUTPUT::
301 301
302 302 id : <id_given_in_input>
303 303 result: {
304 304 "msg" : "created new user `<username>`",
305 305 "user": {
306 306 "user_id" : "<user_id>",
307 307 "username" : "<username>",
308 308 "firstname": "<firstname>",
309 309 "lastname" : "<lastname>",
310 310 "email" : "<email>",
311 311 "emails": "<list_of_all_additional_emails>",
312 312 "active" : "<bool>",
313 313 "admin" :Β  "<bool>",
314 314 "ldap_dn" : "<ldap_dn>",
315 315 "last_login": "<last_login>",
316 316 },
317 317 }
318 318 error: null
319 319
320 320 Example::
321 321
322 322 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
323 323
324 324 update_user
325 325 ^^^^^^^^^^^
326 326
327 327 Update the given user if such user exists.
328 328 This command can only be executed using the api_key of a user with admin rights.
329 329
330 330 INPUT::
331 331
332 332 id : <id_for_response>
333 333 api_key : "<api_key>"
334 334 method : "update_user"
335 335 args : {
336 336 "userid" : "<user_id or username>",
337 337 "username" : "<username> = Optional(None)",
338 338 "email" : "<useremail> = Optional(None)",
339 339 "password" : "<password> = Optional(None)",
340 340 "firstname" : "<firstname> = Optional(None)",
341 341 "lastname" : "<lastname> = Optional(None)",
342 342 "active" : "<bool> = Optional(None)",
343 343 "admin" : "<bool> = Optional(None)",
344 344 "ldap_dn" : "<ldap_dn> = Optional(None)"
345 345 }
346 346
347 347 OUTPUT::
348 348
349 349 id : <id_given_in_input>
350 350 result: {
351 351 "msg" : "updated user ID:<userid> <username>",
352 352 "user": {
353 353 "user_id" : "<user_id>",
354 354 "api_key" : "<api_key>",
355 355 "username" : "<username>",
356 356 "firstname": "<firstname>",
357 357 "lastname" : "<lastname>",
358 358 "email" : "<email>",
359 359 "emails": "<list_of_all_additional_emails>",
360 360 "active" : "<bool>",
361 361 "admin" :Β  "<bool>",
362 362 "ldap_dn" : "<ldap_dn>",
363 363 "last_login": "<last_login>",
364 364 },
365 365 }
366 366 error: null
367 367
368 368 delete_user
369 369 ^^^^^^^^^^^
370 370
371 371 Delete the given user if such a user exists.
372 372 This command can only be executed using the api_key of a user with admin rights.
373 373
374 374 INPUT::
375 375
376 376 id : <id_for_response>
377 377 api_key : "<api_key>"
378 378 method : "delete_user"
379 379 args : {
380 380 "userid" : "<user_id or username>",
381 381 }
382 382
383 383 OUTPUT::
384 384
385 385 id : <id_given_in_input>
386 386 result: {
387 387 "msg" : "deleted user ID:<userid> <username>",
388 388 "user": null
389 389 }
390 390 error: null
391 391
392 392 get_user_group
393 393 ^^^^^^^^^^^^^^
394 394
395 395 Get an existing user group.
396 396 This command can only be executed using the api_key of a user with admin rights.
397 397
398 398 INPUT::
399 399
400 400 id : <id_for_response>
401 401 api_key : "<api_key>"
402 402 method : "get_user_group"
403 403 args : {
404 404 "usergroupid" : "<user group id or name>"
405 405 }
406 406
407 407 OUTPUT::
408 408
409 409 id : <id_given_in_input>
410 410 result : None if group not exist
411 411 {
412 412 "users_group_id" : "<id>",
413 413 "group_name" : "<groupname>",
414 414 "active": "<bool>",
415 415 "members" : [
416 416 {
417 417 "user_id" : "<user_id>",
418 418 "api_key" : "<api_key>",
419 419 "username" : "<username>",
420 420 "firstname": "<firstname>",
421 421 "lastname" : "<lastname>",
422 422 "email" : "<email>",
423 423 "emails": "<list_of_all_additional_emails>",
424 424 "active" : "<bool>",
425 425 "admin" :Β  "<bool>",
426 426 "ldap_dn" : "<ldap_dn>",
427 427 "last_login": "<last_login>",
428 428 },
429 429 …
430 430 ]
431 431 }
432 432 error : null
433 433
434 434 get_user_groups
435 435 ^^^^^^^^^^^^^^^
436 436
437 437 List all existing user groups.
438 438 This command can only be executed using the api_key of a user with admin rights.
439 439
440 440 INPUT::
441 441
442 442 id : <id_for_response>
443 443 api_key : "<api_key>"
444 444 method : "get_user_groups"
445 445 args : { }
446 446
447 447 OUTPUT::
448 448
449 449 id : <id_given_in_input>
450 450 result : [
451 451 {
452 452 "users_group_id" : "<id>",
453 453 "group_name" : "<groupname>",
454 454 "active": "<bool>",
455 455 },
456 456 …
457 457 ]
458 458 error : null
459 459
460 460 create_user_group
461 461 ^^^^^^^^^^^^^^^^^
462 462
463 463 Create a new user group.
464 464 This command can only be executed using the api_key of a user with admin rights.
465 465
466 466 INPUT::
467 467
468 468 id : <id_for_response>
469 469 api_key : "<api_key>"
470 470 method : "create_user_group"
471 471 args: {
472 472 "group_name": "<groupname>",
473 473 "owner" : "<owner_name_or_id = Optional(=apiuser)>",
474 474 "active": "<bool> = Optional(True)"
475 475 }
476 476
477 477 OUTPUT::
478 478
479 479 id : <id_given_in_input>
480 480 result: {
481 481 "msg": "created new user group `<groupname>`",
482 482 "users_group": {
483 483 "users_group_id" : "<id>",
484 484 "group_name" : "<groupname>",
485 485 "active": "<bool>",
486 486 },
487 487 }
488 488 error: null
489 489
490 490 add_user_to_user_group
491 491 ^^^^^^^^^^^^^^^^^^^^^^
492 492
493 493 Adds a user to a user group. If the user already is in that group, success will be
494 494 ``false``.
495 495 This command can only be executed using the api_key of a user with admin rights.
496 496
497 497 INPUT::
498 498
499 499 id : <id_for_response>
500 500 api_key : "<api_key>"
501 501 method : "add_user_user_group"
502 502 args: {
503 503 "usersgroupid" : "<user group id or name>",
504 504 "userid" : "<user_id or username>",
505 505 }
506 506
507 507 OUTPUT::
508 508
509 509 id : <id_given_in_input>
510 510 result: {
511 511 "success": True|False # depends on if member is in group
512 512 "msg": "added member `<username>` to a user group `<groupname>` |
513 513 User is already in that group"
514 514 }
515 515 error: null
516 516
517 517 remove_user_from_user_group
518 518 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
519 519
520 520 Remove a user from a user group. If the user isn't in the given group, success will
521 521 be ``false``.
522 522 This command can only be executed using the api_key of a user with admin rights.
523 523
524 524 INPUT::
525 525
526 526 id : <id_for_response>
527 527 api_key : "<api_key>"
528 528 method : "remove_user_from_user_group"
529 529 args: {
530 530 "usersgroupid" : "<user group id or name>",
531 531 "userid" : "<user_id or username>",
532 532 }
533 533
534 534 OUTPUT::
535 535
536 536 id : <id_given_in_input>
537 537 result: {
538 538 "success": True|False, # depends on if member is in group
539 539 "msg": "removed member <username> from user group <groupname> |
540 540 User wasn't in group"
541 541 }
542 542 error: null
543 543
544 544 get_repo
545 545 ^^^^^^^^
546 546
547 547 Get an existing repository by its name or repository_id. Members will contain
548 548 either users_group or users associated to that repository.
549 549 This command can only be executed using the api_key of a user with admin rights,
550 550 or that of a regular user with at least read access to the repository.
551 551
552 552 INPUT::
553 553
554 554 id : <id_for_response>
555 555 api_key : "<api_key>"
556 556 method : "get_repo"
557 557 args: {
558 558 "repoid" : "<reponame or repo_id>",
559 559 "with_revision_names": "<bool> = Optional(False)",
560 560 "with_pullrequests": "<bool> = Optional(False)",
561 561 }
562 562
563 563 OUTPUT::
564 564
565 565 id : <id_given_in_input>
566 566 result: None if repository does not exist or
567 567 {
568 568 "repo_id" : "<repo_id>",
569 569 "repo_name" : "<reponame>"
570 570 "repo_type" : "<repo_type>",
571 571 "clone_uri" : "<clone_uri>",
572 572 "enable_downloads": "<bool>",
573 573 "enable_statistics": "<bool>",
574 574 "private": "<bool>",
575 575 "created_on" : "<date_time_created>",
576 576 "description" : "<description>",
577 577 "landing_rev": "<landing_rev>",
578 578 "last_changeset": {
579 579 "author": "<full_author>",
580 580 "date": "<date_time_of_commit>",
581 581 "message": "<commit_message>",
582 582 "raw_id": "<raw_id>",
583 583 "revision": "<numeric_revision>",
584 584 "short_id": "<short_id>"
585 585 },
586 586 "owner": "<repo_owner>",
587 587 "fork_of": "<name_of_fork_parent>",
588 588 "members" : [
589 589 {
590 590 "type": "user",
591 591 "user_id" : "<user_id>",
592 592 "api_key" : "<api_key>",
593 593 "username" : "<username>",
594 594 "firstname": "<firstname>",
595 595 "lastname" : "<lastname>",
596 596 "email" : "<email>",
597 597 "emails": "<list_of_all_additional_emails>",
598 598 "active" : "<bool>",
599 599 "admin" :Β  "<bool>",
600 600 "ldap_dn" : "<ldap_dn>",
601 601 "last_login": "<last_login>",
602 602 "permission" : "repository.(read|write|admin)"
603 603 },
604 604 …
605 605 {
606 606 "type": "users_group",
607 607 "id" : "<usersgroupid>",
608 608 "name" : "<usersgroupname>",
609 609 "active": "<bool>",
610 610 "permission" : "repository.(read|write|admin)"
611 611 },
612 612 …
613 613 ],
614 614 "followers": [
615 615 {
616 616 "user_id" : "<user_id>",
617 617 "username" : "<username>",
618 618 "api_key" : "<api_key>",
619 619 "firstname": "<firstname>",
620 620 "lastname" : "<lastname>",
621 621 "email" : "<email>",
622 622 "emails": "<list_of_all_additional_emails>",
623 623 "ip_addresses": "<list_of_ip_addresses_for_user>",
624 624 "active" : "<bool>",
625 625 "admin" :Β  "<bool>",
626 626 "ldap_dn" : "<ldap_dn>",
627 627 "last_login": "<last_login>",
628 628 },
629 629 …
630 630 ],
631 631 <if with_revision_names == True>
632 632 "tags": {
633 633 "<tagname>": "<raw_id>",
634 634 ...
635 635 },
636 636 "branches": {
637 637 "<branchname>": "<raw_id>",
638 638 ...
639 639 },
640 640 "bookmarks": {
641 641 "<bookmarkname>": "<raw_id>",
642 642 ...
643 643 },
644 644 <if with_pullrequests == True>
645 645 "pull_requests": [
646 646 {
647 647 "status": "<pull_request_status>",
648 648 "pull_request_id": <pull_request_id>,
649 649 "description": "<pull_request_description>",
650 650 "title": "<pull_request_title>",
651 651 "url": "<pull_request_url>",
652 652 "reviewers": [
653 653 {
654 654 "username": "<user_id>",
655 655 },
656 656 ...
657 657 ],
658 658 "org_repo_url": "<repo_url>",
659 659 "org_ref_parts": [
660 660 "<ref_type>",
661 661 "<ref_name>",
662 662 "<raw_id>"
663 663 ],
664 664 "other_ref_parts": [
665 665 "<ref_type>",
666 666 "<ref_name>",
667 667 "<raw_id>"
668 668 ],
669 669 "comments": [
670 670 {
671 671 "username": "<user_id>",
672 672 "text": "<comment text>",
673 673 "comment_id": "<comment_id>",
674 674 },
675 675 ...
676 676 ],
677 677 "owner": "<username>",
678 678 "statuses": [
679 679 {
680 680 "status": "<status_of_review>", # "under_review", "approved" or "rejected"
681 681 "reviewer": "<user_id>",
682 682 "modified_at": "<date_time_of_review>" # iso 8601 date, server's timezone
683 683 },
684 684 ...
685 685 ],
686 686 "revisions": [
687 687 "<raw_id>",
688 688 ...
689 689 ]
690 690 },
691 691 ...
692 692 ]
693 693 }
694 694 error: null
695 695
696 696 get_repos
697 697 ^^^^^^^^^
698 698
699 699 List all existing repositories.
700 700 This command can only be executed using the api_key of a user with admin rights,
701 701 or that of a regular user with at least read access to the repository.
702 702
703 703 INPUT::
704 704
705 705 id : <id_for_response>
706 706 api_key : "<api_key>"
707 707 method : "get_repos"
708 708 args: { }
709 709
710 710 OUTPUT::
711 711
712 712 id : <id_given_in_input>
713 713 result: [
714 714 {
715 715 "repo_id" : "<repo_id>",
716 716 "repo_name" : "<reponame>"
717 717 "repo_type" : "<repo_type>",
718 718 "clone_uri" : "<clone_uri>",
719 719 "private" : "<bool>",
720 720 "created_on" : "<datetimecreated>",
721 721 "description" : "<description>",
722 722 "landing_rev": "<landing_rev>",
723 723 "owner": "<repo_owner>",
724 724 "fork_of": "<name_of_fork_parent>",
725 725 "enable_downloads": "<bool>",
726 726 "enable_statistics": "<bool>",
727 727 },
728 728 …
729 729 ]
730 730 error: null
731 731
732 732 get_repo_nodes
733 733 ^^^^^^^^^^^^^^
734 734
735 735 Return a list of files and directories for a given path at the given revision.
736 736 It is possible to specify ret_type to show only ``files`` or ``dirs``.
737 737 This command can only be executed using the api_key of a user with admin rights.
738 738
739 739 INPUT::
740 740
741 741 id : <id_for_response>
742 742 api_key : "<api_key>"
743 743 method : "get_repo_nodes"
744 744 args: {
745 745 "repoid" : "<reponame or repo_id>"
746 746 "revision" : "<revision>",
747 747 "root_path" : "<root_path>",
748 748 "ret_type" : "<ret_type> = Optional('all')"
749 749 }
750 750
751 751 OUTPUT::
752 752
753 753 id : <id_given_in_input>
754 754 result: [
755 755 {
756 756 "name" : "<name>"
757 757 "type" : "<type>",
758 758 },
759 759 …
760 760 ]
761 761 error: null
762 762
763 763 create_repo
764 764 ^^^^^^^^^^^
765 765
766 766 Create a repository. If the repository name contains "/", the repository will be
767 767 created in the repository group indicated by that path. Any such repository
768 768 groups need to exist before calling this method, or the call will fail.
769 769 For example "foo/bar/baz" will create a repository "baz" inside the repository
770 770 group "bar" which itself is in a repository group "foo", but both "foo" and
771 771 "bar" already need to exist before calling this method.
772 772 This command can only be executed using the api_key of a user with admin rights,
773 773 or that of a regular user with create repository permission.
774 774 Regular users cannot specify owner parameter.
775 775
776 776 INPUT::
777 777
778 778 id : <id_for_response>
779 779 api_key : "<api_key>"
780 780 method : "create_repo"
781 781 args: {
782 782 "repo_name" : "<reponame>",
783 783 "owner" : "<owner_name_or_id = Optional(=apiuser)>",
784 784 "repo_type" : "<repo_type> = Optional('hg')",
785 785 "description" : "<description> = Optional('')",
786 786 "private" : "<bool> = Optional(False)",
787 787 "clone_uri" : "<clone_uri> = Optional(None)",
788 788 "landing_rev" : "<landing_rev> = Optional('tip')",
789 789 "enable_downloads": "<bool> = Optional(False)",
790 790 "enable_statistics": "<bool> = Optional(False)",
791 791 }
792 792
793 793 OUTPUT::
794 794
795 795 id : <id_given_in_input>
796 796 result: {
797 797 "msg": "Created new repository `<reponame>`",
798 798 "repo": {
799 799 "repo_id" : "<repo_id>",
800 800 "repo_name" : "<reponame>"
801 801 "repo_type" : "<repo_type>",
802 802 "clone_uri" : "<clone_uri>",
803 803 "private" : "<bool>",
804 804 "created_on" : "<datetimecreated>",
805 805 "description" : "<description>",
806 806 "landing_rev": "<landing_rev>",
807 807 "owner": "<username or user_id>",
808 808 "fork_of": "<name_of_fork_parent>",
809 809 "enable_downloads": "<bool>",
810 810 "enable_statistics": "<bool>",
811 811 },
812 812 }
813 813 error: null
814 814
815 815 update_repo
816 816 ^^^^^^^^^^^
817 817
818 818 Update a repository.
819 819 This command can only be executed using the api_key of a user with admin rights,
820 820 or that of a regular user with create repository permission.
821 821 Regular users cannot specify owner parameter.
822 822
823 823 INPUT::
824 824
825 825 id : <id_for_response>
826 826 api_key : "<api_key>"
827 827 method : "update_repo"
828 828 args: {
829 829 "repoid" : "<reponame or repo_id>"
830 830 "name" : "<reponame> = Optional('')",
831 831 "group" : "<group_id> = Optional(None)",
832 832 "owner" : "<owner_name_or_id = Optional(=apiuser)>",
833 833 "description" : "<description> = Optional('')",
834 834 "private" : "<bool> = Optional(False)",
835 835 "clone_uri" : "<clone_uri> = Optional(None)",
836 836 "landing_rev" : "<landing_rev> = Optional('tip')",
837 837 "enable_downloads": "<bool> = Optional(False)",
838 838 "enable_statistics": "<bool> = Optional(False)",
839 839 }
840 840
841 841 OUTPUT::
842 842
843 843 id : <id_given_in_input>
844 844 result: {
845 845 "msg": "updated repo ID:repo_id `<reponame>`",
846 846 "repository": {
847 847 "repo_id" : "<repo_id>",
848 848 "repo_name" : "<reponame>"
849 849 "repo_type" : "<repo_type>",
850 850 "clone_uri" : "<clone_uri>",
851 851 "private": "<bool>",
852 852 "created_on" : "<datetimecreated>",
853 853 "description" : "<description>",
854 854 "landing_rev": "<landing_rev>",
855 855 "owner": "<username or user_id>",
856 856 "fork_of": "<name_of_fork_parent>",
857 857 "enable_downloads": "<bool>",
858 858 "enable_statistics": "<bool>",
859 859 "last_changeset": {
860 860 "author": "<full_author>",
861 861 "date": "<date_time_of_commit>",
862 862 "message": "<commit_message>",
863 863 "raw_id": "<raw_id>",
864 864 "revision": "<numeric_revision>",
865 865 "short_id": "<short_id>"
866 866 }
867 867 },
868 868 }
869 869 error: null
870 870
871 871 fork_repo
872 872 ^^^^^^^^^
873 873
874 874 Create a fork of the given repo. If using Celery, this will
875 875 return success message immediately and a fork will be created
876 876 asynchronously.
877 877 This command can only be executed using the api_key of a user with admin
878 878 rights, or with the global fork permission, by a regular user with create
879 879 repository permission and at least read access to the repository.
880 880 Regular users cannot specify owner parameter.
881 881
882 882 INPUT::
883 883
884 884 id : <id_for_response>
885 885 api_key : "<api_key>"
886 886 method : "fork_repo"
887 887 args: {
888 888 "repoid" : "<reponame or repo_id>",
889 889 "fork_name": "<forkname>",
890 890 "owner": "<username or user_id = Optional(=apiuser)>",
891 891 "description": "<description>",
892 892 "copy_permissions": "<bool>",
893 893 "private": "<bool>",
894 894 "landing_rev": "<landing_rev>"
895 895
896 896 }
897 897
898 898 OUTPUT::
899 899
900 900 id : <id_given_in_input>
901 901 result: {
902 902 "msg": "Created fork of `<reponame>` as `<forkname>`",
903 903 "success": true
904 904 }
905 905 error: null
906 906
907 907 delete_repo
908 908 ^^^^^^^^^^^
909 909
910 910 Delete a repository.
911 911 This command can only be executed using the api_key of a user with admin rights,
912 912 or that of a regular user with admin access to the repository.
913 913 When ``forks`` param is set it is possible to detach or delete forks of the deleted repository.
914 914
915 915 INPUT::
916 916
917 917 id : <id_for_response>
918 918 api_key : "<api_key>"
919 919 method : "delete_repo"
920 920 args: {
921 921 "repoid" : "<reponame or repo_id>",
922 922 "forks" : "`delete` or `detach` = Optional(None)"
923 923 }
924 924
925 925 OUTPUT::
926 926
927 927 id : <id_given_in_input>
928 928 result: {
929 929 "msg": "Deleted repository `<reponame>`",
930 930 "success": true
931 931 }
932 932 error: null
933 933
934 934 grant_user_permission
935 935 ^^^^^^^^^^^^^^^^^^^^^
936 936
937 937 Grant permission for a user on the given repository, or update the existing one if found.
938 938 This command can only be executed using the api_key of a user with admin rights.
939 939
940 940 INPUT::
941 941
942 942 id : <id_for_response>
943 943 api_key : "<api_key>"
944 944 method : "grant_user_permission"
945 945 args: {
946 946 "repoid" : "<reponame or repo_id>"
947 947 "userid" : "<username or user_id>"
948 948 "perm" : "(repository.(none|read|write|admin))",
949 949 }
950 950
951 951 OUTPUT::
952 952
953 953 id : <id_given_in_input>
954 954 result: {
955 955 "msg" : "Granted perm: `<perm>` for user: `<username>` in repo: `<reponame>`",
956 956 "success": true
957 957 }
958 958 error: null
959 959
960 960 revoke_user_permission
961 961 ^^^^^^^^^^^^^^^^^^^^^^
962 962
963 963 Revoke permission for a user on the given repository.
964 964 This command can only be executed using the api_key of a user with admin rights.
965 965
966 966 INPUT::
967 967
968 968 id : <id_for_response>
969 969 api_key : "<api_key>"
970 970 method : "revoke_user_permission"
971 971 args: {
972 972 "repoid" : "<reponame or repo_id>"
973 973 "userid" : "<username or user_id>"
974 974 }
975 975
976 976 OUTPUT::
977 977
978 978 id : <id_given_in_input>
979 979 result: {
980 980 "msg" : "Revoked perm for user: `<username>` in repo: `<reponame>`",
981 981 "success": true
982 982 }
983 983 error: null
984 984
985 985 grant_user_group_permission
986 986 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
987 987
988 988 Grant permission for a user group on the given repository, or update the
989 989 existing one if found.
990 990 This command can only be executed using the api_key of a user with admin rights.
991 991
992 992 INPUT::
993 993
994 994 id : <id_for_response>
995 995 api_key : "<api_key>"
996 996 method : "grant_user_group_permission"
997 997 args: {
998 998 "repoid" : "<reponame or repo_id>"
999 999 "usersgroupid" : "<user group id or name>"
1000 1000 "perm" : "(repository.(none|read|write|admin))",
1001 1001 }
1002 1002
1003 1003 OUTPUT::
1004 1004
1005 1005 id : <id_given_in_input>
1006 1006 result: {
1007 1007 "msg" : "Granted perm: `<perm>` for group: `<usersgroupname>` in repo: `<reponame>`",
1008 1008 "success": true
1009 1009 }
1010 1010 error: null
1011 1011
1012 1012 revoke_user_group_permission
1013 1013 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1014 1014
1015 1015 Revoke permission for a user group on the given repository.
1016 1016 This command can only be executed using the api_key of a user with admin rights.
1017 1017
1018 1018 INPUT::
1019 1019
1020 1020 id : <id_for_response>
1021 1021 api_key : "<api_key>"
1022 1022 method : "revoke_user_group_permission"
1023 1023 args: {
1024 1024 "repoid" : "<reponame or repo_id>"
1025 1025 "usersgroupid" : "<user group id or name>"
1026 1026 }
1027 1027
1028 1028 OUTPUT::
1029 1029
1030 1030 id : <id_given_in_input>
1031 1031 result: {
1032 1032 "msg" : "Revoked perm for group: `<usersgroupname>` in repo: `<reponame>`",
1033 1033 "success": true
1034 1034 }
1035 1035 error: null
1036 1036
1037 1037 get_changesets
1038 1038 ^^^^^^^^^^^^^^
1039 1039
1040 1040 Get changesets of a given repository. This command can only be executed using the api_key
1041 1041 of a user with read permissions to the repository.
1042 1042
1043 1043 INPUT::
1044 1044
1045 1045 id : <id_for_response>
1046 1046 api_key : "<api_key>"
1047 1047 method : "get_changesets"
1048 1048 args: {
1049 1049 "repoid" : "<reponame or repo_id>",
1050 1050 "start": "<revision number> = Optional(None)",
1051 1051 "end": "<revision number> = Optional(None)",
1052 1052 "start_date": "<date> = Optional(None)", # in "%Y-%m-%dT%H:%M:%S" format
1053 1053 "end_date": "<date> = Optional(None)", # in "%Y-%m-%dT%H:%M:%S" format
1054 1054 "branch_name": "<branch name filter> = Optional(None)",
1055 1055 "reverse": "<bool> = Optional(False)",
1056 1056 "with_file_list": "<bool> = Optional(False)"
1057 1057 }
1058 1058
1059 1059 OUTPUT::
1060 1060
1061 1061 id : <id_given_in_input>
1062 1062 result: [
1063 1063 {
1064 1064 "raw_id": "<raw_id>",
1065 1065 "short_id": "short_id": "<short_id>",
1066 1066 "author": "<full_author>",
1067 1067 "date": "<date_time_of_commit>",
1068 1068 "message": "<commit_message>",
1069 1069 "revision": "<numeric_revision>",
1070 1070 <if with_file_list == True>
1071 1071 "added": [<list of added files>],
1072 1072 "changed": [<list of changed files>],
1073 1073 "removed": [<list of removed files>]
1074 1074 },
1075 1075 ...
1076 1076 ]
1077 1077 error: null
1078 1078
1079 1079 get_changeset
1080 1080 ^^^^^^^^^^^^^
1081 1081
1082 1082 Get information and review status for a given changeset. This command can only
1083 1083 be executed using the api_key of a user with read permissions to the
1084 1084 repository.
1085 1085
1086 1086 INPUT::
1087 1087
1088 1088 id : <id_for_response>
1089 1089 api_key : "<api_key>"
1090 1090 method : "get_changeset"
1091 1091 args: {
1092 1092 "repoid" : "<reponame or repo_id>",
1093 1093 "raw_id" : "<raw_id>",
1094 1094 "with_reviews": "<bool> = Optional(False)"
1095 1095 }
1096 1096
1097 1097 OUTPUT::
1098 1098
1099 1099 id : <id_given_in_input>
1100 1100 result: {
1101 1101 "author": "<full_author>",
1102 1102 "date": "<date_time_of_commit>",
1103 1103 "message": "<commit_message>",
1104 1104 "raw_id": "<raw_id>",
1105 1105 "revision": "<numeric_revision>",
1106 1106 "short_id": "<short_id>",
1107 1107 "reviews": [{
1108 1108 "reviewer": "<username>",
1109 1109 "modified_at": "<date_time_of_review>", # iso 8601 date, server's timezone
1110 1110 "status": "<status_of_review>", # "under_review", "approved" or "rejected"
1111 1111 },
1112 1112 ...
1113 1113 ]
1114 1114 }
1115 1115 error: null
1116 1116
1117 1117 Example output::
1118 1118
1119 1119 {
1120 1120 "id" : 1,
1121 1121 "error" : null,
1122 1122 "result" : {
1123 1123 "author" : {
1124 1124 "email" : "user@example.com",
1125 1125 "name" : "Kallithea Admin"
1126 1126 },
1127 1127 "changed" : [],
1128 1128 "short_id" : "e1022d3d28df",
1129 1129 "date" : "2017-03-28T09:09:03",
1130 1130 "added" : [
1131 1131 "README.rst"
1132 1132 ],
1133 1133 "removed" : [],
1134 1134 "revision" : 0,
1135 1135 "raw_id" : "e1022d3d28dfba02f626cde65dbe08f4ceb0e4e7",
1136 1136 "message" : "Added file via Kallithea",
1137 1137 "id" : "e1022d3d28dfba02f626cde65dbe08f4ceb0e4e7",
1138 1138 "reviews" : [
1139 1139 {
1140 1140 "status" : "under_review",
1141 1141 "modified_at" : "2017-03-28T09:17:08.618",
1142 1142 "reviewer" : "user"
1143 1143 }
1144 1144 ]
1145 1145 }
1146 1146 }
1147 1147
1148 1148 get_pullrequest
1149 1149 ^^^^^^^^^^^^^^^
1150 1150
1151 1151 Get information and review status for a given pull request. This command can only be executed
1152 1152 using the api_key of a user with read permissions to the original repository.
1153 1153
1154 1154 INPUT::
1155 1155
1156 1156 id : <id_for_response>
1157 1157 api_key : "<api_key>"
1158 1158 method : "get_pullrequest"
1159 1159 args: {
1160 1160 "pullrequest_id" : "<pullrequest_id>",
1161 1161 }
1162 1162
1163 1163 OUTPUT::
1164 1164
1165 1165 id : <id_given_in_input>
1166 1166 result: {
1167 1167 "status": "<pull_request_status>",
1168 1168 "pull_request_id": <pull_request_id>,
1169 1169 "description": "<pull_request_description>",
1170 1170 "title": "<pull_request_title>",
1171 1171 "url": "<pull_request_url>",
1172 1172 "reviewers": [
1173 1173 {
1174 1174 "username": "<user_name>",
1175 1175 },
1176 1176 ...
1177 1177 ],
1178 1178 "org_repo_url": "<repo_url>",
1179 1179 "org_ref_parts": [
1180 1180 "<ref_type>",
1181 1181 "<ref_name>",
1182 1182 "<raw_id>"
1183 1183 ],
1184 1184 "other_ref_parts": [
1185 1185 "<ref_type>",
1186 1186 "<ref_name>",
1187 1187 "<raw_id>"
1188 1188 ],
1189 1189 "comments": [
1190 1190 {
1191 1191 "username": "<user_name>",
1192 1192 "text": "<comment text>",
1193 1193 "comment_id": "<comment_id>",
1194 1194 },
1195 1195 ...
1196 1196 ],
1197 1197 "owner": "<username>",
1198 1198 "statuses": [
1199 1199 {
1200 1200 "status": "<status_of_review>", # "under_review", "approved" or "rejected"
1201 1201 "reviewer": "<user_name>",
1202 1202 "modified_at": "<date_time_of_review>" # iso 8601 date, server's timezone
1203 1203 },
1204 1204 ...
1205 1205 ],
1206 1206 "revisions": [
1207 1207 "<raw_id>",
1208 1208 ...
1209 1209 ]
1210 1210 },
1211 1211 error: null
1212 1212
1213 1213 comment_pullrequest
1214 1214 ^^^^^^^^^^^^^^^^^^^
1215 1215
1216 1216 Add comment, change status or close a given pull request. This command can only be executed
1217 1217 using the api_key of a user with read permissions to the original repository.
1218 1218
1219 1219 INPUT::
1220 1220
1221 1221 id : <id_for_response>
1222 1222 api_key : "<api_key>"
1223 1223 method : "comment_pullrequest"
1224 1224 args: {
1225 1225 "pull_request_id": "<pull_request_id>",
1226 1226 "comment_msg": Optional(''),
1227 1227 "status": Optional(None), # "under_review", "approved" or "rejected"
1228 1228 "close_pr": Optional(False)",
1229 1229 }
1230 1230
1231 1231 OUTPUT::
1232 1232
1233 1233 id : <id_given_in_input>
1234 1234 result: True
1235 1235 error: null
1236 1236
1237 1237
1238 1238 API access for web views
1239 1239 ------------------------
1240 1240
1241 1241 Kallithea HTTP entry points can also be accessed without login using bearer
1242 1242 authentication by including this header with the request::
1243 1243
1244 1244 Authentication: Bearer <api_key>
1245 1245
1246 1246 Alternatively, the API key can be passed in the URL query string using
1247 1247 ``?api_key=<api_key>``, though this is not recommended due to the increased
1248 1248 risk of API key leaks, and support will likely be removed in the future.
1249 1249
1250 1250 Exposing raw diffs is a good way to integrate with
1251 1251 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