diff --git a/docs/api/api.rst b/docs/api/api.rst --- a/docs/api/api.rst +++ b/docs/api/api.rst @@ -26,16 +26,18 @@ API ACCESS All clients are required to send JSON-RPC spec JSON data:: - { + { + "id:, "api_key":"", "method":"", "args":{"":""} } Example call for autopulling remotes repos using curl:: - curl https://server.com/_admin/api -X POST -H 'content-type:text/plain' --data-binary '{"api_key":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull","args":{"repo":"CPython"}}' + 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 @@ -47,7 +49,8 @@ Simply provide RhodeCode API will return always a JSON-RPC response:: - { + { + "id":, "result": "", "error": null } @@ -72,21 +75,55 @@ INPUT:: api_key : "" method : "pull" args : { - "repo" : "" + "repo_name" : "" } OUTPUT:: - result : "Pulled from " + result : "Pulled from " 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:: + + api_key : "" + method : "get_user" + args : { + "userid" : "" + } + +OUTPUT:: + + result: None if user does not exist or + { + "id" : "", + "username" : "", + "firstname": "", + "lastname" : "", + "email" : "", + "active" : "", + "admin" :  "", + "ldap_dn" : "" + } + + error: null + + get_users --------- Lists all existing users. This command can be executed only using api_key belonging to user with admin rights. + INPUT:: api_key : "" @@ -104,18 +141,20 @@ OUTPUT:: "email" : "", "active" : "", "admin" :  "", - "ldap" : "" + "ldap_dn" : "" }, … ] error: null + create_user ----------- -Creates new user or updates current one if such user exists. This command can +Creates new user. This command can be executed only using api_key belonging to user with admin rights. + INPUT:: api_key : "" @@ -123,9 +162,9 @@ INPUT:: args : { "username" : "", "password" : "", - "firstname" : "", - "lastname" : "", - "email" : "" + "email" : "", + "firstname" : " = None", + "lastname" : " = None", "active" : " = True", "admin" : " = False", "ldap_dn" : " = None" @@ -134,15 +173,88 @@ INPUT:: OUTPUT:: result: { + "id" : "", "msg" : "created new user " } error: null + +update_user +----------- + +updates current one if such user exists. This command can +be executed only using api_key belonging to user with admin rights. + + +INPUT:: + + api_key : "" + method : "update_user" + args : { + "userid" : "", + "username" : "", + "password" : "", + "email" : "", + "firstname" : "", + "lastname" : "", + "active" : "", + "admin" : "", + "ldap_dn" : "" + } + +OUTPUT:: + + result: { + "id" : "", + "msg" : "updated user " + } + 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:: + + api_key : "" + method : "get_users_group" + args : { + "group_name" : "" + } + +OUTPUT:: + + result : None if group not exist + { + "id" : "", + "group_name" : "", + "active": "", + "members" : [ + { "id" : "", + "username" : "", + "firstname": "", + "lastname" : "", + "email" : "", + "active" : "", + "admin" :  "", + "ldap" : "" + }, + … + ] + } + 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. +Lists all existing users groups. This command can be executed only using +api_key belonging to user with admin rights. + INPUT:: @@ -154,9 +266,9 @@ OUTPUT:: result : [ { - "id" : "", - "name" : "", - "active": "", + "id" : "", + "group_name" : "", + "active": "", "members" : [ { "id" : "", @@ -174,41 +286,6 @@ OUTPUT:: ] 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:: - - api_key : "" - method : "get_users_group" - args : { - "group_name" : "" - } - -OUTPUT:: - - result : None if group not exist - { - "id" : "", - "name" : "", - "active": "", - "members" : [ - { "id" : "", - "username" : "", - "firstname": "", - "lastname" : "", - "email" : "", - "active" : "", - "admin" :  "", - "ldap" : "" - }, - … - ] - } - error : null create_users_group ------------------ @@ -216,12 +293,13 @@ create_users_group Creates new users group. This command can be executed only using api_key belonging to user with admin rights + INPUT:: api_key : "" method : "create_users_group" args: { - "name": "", + "group_name": "", "active":" = True" } @@ -229,39 +307,120 @@ OUTPUT:: result: { "id": "", - "msg": "created new users group " + "msg": "created new users group " } error: null + add_user_to_users_group ----------------------- -Adds a user to a users group. This command can be executed only using api_key +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:: api_key : "" method : "add_user_users_group" args: { "group_name" : "", - "user_name" : "" + "username" : "" } OUTPUT:: result: { "id": "", - "msg": "created new users group member" + "success": True|False # depends on if member is in group + "msg": "added member to users group | + 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:: + + api_key : "" + method : "remove_user_from_users_group" + args: { + "group_name" : "", + "username" : "" + } + +OUTPUT:: + + result: { + "success": True|False, # depends on if member is in group + "msg": "removed member from users group | + User wasn't in group" } error: null + +get_repo +-------- + +Gets an existing repository by it's name or repository_id. This command can +be executed only using api_key belonging to user with admin rights. + + +INPUT:: + + api_key : "" + method : "get_repo" + args: { + "repoid" : "" + } + +OUTPUT:: + + result: None if repository does not exist or + { + "id" : "", + "repo_name" : "" + "type" : "", + "description" : "", + "members" : [ + { "id" : "", + "username" : "", + "firstname": "", + "lastname" : "", + "email" : "", + "active" : "", + "admin" :  "", + "ldap" : "", + "permission" : "repository.(read|write|admin)" + }, + … + { + "id" : "", + "name" : "", + "active": "", + "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:: api_key : "" @@ -273,7 +432,7 @@ OUTPUT:: result: [ { "id" : "", - "name" : "" + "repo_name" : "" "type" : "", "description" : "" }, @@ -281,51 +440,39 @@ OUTPUT:: ] error: null -get_repo --------- + +get_repo_nodes +-------------- -Gets an existing repository. This command can be executed only using api_key -belonging to user with admin rights +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:: api_key : "" - method : "get_repo" + method : "get_repo_nodes" args: { - "name" : "" + "repo_name" : "", + "revision" : "", + "root_path" : "", + "ret_type" : "" = 'all' } OUTPUT:: - result: None if repository not exist - { - "id" : "", + result: [ + { "name" : "" "type" : "", - "description" : "", - "members" : [ - { "id" : "", - "username" : "", - "firstname": "", - "lastname" : "", - "email" : "", - "active" : "", - "admin" :  "", - "ldap" : "", - "permission" : "repository.(read|write|admin)" - }, - … - { - "id" : "", - "name" : "", - "active": "", - "permission" : "repository.(read|write|admin)" - }, - … - ] - } + }, + … + ] error: null + create_repo ----------- @@ -335,58 +482,146 @@ If repository name contains "/", all nee For example "foo/bar/baz" will create groups "foo", "bar" (with "foo" as parent), and create "baz" repository with "bar" as group. + INPUT:: api_key : "" method : "create_repo" args: { - "name" : "", + "repo_name" : "", "owner_name" : "", "description" : " = ''", "repo_type" : " = 'hg'", - "private" : " = False" + "private" : " = False", + "clone_uri" : " = None", } OUTPUT:: - result: None + result: { + "id": "", + "msg": "Created new repository ", + } error: null -add_user_to_repo ----------------- + +delete_repo +----------- + +Deletes a repository. This command can be executed only using api_key +belonging to user with admin rights. + + +INPUT:: + + api_key : "" + method : "delete_repo" + args: { + "repo_name" : "", + } -Add a user to a repository. This command can be executed only using api_key -belonging to user with admin rights. -If "perm" is None, user will be removed from the repository. +OUTPUT:: + + result: { + "msg": "Deleted repository ", + } + 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:: api_key : "" - method : "add_user_to_repo" + method : "grant_user_permission" args: { "repo_name" : "", - "user_name" : "", - "perm" : "(None|repository.(read|write|admin))", + "username" : "", + "perm" : "(repository.(none|read|write|admin))", + } + +OUTPUT:: + + result: { + "msg" : "Granted perm: for user: in repo: " + } + 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:: + + api_key : "" + method : "revoke_user_permission" + args: { + "repo_name" : "", + "username" : "", } OUTPUT:: - result: None + result: { + "msg" : "Revoked perm for user: in repo: " + } error: null -add_users_group_to_repo ------------------------ + +grant_users_group_permission +---------------------------- -Add a users group to a repository. This command can be executed only using -api_key belonging to user with admin rights. If "perm" is None, group will -be removed from the repository. +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:: api_key : "" - method : "add_users_group_to_repo" + method : "grant_users_group_permission" + args: { + "repo_name" : "", + "group_name" : "", + "perm" : "(repository.(none|read|write|admin))", + } + +OUTPUT:: + + result: { + "msg" : "Granted perm: for group: in repo: " + } + 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:: + + api_key : "" + method : "revoke_users_group_permission" args: { "repo_name" : "", - "group_name" : "", - "perm" : "(None|repository.(read|write|admin))", - } \ No newline at end of file + "users_group" : "", + } + +OUTPUT:: + + result: { + "msg" : "Revoked perm for group: in repo: " + } + error: null \ No newline at end of file