##// END OF EJS Templates
updated api docs for stable docs
marcink -
r1910:466292e5 default
parent child Browse files
Show More
@@ -1,379 +1,379 b''
1 .. _api:
1 .. _api:
2
2
3
3
4 API
4 API
5 ===
5 ===
6
6
7
7
8 Starting from RhodeCode version 1.2 a simple API was implemented.
8 Starting from RhodeCode version 1.2 a simple API was implemented.
9 There's a single schema for calling all api methods. API is implemented
9 There's a single schema for calling all api methods. API is implemented
10 with JSON protocol both ways. An url to send API request in RhodeCode is
10 with JSON protocol both ways. An url to send API request in RhodeCode is
11 <your_server>/_admin/api
11 <your_server>/_admin/api
12
12
13
13
14 All clients are required to send JSON-RPC spec JSON data::
14 All clients are required to send JSON-RPC spec JSON data::
15
15
16 {
16 {
17 "api_key":"<api_key>",
17 "api_key":"<api_key>",
18 "method":"<method_name>",
18 "method":"<method_name>",
19 "args":{"<arg_key>":"<arg_val>"}
19 "args":{"<arg_key>":"<arg_val>"}
20 }
20 }
21
21
22 Example call for autopulling remotes repos using curl::
22 Example call for autopulling remotes repos using curl::
23 curl https://server.com/_admin/api -X POST -H 'content-type:text/plain' --data-binary '{"api_key":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull","args":{"repo":"CPython"}}'
23 curl https://server.com/_admin/api -X POST -H 'content-type:text/plain' --data-binary '{"api_key":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull","args":{"repo":"CPython"}}'
24
24
25 Simply provide
25 Simply provide
26 - *api_key* for access and permission validation.
26 - *api_key* for access and permission validation.
27 - *method* is name of method to call
27 - *method* is name of method to call
28 - *args* is an key:value list of arguments to pass to method
28 - *args* is an key:value list of arguments to pass to method
29
29
30 .. note::
30 .. note::
31
31
32 api_key can be found in your user account page
32 api_key can be found in your user account page
33
33
34
34
35 RhodeCode API will return always a JSON-RPC response::
35 RhodeCode API will return always a JSON-RPC response::
36
36
37 {
37 {
38 "result": "<result>",
38 "result": "<result>",
39 "error": null
39 "error": null
40 }
40 }
41
41
42 All responses from API will be `HTTP/1.0 200 OK`, if there's an error while
42 All responses from API will be `HTTP/1.0 200 OK`, if there's an error while
43 calling api *error* key from response will contain failure description
43 calling api *error* key from response will contain failure description
44 and result will be null.
44 and result will be null.
45
45
46 API METHODS
46 API METHODS
47 +++++++++++
47 +++++++++++
48
48
49
49
50 pull
50 pull
51 ----
51 ----
52
52
53 Pulls given repo from remote location. Can be used to automatically keep
53 Pulls given repo from remote location. Can be used to automatically keep
54 remote repos up to date. This command can be executed only using api_key
54 remote repos up to date. This command can be executed only using api_key
55 belonging to user with admin rights
55 belonging to user with admin rights
56
56
57 INPUT::
57 INPUT::
58
58
59 api_key : "<api_key>"
59 api_key : "<api_key>"
60 method : "pull"
60 method : "pull"
61 args : {
61 args : {
62 "repo" : "<repo_name>"
62 "repo" : "<repo_name>"
63 }
63 }
64
64
65 OUTPUT::
65 OUTPUT::
66
66
67 result : "Pulled from <repo_name>"
67 result : "Pulled from <repo_name>"
68 error : null
68 error : null
69
69
70
70
71 get_users
71 get_users
72 ---------
72 ---------
73
73
74 Lists all existing users. This command can be executed only using api_key
74 Lists all existing users. This command can be executed only using api_key
75 belonging to user with admin rights.
75 belonging to user with admin rights.
76
76
77 INPUT::
77 INPUT::
78
78
79 api_key : "<api_key>"
79 api_key : "<api_key>"
80 method : "get_users"
80 method : "get_users"
81 args : { }
81 args : { }
82
82
83 OUTPUT::
83 OUTPUT::
84
84
85 result: [
85 result: [
86 {
86 {
87 "id" : "<id>",
87 "id" : "<id>",
88 "username" : "<username>",
88 "username" : "<username>",
89 "firstname": "<firstname>",
89 "firstname": "<firstname>",
90 "lastname" : "<lastname>",
90 "lastname" : "<lastname>",
91 "email" : "<email>",
91 "email" : "<email>",
92 "active" : "<bool>",
92 "active" : "<bool>",
93 "admin" :Β  "<bool>",
93 "admin" :Β  "<bool>",
94 "ldap" : "<ldap_dn>"
94 "ldap" : "<ldap_dn>"
95 },
95 },
96 …
96 …
97 ]
97 ]
98 error: null
98 error: null
99
99
100 create_user
100 create_user
101 -----------
101 -----------
102
102
103 Creates new user in RhodeCode. This command can be executed only using api_key
103 Creates new user or updates current one if such user exists. This command can
104 belonging to user with admin rights.
104 be executed only using api_key belonging to user with admin rights.
105
105
106 INPUT::
106 INPUT::
107
107
108 api_key : "<api_key>"
108 api_key : "<api_key>"
109 method : "create_user"
109 method : "create_user"
110 args : {
110 args : {
111 "username" : "<username>",
111 "username" : "<username>",
112 "password" : "<password>",
112 "password" : "<password>",
113 "firstname" : "<firstname>",
113 "firstname" : "<firstname>",
114 "lastname" : "<lastname>",
114 "lastname" : "<lastname>",
115 "email" : "<useremail>"
115 "email" : "<useremail>"
116 "active" : "<bool> = True",
116 "active" : "<bool> = True",
117 "admin" : "<bool> = False",
117 "admin" : "<bool> = False",
118 "ldap_dn" : "<ldap_dn> = None"
118 "ldap_dn" : "<ldap_dn> = None"
119 }
119 }
120
120
121 OUTPUT::
121 OUTPUT::
122
122
123 result: {
123 result: {
124 "msg" : "created new user <username>"
124 "msg" : "created new user <username>"
125 }
125 }
126 error: null
126 error: null
127
127
128 get_users_groups
128 get_users_groups
129 ----------------
129 ----------------
130
130
131 Lists all existing users groups. This command can be executed only using api_key
131 Lists all existing users groups. This command can be executed only using api_key
132 belonging to user with admin rights.
132 belonging to user with admin rights.
133
133
134 INPUT::
134 INPUT::
135
135
136 api_key : "<api_key>"
136 api_key : "<api_key>"
137 method : "get_users_groups"
137 method : "get_users_groups"
138 args : { }
138 args : { }
139
139
140 OUTPUT::
140 OUTPUT::
141
141
142 result : [
142 result : [
143 {
143 {
144 "id" : "<id>",
144 "id" : "<id>",
145 "name" : "<name>",
145 "name" : "<name>",
146 "active": "<bool>",
146 "active": "<bool>",
147 "members" : [
147 "members" : [
148 {
148 {
149 "id" : "<userid>",
149 "id" : "<userid>",
150 "username" : "<username>",
150 "username" : "<username>",
151 "firstname": "<firstname>",
151 "firstname": "<firstname>",
152 "lastname" : "<lastname>",
152 "lastname" : "<lastname>",
153 "email" : "<email>",
153 "email" : "<email>",
154 "active" : "<bool>",
154 "active" : "<bool>",
155 "admin" :Β  "<bool>",
155 "admin" :Β  "<bool>",
156 "ldap" : "<ldap_dn>"
156 "ldap" : "<ldap_dn>"
157 },
157 },
158 …
158 …
159 ]
159 ]
160 }
160 }
161 ]
161 ]
162 error : null
162 error : null
163
163
164 get_users_group
164 get_users_group
165 ---------------
165 ---------------
166
166
167 Gets an existing users group. This command can be executed only using api_key
167 Gets an existing users group. This command can be executed only using api_key
168 belonging to user with admin rights.
168 belonging to user with admin rights.
169
169
170 INPUT::
170 INPUT::
171
171
172 api_key : "<api_key>"
172 api_key : "<api_key>"
173 method : "get_users_group"
173 method : "get_users_group"
174 args : {
174 args : {
175 "group_name" : "<name>"
175 "group_name" : "<name>"
176 }
176 }
177
177
178 OUTPUT::
178 OUTPUT::
179
179
180 result : None if group not exist
180 result : None if group not exist
181 {
181 {
182 "id" : "<id>",
182 "id" : "<id>",
183 "name" : "<name>",
183 "name" : "<name>",
184 "active": "<bool>",
184 "active": "<bool>",
185 "members" : [
185 "members" : [
186 { "id" : "<userid>",
186 { "id" : "<userid>",
187 "username" : "<username>",
187 "username" : "<username>",
188 "firstname": "<firstname>",
188 "firstname": "<firstname>",
189 "lastname" : "<lastname>",
189 "lastname" : "<lastname>",
190 "email" : "<email>",
190 "email" : "<email>",
191 "active" : "<bool>",
191 "active" : "<bool>",
192 "admin" :Β  "<bool>",
192 "admin" :Β  "<bool>",
193 "ldap" : "<ldap_dn>"
193 "ldap" : "<ldap_dn>"
194 },
194 },
195 …
195 …
196 ]
196 ]
197 }
197 }
198 error : null
198 error : null
199
199
200 create_users_group
200 create_users_group
201 ------------------
201 ------------------
202
202
203 Creates new users group. This command can be executed only using api_key
203 Creates new users group. This command can be executed only using api_key
204 belonging to user with admin rights
204 belonging to user with admin rights
205
205
206 INPUT::
206 INPUT::
207
207
208 api_key : "<api_key>"
208 api_key : "<api_key>"
209 method : "create_users_group"
209 method : "create_users_group"
210 args: {
210 args: {
211 "name": "<name>",
211 "name": "<name>",
212 "active":"<bool> = True"
212 "active":"<bool> = True"
213 }
213 }
214
214
215 OUTPUT::
215 OUTPUT::
216
216
217 result: {
217 result: {
218 "id": "<newusersgroupid>",
218 "id": "<newusersgroupid>",
219 "msg": "created new users group <name>"
219 "msg": "created new users group <name>"
220 }
220 }
221 error: null
221 error: null
222
222
223 add_user_to_users_group
223 add_user_to_users_group
224 -----------------------
224 -----------------------
225
225
226 Adds a user to a users group. This command can be executed only using api_key
226 Adds a user to a users group. This command can be executed only using api_key
227 belonging to user with admin rights
227 belonging to user with admin rights
228
228
229 INPUT::
229 INPUT::
230
230
231 api_key : "<api_key>"
231 api_key : "<api_key>"
232 method : "add_user_users_group"
232 method : "add_user_users_group"
233 args: {
233 args: {
234 "group_name" : "<groupname>",
234 "group_name" : "<groupname>",
235 "user_name" : "<username>"
235 "user_name" : "<username>"
236 }
236 }
237
237
238 OUTPUT::
238 OUTPUT::
239
239
240 result: {
240 result: {
241 "id": "<newusersgroupmemberid>",
241 "id": "<newusersgroupmemberid>",
242 "msg": "created new users group member"
242 "msg": "created new users group member"
243 }
243 }
244 error: null
244 error: null
245
245
246 get_repos
246 get_repos
247 ---------
247 ---------
248
248
249 Lists all existing repositories. This command can be executed only using api_key
249 Lists all existing repositories. This command can be executed only using api_key
250 belonging to user with admin rights
250 belonging to user with admin rights
251
251
252 INPUT::
252 INPUT::
253
253
254 api_key : "<api_key>"
254 api_key : "<api_key>"
255 method : "get_repos"
255 method : "get_repos"
256 args: { }
256 args: { }
257
257
258 OUTPUT::
258 OUTPUT::
259
259
260 result: [
260 result: [
261 {
261 {
262 "id" : "<id>",
262 "id" : "<id>",
263 "name" : "<name>"
263 "name" : "<name>"
264 "type" : "<type>",
264 "type" : "<type>",
265 "description" : "<description>"
265 "description" : "<description>"
266 },
266 },
267 …
267 …
268 ]
268 ]
269 error: null
269 error: null
270
270
271 get_repo
271 get_repo
272 --------
272 --------
273
273
274 Gets an existing repository. This command can be executed only using api_key
274 Gets an existing repository. This command can be executed only using api_key
275 belonging to user with admin rights
275 belonging to user with admin rights
276
276
277 INPUT::
277 INPUT::
278
278
279 api_key : "<api_key>"
279 api_key : "<api_key>"
280 method : "get_repo"
280 method : "get_repo"
281 args: {
281 args: {
282 "name" : "<name>"
282 "name" : "<name>"
283 }
283 }
284
284
285 OUTPUT::
285 OUTPUT::
286
286
287 result: None if repository not exist
287 result: None if repository not exist
288 {
288 {
289 "id" : "<id>",
289 "id" : "<id>",
290 "name" : "<name>"
290 "name" : "<name>"
291 "type" : "<type>",
291 "type" : "<type>",
292 "description" : "<description>",
292 "description" : "<description>",
293 "members" : [
293 "members" : [
294 { "id" : "<userid>",
294 { "id" : "<userid>",
295 "username" : "<username>",
295 "username" : "<username>",
296 "firstname": "<firstname>",
296 "firstname": "<firstname>",
297 "lastname" : "<lastname>",
297 "lastname" : "<lastname>",
298 "email" : "<email>",
298 "email" : "<email>",
299 "active" : "<bool>",
299 "active" : "<bool>",
300 "admin" :Β  "<bool>",
300 "admin" :Β  "<bool>",
301 "ldap" : "<ldap_dn>",
301 "ldap" : "<ldap_dn>",
302 "permission" : "repository.(read|write|admin)"
302 "permission" : "repository.(read|write|admin)"
303 },
303 },
304 …
304 …
305 {
305 {
306 "id" : "<usersgroupid>",
306 "id" : "<usersgroupid>",
307 "name" : "<usersgroupname>",
307 "name" : "<usersgroupname>",
308 "active": "<bool>",
308 "active": "<bool>",
309 "permission" : "repository.(read|write|admin)"
309 "permission" : "repository.(read|write|admin)"
310 },
310 },
311 …
311 …
312 ]
312 ]
313 }
313 }
314 error: null
314 error: null
315
315
316 create_repo
316 create_repo
317 -----------
317 -----------
318
318
319 Creates a repository. This command can be executed only using api_key
319 Creates a repository. This command can be executed only using api_key
320 belonging to user with admin rights.
320 belonging to user with admin rights.
321 If repository name contains "/", all needed repository groups will be created.
321 If repository name contains "/", all needed repository groups will be created.
322 For example "foo/bar/baz" will create groups "foo", "bar" (with "foo" as parent),
322 For example "foo/bar/baz" will create groups "foo", "bar" (with "foo" as parent),
323 and create "baz" repository with "bar" as group.
323 and create "baz" repository with "bar" as group.
324
324
325 INPUT::
325 INPUT::
326
326
327 api_key : "<api_key>"
327 api_key : "<api_key>"
328 method : "create_repo"
328 method : "create_repo"
329 args: {
329 args: {
330 "name" : "<name>",
330 "name" : "<name>",
331 "owner_name" : "<ownername>",
331 "owner_name" : "<ownername>",
332 "description" : "<description> = ''",
332 "description" : "<description> = ''",
333 "repo_type" : "<type> = 'hg'",
333 "repo_type" : "<type> = 'hg'",
334 "private" : "<bool> = False"
334 "private" : "<bool> = False"
335 }
335 }
336
336
337 OUTPUT::
337 OUTPUT::
338
338
339 result: None
339 result: None
340 error: null
340 error: null
341
341
342 add_user_to_repo
342 add_user_to_repo
343 ----------------
343 ----------------
344
344
345 Add a user to a repository. This command can be executed only using api_key
345 Add a user to a repository. This command can be executed only using api_key
346 belonging to user with admin rights.
346 belonging to user with admin rights.
347 If "perm" is None, user will be removed from the repository.
347 If "perm" is None, user will be removed from the repository.
348
348
349 INPUT::
349 INPUT::
350
350
351 api_key : "<api_key>"
351 api_key : "<api_key>"
352 method : "add_user_to_repo"
352 method : "add_user_to_repo"
353 args: {
353 args: {
354 "repo_name" : "<reponame>",
354 "repo_name" : "<reponame>",
355 "user_name" : "<username>",
355 "user_name" : "<username>",
356 "perm" : "(None|repository.(read|write|admin))",
356 "perm" : "(None|repository.(read|write|admin))",
357 }
357 }
358
358
359 OUTPUT::
359 OUTPUT::
360
360
361 result: None
361 result: None
362 error: null
362 error: null
363
363
364 add_users_group_to_repo
364 add_users_group_to_repo
365 -----------------------
365 -----------------------
366
366
367 Add a users group to a repository. This command can be executed only using
367 Add a users group to a repository. This command can be executed only using
368 api_key belonging to user with admin rights. If "perm" is None, group will
368 api_key belonging to user with admin rights. If "perm" is None, group will
369 be removed from the repository.
369 be removed from the repository.
370
370
371 INPUT::
371 INPUT::
372
372
373 api_key : "<api_key>"
373 api_key : "<api_key>"
374 method : "add_users_group_to_repo"
374 method : "add_users_group_to_repo"
375 args: {
375 args: {
376 "repo_name" : "<reponame>",
376 "repo_name" : "<reponame>",
377 "group_name" : "<groupname>",
377 "group_name" : "<groupname>",
378 "perm" : "(None|repository.(read|write|admin))",
378 "perm" : "(None|repository.(read|write|admin))",
379 } No newline at end of file
379 }
General Comments 0
You need to be logged in to leave comments. Login now