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