api.rst
1002 lines
| 29.4 KiB
| text/x-rst
|
RstLexer
r1446 | .. _api: | |||
r2095 | === | |||
r1446 | API | |||
=== | ||||
Mads Kiilerich
|
r4879 | Kallithea has a simple JSON RPC API with a single schema for calling all api | ||
methods. Everything is available by sending JSON encoded http(s) requests to | ||||
<your_server>/_admin/api . | ||||
r1446 | ||||
r1839 | API ACCESS FOR WEB VIEWS | |||
++++++++++++++++++++++++ | ||||
r1446 | ||||
Bradley M. Kuhn
|
r4192 | API access can also be turned on for each web view in Kallithea that is | ||
Mads Kiilerich
|
r4879 | decorated with the `@LoginRequired` decorator. Some views use | ||
`@LoginRequired(api_access=True)` and are always available. By default only | ||||
RSS/ATOM feed views are enabled. Other views are | ||||
only available if they have been white listed. Edit the | ||||
`api_access_controllers_whitelist` option in your .ini file and define views | ||||
that should have API access enabled. | ||||
r3769 | ||||
Mads Kiilerich
|
r4879 | For example, to enable API access to patch/diff raw file and archive:: | ||
r3769 | ||||
r3777 | api_access_controllers_whitelist = | |||
r3769 | ChangesetController:changeset_patch, | |||
ChangesetController:changeset_raw, | ||||
FilesController:raw, | ||||
FilesController:archivefile | ||||
Mads Kiilerich
|
r4879 | After this change, a Kallithea view can be accessed without login by adding a | ||
GET parameter `?api_key=<api_key>` to url. | ||||
r3769 | ||||
Mads Kiilerich
|
r4879 | Exposing raw diffs is a good way to integrate with | ||
r3769 | 3rd party services like code review, or build farms that could download archives. | |||
r1812 | ||||
r1839 | API ACCESS | |||
++++++++++ | ||||
Mads Kiilerich
|
r4879 | Clients must send JSON encoded JSON-RPC requests:: | ||
r1446 | ||||
r3224 | { | |||
Mads Kiilerich
|
r4879 | "id: "<id>", | ||
"api_key": "<api_key>", | ||||
"method": "<method_name>", | ||||
"args": {"<arg_key>": "<arg_val>"} | ||||
r1446 | } | |||
Mads Kiilerich
|
r4879 | For example, to pull to a local "CPython" mirror using curl:: | ||
r1708 | 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"}}' | |||
r1500 | ||||
Mads Kiilerich
|
r4879 | In general, provide | ||
- *id*, a value of any type, can be used to match the response with the request that it is replying to. | ||||
- *api_key*, for authentication and permission validation. | ||||
- *method*, the name of the method to call - a list of available methods can be found below. | ||||
- *args*, the arguments to pass to the method. | ||||
Nicolas VINOT
|
r1592 | |||
r1446 | .. note:: | |||
Nicolas VINOT
|
r1592 | |||
Mads Kiilerich
|
r4879 | api_key can be found or set on the user account page | ||
Nicolas VINOT
|
r1592 | |||
Mads Kiilerich
|
r4879 | The response to the JSON-RPC API call will always be a JSON structure:: | ||
Nicolas VINOT
|
r1592 | |||
r3224 | { | |||
Mads Kiilerich
|
r4879 | "id":<id>, # the id that was used in the request | ||
r2143 | "result": "<result>"|null, # JSON formatted result, null if any errors | |||
"error": "null"|<error_message> # JSON formatted error (if any) | ||||
r1446 | } | |||
Mads Kiilerich
|
r4879 | All responses from API will be `HTTP/1.0 200 OK`. If there is an error, | ||
the reponse will have a failure description in *error* and | ||||
*result* will be null. | ||||
r1446 | ||||
r2379 | ||||
API CLIENT | ||||
++++++++++ | ||||
Mads Kiilerich
|
r4879 | Kallithea comes with a `kallithea-api` command line tool providing a convenient | ||
way to call the JSON-RPC API. | ||||
r3224 | ||||
Mads Kiilerich
|
r4879 | For example, to call `get_repo`:: | ||
r2379 | ||||
Mads Kiilerich
|
r4879 | kallithea-api --apihost=<your.kallithea.server.url> --apikey=<yourapikey> get_repo | ||
r2379 | ||||
calling {"api_key": "<apikey>", "id": 75, "args": {}, "method": "get_repo"} to http://127.0.0.1:5000 | ||||
Bradley M. Kuhn
|
r4192 | Kallithea said: | ||
r2379 | {'error': 'Missing non optional `repoid` arg in JSON DATA', | |||
'id': 75, | ||||
'result': None} | ||||
Mads Kiilerich
|
r4879 | Oops, looks like we forgot to add an argument. Let's try again, now providing the repoid as parameter:: | ||
r2379 | ||||
Bradley M. Kuhn
|
r4192 | kallithea-api get_repo repoid:myrepo | ||
r3224 | ||||
Bradley M. Kuhn
|
r4192 | calling {"api_key": "<apikey>", "id": 39, "args": {"repoid": "myrepo"}, "method": "get_repo"} to http://127.0.0.1:5000 | ||
Kallithea said: | ||||
r2379 | {'error': None, | |||
'id': 39, | ||||
'result': <json data...>} | ||||
Mads Kiilerich
|
r4879 | To avoid specifying apihost and apikey every time, run:: | ||
kallithea-api --save-config --apihost=<your.kallithea.server.url> --apikey=<yourapikey> | ||||
This will create a `~/.config/kallithea` with the specified hostname and apikey | ||||
so you don't have to specify them every time. | ||||
r2379 | ||||
r1446 | API METHODS | |||
+++++++++++ | ||||
Nicolas VINOT
|
r1592 | |||
r1446 | pull | |||
---- | ||||
Mads Kiilerich
|
r4879 | Pull the given repo from remote location. Can be used to automatically keep | ||
remote repos up to date. | ||||
This command can only be executed using the api_key of a user with admin rights. | ||||
r1500 | ||||
INPUT:: | ||||
r2143 | id : <id_for_response> | |||
Nicolas VINOT
|
r1592 | api_key : "<api_key>" | ||
method : "pull" | ||||
args : { | ||||
r2531 | "repoid" : "<reponame or repo_id>" | |||
Nicolas VINOT
|
r1592 | } | ||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
result : "Pulled from `<reponame>`" | ||||
Nicolas VINOT
|
r1592 | error : null | ||
r2697 | rescan_repos | |||
------------ | ||||
Mads Kiilerich
|
r4879 | Rescan repositories. If remove_obsolete is set, | ||
Bradley M. Kuhn
|
r4192 | Kallithea will delete repos that are in database but not in the filesystem. | ||
Mads Kiilerich
|
r4879 | This command can only be executed using the api_key of a user with admin rights. | ||
r2697 | ||||
INPUT:: | ||||
id : <id_for_response> | ||||
api_key : "<api_key>" | ||||
method : "rescan_repos" | ||||
args : { | ||||
"remove_obsolete" : "<boolean = Optional(False)>" | ||||
} | ||||
OUTPUT:: | ||||
id : <id_given_in_input> | ||||
r3224 | result : "{'added': [<list of names of added repos>], | |||
r2697 | 'removed': [<list of names of removed repos>]}" | |||
error : null | ||||
r3235 | invalidate_cache | |||
---------------- | ||||
Invalidate cache for repository. | ||||
Mads Kiilerich
|
r4879 | This command can only be executed using the api_key of a user with admin rights, | ||
or that of a regular user with admin or write access to the repository. | ||||
r3235 | ||||
INPUT:: | ||||
id : <id_for_response> | ||||
api_key : "<api_key>" | ||||
method : "invalidate_cache" | ||||
args : { | ||||
"repoid" : "<reponame or repo_id>" | ||||
} | ||||
OUTPUT:: | ||||
id : <id_given_in_input> | ||||
Mads Kiilerich
|
r3759 | result : "Caches of repository `<reponame>`" | ||
r3235 | error : null | |||
Mads Kiilerich
|
r4879 | |||
r2737 | lock | |||
---- | ||||
Mads Kiilerich
|
r4879 | Set the locking state on the given repository by the given user. | ||
If param 'userid' is skipped, it is set to the id of the user who is calling this method. | ||||
If param 'locked' is skipped, the current lock state of the repository is returned. | ||||
This command can only be executed using the api_key of a user with admin rights, or that of a regular user with admin or write access to the repository. | ||||
r2737 | ||||
INPUT:: | ||||
id : <id_for_response> | ||||
api_key : "<api_key>" | ||||
method : "lock" | ||||
args : { | ||||
"repoid" : "<reponame or repo_id>" | ||||
r3161 | "userid" : "<user_id or username = Optional(=apiuser)>", | |||
r3457 | "locked" : "<bool true|false = Optional(=None)>" | |||
r2737 | } | |||
OUTPUT:: | ||||
id : <id_given_in_input> | ||||
r3809 | result : { | |||
r3808 | "repo": "<reponame>", | |||
"locked": "<bool true|false>", | ||||
"locked_since": "<float lock_time>", | ||||
"locked_by": "<username>", | ||||
"msg": "User `<username>` set lock state for repo `<reponame>` to `<false|true>`" | ||||
r3809 | } | |||
r2737 | error : null | |||
Rasmus Selsmark
|
r4493 | get_ip | ||
------ | ||||
r3126 | ||||
Mads Kiilerich
|
r4879 | Return IP address as seen from Kallithea server, together with all | ||
r3126 | defined IP addresses for given user. | |||
Mads Kiilerich
|
r4879 | This command can only be executed using the api_key of a user with admin rights. | ||
r3126 | ||||
INPUT:: | ||||
id : <id_for_response> | ||||
api_key : "<api_key>" | ||||
Rasmus Selsmark
|
r4493 | method : "get_ip" | ||
r3126 | args : { | |||
"userid" : "<user_id or username>", | ||||
} | ||||
OUTPUT:: | ||||
id : <id_given_in_input> | ||||
result : { | ||||
"ip_addr_server": <ip_from_clien>", | ||||
"user_ips": [ | ||||
{ | ||||
"ip_addr": "<ip_with_mask>", | ||||
"ip_range": ["<start_ip>", "<end_ip>"], | ||||
}, | ||||
... | ||||
] | ||||
} | ||||
r3224 | ||||
r3126 | error : null | |||
r1843 | get_user | |||
-------- | ||||
Mads Kiilerich
|
r4879 | Get a user by username or userid. The result is empty if user can't be found. | ||
If userid param is skipped, it is set to id of user who is calling this method. | ||||
Any userid can be specified when the command is executed using the api_key of a user with admin rights. | ||||
Regular users can only speicy their own userid. | ||||
r1843 | ||||
r1982 | ||||
r1843 | INPUT:: | |||
r2143 | id : <id_for_response> | |||
r1843 | api_key : "<api_key>" | |||
method : "get_user" | ||||
r3224 | args : { | |||
r3162 | "userid" : "<username or user_id Optional(=apiuser)>" | |||
r1843 | } | |||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r3224 | result: None if user does not exist or | |||
r1843 | { | |||
r3127 | "user_id" : "<user_id>", | |||
r3213 | "api_key" : "<api_key>", | |||
r3127 | "username" : "<username>", | |||
"firstname": "<firstname>", | ||||
"lastname" : "<lastname>", | ||||
"email" : "<email>", | ||||
"emails": "<list_of_all_additional_emails>", | ||||
"ip_addresses": "<list_of_ip_addresses_for_user>", | ||||
"active" : "<bool>", | ||||
"admin" :Â "<bool>", | ||||
"ldap_dn" : "<ldap_dn>", | ||||
"last_login": "<last_login>", | ||||
r2151 | "permissions": { | |||
"global": ["hg.create.repository", | ||||
"repository.read", | ||||
"hg.register.manual_activate"], | ||||
"repositories": {"repo1": "repository.none"}, | ||||
"repositories_groups": {"Group1": "group.read"} | ||||
}, | ||||
r1843 | } | |||
error: null | ||||
Nicolas VINOT
|
r1592 | get_users | ||
--------- | ||||
Mads Kiilerich
|
r4879 | List all existing users. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
Nicolas VINOT
|
r1592 | |||
r1982 | ||||
Nicolas VINOT
|
r1592 | INPUT:: | ||
r2143 | id : <id_for_response> | |||
Nicolas VINOT
|
r1592 | api_key : "<api_key>" | ||
method : "get_users" | ||||
args : { } | ||||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
Nicolas VINOT
|
r1592 | result: [ | ||
{ | ||||
r3127 | "user_id" : "<user_id>", | |||
Ton Plomp
|
r3940 | "api_key" : "<api_key>", | ||
r3127 | "username" : "<username>", | |||
"firstname": "<firstname>", | ||||
"lastname" : "<lastname>", | ||||
"email" : "<email>", | ||||
"emails": "<list_of_all_additional_emails>", | ||||
"ip_addresses": "<list_of_ip_addresses_for_user>", | ||||
"active" : "<bool>", | ||||
"admin" :Â "<bool>", | ||||
"ldap_dn" : "<ldap_dn>", | ||||
"last_login": "<last_login>", | ||||
Nicolas VINOT
|
r1592 | }, | ||
Mads Kiilerich
|
r3267 | … | ||
Nicolas VINOT
|
r1592 | ] | ||
error: null | ||||
r1982 | ||||
Nicolas VINOT
|
r1592 | create_user | ||
----------- | ||||
Mads Kiilerich
|
r4879 | Create new user. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
Nicolas VINOT
|
r1592 | |||
r1982 | ||||
Nicolas VINOT
|
r1592 | INPUT:: | ||
r2143 | id : <id_for_response> | |||
Nicolas VINOT
|
r1592 | api_key : "<api_key>" | ||
method : "create_user" | ||||
args : { | ||||
"username" : "<username>", | ||||
r2531 | "email" : "<useremail>", | |||
r3809 | "password" : "<password = Optional(None)>", | |||
r2531 | "firstname" : "<firstname> = Optional(None)", | |||
"lastname" : "<lastname> = Optional(None)", | ||||
"active" : "<bool> = Optional(True)", | ||||
"admin" : "<bool> = Optional(False)", | ||||
"ldap_dn" : "<ldap_dn> = Optional(None)" | ||||
Nicolas VINOT
|
r1592 | } | ||
r1500 | ||||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
Nicolas VINOT
|
r1592 | result: { | ||
r2531 | "msg" : "created new user `<username>`", | |||
r2365 | "user": { | |||
r2531 | "user_id" : "<user_id>", | |||
r2365 | "username" : "<username>", | |||
"firstname": "<firstname>", | ||||
"lastname" : "<lastname>", | ||||
"email" : "<email>", | ||||
r2531 | "emails": "<list_of_all_additional_emails>", | |||
r2365 | "active" : "<bool>", | |||
"admin" :Â "<bool>", | ||||
"ldap_dn" : "<ldap_dn>", | ||||
"last_login": "<last_login>", | ||||
}, | ||||
Nicolas VINOT
|
r1592 | } | ||
error: null | ||||
r1982 | ||||
r2002 | update_user | |||
----------- | ||||
Mads Kiilerich
|
r4879 | Update the given user if such user exists. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
r2002 | ||||
INPUT:: | ||||
r2143 | id : <id_for_response> | |||
r2002 | api_key : "<api_key>" | |||
method : "update_user" | ||||
args : { | ||||
r2009 | "userid" : "<user_id or username>", | |||
r3162 | "username" : "<username> = Optional(None)", | |||
"email" : "<useremail> = Optional(None)", | ||||
"password" : "<password> = Optional(None)", | ||||
"firstname" : "<firstname> = Optional(None)", | ||||
"lastname" : "<lastname> = Optional(None)", | ||||
"active" : "<bool> = Optional(None)", | ||||
"admin" : "<bool> = Optional(None)", | ||||
"ldap_dn" : "<ldap_dn> = Optional(None)" | ||||
r2002 | } | |||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r2002 | result: { | |||
r2507 | "msg" : "updated user ID:<userid> <username>", | |||
"user": { | ||||
r2531 | "user_id" : "<user_id>", | |||
Ton Plomp
|
r3940 | "api_key" : "<api_key>", | ||
r2507 | "username" : "<username>", | |||
"firstname": "<firstname>", | ||||
"lastname" : "<lastname>", | ||||
"email" : "<email>", | ||||
r2531 | "emails": "<list_of_all_additional_emails>", | |||
r2507 | "active" : "<bool>", | |||
"admin" :Â "<bool>", | ||||
"ldap_dn" : "<ldap_dn>", | ||||
"last_login": "<last_login>", | ||||
r3224 | }, | |||
r2365 | } | |||
error: null | ||||
delete_user | ||||
----------- | ||||
Mads Kiilerich
|
r4879 | Delete given user if such user exists. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
r2365 | ||||
INPUT:: | ||||
id : <id_for_response> | ||||
api_key : "<api_key>" | ||||
method : "delete_user" | ||||
args : { | ||||
"userid" : "<user_id or username>", | ||||
} | ||||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r2365 | result: { | |||
r2531 | "msg" : "deleted user ID:<userid> <username>", | |||
"user": null | ||||
r2002 | } | |||
error: null | ||||
Rasmus Selsmark
|
r4493 | get_user_group | ||
-------------- | ||||
Nicolas VINOT
|
r1592 | |||
Mads Kiilerich
|
r4879 | Get an existing user group. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
Nicolas VINOT
|
r1592 | |||
r1982 | ||||
Nicolas VINOT
|
r1592 | INPUT:: | ||
r2143 | id : <id_for_response> | |||
Nicolas VINOT
|
r1592 | api_key : "<api_key>" | ||
Rasmus Selsmark
|
r4493 | method : "get_user_group" | ||
Nicolas VINOT
|
r1592 | args : { | ||
Rasmus Selsmark
|
r4493 | "usergroupid" : "<user group id or name>" | ||
Nicolas VINOT
|
r1592 | } | ||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
Nicolas VINOT
|
r1592 | result : None if group not exist | ||
{ | ||||
r2531 | "users_group_id" : "<id>", | |||
"group_name" : "<groupname>", | ||||
"active": "<bool>", | ||||
Nicolas VINOT
|
r1592 | "members" : [ | ||
r3224 | { | |||
r2531 | "user_id" : "<user_id>", | |||
Ton Plomp
|
r3940 | "api_key" : "<api_key>", | ||
r1843 | "username" : "<username>", | |||
"firstname": "<firstname>", | ||||
"lastname" : "<lastname>", | ||||
"email" : "<email>", | ||||
r2531 | "emails": "<list_of_all_additional_emails>", | |||
r1843 | "active" : "<bool>", | |||
"admin" :Â "<bool>", | ||||
r2531 | "ldap_dn" : "<ldap_dn>", | |||
"last_login": "<last_login>", | ||||
r1843 | }, | |||
… | ||||
] | ||||
Nicolas VINOT
|
r1592 | } | ||
error : null | ||||
r1982 | ||||
Rasmus Selsmark
|
r4493 | get_user_groups | ||
--------------- | ||||
r1843 | ||||
Mads Kiilerich
|
r4879 | List all existing user groups. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
r1843 | ||||
r1982 | ||||
r1843 | INPUT:: | |||
r2143 | id : <id_for_response> | |||
r1843 | api_key : "<api_key>" | |||
Rasmus Selsmark
|
r4493 | method : "get_user_groups" | ||
r1843 | args : { } | |||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r1843 | result : [ | |||
{ | ||||
r2531 | "users_group_id" : "<id>", | |||
"group_name" : "<groupname>", | ||||
"active": "<bool>", | ||||
}, | ||||
… | ||||
r1843 | ] | |||
error : null | ||||
Rasmus Selsmark
|
r4493 | create_user_group | ||
----------------- | ||||
r1500 | ||||
Mads Kiilerich
|
r4879 | Create a new user group. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
r1500 | ||||
r1982 | ||||
r1500 | INPUT:: | |||
r2143 | id : <id_for_response> | |||
Nicolas VINOT
|
r1592 | api_key : "<api_key>" | ||
Rasmus Selsmark
|
r4493 | method : "create_user_group" | ||
Nicolas VINOT
|
r1592 | args: { | ||
r3714 | "group_name": "<groupname>", | |||
"owner" : "<onwer_name_or_id = Optional(=apiuser)>", | ||||
"active": "<bool> = Optional(True)" | ||||
Nicolas VINOT
|
r1592 | } | ||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
Nicolas VINOT
|
r1592 | result: { | ||
Mads Kiilerich
|
r3410 | "msg": "created new user group `<groupname>`", | ||
r2531 | "users_group": { | |||
"users_group_id" : "<id>", | ||||
"group_name" : "<groupname>", | ||||
"active": "<bool>", | ||||
}, | ||||
Nicolas VINOT
|
r1592 | } | ||
error: null | ||||
r1982 | ||||
Rasmus Selsmark
|
r4493 | add_user_to_user_group | ||
---------------------- | ||||
Nicolas VINOT
|
r1592 | |||
Mads Kiilerich
|
r4879 | Addsa user to a user group. If the user already is in that group, success will be | ||
`false`. | ||||
This command can only be executed using the api_key of a user with admin rights. | ||||
Nicolas VINOT
|
r1592 | |||
r1982 | ||||
Nicolas VINOT
|
r1592 | INPUT:: | ||
r2143 | id : <id_for_response> | |||
Nicolas VINOT
|
r1592 | api_key : "<api_key>" | ||
Rasmus Selsmark
|
r4493 | method : "add_user_user_group" | ||
Nicolas VINOT
|
r1592 | args: { | ||
Mads Kiilerich
|
r3410 | "usersgroupid" : "<user group id or name>", | ||
r2531 | "userid" : "<user_id or username>", | |||
Nicolas VINOT
|
r1592 | } | ||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
Nicolas VINOT
|
r1592 | result: { | ||
r1989 | "success": True|False # depends on if member is in group | |||
Mads Kiilerich
|
r4879 | "msg": "added member `<username>` to a user group `<groupname>` | | ||
r1989 | User is already in that group" | |||
} | ||||
error: null | ||||
Rasmus Selsmark
|
r4493 | remove_user_from_user_group | ||
--------------------------- | ||||
r1989 | ||||
Mads Kiilerich
|
r4879 | Remove a user from a user group. If the user isn't in the given group, success will | ||
be `false`. | ||||
This command can only be executed using the api_key of a user with admin rights. | ||||
r1989 | ||||
INPUT:: | ||||
r2143 | id : <id_for_response> | |||
r1989 | api_key : "<api_key>" | |||
Rasmus Selsmark
|
r4493 | method : "remove_user_from_user_group" | ||
r1989 | args: { | |||
Mads Kiilerich
|
r3410 | "usersgroupid" : "<user group id or name>", | ||
r2531 | "userid" : "<user_id or username>", | |||
r1989 | } | |||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r1989 | result: { | |||
"success": True|False, # depends on if member is in group | ||||
Mads Kiilerich
|
r3410 | "msg": "removed member <username> from user group <groupname> | | ||
r1989 | User wasn't in group" | |||
Nicolas VINOT
|
r1592 | } | ||
error: null | ||||
r1982 | ||||
r1843 | get_repo | |||
-------- | ||||
Mads Kiilerich
|
r4879 | Get an existing repository by its name or repository_id. Members will contain | ||
either users_group or user associated to that repository. | ||||
This command can only be executed using the api_key of a user with admin rights, | ||||
or that of a regular user with at least read access to the repository. | ||||
r1982 | ||||
r1843 | INPUT:: | |||
r2143 | id : <id_for_response> | |||
r1843 | api_key : "<api_key>" | |||
method : "get_repo" | ||||
args: { | ||||
r2010 | "repoid" : "<reponame or repo_id>" | |||
r1843 | } | |||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r1843 | result: None if repository does not exist or | |||
{ | ||||
r3115 | "repo_id" : "<repo_id>", | |||
"repo_name" : "<reponame>" | ||||
"repo_type" : "<repo_type>", | ||||
"clone_uri" : "<clone_uri>", | ||||
"enable_downloads": "<bool>", | ||||
"enable_locking": "<bool>", | ||||
r3224 | "enable_statistics": "<bool>", | |||
r3115 | "private": "<bool>", | |||
r3224 | "created_on" : "<date_time_created>", | |||
r3115 | "description" : "<description>", | |||
"landing_rev": "<landing_rev>", | ||||
r3174 | "last_changeset": { | |||
"author": "<full_author>", | ||||
"date": "<date_time_of_commit>", | ||||
"message": "<commit_message>", | ||||
"raw_id": "<raw_id>", | ||||
"revision": "<numeric_revision>", | ||||
"short_id": "<short_id>" | ||||
} | ||||
r3115 | "owner": "<repo_owner>", | |||
"fork_of": "<name_of_fork_parent>", | ||||
r1843 | "members" : [ | |||
r3224 | { | |||
r3213 | "type": "user", | |||
r3174 | "user_id" : "<user_id>", | |||
Ton Plomp
|
r3940 | "api_key" : "<api_key>", | ||
r3174 | "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>", | ||||
r1843 | "permission" : "repository.(read|write|admin)" | |||
}, | ||||
… | ||||
r3224 | { | |||
r3213 | "type": "users_group", | |||
r1843 | "id" : "<usersgroupid>", | |||
"name" : "<usersgroupname>", | ||||
"active": "<bool>", | ||||
"permission" : "repository.(read|write|admin)" | ||||
}, | ||||
… | ||||
] | ||||
r3213 | "followers": [ | |||
{ | ||||
"user_id" : "<user_id>", | ||||
"username" : "<username>", | ||||
Ton Plomp
|
r3940 | "api_key" : "<api_key>", | ||
r3213 | "firstname": "<firstname>", | |||
"lastname" : "<lastname>", | ||||
"email" : "<email>", | ||||
"emails": "<list_of_all_additional_emails>", | ||||
"ip_addresses": "<list_of_ip_addresses_for_user>", | ||||
"active" : "<bool>", | ||||
"admin" :Â "<bool>", | ||||
"ldap_dn" : "<ldap_dn>", | ||||
r3224 | "last_login": "<last_login>", | |||
r3213 | }, | |||
r3224 | … | |||
r3213 | ] | |||
r1843 | } | |||
error: null | ||||
r1982 | ||||
Nicolas VINOT
|
r1592 | get_repos | ||
--------- | ||||
Mads Kiilerich
|
r4879 | List all existing repositories. | ||
This command can only be executed using the api_key of a user with admin rights, | ||||
or that of a regular user with at least read access to the repository. | ||||
Nicolas VINOT
|
r1592 | |||
r1982 | ||||
Nicolas VINOT
|
r1592 | INPUT:: | ||
r2143 | id : <id_for_response> | |||
Nicolas VINOT
|
r1592 | api_key : "<api_key>" | ||
method : "get_repos" | ||||
args: { } | ||||
r1500 | ||||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
Nicolas VINOT
|
r1592 | result: [ | ||
{ | ||||
r3115 | "repo_id" : "<repo_id>", | |||
"repo_name" : "<reponame>" | ||||
"repo_type" : "<repo_type>", | ||||
"clone_uri" : "<clone_uri>", | ||||
"private": : "<bool>", | ||||
r3224 | "created_on" : "<datetimecreated>", | |||
r3115 | "description" : "<description>", | |||
"landing_rev": "<landing_rev>", | ||||
"owner": "<repo_owner>", | ||||
"fork_of": "<name_of_fork_parent>", | ||||
"enable_downloads": "<bool>", | ||||
"enable_locking": "<bool>", | ||||
r3224 | "enable_statistics": "<bool>", | |||
Nicolas VINOT
|
r1592 | }, | ||
… | ||||
] | ||||
error: null | ||||
r1810 | get_repo_nodes | |||
-------------- | ||||
Mads Kiilerich
|
r4879 | Return a list of files and directories for a given path at the given revision. | ||
It's possible to specify ret_type to show only `files` or `dirs`. | ||||
This command can only be executed using the api_key of a user with admin rights. | ||||
r1810 | ||||
r1982 | ||||
r1810 | INPUT:: | |||
r2143 | id : <id_for_response> | |||
r1810 | api_key : "<api_key>" | |||
method : "get_repo_nodes" | ||||
args: { | ||||
r2531 | "repoid" : "<reponame or repo_id>" | |||
r1810 | "revision" : "<revision>", | |||
"root_path" : "<root_path>", | ||||
r2531 | "ret_type" : "<ret_type> = Optional('all')" | |||
r1810 | } | |||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r1810 | result: [ | |||
{ | ||||
"name" : "<name>" | ||||
"type" : "<type>", | ||||
}, | ||||
… | ||||
] | ||||
error: null | ||||
Nicolas VINOT
|
r1592 | create_repo | ||
----------- | ||||
Mads Kiilerich
|
r4879 | Create a repository. If repository name contains "/", all needed repository | ||
groups will be created. For example "foo/bar/baz" will create repository groups | ||||
r3224 | "foo", "bar" (with "foo" as parent), and create "baz" repository with | |||
Mads Kiilerich
|
r4879 | "bar" as group. | ||
This command can only be executed using the api_key of a user with admin rights, | ||||
or that of a regular user with create repository permission. | ||||
Regular users cannot specify owner parameter. | ||||
Nicolas VINOT
|
r1592 | |||
r1982 | ||||
Nicolas VINOT
|
r1592 | INPUT:: | ||
r2143 | id : <id_for_response> | |||
Nicolas VINOT
|
r1592 | api_key : "<api_key>" | ||
method : "create_repo" | ||||
args: { | ||||
r3115 | "repo_name" : "<reponame>", | |||
r3163 | "owner" : "<onwer_name_or_id = Optional(=apiuser)>", | |||
r3115 | "repo_type" : "<repo_type> = Optional('hg')", | |||
"description" : "<description> = Optional('')", | ||||
"private" : "<bool> = Optional(False)", | ||||
"clone_uri" : "<clone_uri> = Optional(None)", | ||||
"landing_rev" : "<landing_rev> = Optional('tip')", | ||||
"enable_downloads": "<bool> = Optional(False)", | ||||
"enable_locking": "<bool> = Optional(False)", | ||||
"enable_statistics": "<bool> = Optional(False)", | ||||
Nicolas VINOT
|
r1592 | } | ||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r1843 | result: { | |||
r2531 | "msg": "Created new repository `<reponame>`", | |||
r2378 | "repo": { | |||
r3115 | "repo_id" : "<repo_id>", | |||
"repo_name" : "<reponame>" | ||||
"repo_type" : "<repo_type>", | ||||
"clone_uri" : "<clone_uri>", | ||||
"private": : "<bool>", | ||||
r3224 | "created_on" : "<datetimecreated>", | |||
r3115 | "description" : "<description>", | |||
"landing_rev": "<landing_rev>", | ||||
r3122 | "owner": "<username or user_id>", | |||
r3115 | "fork_of": "<name_of_fork_parent>", | |||
"enable_downloads": "<bool>", | ||||
"enable_locking": "<bool>", | ||||
r3224 | "enable_statistics": "<bool>", | |||
r2378 | }, | |||
r1843 | } | |||
Nicolas VINOT
|
r1592 | error: null | ||
r1982 | ||||
r3122 | fork_repo | |||
--------- | ||||
Mads Kiilerich
|
r4879 | Create a fork of given repo. If using celery, this will | ||
return success message immidiatelly and fork will be created | ||||
asynchronously. | ||||
This command can only be executed using the api_key of a user with admin rights, | ||||
or that of a regular user with fork permission and at least read access to the repository. | ||||
Regular users cannot specify owner parameter. | ||||
r3122 | ||||
INPUT:: | ||||
id : <id_for_response> | ||||
api_key : "<api_key>" | ||||
method : "fork_repo" | ||||
args: { | ||||
"repoid" : "<reponame or repo_id>", | ||||
"fork_name": "<forkname>", | ||||
r3163 | "owner": "<username or user_id = Optional(=apiuser)>", | |||
r3122 | "description": "<description>", | |||
"copy_permissions": "<bool>", | ||||
"private": "<bool>", | ||||
"landing_rev": "<landing_rev>" | ||||
r3224 | ||||
r3122 | } | |||
OUTPUT:: | ||||
id : <id_given_in_input> | ||||
result: { | ||||
"msg": "Created fork of `<reponame>` as `<forkname>`", | ||||
"success": true | ||||
} | ||||
error: null | ||||
r2003 | delete_repo | |||
----------- | ||||
Mads Kiilerich
|
r4879 | Delete a repository. | ||
This command can only be executed using the api_key of a user with admin rights, | ||||
or that of a regular user with admin access to the repository. | ||||
When `forks` param is set it's possible to detach or delete forks of the deleted repository. | ||||
r2003 | ||||
INPUT:: | ||||
r2143 | id : <id_for_response> | |||
r2003 | api_key : "<api_key>" | |||
method : "delete_repo" | ||||
args: { | ||||
r3641 | "repoid" : "<reponame or repo_id>", | |||
"forks" : "`delete` or `detach` = Optional(None)" | ||||
r2003 | } | |||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r2003 | result: { | |||
r2531 | "msg": "Deleted repository `<reponame>`", | |||
"success": true | ||||
r2003 | } | |||
error: null | ||||
r1982 | grant_user_permission | |||
--------------------- | ||||
Nicolas VINOT
|
r1592 | |||
Mads Kiilerich
|
r4879 | Grant permission for user on given repository, or update existing one if found. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
r1982 | ||||
Nicolas VINOT
|
r1592 | |||
INPUT:: | ||||
r2143 | id : <id_for_response> | |||
Nicolas VINOT
|
r1592 | api_key : "<api_key>" | ||
r1982 | method : "grant_user_permission" | |||
Nicolas VINOT
|
r1592 | args: { | ||
r2531 | "repoid" : "<reponame or repo_id>" | |||
"userid" : "<username or user_id>" | ||||
r1982 | "perm" : "(repository.(none|read|write|admin))", | |||
} | ||||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r1982 | result: { | |||
r2531 | "msg" : "Granted perm: `<perm>` for user: `<username>` in repo: `<reponame>`", | |||
"success": true | ||||
r1982 | } | |||
error: null | ||||
revoke_user_permission | ||||
---------------------- | ||||
Mads Kiilerich
|
r4879 | Revoke permission for user on given repository. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
r1982 | ||||
INPUT:: | ||||
r2143 | id : <id_for_response> | |||
r1982 | api_key : "<api_key>" | |||
method : "revoke_user_permission" | ||||
args: { | ||||
r2531 | "repoid" : "<reponame or repo_id>" | |||
"userid" : "<username or user_id>" | ||||
Nicolas VINOT
|
r1592 | } | ||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r1843 | result: { | |||
r2531 | "msg" : "Revoked perm for user: `<username>` in repo: `<reponame>`", | |||
"success": true | ||||
r1843 | } | |||
Nicolas VINOT
|
r1592 | error: null | ||
r1793 | ||||
r1982 | ||||
Rasmus Selsmark
|
r4493 | grant_user_group_permission | ||
--------------------------- | ||||
r1793 | ||||
Mads Kiilerich
|
r3410 | Grant permission for user group on given repository, or update | ||
Mads Kiilerich
|
r4879 | existing one if found. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
r1982 | ||||
r1793 | ||||
INPUT:: | ||||
r2143 | id : <id_for_response> | |||
r1793 | api_key : "<api_key>" | |||
Rasmus Selsmark
|
r4493 | method : "grant_user_group_permission" | ||
r1982 | args: { | |||
r2531 | "repoid" : "<reponame or repo_id>" | |||
Mads Kiilerich
|
r3410 | "usersgroupid" : "<user group id or name>" | ||
r1982 | "perm" : "(repository.(none|read|write|admin))", | |||
} | ||||
OUTPUT:: | ||||
r2531 | id : <id_given_in_input> | |||
r1982 | result: { | |||
r2531 | "msg" : "Granted perm: `<perm>` for group: `<usersgroupname>` in repo: `<reponame>`", | |||
"success": true | ||||
r1982 | } | |||
error: null | ||||
r3224 | ||||
Rasmus Selsmark
|
r4493 | revoke_user_group_permission | ||
---------------------------- | ||||
r1982 | ||||
Mads Kiilerich
|
r4879 | Revoke permission for user group on given repository. | ||
This command can only be executed using the api_key of a user with admin rights. | ||||
r1982 | ||||
INPUT:: | ||||
r2143 | id : <id_for_response> | |||
r1982 | api_key : "<api_key>" | |||
Rasmus Selsmark
|
r4493 | method : "revoke_user_group_permission" | ||
r1793 | args: { | |||
r2531 | "repoid" : "<reponame or repo_id>" | |||
Mads Kiilerich
|
r3410 | "usersgroupid" : "<user group id or name>" | ||
r1843 | } | |||
r1982 | ||||
r1843 | OUTPUT:: | |||
r1982 | ||||
r2531 | id : <id_given_in_input> | |||
r1843 | result: { | |||
r2531 | "msg" : "Revoked perm for group: `<usersgroupname>` in repo: `<reponame>`", | |||
"success": true | ||||
r1843 | } | |||
r3224 | error: null | |||