Changeset - 2dd317e9cc4b
[Not reviewed]
stable
0 2 0
Mads Kiilerich (mads) - 3 years ago 2022-10-14 13:17:57
mads@kiilerich.com
Grafted from: a63d2890b5be
api docs: make examples use comma more like json does
2 files changed with 61 insertions and 61 deletions:
0 comments (0 inline, 0 general)
docs/api/api.rst
Show inline comments
 
@@ -166,36 +166,36 @@ get_ip
 
^^^^^^
 

	
 
Return IP address as seen from Kallithea server, together with all
 
defined IP addresses for given user.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

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

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : {
 
                 "ip_addr_server" : <ip_from_client>",
 
                 "user_ips" : [
 
                                {
 
                                   "ip_addr" : "<ip_with_mask>",
 
                                   "ip_range" : ["<start_ip>", "<end_ip>"],
 
                                   "ip_range" : ["<start_ip>", "<end_ip>"]
 
                                },
 
                                ...
 
                              ]
 
             }
 
    error : null
 

	
 
get_user
 
^^^^^^^^
 

	
 
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.
 
@@ -224,25 +224,25 @@ OUTPUT::
 
                "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>",
 
                "permissions": {
 
                    "global": ["hg.create.repository",
 
                               "repository.read",
 
                               "hg.register.manual_activate"],
 
                    "repositories" : {"repo1" : "repository.none"},
 
                    "repositories_groups" : {"Group1" : "group.read"}
 
                 },
 
                 }
 
             }
 
    error : null
 

	
 
get_users
 
^^^^^^^^^
 

	
 
List all existing users.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
@@ -257,25 +257,25 @@ OUTPUT::
 
              {
 
                "user_id" :     "<user_id>",
 
                "api_key" :     "<api_key>",
 
                "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>",
 
                "last_login" :  "<last_login>"
 
              },
 
 
             ]
 
    error : null
 

	
 
.. _create-user:
 

	
 
create_user
 
^^^^^^^^^^^
 

	
 
Create new user.
 
This command can only be executed using the api_key of a user with admin rights.
 
@@ -302,26 +302,26 @@ OUTPUT::
 
    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>",
 
              },
 
                "last_login": "<last_login>"
 
              }
 
             }
 
    error : null
 

	
 
Example::
 

	
 
    kallithea-api create_user username:bent email:bent@example.com firstname:Bent lastname:Bentsen extern_type:ldap extern_name:uid=bent,dc=example,dc=com
 

	
 
update_user
 
^^^^^^^^^^^
 

	
 
Update the given user if such user exists.
 
This command can only be executed using the api_key of a user with admin rights.
 
@@ -350,42 +350,42 @@ OUTPUT::
 
              "msg" : "updated user ID:<userid> <username>",
 
              "user" : {
 
                "user_id" :  "<user_id>",
 
                "api_key" :  "<api_key>",
 
                "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>",
 
              },
 
                "last_login": "<last_login>"
 
              }
 
             }
 
    error : null
 

	
 
delete_user
 
^^^^^^^^^^^
 

	
 
Delete the given user if such a user exists.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

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

	
 
OUTPUT::
 

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

	
 
get_user_group
 
@@ -414,25 +414,25 @@ OUTPUT::
 
               "members" :  [
 
                              {
 
                                "user_id" :  "<user_id>",
 
                                "api_key" :  "<api_key>",
 
                                "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>",
 
                                "last_login": "<last_login>"
 
                              },
 
 
                            ]
 
             }
 
    error : null
 

	
 
get_user_groups
 
^^^^^^^^^^^^^^^
 

	
 
List all existing user groups.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
@@ -441,25 +441,25 @@ INPUT::
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_user_groups"
 
    args :    { }
 

	
 
OUTPUT::
 

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

	
 
create_user_group
 
^^^^^^^^^^^^^^^^^
 

	
 
Create a new user group.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 
@@ -472,71 +472,71 @@ INPUT::
 
                "owner" :     "<owner_name_or_id = Optional(=apiuser)>",
 
                "active" :    "<bool> = Optional(True)"
 
              }
 

	
 
OUTPUT::
 

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

	
 
add_user_to_user_group
 
^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Adds a 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.
 

	
 
INPUT::
 

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

	
 
OUTPUT::
 

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

	
 
remove_user_from_user_group
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
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.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "remove_user_from_user_group"
 
    args :    {
 
                "usersgroupid" : "<user group id or name>",
 
                "userid" : "<user_id or username>",
 
                "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 user group <groupname> |
 
                       User wasn't in group"
 
             }
 
    error : null
 

	
 
@@ -547,34 +547,34 @@ Get an existing repository by its name o
 
either users_group or users 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.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_repo"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>",
 
                "with_revision_names" : "<bool> = Optional(False)",
 
                "with_pullrequests" : "<bool> = Optional(False)",
 
                "with_pullrequests" : "<bool> = Optional(False)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : None if repository does not exist or
 
             {
 
                "repo_id" :          "<repo_id>",
 
                "repo_name" :        "<reponame>"
 
                "repo_name" :        "<reponame>",
 
                "repo_type" :        "<repo_type>",
 
                "clone_uri" :        "<clone_uri>",
 
                "enable_downloads" : "<bool>",
 
                "enable_statistics": "<bool>",
 
                "private" :          "<bool>",
 
                "created_on" :       "<date_time_created>",
 
                "description" :      "<description>",
 
                "landing_rev" :      "<landing_rev>",
 
                "last_changeset" :   {
 
                                         "author" :  "<full_author>",
 
                                         "date" :    "<date_time_of_commit>",
 
                                         "message" : "<commit_message>",
 
@@ -614,25 +614,25 @@ OUTPUT::
 
                                  {
 
                                    "user_id" :     "<user_id>",
 
                                    "username" :    "<username>",
 
                                    "api_key" :     "<api_key>",
 
                                    "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>",
 
                                    "last_login" :  "<last_login>"
 
                                  },
 
 
                              ],
 
                <if with_revision_names == True>
 
                "tags" : {
 
                            "<tagname>" : "<raw_id>",
 
                            ...
 
                        },
 
                "branches" : {
 
                            "<branchname>" : "<raw_id>",
 
                            ...
 
                        },
 
@@ -641,44 +641,44 @@ OUTPUT::
 
                            ...
 
                        },
 
                <if with_pullrequests == True>
 
                "pull_requests" : [
 
                  {
 
                    "status" : "<pull_request_status>",
 
                    "pull_request_id" : <pull_request_id>,
 
                    "description" : "<pull_request_description>",
 
                    "title" : "<pull_request_title>",
 
                    "url" : "<pull_request_url>",
 
                    "reviewers" : [
 
                      {
 
                        "username" : "<user_id>",
 
                        "username" : "<user_id>"
 
                      },
 
                      ...
 
                    ],
 
                    "org_repo_url" : "<repo_url>",
 
                    "org_ref_parts" : [
 
                      "<ref_type>",
 
                      "<ref_name>",
 
                      "<raw_id>"
 
                    ],
 
                    "other_ref_parts" : [
 
                      "<ref_type>",
 
                      "<ref_name>",
 
                      "<raw_id>"
 
                    ],
 
                    "comments" : [
 
                      {
 
                        "username" : "<user_id>",
 
                        "text" : "<comment text>",
 
                        "comment_id" : "<comment_id>",
 
                        "comment_id" : "<comment_id>"
 
                      },
 
                      ...
 
                    ],
 
                    "owner" : "<username>",
 
                    "statuses" : [
 
                      {
 
                        "status" : "<status_of_review>",        # "under_review", "approved" or "rejected"
 
                        "reviewer" : "<user_id>",
 
                        "modified_at" : "<date_time_of_review>" # iso 8601 date, server's timezone
 
                      },
 
                      ...
 
                    ],
 
@@ -703,66 +703,66 @@ 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_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>",
 
                "enable_downloads" : "<bool>",
 
                "enable_statistics": "<bool>",
 
                "enable_statistics": "<bool>"
 
              },
 
 
             ]
 
    error : null
 

	
 
get_repo_nodes
 
^^^^^^^^^^^^^^
 

	
 
Return a list of files and directories for a given path at the given revision.
 
It is 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.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_repo_nodes"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>"
 
                "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>",
 
                "name" :        "<name>",
 
                "type" :        "<type>"
 
              },
 
 
             ]
 
    error : null
 

	
 
create_repo
 
^^^^^^^^^^^
 

	
 
Create a repository. If the repository name contains "/", the repository will be
 
created in the repository group indicated by that path. Any such repository
 
groups need to exist before calling this method, or the call will fail.
 
For example "foo/bar/baz" will create a repository "baz" inside the repository
 
@@ -777,102 +777,102 @@ INPUT::
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "create_repo"
 
    args :    {
 
                "repo_name" :        "<reponame>",
 
                "owner" :            "<owner_name_or_id = Optional(=apiuser)>",
 
                "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_statistics": "<bool> = Optional(False)",
 
                "enable_statistics": "<bool> = Optional(False)"
 
              }
 

	
 
OUTPUT::
 

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

	
 
update_repo
 
^^^^^^^^^^^
 

	
 
Update 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 create repository permission.
 
Regular users cannot specify owner parameter.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "update_repo"
 
    args :    {
 
                "repoid" :           "<reponame or repo_id>"
 
                "repoid" :           "<reponame or repo_id>",
 
                "name" :             "<reponame> = Optional('')",
 
                "group" :            "<group_id> = Optional(None)",
 
                "owner" :            "<owner_name_or_id = Optional(=apiuser)>",
 
                "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_statistics": "<bool> = Optional(False)",
 
                "enable_statistics": "<bool> = Optional(False)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : {
 
              "msg" : "updated repo ID:repo_id `<reponame>`",
 
              "repository" : {
 
                "repo_id" :          "<repo_id>",
 
                "repo_name" :        "<reponame>"
 
                "repo_name" :        "<reponame>",
 
                "repo_type" :        "<repo_type>",
 
                "clone_uri" :        "<clone_uri>",
 
                "private" :          "<bool>",
 
                "created_on" :       "<datetimecreated>",
 
                "description" :      "<description>",
 
                "landing_rev" :      "<landing_rev>",
 
                "owner" :            "<username or user_id>",
 
                "fork_of" :          "<name_of_fork_parent>",
 
                "enable_downloads" : "<bool>",
 
                "enable_statistics": "<bool>",
 
                "last_changeset" :   {
 
                                       "author" :  "<full_author>",
 
                                       "date" :    "<date_time_of_commit>",
 
                                       "message" : "<commit_message>",
 
                                       "raw_id" :  "<raw_id>",
 
                                       "revision": "<numeric_revision>",
 
                                       "short_id": "<short_id>"
 
                                     }
 
              },
 
              }
 
             }
 
    error : null
 

	
 
fork_repo
 
^^^^^^^^^
 

	
 
Create a fork of the given repo. If using Celery, this will
 
return success message immediately and a fork will be created
 
asynchronously.
 
This command can only be executed using the api_key of a user with admin
 
rights, or with the global fork permission, by a regular user with create
 
repository permission and at least read access to the repository.
 
@@ -932,51 +932,51 @@ OUTPUT::
 
grant_user_permission
 
^^^^^^^^^^^^^^^^^^^^^
 

	
 
Grant permission for a user on the given repository, or update the existing one if found.
 
This command can only be executed using the api_key of a 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))",
 
                "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 a user on the given repository.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "revoke_user_permission"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>"
 
                "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
 

	
 
@@ -984,51 +984,51 @@ grant_user_group_permission
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

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

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "grant_user_group_permission"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>"
 
                "usersgroupid" : "<user group id or name>"
 
                "perm" : "(repository.(none|read|write|admin))",
 
                "repoid" : "<reponame or repo_id>",
 
                "usersgroupid" : "<user 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_user_group_permission
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Revoke permission for a user group on the given repository.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "revoke_user_group_permission"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>"
 
                "repoid" : "<reponame or repo_id>",
 
                "usersgroupid" : "<user group id or name>"
 
              }
 

	
 
OUTPUT::
 

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

	
 
@@ -1146,58 +1146,58 @@ Example output::
 
get_pullrequest
 
^^^^^^^^^^^^^^^
 

	
 
Get information and review status for a given pull request. This command can only be executed
 
using the api_key of a user with read permissions to the original repository.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_pullrequest"
 
    args :    {
 
                "pullrequest_id" : "<pullrequest_id>",
 
                "pullrequest_id" : "<pullrequest_id>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : {
 
        "status" : "<pull_request_status>",
 
        "pull_request_id" : <pull_request_id>,
 
        "description" : "<pull_request_description>",
 
        "title" : "<pull_request_title>",
 
        "url" : "<pull_request_url>",
 
        "reviewers" : [
 
          {
 
            "username" : "<user_name>",
 
            "username" : "<user_name>"
 
          },
 
          ...
 
        ],
 
        "org_repo_url" : "<repo_url>",
 
        "org_ref_parts" : [
 
          "<ref_type>",
 
          "<ref_name>",
 
          "<raw_id>"
 
        ],
 
        "other_ref_parts" : [
 
          "<ref_type>",
 
          "<ref_name>",
 
          "<raw_id>"
 
        ],
 
        "comments" : [
 
          {
 
            "username" : "<user_name>",
 
            "text" : "<comment text>",
 
            "comment_id" : "<comment_id>",
 
            "comment_id" : "<comment_id>"
 
          },
 
          ...
 
        ],
 
        "owner" : "<username>",
 
        "statuses" : [
 
          {
 
            "status" : "<status_of_review>",        # "under_review", "approved" or "rejected"
 
            "reviewer" : "<user_name>",
 
            "modified_at" : "<date_time_of_review>" # iso 8601 date, server's timezone
 
          },
 
          ...
 
        ],
 
@@ -1214,25 +1214,25 @@ comment_pullrequest
 
Add comment, change status or close a given pull request. This command can only be executed
 
using the api_key of a user with read permissions to the original repository.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "comment_pullrequest"
 
    args :    {
 
                "pull_request_id" : "<pull_request_id>",
 
                "comment_msg" :     Optional(''),
 
                "status" :          Optional(None),     # "under_review", "approved" or "rejected"
 
                "close_pr" :        Optional(False)",
 
                "close_pr" :        Optional(False)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : True
 
    error : null
 

	
 

	
 
API access for web views
 
------------------------
 

	
kallithea/controllers/api/api.py
Show inline comments
 
@@ -165,25 +165,25 @@ class ApiController(JSONRPCController):
 
        automatically keep remote repos up to date. This command can be executed
 
        only using api_key belonging to user with admin rights
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param clone_uri: repository URI to pull from (optional)
 
        :type clone_uri: str
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : {
 
                "msg" : "Pulled from `<repository name>`"
 
                "msg" : "Pulled from `<repository name>`",
 
                "repository" : "<repository name>"
 
            }
 
            error : null
 

	
 
        ERROR OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : null
 
            error :  {
 
                "Unable to pull changes from `<reponame>`"
 
            }
 
        """
 
@@ -298,25 +298,25 @@ class ApiController(JSONRPCController):
 

	
 
        :param userid: username to show ips for
 
        :type userid: Optional(str or int)
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : {
 
                         "server_ip_addr" : "<ip_from_client>",
 
                         "user_ips" : [
 
                                        {
 
                                           "ip_addr" : "<ip_with_mask>",
 
                                           "ip_range" : ["<start_ip>", "<end_ip>"],
 
                                           "ip_range" : ["<start_ip>", "<end_ip>"]
 
                                        },
 
                                        ...
 
                                      ]
 
            }
 
            error : null
 
        """
 
        if userid is None:
 
            userid = request.authuser.user_id
 
        user = get_user_or_error(userid)
 
        ips = db.UserIpMap.query().filter(db.UserIpMap.user == user).all()
 
        return dict(
 
            server_ip_addr=request.ip_addr,
 
@@ -368,25 +368,25 @@ class ApiController(JSONRPCController):
 
                        "lastname" :    "<lastname>",
 
                        "email" :       "<email>",
 
                        "emails" :      "[<list of all emails including additional ones>]",
 
                        "active" :      "<bool: user active>",
 
                        "admin" :       "<bool: user is admin>",
 
                        "permissions" : {
 
                            "global" : ["hg.create.repository",
 
                                        "repository.read",
 
                                        "hg.register.manual_activate"],
 
                            "repositories" : {"repo1" : "repository.none"},
 
                            "repositories_groups" : {"Group1" : "group.read"},
 
                            "user_groups" : { "usrgrp1" : "usergroup.admin" }
 
                         },
 
                         }
 
                     }
 
            error : null
 
        """
 
        if not HasPermissionAny('hg.admin')():
 
            # make sure normal user does not pass someone else userid,
 
            # he is not allowed to do that
 
            if userid is not None and userid != request.authuser.user_id:
 
                raise JSONRPCError(
 
                    'userid is not the same as your user'
 
                )
 

	
 
        if userid is None:
 
@@ -520,25 +520,25 @@ class ApiController(JSONRPCController):
 
        :param admin: admin
 
        :type admin: Optional(bool)
 
        :param extern_name:
 
        :type extern_name: Optional(str)
 
        :param extern_type:
 
        :type extern_type: Optional(str)
 

	
 
        OUTPUT::
 

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

	
 
        ERROR OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : null
 
            error :  {
 
                "failed to update user `<username>`"
 
            }
 
        """
 
        user = get_user_or_error(userid)
 
@@ -620,27 +620,27 @@ class ApiController(JSONRPCController):
 
        read access to user group.
 

	
 
        :param usergroupid: id of user_group to edit
 
        :type usergroupid: str or int
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : None if group not exist
 
                     {
 
                       "users_group_id" : "<id>",
 
                       "group_name" :     "<groupname>",
 
                       "group_description" : "<description>"
 
                       "group_description" : "<description>",
 
                       "active" :         "<bool>",
 
                       "owner" :          "<username>"
 
                       "owner" :          "<username>",
 
                       "members" :        [<user_obj>,...]
 
                     }
 
            error : null
 
        """
 
        user_group = get_user_group_or_error(usergroupid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasUserGroupPermissionLevel('read')(user_group.users_group_name):
 
                raise JSONRPCError('user group `%s` does not exist' % (usergroupid,))
 

	
 
        data = user_group.get_api_data()
 
        return data
 

	
 
@@ -937,71 +937,71 @@ class ApiController(JSONRPCController):
 
        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.
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : {
 
                        "repo_id" :          "<repo_id>",
 
                        "repo_name" :        "<reponame>"
 
                        "repo_name" :        "<reponame>",
 
                        "repo_type" :        "<repo_type>",
 
                        "clone_uri" :        "<clone_uri>",
 
                        "enable_downloads" : "<bool>",
 
                        "enable_statistics": "<bool>",
 
                        "private" :          "<bool>",
 
                        "created_on" :       "<date_time_created>",
 
                        "description" :      "<description>",
 
                        "landing_rev" :      "<landing_rev>",
 
                        "last_changeset" :   {
 
                                                 "author" :  "<full_author>",
 
                                                 "date" :    "<date_time_of_commit>",
 
                                                 "message" : "<commit_message>",
 
                                                 "raw_id" :  "<raw_id>",
 
                                                 "revision": "<numeric_revision>",
 
                                                 "short_id": "<short_id>"
 
                                             }
 
                                             },
 
                        "owner" :            "<repo_owner>",
 
                        "fork_of" :          "<name_of_fork_parent>",
 
                        "members" :     [
 
                                            {
 
                                                "name" :    "<username>",
 
                                                "type" :    "user",
 
                                                "permission" : "repository.(read|write|admin)"
 
                                            },
 
 
                                            {
 
                                                "name" :    "<usergroup name>",
 
                                                "type" :    "user_group",
 
                                                "permission" : "usergroup.(read|write|admin)"
 
                                            },
 
 
                                        ]
 
                                        ],
 
                        "followers" :  [<user_obj>, ...],
 
                        <if with_revision_names == True>
 
                        "tags" : {
 
                                    "<tagname>" : "<raw_id>",
 
                                    ...
 
                                },
 
                        "branches" : {
 
                                    "<branchname>" : "<raw_id>",
 
                                    ...
 
                                },
 
                        "bookmarks" : {
 
                                    "<bookmarkname>" : "<raw_id>",
 
                                    ...
 
                                },
 
                                }
 
                     }
 
            error : null
 
        """
 
        repo = get_repo_or_error(repoid)
 

	
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoPermissionLevel('read')(repo.repo_name):
 
                raise JSONRPCError('repository `%s` does not exist' % (repoid,))
 

	
 
        members = []
 
        for user in repo.repo_to_perm:
 
            perm = user.permission.permission_name
 
@@ -1038,35 +1038,35 @@ class ApiController(JSONRPCController):
 
    def get_repos(self):
 
        """
 
        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.
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : [
 
                      {
 
                        "repo_id" :          "<repo_id>",
 
                        "repo_name" :        "<reponame>"
 
                        "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>",
 
                        "enable_downloads" : "<bool>",
 
                        "enable_statistics": "<bool>",
 
                        "enable_statistics": "<bool>"
 
                      },
 
 
                     ]
 
            error : null
 
        """
 
        if not HasPermissionAny('hg.admin')():
 
            repos = request.authuser.get_all_user_repos()
 
        else:
 
            repos = db.Repository.query()
 

	
 
        return [
 
            repo.get_api_data()
 
@@ -1087,26 +1087,26 @@ class ApiController(JSONRPCController):
 
        :param revision: revision for which listing should be done
 
        :type revision: str
 
        :param root_path: path from which start displaying
 
        :type root_path: str
 
        :param ret_type: return type 'all|files|dirs' nodes
 
        :type ret_type: Optional(str)
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : [
 
                      {
 
                        "name" :        "<name>"
 
                        "type" :        "<type>",
 
                        "name" :        "<name>",
 
                        "type" :        "<type>"
 
                      },
 
 
                     ]
 
            error : null
 
        """
 
        repo = get_repo_or_error(repoid)
 

	
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoPermissionLevel('read')(repo.repo_name):
 
                raise JSONRPCError('repository `%s` does not exist' % (repoid,))
 

	
 
        _map = {}
 
@@ -1735,25 +1735,25 @@ class ApiController(JSONRPCController):
 
        :type description:
 
        :param owner:
 
        :type owner:
 
        :param parent:
 
        :type parent:
 
        :param copy_permissions:
 
        :type copy_permissions:
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
              "msg" : "created new repo group `<repo_group_name>`"
 
              "msg" : "created new repo group `<repo_group_name>`",
 
              "repo_group" : <repogroup_object>
 
          }
 
          error : null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            failed to create repo group `<repogroupid>`
 
          }
 
        """
0 comments (0 inline, 0 general)