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