##// END OF EJS Templates
return proper id from users_group...
marcink -
r2531:d80a68e2 beta
parent child Browse files
Show More
@@ -7,7 +7,7 b' API'
7
7
8 Starting from RhodeCode version 1.2 a simple API was implemented.
8 Starting from RhodeCode version 1.2 a simple API was implemented.
9 There's a single schema for calling all api methods. API is implemented
9 There's a single schema for calling all api methods. API is implemented
10 with JSON protocol both ways. An url to send API request in RhodeCode is
10 with JSON protocol both ways. An url to send API request to RhodeCode is
11 <your_server>/_admin/api
11 <your_server>/_admin/api
12
12
13 API ACCESS FOR WEB VIEWS
13 API ACCESS FOR WEB VIEWS
@@ -63,7 +63,7 b' and result will be null.'
63 API CLIENT
63 API CLIENT
64 ++++++++++
64 ++++++++++
65
65
66 From version 1.4 RhodeCode adds a binary script that allows to easily
66 From version 1.4 RhodeCode adds a script that allows to easily
67 communicate with API. After installing RhodeCode a `rhodecode-api` script
67 communicate with API. After installing RhodeCode a `rhodecode-api` script
68 will be available.
68 will be available.
69
69
@@ -117,12 +117,13 b' INPUT::'
117 api_key : "<api_key>"
117 api_key : "<api_key>"
118 method : "pull"
118 method : "pull"
119 args : {
119 args : {
120 "repo_name" : "<reponame>"
120 "repoid" : "<reponame or repo_id>"
121 }
121 }
122
122
123 OUTPUT::
123 OUTPUT::
124
124
125 result : "Pulled from <reponame>"
125 id : <id_given_in_input>
126 result : "Pulled from `<reponame>`"
126 error : null
127 error : null
127
128
128
129
@@ -145,9 +146,10 b' INPUT::'
145
146
146 OUTPUT::
147 OUTPUT::
147
148
149 id : <id_given_in_input>
148 result: None if user does not exist or
150 result: None if user does not exist or
149 {
151 {
150 "id" : "<id>",
152 "user_id" : "<user_id>",
151 "username" : "<username>",
153 "username" : "<username>",
152 "firstname": "<firstname>",
154 "firstname": "<firstname>",
153 "lastname" : "<lastname>",
155 "lastname" : "<lastname>",
@@ -185,13 +187,15 b' INPUT::'
185
187
186 OUTPUT::
188 OUTPUT::
187
189
190 id : <id_given_in_input>
188 result: [
191 result: [
189 {
192 {
190 "id" : "<id>",
193 "user_id" : "<user_id>",
191 "username" : "<username>",
194 "username" : "<username>",
192 "firstname": "<firstname>",
195 "firstname": "<firstname>",
193 "lastname" : "<lastname>",
196 "lastname" : "<lastname>",
194 "email" : "<email>",
197 "email" : "<email>",
198 "emails": "<list_of_all_additional_emails>",
195 "active" : "<bool>",
199 "active" : "<bool>",
196 "admin" :  "<bool>",
200 "admin" :  "<bool>",
197 "ldap_dn" : "<ldap_dn>",
201 "ldap_dn" : "<ldap_dn>",
@@ -216,26 +220,27 b' INPUT::'
216 method : "create_user"
220 method : "create_user"
217 args : {
221 args : {
218 "username" : "<username>",
222 "username" : "<username>",
223 "email" : "<useremail>",
219 "password" : "<password>",
224 "password" : "<password>",
220 "email" : "<useremail>",
225 "firstname" : "<firstname> = Optional(None)",
221 "firstname" : "<firstname> = None",
226 "lastname" : "<lastname> = Optional(None)",
222 "lastname" : "<lastname> = None",
227 "active" : "<bool> = Optional(True)",
223 "active" : "<bool> = True",
228 "admin" : "<bool> = Optional(False)",
224 "admin" : "<bool> = False",
229 "ldap_dn" : "<ldap_dn> = Optional(None)"
225 "ldap_dn" : "<ldap_dn> = None"
226 }
230 }
227
231
228 OUTPUT::
232 OUTPUT::
229
233
234 id : <id_given_in_input>
230 result: {
235 result: {
231 "id" : "<new_user_id>",
236 "msg" : "created new user `<username>`",
232 "msg" : "created new user <username>",
233 "user": {
237 "user": {
234 "id" : "<id>",
238 "user_id" : "<user_id>",
235 "username" : "<username>",
239 "username" : "<username>",
236 "firstname": "<firstname>",
240 "firstname": "<firstname>",
237 "lastname" : "<lastname>",
241 "lastname" : "<lastname>",
238 "email" : "<email>",
242 "email" : "<email>",
243 "emails": "<list_of_all_additional_emails>",
239 "active" : "<bool>",
244 "active" : "<bool>",
240 "admin" :  "<bool>",
245 "admin" :  "<bool>",
241 "ldap_dn" : "<ldap_dn>",
246 "ldap_dn" : "<ldap_dn>",
@@ -259,27 +264,28 b' INPUT::'
259 method : "update_user"
264 method : "update_user"
260 args : {
265 args : {
261 "userid" : "<user_id or username>",
266 "userid" : "<user_id or username>",
262 "username" : "<username>",
267 "username" : "<username> = Optional",
263 "password" : "<password>",
268 "email" : "<useremail> = Optional",
264 "email" : "<useremail>",
269 "password" : "<password> = Optional",
265 "firstname" : "<firstname>",
270 "firstname" : "<firstname> = Optional",
266 "lastname" : "<lastname>",
271 "lastname" : "<lastname> = Optional",
267 "active" : "<bool>",
272 "active" : "<bool> = Optional",
268 "admin" : "<bool>",
273 "admin" : "<bool> = Optional",
269 "ldap_dn" : "<ldap_dn>"
274 "ldap_dn" : "<ldap_dn> = Optional"
270 }
275 }
271
276
272 OUTPUT::
277 OUTPUT::
273
278
279 id : <id_given_in_input>
274 result: {
280 result: {
275 "id" : "<edited_user_id>",
276 "msg" : "updated user ID:<userid> <username>",
281 "msg" : "updated user ID:<userid> <username>",
277 "user": {
282 "user": {
278 "id" : "<id>",
283 "user_id" : "<user_id>",
279 "username" : "<username>",
284 "username" : "<username>",
280 "firstname": "<firstname>",
285 "firstname": "<firstname>",
281 "lastname" : "<lastname>",
286 "lastname" : "<lastname>",
282 "email" : "<email>",
287 "email" : "<email>",
288 "emails": "<list_of_all_additional_emails>",
283 "active" : "<bool>",
289 "active" : "<bool>",
284 "admin" :  "<bool>",
290 "admin" :  "<bool>",
285 "ldap_dn" : "<ldap_dn>",
291 "ldap_dn" : "<ldap_dn>",
@@ -308,9 +314,10 b' INPUT::'
308
314
309 OUTPUT::
315 OUTPUT::
310
316
317 id : <id_given_in_input>
311 result: {
318 result: {
312 "id" : "<edited_user_id>",
319 "msg" : "deleted user ID:<userid> <username>",
313 "msg" : "deleted user ID:<userid> <username>"
320 "user": null
314 }
321 }
315 error: null
322 error: null
316
323
@@ -328,25 +335,29 b' INPUT::'
328 api_key : "<api_key>"
335 api_key : "<api_key>"
329 method : "get_users_group"
336 method : "get_users_group"
330 args : {
337 args : {
331 "group_name" : "<name>"
338 "usersgroupid" : "<users group id or name>"
332 }
339 }
333
340
334 OUTPUT::
341 OUTPUT::
335
342
343 id : <id_given_in_input>
336 result : None if group not exist
344 result : None if group not exist
337 {
345 {
338 "id" : "<id>",
346 "users_group_id" : "<id>",
339 "group_name" : "<groupname>",
347 "group_name" : "<groupname>",
340 "active": "<bool>",
348 "active": "<bool>",
341 "members" : [
349 "members" : [
342 { "id" : "<userid>",
350 {
351 "user_id" : "<user_id>",
343 "username" : "<username>",
352 "username" : "<username>",
344 "firstname": "<firstname>",
353 "firstname": "<firstname>",
345 "lastname" : "<lastname>",
354 "lastname" : "<lastname>",
346 "email" : "<email>",
355 "email" : "<email>",
356 "emails": "<list_of_all_additional_emails>",
347 "active" : "<bool>",
357 "active" : "<bool>",
348 "admin" :  "<bool>",
358 "admin" :  "<bool>",
349 "ldap" : "<ldap_dn>"
359 "ldap_dn" : "<ldap_dn>",
360 "last_login": "<last_login>",
350 },
361 },
351
362
352 ]
363 ]
@@ -370,25 +381,29 b' INPUT::'
370
381
371 OUTPUT::
382 OUTPUT::
372
383
384 id : <id_given_in_input>
373 result : [
385 result : [
374 {
386 {
375 "id" : "<id>",
387 "users_group_id" : "<id>",
376 "group_name" : "<groupname>",
388 "group_name" : "<groupname>",
377 "active": "<bool>",
389 "active": "<bool>",
378 "members" : [
390 "members" : [
379 {
391 {
380 "id" : "<userid>",
392 "user_id" : "<user_id>",
381 "username" : "<username>",
393 "username" : "<username>",
382 "firstname": "<firstname>",
394 "firstname": "<firstname>",
383 "lastname" : "<lastname>",
395 "lastname" : "<lastname>",
384 "email" : "<email>",
396 "email" : "<email>",
397 "emails": "<list_of_all_additional_emails>",
385 "active" : "<bool>",
398 "active" : "<bool>",
386 "admin" :  "<bool>",
399 "admin" :  "<bool>",
387 "ldap" : "<ldap_dn>"
400 "ldap_dn" : "<ldap_dn>",
401 "last_login": "<last_login>",
388 },
402 },
389
403
390 ]
404 ]
391 }
405 },
406
392 ]
407 ]
393 error : null
408 error : null
394
409
@@ -407,14 +422,34 b' INPUT::'
407 method : "create_users_group"
422 method : "create_users_group"
408 args: {
423 args: {
409 "group_name": "<groupname>",
424 "group_name": "<groupname>",
410 "active":"<bool> = True"
425 "active":"<bool> = Optional(True)"
411 }
426 }
412
427
413 OUTPUT::
428 OUTPUT::
414
429
430 id : <id_given_in_input>
415 result: {
431 result: {
416 "id": "<newusersgroupid>",
432 "msg": "created new users group `<groupname>`",
417 "msg": "created new users group <groupname>"
433 "users_group": {
434 "users_group_id" : "<id>",
435 "group_name" : "<groupname>",
436 "active": "<bool>",
437 "members" : [
438 {
439 "user_id" : "<user_id>",
440 "username" : "<username>",
441 "firstname": "<firstname>",
442 "lastname" : "<lastname>",
443 "email" : "<email>",
444 "emails": "<list_of_all_additional_emails>",
445 "active" : "<bool>",
446 "admin" :  "<bool>",
447 "ldap_dn" : "<ldap_dn>",
448 "last_login": "<last_login>",
449 },
450
451 ]
452 },
418 }
453 }
419 error: null
454 error: null
420
455
@@ -433,16 +468,16 b' INPUT::'
433 api_key : "<api_key>"
468 api_key : "<api_key>"
434 method : "add_user_users_group"
469 method : "add_user_users_group"
435 args: {
470 args: {
436 "group_name" : "<groupname>",
471 "usersgroupid" : "<users group id or name>",
437 "username" : "<username>"
472 "userid" : "<user_id or username>",
438 }
473 }
439
474
440 OUTPUT::
475 OUTPUT::
441
476
477 id : <id_given_in_input>
442 result: {
478 result: {
443 "id": "<newusersgroupmemberid>",
444 "success": True|False # depends on if member is in group
479 "success": True|False # depends on if member is in group
445 "msg": "added member <username> to users group <groupname> |
480 "msg": "added member `<username>` to users group `<groupname>` |
446 User is already in that group"
481 User is already in that group"
447 }
482 }
448 error: null
483 error: null
@@ -462,12 +497,13 b' INPUT::'
462 api_key : "<api_key>"
497 api_key : "<api_key>"
463 method : "remove_user_from_users_group"
498 method : "remove_user_from_users_group"
464 args: {
499 args: {
465 "group_name" : "<groupname>",
500 "usersgroupid" : "<users group id or name>",
466 "username" : "<username>"
501 "userid" : "<user_id or username>",
467 }
502 }
468
503
469 OUTPUT::
504 OUTPUT::
470
505
506 id : <id_given_in_input>
471 result: {
507 result: {
472 "success": True|False, # depends on if member is in group
508 "success": True|False, # depends on if member is in group
473 "msg": "removed member <username> from users group <groupname> |
509 "msg": "removed member <username> from users group <groupname> |
@@ -495,26 +531,32 b' INPUT::'
495
531
496 OUTPUT::
532 OUTPUT::
497
533
534 id : <id_given_in_input>
498 result: None if repository does not exist or
535 result: None if repository does not exist or
499 {
536 {
500 "id" : "<id>",
537 "repo_id" : "<repo_id>",
501 "repo_name" : "<reponame>"
538 "repo_name" : "<reponame>"
502 "type" : "<type>",
539 "repo_type" : "<repo_type>",
503 "description" : "<description>",
504 "clone_uri" : "<clone_uri>",
540 "clone_uri" : "<clone_uri>",
505 "private": : "<bool>",
541 "private": : "<bool>",
506 "created_on" : "<datetimecreated>",
542 "created_on" : "<datetimecreated>",
543 "description" : "<description>",
544 "landing_rev": "<landing_rev>",
545 "owner": "<repo_owner>",
546 "fork_of": "<name_of_fork_parent>",
507 "members" : [
547 "members" : [
508 {
548 {
509 "type": "user",
549 "type": "user",
510 "id" : "<userid>",
550 "user_id" : "<user_id>",
511 "username" : "<username>",
551 "username" : "<username>",
512 "firstname": "<firstname>",
552 "firstname": "<firstname>",
513 "lastname" : "<lastname>",
553 "lastname" : "<lastname>",
514 "email" : "<email>",
554 "email" : "<email>",
555 "emails": "<list_of_all_additional_emails>",
515 "active" : "<bool>",
556 "active" : "<bool>",
516 "admin" :  "<bool>",
557 "admin" :  "<bool>",
517 "ldap" : "<ldap_dn>",
558 "ldap_dn" : "<ldap_dn>",
559 "last_login": "<last_login>",
518 "permission" : "repository.(read|write|admin)"
560 "permission" : "repository.(read|write|admin)"
519 },
561 },
520
562
@@ -547,15 +589,19 b' INPUT::'
547
589
548 OUTPUT::
590 OUTPUT::
549
591
592 id : <id_given_in_input>
550 result: [
593 result: [
551 {
594 {
552 "id" : "<id>",
595 "repo_id" : "<repo_id>",
553 "repo_name" : "<reponame>"
596 "repo_name" : "<reponame>"
554 "type" : "<type>",
597 "repo_type" : "<repo_type>",
555 "description" : "<description>",
556 "clone_uri" : "<clone_uri>",
598 "clone_uri" : "<clone_uri>",
557 "private": : "<bool>",
599 "private": : "<bool>",
558 "created_on" : "<datetimecreated>",
600 "created_on" : "<datetimecreated>",
601 "description" : "<description>",
602 "landing_rev": "<landing_rev>",
603 "owner": "<repo_owner>",
604 "fork_of": "<name_of_fork_parent>",
559 },
605 },
560
606
561 ]
607 ]
@@ -577,14 +623,15 b' INPUT::'
577 api_key : "<api_key>"
623 api_key : "<api_key>"
578 method : "get_repo_nodes"
624 method : "get_repo_nodes"
579 args: {
625 args: {
580 "repo_name" : "<reponame>",
626 "repoid" : "<reponame or repo_id>"
581 "revision" : "<revision>",
627 "revision" : "<revision>",
582 "root_path" : "<root_path>",
628 "root_path" : "<root_path>",
583 "ret_type" : "<ret_type>" = 'all'
629 "ret_type" : "<ret_type> = Optional('all')"
584 }
630 }
585
631
586 OUTPUT::
632 OUTPUT::
587
633
634 id : <id_given_in_input>
588 result: [
635 result: [
589 {
636 {
590 "name" : "<name>"
637 "name" : "<name>"
@@ -612,26 +659,30 b' INPUT::'
612 method : "create_repo"
659 method : "create_repo"
613 args: {
660 args: {
614 "repo_name" : "<reponame>",
661 "repo_name" : "<reponame>",
615 "owner_name" : "<ownername>",
662 "owner" : "<onwer_name_or_id>",
616 "description" : "<description> = ''",
663 "repo_type" : "<repo_type>",
617 "repo_type" : "<type> = 'hg'",
664 "description" : "<description> = Optional('')",
618 "private" : "<bool> = False",
665 "private" : "<bool> = Optional(False)",
619 "clone_uri" : "<clone_uri> = None",
666 "clone_uri" : "<clone_uri> = Optional(None)",
667 "landing_rev" : "<landing_rev> = Optional('tip')",
620 }
668 }
621
669
622 OUTPUT::
670 OUTPUT::
623
671
672 id : <id_given_in_input>
624 result: {
673 result: {
625 "id": "<newrepoid>",
674 "msg": "Created new repository `<reponame>`",
626 "msg": "Created new repository <reponame>",
627 "repo": {
675 "repo": {
628 "id" : "<id>",
676 "repo_id" : "<repo_id>",
629 "repo_name" : "<reponame>"
677 "repo_name" : "<reponame>"
630 "type" : "<type>",
678 "repo_type" : "<repo_type>",
631 "description" : "<description>",
632 "clone_uri" : "<clone_uri>",
679 "clone_uri" : "<clone_uri>",
633 "private": : "<bool>",
680 "private": : "<bool>",
634 "created_on" : "<datetimecreated>",
681 "created_on" : "<datetimecreated>",
682 "description" : "<description>",
683 "landing_rev": "<landing_rev>",
684 "owner": "<repo_owner>",
685 "fork_of": "<name_of_fork_parent>",
635 },
686 },
636 }
687 }
637 error: null
688 error: null
@@ -650,13 +701,15 b' INPUT::'
650 api_key : "<api_key>"
701 api_key : "<api_key>"
651 method : "delete_repo"
702 method : "delete_repo"
652 args: {
703 args: {
653 "repo_name" : "<reponame>",
704 "repoid" : "<reponame or repo_id>"
654 }
705 }
655
706
656 OUTPUT::
707 OUTPUT::
657
708
709 id : <id_given_in_input>
658 result: {
710 result: {
659 "msg": "Deleted repository <reponame>",
711 "msg": "Deleted repository `<reponame>`",
712 "success": true
660 }
713 }
661 error: null
714 error: null
662
715
@@ -675,15 +728,17 b' INPUT::'
675 api_key : "<api_key>"
728 api_key : "<api_key>"
676 method : "grant_user_permission"
729 method : "grant_user_permission"
677 args: {
730 args: {
678 "repo_name" : "<reponame>",
731 "repoid" : "<reponame or repo_id>"
679 "username" : "<username>",
732 "userid" : "<username or user_id>"
680 "perm" : "(repository.(none|read|write|admin))",
733 "perm" : "(repository.(none|read|write|admin))",
681 }
734 }
682
735
683 OUTPUT::
736 OUTPUT::
684
737
738 id : <id_given_in_input>
685 result: {
739 result: {
686 "msg" : "Granted perm: <perm> for user: <username> in repo: <reponame>"
740 "msg" : "Granted perm: `<perm>` for user: `<username>` in repo: `<reponame>`",
741 "success": true
687 }
742 }
688 error: null
743 error: null
689
744
@@ -701,14 +756,16 b' INPUT::'
701 api_key : "<api_key>"
756 api_key : "<api_key>"
702 method : "revoke_user_permission"
757 method : "revoke_user_permission"
703 args: {
758 args: {
704 "repo_name" : "<reponame>",
759 "repoid" : "<reponame or repo_id>"
705 "username" : "<username>",
760 "userid" : "<username or user_id>"
706 }
761 }
707
762
708 OUTPUT::
763 OUTPUT::
709
764
765 id : <id_given_in_input>
710 result: {
766 result: {
711 "msg" : "Revoked perm for user: <suername> in repo: <reponame>"
767 "msg" : "Revoked perm for user: `<username>` in repo: `<reponame>`",
768 "success": true
712 }
769 }
713 error: null
770 error: null
714
771
@@ -727,15 +784,17 b' INPUT::'
727 api_key : "<api_key>"
784 api_key : "<api_key>"
728 method : "grant_users_group_permission"
785 method : "grant_users_group_permission"
729 args: {
786 args: {
730 "repo_name" : "<reponame>",
787 "repoid" : "<reponame or repo_id>"
731 "group_name" : "<usersgroupname>",
788 "usersgroupid" : "<users group id or name>"
732 "perm" : "(repository.(none|read|write|admin))",
789 "perm" : "(repository.(none|read|write|admin))",
733 }
790 }
734
791
735 OUTPUT::
792 OUTPUT::
736
793
794 id : <id_given_in_input>
737 result: {
795 result: {
738 "msg" : "Granted perm: <perm> for group: <usersgroupname> in repo: <reponame>"
796 "msg" : "Granted perm: `<perm>` for group: `<usersgroupname>` in repo: `<reponame>`",
797 "success": true
739 }
798 }
740 error: null
799 error: null
741
800
@@ -752,13 +811,15 b' INPUT::'
752 api_key : "<api_key>"
811 api_key : "<api_key>"
753 method : "revoke_users_group_permission"
812 method : "revoke_users_group_permission"
754 args: {
813 args: {
755 "repo_name" : "<reponame>",
814 "repoid" : "<reponame or repo_id>"
756 "users_group" : "<usersgroupname>",
815 "usersgroupid" : "<users group id or name>"
757 }
816 }
758
817
759 OUTPUT::
818 OUTPUT::
760
819
820 id : <id_given_in_input>
761 result: {
821 result: {
762 "msg" : "Revoked perm for group: <usersgroupname> in repo: <reponame>"
822 "msg" : "Revoked perm for group: `<usersgroupname>` in repo: `<reponame>`",
823 "success": true
763 }
824 }
764 error: null No newline at end of file
825 error: null
@@ -558,7 +558,7 b' class UsersGroup(Base, BaseModel):'
558 users_group = self
558 users_group = self
559
559
560 data = dict(
560 data = dict(
561 id=users_group.users_group_id,
561 users_group_id=users_group.users_group_id,
562 group_name=users_group.users_group_name,
562 group_name=users_group.users_group_name,
563 active=users_group.users_group_active,
563 active=users_group.users_group_active,
564 )
564 )
General Comments 0
You need to be logged in to leave comments. Login now