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