annotate docs/api/api.rst @ 1500:256e729a94cd beta

Extended API - updated docs - created two new methods for creating users and creating users groups - changed user attribute generated from api_key to apiuser for better name compatibility with functoin parameters
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 30 Sep 2011 18:03:20 +0300
parents e63a2841714d
children 8628c8706bf8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1446
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 .. _api:
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 API
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 ===
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 Starting from RhodeCode version 1.2 a simple API was implemented.
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
9 There's a single schema for calling all api methods. API is implemented
1491
e63a2841714d API docs update
Marcin Kuzminski <marcin@python-works.com>
parents: 1447
diff changeset
10 with JSON protocol both ways. An url to send API request in RhodeCode is
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
11 <your_server>/_admin/api
1446
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
14 All clients need to send JSON data in such format::
1446
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 {
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 "api_key":"<api_key>",
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 "method":"<method_name>",
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 "args":{"<arg_key>":"<arg_val>"}
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 }
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
22 Example call for autopulling remotes repos using curl::
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
23 curl https://server.com/_admin/api -X POST -H 'content-type:text/plain' --data-binary '{"api_key":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull","args":{"repo":"CPython"}}'
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
24
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
25 Simply provide
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
26 - *api_key* for access and permission validation.
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
27 - *method* is name of method to call
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
28 - *args* is an key:value list of arguments to pass to method
1446
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 .. note::
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 api_key can be found in your user account page
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
35 RhodeCode API will return always a JSON formatted answer::
1446
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37 {
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 "result": "<result>",
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 "error": null
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 }
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 All responses from API will be `HTTP/1.0 200 OK`, if there's an error while
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
43 calling api *error* key from response will contain failure description
1446
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 and result will be null.
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 API METHODS
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 +++++++++++
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 pull
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 ----
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52
1447
ebb90cfdac83 api doc fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1446
diff changeset
53 Pulls given repo from remote location. Can be used to automatically keep
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
54 remote repos up to date. This command can be executed only using api_key
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
55 belonging to user with admin rights
1446
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
57 INPUT::
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
58
1491
e63a2841714d API docs update
Marcin Kuzminski <marcin@python-works.com>
parents: 1447
diff changeset
59 api_key:"<api_key>"
1446
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 method: "pull"
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 args: {"repo":<repo_name>}
eab0cf9ab8bf API docs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62
1500
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
63 OUTPUT::
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
64
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
65 result:"Pulled from <repo_name>"
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
66 error:null
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
67
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
68
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
69 create_user
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
70 -----------
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
71
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
72 Creates new user in RhodeCode. This command can be executed only using api_key
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
73 belonging to user with admin rights
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
74
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
75 INPUT::
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
76
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
77 api_key:"<api_key>"
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
78 method: "create_user"
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
79 args: {"username": "<username>",
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
80 "password": "<password>",
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
81 "active": "<bool>",
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
82 "admin": "<bool>",
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
83 "name": "<firstname>",
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
84 "lastname": "<lastname>",
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
85 "email": "<useremail>"}
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
86
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
87 OUTPUT::
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
88
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
89 result:{"id": <newuserid>,
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
90 "msg":"created new user <username>"}
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
91 error:null
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
92
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
93
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
94 create_users_group
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
95 ------------------
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
96
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
97 creates new users group. This command can be executed only using api_key
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
98 belonging to user with admin rights
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
99
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
100 INPUT::
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
101
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
102 api_key:"<api_key>"
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
103 method: "create_user"
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
104 args: {"name": "<groupname>",
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
105 "active":"<bool>"}
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
106
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
107 OUTPUT::
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
108
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
109 result:{"id": <newusersgroupid>,
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
110 "msg":"created new users group <groupname>"}
256e729a94cd Extended API
Marcin Kuzminski <marcin@python-works.com>
parents: 1491
diff changeset
111 error:null