Source

RhodeCode / docs / api / api.rst

Marcin Kuzminski eab0cf9 

Marcin Kuzminski 17c9393 
Marcin Kuzminski eab0cf9 




Marcin Kuzminski 256e729 
Marcin Kuzminski d80a68e 
Marcin Kuzminski 256e729 
Marcin Kuzminski eab0cf9 
Marcin Kuzminski 9da2475 

Marcin Kuzminski eab0cf9 
Marcin Kuzminski 0bd9725 




Marcin Kuzminski 320dec2 


Marcin Kuzminski 9da2475 


Marcin Kuzminski fee9895 
Marcin Kuzminski eab0cf9 
Marcin Kuzminski fee9895 
Marcin Kuzminski c1f1f06 
Marcin Kuzminski eab0cf9 




Marcin Kuzminski 256e729 
Marcin Kuzminski fee9895 
Marcin Kuzminski 256e729 
aeris 8628c87 
Marcin Kuzminski fee9895 
Marcin Kuzminski 256e729 


aeris 8628c87 
Marcin Kuzminski eab0cf9 
aeris 8628c87 



Marcin Kuzminski fee9895 
aeris 8628c87 
Marcin Kuzminski fee9895 
Marcin Kuzminski c1f1f06 


Marcin Kuzminski eab0cf9 


aeris 8628c87 
Marcin Kuzminski eab0cf9 

Marcin Kuzminski 7ac0951 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 7ac0951 



































Marcin Kuzminski eab0cf9 


aeris 8628c87 
Marcin Kuzminski eab0cf9 


aeris 8628c87 

Marcin Kuzminski 256e729 
Marcin Kuzminski eab0cf9 
Marcin Kuzminski 256e729 

Marcin Kuzminski c1f1f06 
aeris 8628c87 


Marcin Kuzminski d80a68e 
aeris 8628c87 
Marcin Kuzminski eab0cf9 
Marcin Kuzminski 256e729 

Marcin Kuzminski d80a68e 

aeris 8628c87 
Marcin Kuzminski 256e729 
aeris 8628c87 
Marcin Kuzminski 4565e65 
























Marcin Kuzminski e21cb7b 

























Marcin Kuzminski 0771f0f 


Marcin Kuzminski 14dffcf 
Marcin Kuzminski 0771f0f 


Marcin Kuzminski 87f0800 
Marcin Kuzminski 0771f0f 

Marcin Kuzminski c1f1f06 
Marcin Kuzminski 0771f0f 


Marcin Kuzminski 14dffcf 
Marcin Kuzminski 0771f0f 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 0771f0f 

Marcin Kuzminski d80a68e 
Marcin Kuzminski 0771f0f 



Marcin Kuzminski 7e3e9d0 
Marcin Kuzminski 0771f0f 

Marcin Kuzminski 12ceeda 








Marcin Kuzminski 0771f0f 




aeris 8628c87 





Marcin Kuzminski 87f0800 
aeris 8628c87 

Marcin Kuzminski c1f1f06 
aeris 8628c87 





Marcin Kuzminski d80a68e 
aeris 8628c87 

Marcin Kuzminski d80a68e 
aeris 8628c87 



Marcin Kuzminski d80a68e 
aeris 8628c87 

Marcin Kuzminski 12ceeda 

aeris 8628c87 




Marcin Kuzminski 87f0800 
Marcin Kuzminski 256e729 


Marcin Kuzminski bdc0ad1 
Marcin Kuzminski f2bd5b0 
aeris 8628c87 
Marcin Kuzminski 87f0800 
aeris 8628c87 

Marcin Kuzminski c1f1f06 
aeris 8628c87 



Marcin Kuzminski d80a68e 
aeris 8628c87 
Marcin Kuzminski d80a68e 




aeris 8628c87 



Marcin Kuzminski d80a68e 
aeris 8628c87 
Marcin Kuzminski d80a68e 
Marcin Kuzminski b902bae 
Marcin Kuzminski d80a68e 
Marcin Kuzminski b902bae 



Marcin Kuzminski d80a68e 
Marcin Kuzminski b902bae 




aeris 8628c87 


Marcin Kuzminski 87f0800 
Marcin Kuzminski bdc0ad1 


Marcin Kuzminski b902bae 
Marcin Kuzminski bdc0ad1 




Marcin Kuzminski c1f1f06 
Marcin Kuzminski bdc0ad1 


Marcin Kuzminski b63adad 
Marcin Kuzminski d80a68e 







Marcin Kuzminski bdc0ad1 



Marcin Kuzminski d80a68e 
Marcin Kuzminski bdc0ad1 
Marcin Kuzminski 374693a 

Marcin Kuzminski d80a68e 
Marcin Kuzminski 374693a 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 374693a 




Marcin Kuzminski b902bae 






















Marcin Kuzminski d80a68e 
Marcin Kuzminski b902bae 
Marcin Kuzminski d80a68e 

Marcin Kuzminski bdc0ad1 



aeris 8628c87 





Marcin Kuzminski 87f0800 
aeris 8628c87 

Marcin Kuzminski c1f1f06 
aeris 8628c87 


Marcin Kuzminski d80a68e 
aeris 8628c87 



Marcin Kuzminski d80a68e 
aeris 8628c87 

Marcin Kuzminski d80a68e 


aeris 8628c87 
Marcin Kuzminski d80a68e 

Marcin Kuzminski 0771f0f 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 0771f0f 

Marcin Kuzminski d80a68e 

Marcin Kuzminski 0771f0f 


aeris 8628c87 


Marcin Kuzminski 87f0800 
Marcin Kuzminski 0771f0f 





Marcin Kuzminski 87f0800 
Marcin Kuzminski 0771f0f 

Marcin Kuzminski c1f1f06 
Marcin Kuzminski 0771f0f 





Marcin Kuzminski d80a68e 
Marcin Kuzminski 0771f0f 

Marcin Kuzminski d80a68e 




Marcin Kuzminski 0771f0f 



aeris 8628c87 



Marcin Kuzminski 256e729 

Marcin Kuzminski 87f0800 
Marcin Kuzminski 256e729 

Marcin Kuzminski c1f1f06 
aeris 8628c87 


Marcin Kuzminski 0771f0f 
Marcin Kuzminski d80a68e 
aeris 8628c87 
Marcin Kuzminski 256e729 


Marcin Kuzminski d80a68e 
aeris 8628c87 
Marcin Kuzminski d80a68e 





aeris 8628c87 

Marcin Kuzminski 256e729 
Marcin Kuzminski 87f0800 
Marcin Kuzminski 631caf8 

aeris 8628c87 
Marcin Kuzminski 0f87c78 

Marcin Kuzminski 256e729 

Marcin Kuzminski 87f0800 
Marcin Kuzminski 256e729 

Marcin Kuzminski c1f1f06 
aeris 8628c87 


Marcin Kuzminski d80a68e 

aeris 8628c87 
Marcin Kuzminski 256e729 


Marcin Kuzminski d80a68e 
aeris 8628c87 
Marcin Kuzminski 0f87c78 
Marcin Kuzminski d80a68e 
Marcin Kuzminski 0f87c78 














Marcin Kuzminski c1f1f06 
Marcin Kuzminski 0f87c78 


Marcin Kuzminski d80a68e 

Marcin Kuzminski 0f87c78 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 0f87c78 



aeris 8628c87 


Marcin Kuzminski 87f0800 
Marcin Kuzminski 0771f0f 


Marcin Kuzminski ee45677 

Marcin Kuzminski 14dffcf 
Marcin Kuzminski 0771f0f 
Marcin Kuzminski 87f0800 
Marcin Kuzminski 0771f0f 

Marcin Kuzminski c1f1f06 
Marcin Kuzminski 0771f0f 


Marcin Kuzminski 14dffcf 
Marcin Kuzminski 0771f0f 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 0771f0f 

Marcin Kuzminski d80a68e 
Marcin Kuzminski 0771f0f 
Marcin Kuzminski d80a68e 
Marcin Kuzminski 347b005 

Marcin Kuzminski d80a68e 




Marcin Kuzminski 0771f0f 
Marcin Kuzminski ee45677 

Marcin Kuzminski d80a68e 









Marcin Kuzminski 0771f0f 


Marcin Kuzminski ee45677 

Marcin Kuzminski 0771f0f 









Marcin Kuzminski 87f0800 
aeris 8628c87 





Marcin Kuzminski 87f0800 
aeris 8628c87 

Marcin Kuzminski c1f1f06 
aeris 8628c87 





Marcin Kuzminski d80a68e 
aeris 8628c87 

Marcin Kuzminski d80a68e 
Marcin Kuzminski 0771f0f 
Marcin Kuzminski d80a68e 
Marcin Kuzminski 347b005 

Marcin Kuzminski d80a68e 




aeris 8628c87 





Marcin Kuzminski 203af05 



Marcin Kuzminski 0771f0f 

Marcin Kuzminski 203af05 

Marcin Kuzminski 87f0800 
Marcin Kuzminski 203af05 

Marcin Kuzminski c1f1f06 
Marcin Kuzminski 203af05 


Marcin Kuzminski d80a68e 
Marcin Kuzminski 203af05 

Marcin Kuzminski d80a68e 
Marcin Kuzminski 203af05 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 203af05 









aeris 8628c87 








Marcin Kuzminski 87f0800 
aeris 8628c87 

Marcin Kuzminski c1f1f06 
aeris 8628c87 


Marcin Kuzminski 0771f0f 
Marcin Kuzminski d80a68e 





aeris 8628c87 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 0771f0f 
Marcin Kuzminski d80a68e 
Marcin Kuzminski 04ef27c 
Marcin Kuzminski d80a68e 
Marcin Kuzminski 04ef27c 
Marcin Kuzminski d80a68e 
Marcin Kuzminski 04ef27c 

Marcin Kuzminski d80a68e 




Marcin Kuzminski 04ef27c 
Marcin Kuzminski 0771f0f 
aeris 8628c87 


Marcin Kuzminski 7dfcdf4 








Marcin Kuzminski c1f1f06 
Marcin Kuzminski 7dfcdf4 


Marcin Kuzminski d80a68e 
Marcin Kuzminski 7dfcdf4 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 7dfcdf4 
Marcin Kuzminski d80a68e 

Marcin Kuzminski 7dfcdf4 



Marcin Kuzminski 87f0800 






aeris 8628c87 


Marcin Kuzminski c1f1f06 
aeris 8628c87 
Marcin Kuzminski 87f0800 
aeris 8628c87 
Marcin Kuzminski d80a68e 

Marcin Kuzminski 87f0800 
aeris 8628c87 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 0771f0f 
Marcin Kuzminski d80a68e 

Marcin Kuzminski 0771f0f 
aeris 8628c87 
Marcin Kuzminski 631caf8 

Marcin Kuzminski 87f0800 





Marcin Kuzminski 631caf8 


Marcin Kuzminski c1f1f06 
Marcin Kuzminski 631caf8 
Marcin Kuzminski 87f0800 
Marcin Kuzminski 631caf8 
Marcin Kuzminski d80a68e 

Marcin Kuzminski 0771f0f 
Marcin Kuzminski 87f0800 
Marcin Kuzminski 0771f0f 
Marcin Kuzminski 87f0800 
Marcin Kuzminski d80a68e 
Marcin Kuzminski 87f0800 
Marcin Kuzminski d80a68e 

Marcin Kuzminski 87f0800 













Marcin Kuzminski c1f1f06 
Marcin Kuzminski 87f0800 


Marcin Kuzminski d80a68e 

Marcin Kuzminski 87f0800 




Marcin Kuzminski d80a68e 
Marcin Kuzminski 87f0800 
Marcin Kuzminski d80a68e 

Marcin Kuzminski 87f0800 

Marcin Kuzminski 0771f0f 
Marcin Kuzminski 87f0800 








Marcin Kuzminski c1f1f06 
Marcin Kuzminski 87f0800 


Marcin Kuzminski d80a68e 

Marcin Kuzminski 87f0800 



Marcin Kuzminski d80a68e 
Marcin Kuzminski 0771f0f 
Marcin Kuzminski d80a68e 

Marcin Kuzminski 0771f0f 
Marcin Kuzminski 87f0800 
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
.. _api:

===
API
===


Starting from RhodeCode version 1.2 a simple API was implemented.
There's a single schema for calling all api methods. API is implemented
with JSON protocol both ways. An url to send API request to RhodeCode is
<your_server>/_admin/api

API ACCESS FOR WEB VIEWS
++++++++++++++++++++++++

API access can also be turned on for each web view in RhodeCode that is 
decorated with `@LoginRequired` decorator. To enable API access simple change 
the standard login decorator to `@LoginRequired(api_access=True)`. 
After this change, a rhodecode view can be accessed without login by adding a 
GET parameter `?api_key=<api_key>` to url. By default this is only
enabled on RSS/ATOM feed views.


API ACCESS
++++++++++

All clients are required to send JSON-RPC spec JSON data::

    {   
        "id:"<id>",
        "api_key":"<api_key>",
        "method":"<method_name>",
        "args":{"<arg_key>":"<arg_val>"}
    }

Example call for autopulling remotes repos using curl::
    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"}}'

Simply provide
 - *id* A value of any type, which is used to match the response with the request that it is replying to.
 - *api_key* for access and permission validation.
 - *method* is name of method to call
 - *args* is an key:value list of arguments to pass to method

.. note::

    api_key can be found in your user account page


RhodeCode API will return always a JSON-RPC response::

    {   
        "id":<id>, # matching id sent by request
        "result": "<result>"|null, # JSON formatted result, null if any errors
        "error": "null"|<error_message> # JSON formatted error (if any)
    }

All responses from API will be `HTTP/1.0 200 OK`, if there's an error while
calling api *error* key from response will contain failure description
and result will be null.


API CLIENT
++++++++++

From version 1.4 RhodeCode adds a script that allows to easily
communicate with API. After installing RhodeCode a `rhodecode-api` script
will be available.

To get started quickly simply run::

  rhodecode-api _create_config --apikey=<youapikey> --apihost=<rhodecode host>
 
This will create a file named .config in the directory you executed it storing
json config file with credentials. You can skip this step and always provide
both of the arguments to be able to communicate with server


after that simply run any api command for example get_repo::
 
 rhodecode-api get_repo

 calling {"api_key": "<apikey>", "id": 75, "args": {}, "method": "get_repo"} to http://127.0.0.1:5000
 rhodecode said:
 {'error': 'Missing non optional `repoid` arg in JSON DATA',
  'id': 75,
  'result': None}

Ups looks like we forgot to add an argument

Let's try again now giving the repoid as parameters::

    rhodecode-api get_repo repoid:rhodecode   
 
    calling {"api_key": "<apikey>", "id": 39, "args": {"repoid": "rhodecode"}, "method": "get_repo"} to http://127.0.0.1:5000
    rhodecode said:
    {'error': None,
     'id': 39,
     'result': <json data...>}



API METHODS
+++++++++++


pull
----

Pulls given repo from remote location. Can be used to automatically keep
remote repos up to date. This command can be executed only using api_key
belonging to user with admin rights

INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "pull"
    args :    {
                "repoid" : "<reponame or repo_id>"
              }

OUTPUT::

    id : <id_given_in_input>
    result : "Pulled from `<reponame>`"
    error :  null


rescan_repos
------------

Dispatch rescan repositories action. If remove_obsolete is set
RhodeCode will delete repos that are in database but not in the filesystem.
This command can be executed only using api_key belonging to user with admin 
rights.

INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "rescan_repos"
    args :    {
                "remove_obsolete" : "<boolean = Optional(False)>"
              }

OUTPUT::

    id : <id_given_in_input>
    result : "{'added': [<list of names of added repos>], 
               'removed': [<list of names of removed repos>]}"
    error :  null


lock
----

Set locking state on given repository by given user.
This command can be executed only using api_key belonging to user with admin 
rights.

INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "lock"
    args :    {
                "repoid" : "<reponame or repo_id>"
                "userid" : "<user_id or username>",
                "locked" : "<bool true|false>"
                
              }

OUTPUT::

    id : <id_given_in_input>
    result : "User `<username>` set lock state for repo `<reponame>` to `true|false`"
    error :  null


get_user
--------

Get's an user by username or user_id, Returns empty result if user is not found.
This command can be executed only using api_key belonging to user with admin 
rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "get_user"
    args :    { 
                "userid" : "<username or user_id>"
              }

OUTPUT::

    id : <id_given_in_input>
    result: None if user does not exist or 
            {
                "user_id" :  "<user_id>",
                "username" : "<username>",
                "firstname": "<firstname>",
                "lastname" : "<lastname>",
                "email" :    "<email>",
                "emails":    "<list_of_all_additional_emails>",
                "active" :   "<bool>",
                "admin" :    "<bool>",
                "ldap_dn" :  "<ldap_dn>",
                "last_login": "<last_login>",
                "permissions": {
                    "global": ["hg.create.repository",
                               "repository.read",
                               "hg.register.manual_activate"],
                    "repositories": {"repo1": "repository.none"},
                    "repositories_groups": {"Group1": "group.read"}
                 },
            }

    error:  null


get_users
---------

Lists all existing users. This command can be executed only using api_key
belonging to user with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "get_users"
    args :    { }

OUTPUT::

    id : <id_given_in_input>
    result: [
              {
                "user_id" :  "<user_id>",
                "username" : "<username>",
                "firstname": "<firstname>",
                "lastname" : "<lastname>",
                "email" :    "<email>",
                "emails":    "<list_of_all_additional_emails>",
                "active" :   "<bool>",
                "admin" :    "<bool>",
                "ldap_dn" :  "<ldap_dn>",
                "last_login": "<last_login>",
              },

            ]
    error:  null


create_user
-----------

Creates new user. This command can 
be executed only using api_key belonging to user with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "create_user"
    args :    {
                "username" :  "<username>",
                "email" :     "<useremail>",
                "password" :  "<password>",
                "firstname" : "<firstname> = Optional(None)",
                "lastname" :  "<lastname> = Optional(None)",
                "active" :    "<bool> = Optional(True)",
                "admin" :     "<bool> = Optional(False)",
                "ldap_dn" :   "<ldap_dn> = Optional(None)"
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "msg" : "created new user `<username>`",
              "user": {
                "user_id" :  "<user_id>",
                "username" : "<username>",
                "firstname": "<firstname>",
                "lastname" : "<lastname>",
                "email" :    "<email>",
                "emails":    "<list_of_all_additional_emails>",
                "active" :   "<bool>",
                "admin" :    "<bool>",
                "ldap_dn" :  "<ldap_dn>",
                "last_login": "<last_login>",
              },
            }
    error:  null


update_user
-----------

updates given user if such user exists. This command can 
be executed only using api_key belonging to user with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "update_user"
    args :    {
                "userid" : "<user_id or username>",
                "username" :  "<username> = Optional",
                "email" :     "<useremail> = Optional",
                "password" :  "<password> = Optional",
                "firstname" : "<firstname> = Optional",
                "lastname" :  "<lastname> = Optional",
                "active" :    "<bool> = Optional",
                "admin" :     "<bool> = Optional",
                "ldap_dn" :   "<ldap_dn> = Optional"
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "msg" : "updated user ID:<userid> <username>",
              "user": {
                "user_id" :  "<user_id>",
                "username" : "<username>",
                "firstname": "<firstname>",
                "lastname" : "<lastname>",
                "email" :    "<email>",
                "emails":    "<list_of_all_additional_emails>",
                "active" :   "<bool>",
                "admin" :    "<bool>",
                "ldap_dn" :  "<ldap_dn>",
                "last_login": "<last_login>",
              },              
            }
    error:  null


delete_user
-----------


deletes givenuser if such user exists. This command can 
be executed only using api_key belonging to user with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "delete_user"
    args :    {
                "userid" : "<user_id or username>",
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "msg" : "deleted user ID:<userid> <username>",
              "user": null
            }
    error:  null


get_users_group
---------------

Gets an existing users group. This command can be executed only using api_key
belonging to user with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "get_users_group"
    args :    {
                "usersgroupid" : "<users group id or name>"
              }

OUTPUT::

    id : <id_given_in_input>
    result : None if group not exist
             {
               "users_group_id" : "<id>",
               "group_name" :     "<groupname>",
               "active":          "<bool>",
               "members" :  [
                              { 
                                "user_id" :  "<user_id>",
                                "username" : "<username>",
                                "firstname": "<firstname>",
                                "lastname" : "<lastname>",
                                "email" :    "<email>",
                                "emails":    "<list_of_all_additional_emails>",
                                "active" :   "<bool>",
                                "admin" :    "<bool>",
                                "ldap_dn" :  "<ldap_dn>",
                                "last_login": "<last_login>",
                              },

                            ]
             }
    error : null


get_users_groups
----------------

Lists all existing users groups. This command can be executed only using 
api_key belonging to user with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "get_users_groups"
    args :    { }

OUTPUT::

    id : <id_given_in_input>
    result : [
               {
               "users_group_id" : "<id>",
               "group_name" :     "<groupname>",
               "active":          "<bool>",
               },

              ]
    error : null


create_users_group
------------------

Creates new users group. This command can be executed only using api_key
belonging to user with admin rights


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "create_users_group"
    args:     {
                "group_name":  "<groupname>",
                "active":"<bool> = Optional(True)"
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "msg": "created new users group `<groupname>`",
              "users_group": {
                     "users_group_id" : "<id>",
                     "group_name" :     "<groupname>",
                     "active":          "<bool>",
               },
            }
    error:  null


add_user_to_users_group
-----------------------

Adds a user to a users group. If user exists in that group success will be 
`false`. This command can be executed only using api_key
belonging to user with admin rights


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "add_user_users_group"
    args:     {
                "usersgroupid" : "<users group id or name>",
                "userid" : "<user_id or username>",
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "success": True|False # depends on if member is in group
              "msg": "added member `<username>` to users group `<groupname>` | 
                      User is already in that group"
            }
    error:  null


remove_user_from_users_group
----------------------------

Removes a user from a users group. If user is not in given group success will
be `false`. This command can be executed only 
using api_key belonging to user with admin rights


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "remove_user_from_users_group"
    args:     {
                "usersgroupid" : "<users group id or name>",
                "userid" : "<user_id or username>",
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "success":  True|False,  # depends on if member is in group
              "msg": "removed member <username> from users group <groupname> | 
                      User wasn't in group"
            }
    error:  null


get_repo
--------

Gets an existing repository by it's name or repository_id. Members will return
either users_group or user associated to that repository. This command can 
be executed only using api_key belonging to user with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "get_repo"
    args:     {
                "repoid" : "<reponame or repo_id>"
              }

OUTPUT::

    id : <id_given_in_input>
    result: None if repository does not exist or
            {
                "repo_id" :     "<repo_id>",
                "repo_name" :   "<reponame>"
                "repo_type" :   "<repo_type>",
                "clone_uri" :   "<clone_uri>",
                "private": :    "<bool>",
                "created_on" :  "<datetimecreated>",                
                "description" : "<description>",
                "landing_rev":  "<landing_rev>",
                "owner":        "<repo_owner>",
                "fork_of":  "<name_of_fork_parent>",
                "members" :     [
                                  { 
                                    "type": "user",
                                    "user_id" :  "<user_id>",
                                    "username" : "<username>",
                                    "firstname": "<firstname>",
                                    "lastname" : "<lastname>",
                                    "email" :    "<email>",
                                    "emails":    "<list_of_all_additional_emails>",
                                    "active" :   "<bool>",
                                    "admin" :    "<bool>",
                                    "ldap_dn" :  "<ldap_dn>",
                                    "last_login": "<last_login>",
                                    "permission" : "repository.(read|write|admin)"
                                  },

                                  { 
                                    "type": "users_group",
                                    "id" :       "<usersgroupid>",
                                    "name" :     "<usersgroupname>",
                                    "active":    "<bool>",
                                    "permission" : "repository.(read|write|admin)"
                                  },

                                ]
            }
    error:  null


get_repos
---------

Lists all existing repositories. This command can be executed only using api_key
belonging to user with admin rights


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "get_repos"
    args:     { }

OUTPUT::

    id : <id_given_in_input>
    result: [
              {
                "repo_id" :     "<repo_id>",
                "repo_name" :   "<reponame>"
                "repo_type" :   "<repo_type>",
                "clone_uri" :   "<clone_uri>",
                "private": :    "<bool>",
                "created_on" :  "<datetimecreated>",                
                "description" : "<description>",
                "landing_rev":  "<landing_rev>",
                "owner":        "<repo_owner>",
                "fork_of":  "<name_of_fork_parent>",
              },

            ]
    error:  null


get_repo_nodes
--------------

returns a list of nodes and it's children in a flat list for a given path 
at given revision. It's possible to specify ret_type to show only `files` or 
`dirs`. This command can be executed only using api_key belonging to user 
with admin rights


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "get_repo_nodes"
    args:     {
                "repoid" : "<reponame or repo_id>"
                "revision"  : "<revision>",
                "root_path" : "<root_path>",
                "ret_type"  : "<ret_type> = Optional('all')"
              }

OUTPUT::

    id : <id_given_in_input>
    result: [
              {
                "name" :        "<name>"
                "type" :        "<type>",
              },

            ]
    error:  null


create_repo
-----------

Creates a repository. This command can be executed only using api_key
belonging to user with admin rights.
If repository name contains "/", all needed repository groups will be created.
For example "foo/bar/baz" will create groups "foo", "bar" (with "foo" as parent),
and create "baz" repository with "bar" as group.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "create_repo"
    args:     {
                "repo_name" :   "<reponame>",
                "owner" :       "<onwer_name_or_id>",
                "repo_type" :   "<repo_type>",
                "description" : "<description> = Optional('')",
                "private" :     "<bool> = Optional(False)",
                "clone_uri" :   "<clone_uri> = Optional(None)",
                "landing_rev" : "<landing_rev> = Optional('tip')",
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "msg": "Created new repository `<reponame>`",
              "repo": {
                "repo_id" :     "<repo_id>",
                "repo_name" :   "<reponame>"
                "repo_type" :   "<repo_type>",
                "clone_uri" :   "<clone_uri>",
                "private": :    "<bool>",
                "created_on" :  "<datetimecreated>",                
                "description" : "<description>",
                "landing_rev":  "<landing_rev>",
                "owner":        "<repo_owner>",
                "fork_of":  "<name_of_fork_parent>",
              },
            }
    error:  null


delete_repo
-----------

Deletes a repository. This command can be executed only using api_key
belonging to user with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "delete_repo"
    args:     {
                "repoid" : "<reponame or repo_id>"
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "msg": "Deleted repository `<reponame>`",
              "success": true
            }
    error:  null


grant_user_permission
---------------------

Grant permission for user on given repository, or update existing one
if found. This command can be executed only using api_key belonging to user 
with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "grant_user_permission"
    args:     {
                "repoid" : "<reponame or repo_id>"
                "userid" : "<username or user_id>"
                "perm" :       "(repository.(none|read|write|admin))",
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "msg" : "Granted perm: `<perm>` for user: `<username>` in repo: `<reponame>`",
              "success": true
            }
    error:  null


revoke_user_permission
----------------------

Revoke permission for user on given repository. This command can be executed 
only using api_key belonging to user with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method  : "revoke_user_permission"
    args:     {
                "repoid" : "<reponame or repo_id>"
                "userid" : "<username or user_id>"
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "msg" : "Revoked perm for user: `<username>` in repo: `<reponame>`",
              "success": true
            }
    error:  null


grant_users_group_permission
----------------------------

Grant permission for users group on given repository, or update
existing one if found. This command can be executed only using 
api_key belonging to user with admin rights.


INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method :  "grant_users_group_permission"
    args:     {
                "repoid" : "<reponame or repo_id>"
                "usersgroupid" : "<users group id or name>"
                "perm" : "(repository.(none|read|write|admin))",
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "msg" : "Granted perm: `<perm>` for group: `<usersgroupname>` in repo: `<reponame>`",
              "success": true
            }
    error:  null
    
    
revoke_users_group_permission
-----------------------------

Revoke permission for users group on given repository.This command can be 
executed only using api_key belonging to user with admin rights.

INPUT::

    id : <id_for_response>
    api_key : "<api_key>"
    method  : "revoke_users_group_permission"
    args:     {
                "repoid" : "<reponame or repo_id>"
                "usersgroupid" : "<users group id or name>"
              }

OUTPUT::

    id : <id_given_in_input>
    result: {
              "msg" : "Revoked perm for group: `<usersgroupname>` in repo: `<reponame>`",
              "success": true
            }
    error:  null