Show More
@@ -1,627 +1,646 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 | API ACCESS FOR WEB VIEWS |
|
13 | API ACCESS FOR WEB VIEWS | |
14 | ++++++++++++++++++++++++ |
|
14 | ++++++++++++++++++++++++ | |
15 |
|
15 | |||
16 | API access can also be turned on for each web view in RhodeCode that is |
|
16 | API access can also be turned on for each web view in RhodeCode that is | |
17 | decorated with `@LoginRequired` decorator. To enable API access simple change |
|
17 | decorated with `@LoginRequired` decorator. To enable API access simple change | |
18 | the standard login decorator to `@LoginRequired(api_access=True)`. |
|
18 | the standard login decorator to `@LoginRequired(api_access=True)`. | |
19 | After this change, a rhodecode view can be accessed without login by adding a |
|
19 | After this change, a rhodecode view can be accessed without login by adding a | |
20 | GET parameter `?api_key=<api_key>` to url. By default this is only |
|
20 | GET parameter `?api_key=<api_key>` to url. By default this is only | |
21 | enabled on RSS/ATOM feed views. |
|
21 | enabled on RSS/ATOM feed views. | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | API ACCESS |
|
24 | API ACCESS | |
25 | ++++++++++ |
|
25 | ++++++++++ | |
26 |
|
26 | |||
27 | All clients are required to send JSON-RPC spec JSON data:: |
|
27 | All clients are required to send JSON-RPC spec JSON data:: | |
28 |
|
28 | |||
29 | { |
|
29 | { | |
30 | "id:<id>, |
|
30 | "id:"<id>", | |
31 | "api_key":"<api_key>", |
|
31 | "api_key":"<api_key>", | |
32 | "method":"<method_name>", |
|
32 | "method":"<method_name>", | |
33 | "args":{"<arg_key>":"<arg_val>"} |
|
33 | "args":{"<arg_key>":"<arg_val>"} | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | Example call for autopulling remotes repos using curl:: |
|
36 | Example call for autopulling remotes repos using curl:: | |
37 | 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"}}' |
|
37 | 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"}}' | |
38 |
|
38 | |||
39 | Simply provide |
|
39 | Simply provide | |
40 | - *id* A value of any type, which is used to match the response with the request that it is replying to. |
|
40 | - *id* A value of any type, which is used to match the response with the request that it is replying to. | |
41 | - *api_key* for access and permission validation. |
|
41 | - *api_key* for access and permission validation. | |
42 | - *method* is name of method to call |
|
42 | - *method* is name of method to call | |
43 | - *args* is an key:value list of arguments to pass to method |
|
43 | - *args* is an key:value list of arguments to pass to method | |
44 |
|
44 | |||
45 | .. note:: |
|
45 | .. note:: | |
46 |
|
46 | |||
47 | api_key can be found in your user account page |
|
47 | api_key can be found in your user account page | |
48 |
|
48 | |||
49 |
|
49 | |||
50 | RhodeCode API will return always a JSON-RPC response:: |
|
50 | RhodeCode API will return always a JSON-RPC response:: | |
51 |
|
51 | |||
52 | { |
|
52 | { | |
53 | "id":<id>, |
|
53 | "id":<id>, # matching id sent by request | |
54 | "result": "<result>", |
|
54 | "result": "<result>"|null, # JSON formatted result, null if any errors | |
55 | "error": null |
|
55 | "error": "null"|<error_message> # JSON formatted error (if any) | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | All responses from API will be `HTTP/1.0 200 OK`, if there's an error while |
|
58 | All responses from API will be `HTTP/1.0 200 OK`, if there's an error while | |
59 | calling api *error* key from response will contain failure description |
|
59 | calling api *error* key from response will contain failure description | |
60 | and result will be null. |
|
60 | and result will be null. | |
61 |
|
61 | |||
62 | API METHODS |
|
62 | API METHODS | |
63 | +++++++++++ |
|
63 | +++++++++++ | |
64 |
|
64 | |||
65 |
|
65 | |||
66 | pull |
|
66 | pull | |
67 | ---- |
|
67 | ---- | |
68 |
|
68 | |||
69 | Pulls given repo from remote location. Can be used to automatically keep |
|
69 | Pulls given repo from remote location. Can be used to automatically keep | |
70 | remote repos up to date. This command can be executed only using api_key |
|
70 | remote repos up to date. This command can be executed only using api_key | |
71 | belonging to user with admin rights |
|
71 | belonging to user with admin rights | |
72 |
|
72 | |||
73 | INPUT:: |
|
73 | INPUT:: | |
74 |
|
74 | |||
|
75 | id : <id_for_response> | |||
75 | api_key : "<api_key>" |
|
76 | api_key : "<api_key>" | |
76 |
|
|
77 | method : "pull" | |
77 | args : { |
|
78 | args : { | |
78 | "repo_name" : "<reponame>" |
|
79 | "repo_name" : "<reponame>" | |
79 | } |
|
80 | } | |
80 |
|
81 | |||
81 | OUTPUT:: |
|
82 | OUTPUT:: | |
82 |
|
83 | |||
83 | result : "Pulled from <reponame>" |
|
84 | result : "Pulled from <reponame>" | |
84 | error : null |
|
85 | error : null | |
85 |
|
86 | |||
86 |
|
87 | |||
87 | get_user |
|
88 | get_user | |
88 | -------- |
|
89 | -------- | |
89 |
|
90 | |||
90 | Get's an user by username or user_id, Returns empty result if user is not found. |
|
91 | Get's an user by username or user_id, Returns empty result if user is not found. | |
91 | This command can be executed only using api_key belonging to user with admin |
|
92 | This command can be executed only using api_key belonging to user with admin | |
92 | rights. |
|
93 | rights. | |
93 |
|
94 | |||
94 |
|
95 | |||
95 | INPUT:: |
|
96 | INPUT:: | |
96 |
|
97 | |||
|
98 | id : <id_for_response> | |||
97 | api_key : "<api_key>" |
|
99 | api_key : "<api_key>" | |
98 |
|
|
100 | method : "get_user" | |
99 | args : { |
|
101 | args : { | |
100 | "userid" : "<username or user_id>" |
|
102 | "userid" : "<username or user_id>" | |
101 | } |
|
103 | } | |
102 |
|
104 | |||
103 | OUTPUT:: |
|
105 | OUTPUT:: | |
104 |
|
106 | |||
105 | result: None if user does not exist or |
|
107 | result: None if user does not exist or | |
106 | { |
|
108 | { | |
107 | "id" : "<id>", |
|
109 | "id" : "<id>", | |
108 | "username" : "<username>", |
|
110 | "username" : "<username>", | |
109 | "firstname": "<firstname>", |
|
111 | "firstname": "<firstname>", | |
110 | "lastname" : "<lastname>", |
|
112 | "lastname" : "<lastname>", | |
111 | "email" : "<email>", |
|
113 | "email" : "<email>", | |
112 | "active" : "<bool>", |
|
114 | "active" : "<bool>", | |
113 | "admin" :Β "<bool>", |
|
115 | "admin" :Β "<bool>", | |
114 | "ldap_dn" : "<ldap_dn>" |
|
116 | "ldap_dn" : "<ldap_dn>" | |
115 | } |
|
117 | } | |
116 |
|
118 | |||
117 | error: null |
|
119 | error: null | |
118 |
|
120 | |||
119 |
|
121 | |||
120 | get_users |
|
122 | get_users | |
121 | --------- |
|
123 | --------- | |
122 |
|
124 | |||
123 | Lists all existing users. This command can be executed only using api_key |
|
125 | Lists all existing users. This command can be executed only using api_key | |
124 | belonging to user with admin rights. |
|
126 | belonging to user with admin rights. | |
125 |
|
127 | |||
126 |
|
128 | |||
127 | INPUT:: |
|
129 | INPUT:: | |
128 |
|
130 | |||
|
131 | id : <id_for_response> | |||
129 | api_key : "<api_key>" |
|
132 | api_key : "<api_key>" | |
130 |
|
|
133 | method : "get_users" | |
131 | args : { } |
|
134 | args : { } | |
132 |
|
135 | |||
133 | OUTPUT:: |
|
136 | OUTPUT:: | |
134 |
|
137 | |||
135 | result: [ |
|
138 | result: [ | |
136 | { |
|
139 | { | |
137 | "id" : "<id>", |
|
140 | "id" : "<id>", | |
138 | "username" : "<username>", |
|
141 | "username" : "<username>", | |
139 | "firstname": "<firstname>", |
|
142 | "firstname": "<firstname>", | |
140 | "lastname" : "<lastname>", |
|
143 | "lastname" : "<lastname>", | |
141 | "email" : "<email>", |
|
144 | "email" : "<email>", | |
142 | "active" : "<bool>", |
|
145 | "active" : "<bool>", | |
143 | "admin" :Β "<bool>", |
|
146 | "admin" :Β "<bool>", | |
144 | "ldap_dn" : "<ldap_dn>" |
|
147 | "ldap_dn" : "<ldap_dn>" | |
145 | }, |
|
148 | }, | |
146 | β¦ |
|
149 | β¦ | |
147 | ] |
|
150 | ] | |
148 | error: null |
|
151 | error: null | |
149 |
|
152 | |||
150 |
|
153 | |||
151 | create_user |
|
154 | create_user | |
152 | ----------- |
|
155 | ----------- | |
153 |
|
156 | |||
154 | Creates new user. This command can |
|
157 | Creates new user. This command can | |
155 | be executed only using api_key belonging to user with admin rights. |
|
158 | be executed only using api_key belonging to user with admin rights. | |
156 |
|
159 | |||
157 |
|
160 | |||
158 | INPUT:: |
|
161 | INPUT:: | |
159 |
|
162 | |||
|
163 | id : <id_for_response> | |||
160 | api_key : "<api_key>" |
|
164 | api_key : "<api_key>" | |
161 |
|
|
165 | method : "create_user" | |
162 | args : { |
|
166 | args : { | |
163 | "username" : "<username>", |
|
167 | "username" : "<username>", | |
164 | "password" : "<password>", |
|
168 | "password" : "<password>", | |
165 | "email" : "<useremail>", |
|
169 | "email" : "<useremail>", | |
166 | "firstname" : "<firstname> = None", |
|
170 | "firstname" : "<firstname> = None", | |
167 | "lastname" : "<lastname> = None", |
|
171 | "lastname" : "<lastname> = None", | |
168 | "active" : "<bool> = True", |
|
172 | "active" : "<bool> = True", | |
169 | "admin" : "<bool> = False", |
|
173 | "admin" : "<bool> = False", | |
170 | "ldap_dn" : "<ldap_dn> = None" |
|
174 | "ldap_dn" : "<ldap_dn> = None" | |
171 | } |
|
175 | } | |
172 |
|
176 | |||
173 | OUTPUT:: |
|
177 | OUTPUT:: | |
174 |
|
178 | |||
175 | result: { |
|
179 | result: { | |
176 | "id" : "<new_user_id>", |
|
180 | "id" : "<new_user_id>", | |
177 | "msg" : "created new user <username>" |
|
181 | "msg" : "created new user <username>" | |
178 | } |
|
182 | } | |
179 | error: null |
|
183 | error: null | |
180 |
|
184 | |||
181 |
|
185 | |||
182 | update_user |
|
186 | update_user | |
183 | ----------- |
|
187 | ----------- | |
184 |
|
188 | |||
185 | updates current one if such user exists. This command can |
|
189 | updates current one if such user exists. This command can | |
186 | be executed only using api_key belonging to user with admin rights. |
|
190 | be executed only using api_key belonging to user with admin rights. | |
187 |
|
191 | |||
188 |
|
192 | |||
189 | INPUT:: |
|
193 | INPUT:: | |
190 |
|
194 | |||
|
195 | id : <id_for_response> | |||
191 | api_key : "<api_key>" |
|
196 | api_key : "<api_key>" | |
192 |
|
|
197 | method : "update_user" | |
193 | args : { |
|
198 | args : { | |
194 | "userid" : "<user_id or username>", |
|
199 | "userid" : "<user_id or username>", | |
195 | "username" : "<username>", |
|
200 | "username" : "<username>", | |
196 | "password" : "<password>", |
|
201 | "password" : "<password>", | |
197 | "email" : "<useremail>", |
|
202 | "email" : "<useremail>", | |
198 | "firstname" : "<firstname>", |
|
203 | "firstname" : "<firstname>", | |
199 | "lastname" : "<lastname>", |
|
204 | "lastname" : "<lastname>", | |
200 | "active" : "<bool>", |
|
205 | "active" : "<bool>", | |
201 | "admin" : "<bool>", |
|
206 | "admin" : "<bool>", | |
202 | "ldap_dn" : "<ldap_dn>" |
|
207 | "ldap_dn" : "<ldap_dn>" | |
203 | } |
|
208 | } | |
204 |
|
209 | |||
205 | OUTPUT:: |
|
210 | OUTPUT:: | |
206 |
|
211 | |||
207 | result: { |
|
212 | result: { | |
208 | "id" : "<edited_user_id>", |
|
213 | "id" : "<edited_user_id>", | |
209 | "msg" : "updated user <username>" |
|
214 | "msg" : "updated user <username>" | |
210 | } |
|
215 | } | |
211 | error: null |
|
216 | error: null | |
212 |
|
217 | |||
213 |
|
218 | |||
214 | get_users_group |
|
219 | get_users_group | |
215 | --------------- |
|
220 | --------------- | |
216 |
|
221 | |||
217 | Gets an existing users group. This command can be executed only using api_key |
|
222 | Gets an existing users group. This command can be executed only using api_key | |
218 | belonging to user with admin rights. |
|
223 | belonging to user with admin rights. | |
219 |
|
224 | |||
220 |
|
225 | |||
221 | INPUT:: |
|
226 | INPUT:: | |
222 |
|
227 | |||
|
228 | id : <id_for_response> | |||
223 | api_key : "<api_key>" |
|
229 | api_key : "<api_key>" | |
224 |
|
|
230 | method : "get_users_group" | |
225 | args : { |
|
231 | args : { | |
226 | "group_name" : "<name>" |
|
232 | "group_name" : "<name>" | |
227 | } |
|
233 | } | |
228 |
|
234 | |||
229 | OUTPUT:: |
|
235 | OUTPUT:: | |
230 |
|
236 | |||
231 | result : None if group not exist |
|
237 | result : None if group not exist | |
232 | { |
|
238 | { | |
233 | "id" : "<id>", |
|
239 | "id" : "<id>", | |
234 | "group_name" : "<groupname>", |
|
240 | "group_name" : "<groupname>", | |
235 | "active": "<bool>", |
|
241 | "active": "<bool>", | |
236 | "members" : [ |
|
242 | "members" : [ | |
237 | { "id" : "<userid>", |
|
243 | { "id" : "<userid>", | |
238 | "username" : "<username>", |
|
244 | "username" : "<username>", | |
239 | "firstname": "<firstname>", |
|
245 | "firstname": "<firstname>", | |
240 | "lastname" : "<lastname>", |
|
246 | "lastname" : "<lastname>", | |
241 | "email" : "<email>", |
|
247 | "email" : "<email>", | |
242 | "active" : "<bool>", |
|
248 | "active" : "<bool>", | |
243 | "admin" :Β "<bool>", |
|
249 | "admin" :Β "<bool>", | |
244 | "ldap" : "<ldap_dn>" |
|
250 | "ldap" : "<ldap_dn>" | |
245 | }, |
|
251 | }, | |
246 | β¦ |
|
252 | β¦ | |
247 | ] |
|
253 | ] | |
248 | } |
|
254 | } | |
249 | error : null |
|
255 | error : null | |
250 |
|
256 | |||
251 |
|
257 | |||
252 | get_users_groups |
|
258 | get_users_groups | |
253 | ---------------- |
|
259 | ---------------- | |
254 |
|
260 | |||
255 | Lists all existing users groups. This command can be executed only using |
|
261 | Lists all existing users groups. This command can be executed only using | |
256 | api_key belonging to user with admin rights. |
|
262 | api_key belonging to user with admin rights. | |
257 |
|
263 | |||
258 |
|
264 | |||
259 | INPUT:: |
|
265 | INPUT:: | |
260 |
|
266 | |||
|
267 | id : <id_for_response> | |||
261 | api_key : "<api_key>" |
|
268 | api_key : "<api_key>" | |
262 |
|
|
269 | method : "get_users_groups" | |
263 | args : { } |
|
270 | args : { } | |
264 |
|
271 | |||
265 | OUTPUT:: |
|
272 | OUTPUT:: | |
266 |
|
273 | |||
267 | result : [ |
|
274 | result : [ | |
268 | { |
|
275 | { | |
269 | "id" : "<id>", |
|
276 | "id" : "<id>", | |
270 | "group_name" : "<groupname>", |
|
277 | "group_name" : "<groupname>", | |
271 | "active": "<bool>", |
|
278 | "active": "<bool>", | |
272 | "members" : [ |
|
279 | "members" : [ | |
273 | { |
|
280 | { | |
274 | "id" : "<userid>", |
|
281 | "id" : "<userid>", | |
275 | "username" : "<username>", |
|
282 | "username" : "<username>", | |
276 | "firstname": "<firstname>", |
|
283 | "firstname": "<firstname>", | |
277 | "lastname" : "<lastname>", |
|
284 | "lastname" : "<lastname>", | |
278 | "email" : "<email>", |
|
285 | "email" : "<email>", | |
279 | "active" : "<bool>", |
|
286 | "active" : "<bool>", | |
280 | "admin" :Β "<bool>", |
|
287 | "admin" :Β "<bool>", | |
281 | "ldap" : "<ldap_dn>" |
|
288 | "ldap" : "<ldap_dn>" | |
282 | }, |
|
289 | }, | |
283 | β¦ |
|
290 | β¦ | |
284 | ] |
|
291 | ] | |
285 | } |
|
292 | } | |
286 | ] |
|
293 | ] | |
287 | error : null |
|
294 | error : null | |
288 |
|
295 | |||
289 |
|
296 | |||
290 | create_users_group |
|
297 | create_users_group | |
291 | ------------------ |
|
298 | ------------------ | |
292 |
|
299 | |||
293 | Creates new users group. This command can be executed only using api_key |
|
300 | Creates new users group. This command can be executed only using api_key | |
294 | belonging to user with admin rights |
|
301 | belonging to user with admin rights | |
295 |
|
302 | |||
296 |
|
303 | |||
297 | INPUT:: |
|
304 | INPUT:: | |
298 |
|
305 | |||
|
306 | id : <id_for_response> | |||
299 | api_key : "<api_key>" |
|
307 | api_key : "<api_key>" | |
300 |
|
|
308 | method : "create_users_group" | |
301 | args: { |
|
309 | args: { | |
302 | "group_name": "<groupname>", |
|
310 | "group_name": "<groupname>", | |
303 | "active":"<bool> = True" |
|
311 | "active":"<bool> = True" | |
304 | } |
|
312 | } | |
305 |
|
313 | |||
306 | OUTPUT:: |
|
314 | OUTPUT:: | |
307 |
|
315 | |||
308 | result: { |
|
316 | result: { | |
309 | "id": "<newusersgroupid>", |
|
317 | "id": "<newusersgroupid>", | |
310 | "msg": "created new users group <groupname>" |
|
318 | "msg": "created new users group <groupname>" | |
311 | } |
|
319 | } | |
312 | error: null |
|
320 | error: null | |
313 |
|
321 | |||
314 |
|
322 | |||
315 | add_user_to_users_group |
|
323 | add_user_to_users_group | |
316 | ----------------------- |
|
324 | ----------------------- | |
317 |
|
325 | |||
318 | Adds a user to a users group. If user exists in that group success will be |
|
326 | Adds a user to a users group. If user exists in that group success will be | |
319 | `false`. This command can be executed only using api_key |
|
327 | `false`. This command can be executed only using api_key | |
320 | belonging to user with admin rights |
|
328 | belonging to user with admin rights | |
321 |
|
329 | |||
322 |
|
330 | |||
323 | INPUT:: |
|
331 | INPUT:: | |
324 |
|
332 | |||
|
333 | id : <id_for_response> | |||
325 | api_key : "<api_key>" |
|
334 | api_key : "<api_key>" | |
326 |
|
|
335 | method : "add_user_users_group" | |
327 | args: { |
|
336 | args: { | |
328 | "group_name" : "<groupname>", |
|
337 | "group_name" : "<groupname>", | |
329 | "username" : "<username>" |
|
338 | "username" : "<username>" | |
330 | } |
|
339 | } | |
331 |
|
340 | |||
332 | OUTPUT:: |
|
341 | OUTPUT:: | |
333 |
|
342 | |||
334 | result: { |
|
343 | result: { | |
335 | "id": "<newusersgroupmemberid>", |
|
344 | "id": "<newusersgroupmemberid>", | |
336 | "success": True|False # depends on if member is in group |
|
345 | "success": True|False # depends on if member is in group | |
337 | "msg": "added member <username> to users group <groupname> | |
|
346 | "msg": "added member <username> to users group <groupname> | | |
338 | User is already in that group" |
|
347 | User is already in that group" | |
339 | } |
|
348 | } | |
340 | error: null |
|
349 | error: null | |
341 |
|
350 | |||
342 |
|
351 | |||
343 | remove_user_from_users_group |
|
352 | remove_user_from_users_group | |
344 | ---------------------------- |
|
353 | ---------------------------- | |
345 |
|
354 | |||
346 | Removes a user from a users group. If user is not in given group success will |
|
355 | Removes a user from a users group. If user is not in given group success will | |
347 | be `false`. This command can be executed only |
|
356 | be `false`. This command can be executed only | |
348 | using api_key belonging to user with admin rights |
|
357 | using api_key belonging to user with admin rights | |
349 |
|
358 | |||
350 |
|
359 | |||
351 | INPUT:: |
|
360 | INPUT:: | |
352 |
|
361 | |||
|
362 | id : <id_for_response> | |||
353 | api_key : "<api_key>" |
|
363 | api_key : "<api_key>" | |
354 |
|
|
364 | method : "remove_user_from_users_group" | |
355 | args: { |
|
365 | args: { | |
356 | "group_name" : "<groupname>", |
|
366 | "group_name" : "<groupname>", | |
357 | "username" : "<username>" |
|
367 | "username" : "<username>" | |
358 | } |
|
368 | } | |
359 |
|
369 | |||
360 | OUTPUT:: |
|
370 | OUTPUT:: | |
361 |
|
371 | |||
362 | result: { |
|
372 | result: { | |
363 | "success": True|False, # depends on if member is in group |
|
373 | "success": True|False, # depends on if member is in group | |
364 | "msg": "removed member <username> from users group <groupname> | |
|
374 | "msg": "removed member <username> from users group <groupname> | | |
365 | User wasn't in group" |
|
375 | User wasn't in group" | |
366 | } |
|
376 | } | |
367 | error: null |
|
377 | error: null | |
368 |
|
378 | |||
369 |
|
379 | |||
370 | get_repo |
|
380 | get_repo | |
371 | -------- |
|
381 | -------- | |
372 |
|
382 | |||
373 | Gets an existing repository by it's name or repository_id. This command can |
|
383 | Gets an existing repository by it's name or repository_id. This command can | |
374 | be executed only using api_key belonging to user with admin rights. |
|
384 | be executed only using api_key belonging to user with admin rights. | |
375 |
|
385 | |||
376 |
|
386 | |||
377 | INPUT:: |
|
387 | INPUT:: | |
378 |
|
388 | |||
|
389 | id : <id_for_response> | |||
379 | api_key : "<api_key>" |
|
390 | api_key : "<api_key>" | |
380 |
|
|
391 | method : "get_repo" | |
381 | args: { |
|
392 | args: { | |
382 | "repoid" : "<reponame or repo_id>" |
|
393 | "repoid" : "<reponame or repo_id>" | |
383 | } |
|
394 | } | |
384 |
|
395 | |||
385 | OUTPUT:: |
|
396 | OUTPUT:: | |
386 |
|
397 | |||
387 | result: None if repository does not exist or |
|
398 | result: None if repository does not exist or | |
388 | { |
|
399 | { | |
389 | "id" : "<id>", |
|
400 | "id" : "<id>", | |
390 | "repo_name" : "<reponame>" |
|
401 | "repo_name" : "<reponame>" | |
391 | "type" : "<type>", |
|
402 | "type" : "<type>", | |
392 | "description" : "<description>", |
|
403 | "description" : "<description>", | |
393 | "members" : [ |
|
404 | "members" : [ | |
394 | { "id" : "<userid>", |
|
405 | { "id" : "<userid>", | |
395 | "username" : "<username>", |
|
406 | "username" : "<username>", | |
396 | "firstname": "<firstname>", |
|
407 | "firstname": "<firstname>", | |
397 | "lastname" : "<lastname>", |
|
408 | "lastname" : "<lastname>", | |
398 | "email" : "<email>", |
|
409 | "email" : "<email>", | |
399 | "active" : "<bool>", |
|
410 | "active" : "<bool>", | |
400 | "admin" :Β "<bool>", |
|
411 | "admin" :Β "<bool>", | |
401 | "ldap" : "<ldap_dn>", |
|
412 | "ldap" : "<ldap_dn>", | |
402 | "permission" : "repository.(read|write|admin)" |
|
413 | "permission" : "repository.(read|write|admin)" | |
403 | }, |
|
414 | }, | |
404 | β¦ |
|
415 | β¦ | |
405 | { |
|
416 | { | |
406 | "id" : "<usersgroupid>", |
|
417 | "id" : "<usersgroupid>", | |
407 | "name" : "<usersgroupname>", |
|
418 | "name" : "<usersgroupname>", | |
408 | "active": "<bool>", |
|
419 | "active": "<bool>", | |
409 | "permission" : "repository.(read|write|admin)" |
|
420 | "permission" : "repository.(read|write|admin)" | |
410 | }, |
|
421 | }, | |
411 | β¦ |
|
422 | β¦ | |
412 | ] |
|
423 | ] | |
413 | } |
|
424 | } | |
414 | error: null |
|
425 | error: null | |
415 |
|
426 | |||
416 |
|
427 | |||
417 | get_repos |
|
428 | get_repos | |
418 | --------- |
|
429 | --------- | |
419 |
|
430 | |||
420 | Lists all existing repositories. This command can be executed only using api_key |
|
431 | Lists all existing repositories. This command can be executed only using api_key | |
421 | belonging to user with admin rights |
|
432 | belonging to user with admin rights | |
422 |
|
433 | |||
423 |
|
434 | |||
424 | INPUT:: |
|
435 | INPUT:: | |
425 |
|
436 | |||
|
437 | id : <id_for_response> | |||
426 | api_key : "<api_key>" |
|
438 | api_key : "<api_key>" | |
427 |
|
|
439 | method : "get_repos" | |
428 | args: { } |
|
440 | args: { } | |
429 |
|
441 | |||
430 | OUTPUT:: |
|
442 | OUTPUT:: | |
431 |
|
443 | |||
432 | result: [ |
|
444 | result: [ | |
433 | { |
|
445 | { | |
434 | "id" : "<id>", |
|
446 | "id" : "<id>", | |
435 | "repo_name" : "<reponame>" |
|
447 | "repo_name" : "<reponame>" | |
436 | "type" : "<type>", |
|
448 | "type" : "<type>", | |
437 | "description" : "<description>" |
|
449 | "description" : "<description>" | |
438 | }, |
|
450 | }, | |
439 | β¦ |
|
451 | β¦ | |
440 | ] |
|
452 | ] | |
441 | error: null |
|
453 | error: null | |
442 |
|
454 | |||
443 |
|
455 | |||
444 | get_repo_nodes |
|
456 | get_repo_nodes | |
445 | -------------- |
|
457 | -------------- | |
446 |
|
458 | |||
447 | returns a list of nodes and it's children in a flat list for a given path |
|
459 | returns a list of nodes and it's children in a flat list for a given path | |
448 | at given revision. It's possible to specify ret_type to show only `files` or |
|
460 | at given revision. It's possible to specify ret_type to show only `files` or | |
449 | `dirs`. This command can be executed only using api_key belonging to user |
|
461 | `dirs`. This command can be executed only using api_key belonging to user | |
450 | with admin rights |
|
462 | with admin rights | |
451 |
|
463 | |||
452 |
|
464 | |||
453 | INPUT:: |
|
465 | INPUT:: | |
454 |
|
466 | |||
|
467 | id : <id_for_response> | |||
455 | api_key : "<api_key>" |
|
468 | api_key : "<api_key>" | |
456 |
|
|
469 | method : "get_repo_nodes" | |
457 | args: { |
|
470 | args: { | |
458 | "repo_name" : "<reponame>", |
|
471 | "repo_name" : "<reponame>", | |
459 | "revision" : "<revision>", |
|
472 | "revision" : "<revision>", | |
460 | "root_path" : "<root_path>", |
|
473 | "root_path" : "<root_path>", | |
461 | "ret_type" : "<ret_type>" = 'all' |
|
474 | "ret_type" : "<ret_type>" = 'all' | |
462 | } |
|
475 | } | |
463 |
|
476 | |||
464 | OUTPUT:: |
|
477 | OUTPUT:: | |
465 |
|
478 | |||
466 | result: [ |
|
479 | result: [ | |
467 | { |
|
480 | { | |
468 | "name" : "<name>" |
|
481 | "name" : "<name>" | |
469 | "type" : "<type>", |
|
482 | "type" : "<type>", | |
470 | }, |
|
483 | }, | |
471 | β¦ |
|
484 | β¦ | |
472 | ] |
|
485 | ] | |
473 | error: null |
|
486 | error: null | |
474 |
|
487 | |||
475 |
|
488 | |||
476 | create_repo |
|
489 | create_repo | |
477 | ----------- |
|
490 | ----------- | |
478 |
|
491 | |||
479 | Creates a repository. This command can be executed only using api_key |
|
492 | Creates a repository. This command can be executed only using api_key | |
480 | belonging to user with admin rights. |
|
493 | belonging to user with admin rights. | |
481 | If repository name contains "/", all needed repository groups will be created. |
|
494 | If repository name contains "/", all needed repository groups will be created. | |
482 | For example "foo/bar/baz" will create groups "foo", "bar" (with "foo" as parent), |
|
495 | For example "foo/bar/baz" will create groups "foo", "bar" (with "foo" as parent), | |
483 | and create "baz" repository with "bar" as group. |
|
496 | and create "baz" repository with "bar" as group. | |
484 |
|
497 | |||
485 |
|
498 | |||
486 | INPUT:: |
|
499 | INPUT:: | |
487 |
|
500 | |||
|
501 | id : <id_for_response> | |||
488 | api_key : "<api_key>" |
|
502 | api_key : "<api_key>" | |
489 |
|
|
503 | method : "create_repo" | |
490 | args: { |
|
504 | args: { | |
491 | "repo_name" : "<reponame>", |
|
505 | "repo_name" : "<reponame>", | |
492 | "owner_name" : "<ownername>", |
|
506 | "owner_name" : "<ownername>", | |
493 | "description" : "<description> = ''", |
|
507 | "description" : "<description> = ''", | |
494 | "repo_type" : "<type> = 'hg'", |
|
508 | "repo_type" : "<type> = 'hg'", | |
495 | "private" : "<bool> = False", |
|
509 | "private" : "<bool> = False", | |
496 | "clone_uri" : "<clone_uri> = None", |
|
510 | "clone_uri" : "<clone_uri> = None", | |
497 | } |
|
511 | } | |
498 |
|
512 | |||
499 | OUTPUT:: |
|
513 | OUTPUT:: | |
500 |
|
514 | |||
501 | result: { |
|
515 | result: { | |
502 | "id": "<newrepoid>", |
|
516 | "id": "<newrepoid>", | |
503 | "msg": "Created new repository <reponame>", |
|
517 | "msg": "Created new repository <reponame>", | |
504 | } |
|
518 | } | |
505 | error: null |
|
519 | error: null | |
506 |
|
520 | |||
507 |
|
521 | |||
508 | delete_repo |
|
522 | delete_repo | |
509 | ----------- |
|
523 | ----------- | |
510 |
|
524 | |||
511 | Deletes a repository. This command can be executed only using api_key |
|
525 | Deletes a repository. This command can be executed only using api_key | |
512 | belonging to user with admin rights. |
|
526 | belonging to user with admin rights. | |
513 |
|
527 | |||
514 |
|
528 | |||
515 | INPUT:: |
|
529 | INPUT:: | |
516 |
|
530 | |||
|
531 | id : <id_for_response> | |||
517 | api_key : "<api_key>" |
|
532 | api_key : "<api_key>" | |
518 |
|
|
533 | method : "delete_repo" | |
519 | args: { |
|
534 | args: { | |
520 | "repo_name" : "<reponame>", |
|
535 | "repo_name" : "<reponame>", | |
521 | } |
|
536 | } | |
522 |
|
537 | |||
523 | OUTPUT:: |
|
538 | OUTPUT:: | |
524 |
|
539 | |||
525 | result: { |
|
540 | result: { | |
526 | "msg": "Deleted repository <reponame>", |
|
541 | "msg": "Deleted repository <reponame>", | |
527 | } |
|
542 | } | |
528 | error: null |
|
543 | error: null | |
529 |
|
544 | |||
530 |
|
545 | |||
531 | grant_user_permission |
|
546 | grant_user_permission | |
532 | --------------------- |
|
547 | --------------------- | |
533 |
|
548 | |||
534 | Grant permission for user on given repository, or update existing one |
|
549 | Grant permission for user on given repository, or update existing one | |
535 | if found. This command can be executed only using api_key belonging to user |
|
550 | if found. This command can be executed only using api_key belonging to user | |
536 | with admin rights. |
|
551 | with admin rights. | |
537 |
|
552 | |||
538 |
|
553 | |||
539 | INPUT:: |
|
554 | INPUT:: | |
540 |
|
555 | |||
|
556 | id : <id_for_response> | |||
541 | api_key : "<api_key>" |
|
557 | api_key : "<api_key>" | |
542 |
|
|
558 | method : "grant_user_permission" | |
543 | args: { |
|
559 | args: { | |
544 | "repo_name" : "<reponame>", |
|
560 | "repo_name" : "<reponame>", | |
545 | "username" : "<username>", |
|
561 | "username" : "<username>", | |
546 | "perm" : "(repository.(none|read|write|admin))", |
|
562 | "perm" : "(repository.(none|read|write|admin))", | |
547 | } |
|
563 | } | |
548 |
|
564 | |||
549 | OUTPUT:: |
|
565 | OUTPUT:: | |
550 |
|
566 | |||
551 | result: { |
|
567 | result: { | |
552 | "msg" : "Granted perm: <perm> for user: <username> in repo: <reponame>" |
|
568 | "msg" : "Granted perm: <perm> for user: <username> in repo: <reponame>" | |
553 | } |
|
569 | } | |
554 | error: null |
|
570 | error: null | |
555 |
|
571 | |||
556 |
|
572 | |||
557 | revoke_user_permission |
|
573 | revoke_user_permission | |
558 | ---------------------- |
|
574 | ---------------------- | |
559 |
|
575 | |||
560 | Revoke permission for user on given repository. This command can be executed |
|
576 | Revoke permission for user on given repository. This command can be executed | |
561 | only using api_key belonging to user with admin rights. |
|
577 | only using api_key belonging to user with admin rights. | |
562 |
|
578 | |||
563 |
|
579 | |||
564 | INPUT:: |
|
580 | INPUT:: | |
565 |
|
581 | |||
|
582 | id : <id_for_response> | |||
566 | api_key : "<api_key>" |
|
583 | api_key : "<api_key>" | |
567 |
|
|
584 | method : "revoke_user_permission" | |
568 | args: { |
|
585 | args: { | |
569 | "repo_name" : "<reponame>", |
|
586 | "repo_name" : "<reponame>", | |
570 | "username" : "<username>", |
|
587 | "username" : "<username>", | |
571 | } |
|
588 | } | |
572 |
|
589 | |||
573 | OUTPUT:: |
|
590 | OUTPUT:: | |
574 |
|
591 | |||
575 | result: { |
|
592 | result: { | |
576 | "msg" : "Revoked perm for user: <suername> in repo: <reponame>" |
|
593 | "msg" : "Revoked perm for user: <suername> in repo: <reponame>" | |
577 | } |
|
594 | } | |
578 | error: null |
|
595 | error: null | |
579 |
|
596 | |||
580 |
|
597 | |||
581 | grant_users_group_permission |
|
598 | grant_users_group_permission | |
582 | ---------------------------- |
|
599 | ---------------------------- | |
583 |
|
600 | |||
584 | Grant permission for users group on given repository, or update |
|
601 | Grant permission for users group on given repository, or update | |
585 | existing one if found. This command can be executed only using |
|
602 | existing one if found. This command can be executed only using | |
586 | api_key belonging to user with admin rights. |
|
603 | api_key belonging to user with admin rights. | |
587 |
|
604 | |||
588 |
|
605 | |||
589 | INPUT:: |
|
606 | INPUT:: | |
590 |
|
607 | |||
|
608 | id : <id_for_response> | |||
591 | api_key : "<api_key>" |
|
609 | api_key : "<api_key>" | |
592 |
|
|
610 | method : "grant_users_group_permission" | |
593 | args: { |
|
611 | args: { | |
594 | "repo_name" : "<reponame>", |
|
612 | "repo_name" : "<reponame>", | |
595 | "group_name" : "<usersgroupname>", |
|
613 | "group_name" : "<usersgroupname>", | |
596 | "perm" : "(repository.(none|read|write|admin))", |
|
614 | "perm" : "(repository.(none|read|write|admin))", | |
597 | } |
|
615 | } | |
598 |
|
616 | |||
599 | OUTPUT:: |
|
617 | OUTPUT:: | |
600 |
|
618 | |||
601 | result: { |
|
619 | result: { | |
602 | "msg" : "Granted perm: <perm> for group: <usersgroupname> in repo: <reponame>" |
|
620 | "msg" : "Granted perm: <perm> for group: <usersgroupname> in repo: <reponame>" | |
603 | } |
|
621 | } | |
604 | error: null |
|
622 | error: null | |
605 |
|
623 | |||
606 |
|
624 | |||
607 | revoke_users_group_permission |
|
625 | revoke_users_group_permission | |
608 | ----------------------------- |
|
626 | ----------------------------- | |
609 |
|
627 | |||
610 | Revoke permission for users group on given repository.This command can be |
|
628 | Revoke permission for users group on given repository.This command can be | |
611 | executed only using api_key belonging to user with admin rights. |
|
629 | executed only using api_key belonging to user with admin rights. | |
612 |
|
630 | |||
613 | INPUT:: |
|
631 | INPUT:: | |
614 |
|
632 | |||
|
633 | id : <id_for_response> | |||
615 | api_key : "<api_key>" |
|
634 | api_key : "<api_key>" | |
616 |
|
|
635 | method : "revoke_users_group_permission" | |
617 | args: { |
|
636 | args: { | |
618 | "repo_name" : "<reponame>", |
|
637 | "repo_name" : "<reponame>", | |
619 | "users_group" : "<usersgroupname>", |
|
638 | "users_group" : "<usersgroupname>", | |
620 | } |
|
639 | } | |
621 |
|
640 | |||
622 | OUTPUT:: |
|
641 | OUTPUT:: | |
623 |
|
642 | |||
624 | result: { |
|
643 | result: { | |
625 | "msg" : "Revoked perm for group: <usersgroupname> in repo: <reponame>" |
|
644 | "msg" : "Revoked perm for group: <usersgroupname> in repo: <reponame>" | |
626 | } |
|
645 | } | |
627 | error: null No newline at end of file |
|
646 | error: null |
General Comments 0
You need to be logged in to leave comments.
Login now