diff --git a/docs/api/api.rst b/docs/api/api.rst --- a/docs/api/api.rst +++ b/docs/api/api.rst @@ -13,10 +13,10 @@ with JSON protocol both ways. An url to 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 +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=` to url. By default this is only enabled on RSS/ATOM feed views. @@ -26,7 +26,7 @@ API ACCESS All clients are required to send JSON-RPC spec JSON data:: - { + { "id:"", "api_key":"", "method":"", @@ -49,7 +49,7 @@ Simply provide RhodeCode API will return always a JSON-RPC response:: - { + { "id":, # matching id sent by request "result": ""|null, # JSON formatted result, null if any errors "error": "null"| # JSON formatted error (if any) @@ -70,14 +70,14 @@ will be available. To get started quickly simply run:: rhodecode-api _create_config --apikey= --apihost= - + 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": "", "id": 75, "args": {}, "method": "get_repo"} to http://127.0.0.1:5000 @@ -90,8 +90,8 @@ Ups looks like we forgot to add an argum Let's try again now giving the repoid as parameters:: - rhodecode-api get_repo repoid:rhodecode - + rhodecode-api get_repo repoid:rhodecode + calling {"api_key": "", "id": 39, "args": {"repoid": "rhodecode"}, "method": "get_repo"} to http://127.0.0.1:5000 rhodecode said: {'error': None, @@ -132,7 +132,7 @@ 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 +This command can be executed only using api_key belonging to user with admin rights. INPUT:: @@ -147,17 +147,40 @@ INPUT:: OUTPUT:: id : - result : "{'added': [], + result : "{'added': [], 'removed': []}" error : null +invalidate_cache +---------------- + +Invalidate cache for repository. +This command can be executed only using api_key belonging to user with admin +rights or regular user that have write or admin or write access to repository. + +INPUT:: + + id : + api_key : "" + method : "invalidate_cache" + args : { + "repoid" : "" + } + +OUTPUT:: + + id : + result : "Cache for repository `` was invalidated: invalidated cache keys: " + error : null + lock ---- Set locking state on given repository by given user. If userid param is skipped -, then it is set to id of user whos calling this method. -This command can be executed only using api_key belonging to user with admin +, then it is set to id of user whos calling this method. If locked param is skipped +then function shows current lock state of given repo. +This command can be executed only using api_key belonging to user with admin rights or regular user that have admin or write access to repository. INPUT:: @@ -168,7 +191,7 @@ INPUT:: args : { "repoid" : "" "userid" : "", - "locked" : "" + "locked" : "" } OUTPUT:: @@ -183,7 +206,7 @@ show_ip Shows IP address as seen from RhodeCode server, together with all defined IP addresses for given user. -This command can be executed only using api_key belonging to user with admin +This command can be executed only using api_key belonging to user with admin rights. INPUT:: @@ -208,7 +231,7 @@ OUTPUT:: ... ] } - + error : null @@ -217,7 +240,7 @@ get_user Get's an user by username or user_id, Returns empty result if user is not found. If userid param is skipped it is set to id of user who is calling this method. -This command can be executed only using api_key belonging to user with admin +This command can be executed only using api_key belonging to user with admin rights, or regular users that cannot specify different userid than theirs @@ -226,16 +249,17 @@ INPUT:: id : api_key : "" method : "get_user" - args : { + args : { "userid" : "" } OUTPUT:: id : - result: None if user does not exist or + result: None if user does not exist or { "user_id" : "", + "api_key" : "", "username" : "", "firstname": "", "lastname" : "", @@ -289,7 +313,7 @@ OUTPUT:: "ldap_dn" : "", "last_login": "", }, - … + … ] error: null @@ -297,7 +321,7 @@ OUTPUT:: create_user ----------- -Creates new user. This command can +Creates new user. This command can be executed only using api_key belonging to user with admin rights. @@ -341,7 +365,7 @@ OUTPUT:: update_user ----------- -updates given user if such user exists. This command can +updates given user if such user exists. This command can be executed only using api_key belonging to user with admin rights. @@ -378,7 +402,7 @@ OUTPUT:: "admin" :  "", "ldap_dn" : "", "last_login": "", - }, + }, } error: null @@ -387,7 +411,7 @@ delete_user ----------- -deletes givenuser if such user exists. This command can +deletes givenuser if such user exists. This command can be executed only using api_key belonging to user with admin rights. @@ -413,7 +437,7 @@ OUTPUT:: get_users_group --------------- -Gets an existing users group. This command can be executed only using api_key +Gets an existing user group. This command can be executed only using api_key belonging to user with admin rights. @@ -423,7 +447,7 @@ INPUT:: api_key : "" method : "get_users_group" args : { - "usersgroupid" : "" + "usersgroupid" : "" } OUTPUT:: @@ -435,7 +459,7 @@ OUTPUT:: "group_name" : "", "active": "", "members" : [ - { + { "user_id" : "", "username" : "", "firstname": "", @@ -456,7 +480,7 @@ OUTPUT:: get_users_groups ---------------- -Lists all existing users groups. This command can be executed only using +Lists all existing user groups. This command can be executed only using api_key belonging to user with admin rights. @@ -484,7 +508,7 @@ OUTPUT:: create_users_group ------------------ -Creates new users group. This command can be executed only using api_key +Creates new user group. This command can be executed only using api_key belonging to user with admin rights @@ -502,7 +526,7 @@ OUTPUT:: id : result: { - "msg": "created new users group ``", + "msg": "created new user group ``", "users_group": { "users_group_id" : "", "group_name" : "", @@ -515,7 +539,7 @@ OUTPUT:: add_user_to_users_group ----------------------- -Adds a user to a users group. If user exists in that group success will be +Adds a user to a user 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 @@ -526,7 +550,7 @@ INPUT:: api_key : "" method : "add_user_users_group" args: { - "usersgroupid" : "", + "usersgroupid" : "", "userid" : "", } @@ -535,7 +559,7 @@ OUTPUT:: id : result: { "success": True|False # depends on if member is in group - "msg": "added member `` to users group `` | + "msg": "added member `` to user group `` | User is already in that group" } error: null @@ -544,8 +568,8 @@ OUTPUT:: 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 +Removes a user from a user 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 @@ -555,7 +579,7 @@ INPUT:: api_key : "" method : "remove_user_from_users_group" args: { - "usersgroupid" : "", + "usersgroupid" : "", "userid" : "", } @@ -564,7 +588,7 @@ OUTPUT:: id : result: { "success": True|False, # depends on if member is in group - "msg": "removed member from users group | + "msg": "removed member from user group | User wasn't in group" } error: null @@ -574,8 +598,8 @@ 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 +either users_group or user associated to that repository. This command can be +executed only using api_key belonging to user with admin rights or regular user that have at least read access to repository. @@ -599,9 +623,9 @@ OUTPUT:: "clone_uri" : "", "enable_downloads": "", "enable_locking": "", - "enable_statistics": "", + "enable_statistics": "", "private": "", - "created_on" : "", + "created_on" : "", "description" : "", "landing_rev": "", "last_changeset": { @@ -615,8 +639,8 @@ OUTPUT:: "owner": "", "fork_of": "", "members" : [ - { - "type": "user", + { + "type": "user", "user_id" : "", "username" : "", "firstname": "", @@ -630,8 +654,8 @@ OUTPUT:: "permission" : "repository.(read|write|admin)" }, … - { - "type": "users_group", + { + "type": "users_group", "id" : "", "name" : "", "active": "", @@ -639,6 +663,22 @@ OUTPUT:: }, … ] + "followers": [ + { + "user_id" : "", + "username" : "", + "firstname": "", + "lastname" : "", + "email" : "", + "emails": "", + "ip_addresses": "", + "active" : "", + "admin" :  "", + "ldap_dn" : "", + "last_login": "", + }, + … + ] } error: null @@ -646,8 +686,8 @@ OUTPUT:: get_repos --------- -Lists all existing repositories. This command can be executed only using -api_key belonging to user with admin rights or regular user that have +Lists all existing repositories. This command can be executed only using +api_key belonging to user with admin rights or regular user that have admin, write or read access to repository. @@ -668,14 +708,14 @@ OUTPUT:: "repo_type" : "", "clone_uri" : "", "private": : "", - "created_on" : "", + "created_on" : "", "description" : "", "landing_rev": "", "owner": "", "fork_of": "", "enable_downloads": "", "enable_locking": "", - "enable_statistics": "", + "enable_statistics": "", }, … ] @@ -685,9 +725,9 @@ OUTPUT:: 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 +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 @@ -720,9 +760,9 @@ create_repo ----------- Creates a repository. 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. This command can be executed only using api_key belonging to user with admin +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. This command can be executed only using api_key belonging to user with admin rights or regular user that have create repository permission. Regular users cannot specify owner parameter @@ -756,14 +796,14 @@ OUTPUT:: "repo_type" : "", "clone_uri" : "", "private": : "", - "created_on" : "", + "created_on" : "", "description" : "", "landing_rev": "", "owner": "", "fork_of": "", "enable_downloads": "", "enable_locking": "", - "enable_statistics": "", + "enable_statistics": "", }, } error: null @@ -792,7 +832,7 @@ INPUT:: "copy_permissions": "", "private": "", "landing_rev": "" - + } OUTPUT:: @@ -808,8 +848,10 @@ OUTPUT:: delete_repo ----------- -Deletes a repository. This command can be executed only using api_key belonging to user with admin -rights or regular user that have admin access to repository. +Deletes a repository. This command can be executed only using api_key belonging +to user with admin rights or regular user that have admin access to repository. +When `forks` param is set it's possible to detach or delete forks of deleting +repository INPUT:: @@ -818,7 +860,8 @@ INPUT:: api_key : "" method : "delete_repo" args: { - "repoid" : "" + "repoid" : "", + "forks" : "`delete` or `detach` = Optional(None)" } OUTPUT:: @@ -835,7 +878,7 @@ 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 +if found. This command can be executed only using api_key belonging to user with admin rights. @@ -863,7 +906,7 @@ OUTPUT:: revoke_user_permission ---------------------- -Revoke permission for user on given repository. This command can be executed +Revoke permission for user on given repository. This command can be executed only using api_key belonging to user with admin rights. @@ -890,8 +933,8 @@ OUTPUT:: 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 +Grant permission for user 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. @@ -902,7 +945,7 @@ INPUT:: method : "grant_users_group_permission" args: { "repoid" : "" - "usersgroupid" : "" + "usersgroupid" : "" "perm" : "(repository.(none|read|write|admin))", } @@ -914,12 +957,12 @@ OUTPUT:: "success": true } error: null - - + + revoke_users_group_permission ----------------------------- -Revoke permission for users group on given repository.This command can be +Revoke permission for user group on given repository.This command can be executed only using api_key belonging to user with admin rights. INPUT:: @@ -929,7 +972,7 @@ INPUT:: method : "revoke_users_group_permission" args: { "repoid" : "" - "usersgroupid" : "" + "usersgroupid" : "" } OUTPUT:: @@ -939,4 +982,4 @@ OUTPUT:: "msg" : "Revoked perm for group: `` in repo: ``", "success": true } - error: null \ No newline at end of file + error: null