##// END OF EJS Templates
docs: update api generated documentation
marcink -
r2692:26fd6263 default
parent child Browse files
Show More
@@ -0,0 +1,48 b''
1 .. _views-ref:
2
3 views
4 =====
5
6 push (EE only)
7 --------------
8
9 .. py:function:: push(apiuser, repoid, remote_uri=<Optional:None>)
10
11 Triggers a push on the given repository from a remote location. You
12 can use this to keep remote repositories up-to-date.
13
14 This command can only be run using an |authtoken| with admin
15 rights to the specified repository. For more information,
16 see :ref:`config-token-ref`.
17
18 This command takes the following options:
19
20 :param apiuser: This is filled automatically from the |authtoken|.
21 :type apiuser: AuthUser
22 :param repoid: The repository name or repository ID.
23 :type repoid: str or int
24 :param remote_uri: Optional remote URI to pass in for push
25 :type remote_uri: str
26
27 Example output:
28
29 .. code-block:: bash
30
31 id : <id_given_in_input>
32 result : {
33 "msg": "Pushed to url `<remote_url>` on repo `<repository name>`"
34 "repository": "<repository name>"
35 }
36 error : null
37
38 Example error output:
39
40 .. code-block:: bash
41
42 id : <id_given_in_input>
43 result : null
44 error : {
45 "Unable to push changes to `<remote_url>`"
46 }
47
48
@@ -1,207 +1,208 b''
1 1 .. _api:
2 2
3 3 API Documentation
4 4 =================
5 5
6 6 The |RCE| API uses a single scheme for calling all API methods. The API is
7 7 implemented with JSON protocol in both directions. To send API requests to
8 8 your instance of |RCE|, use the following URL format
9 9 ``<your_server>/_admin``
10 10
11 11 .. note::
12 12
13 13 To use the API, you should configure the :file:`~/.rhoderc` file with
14 14 access details per instance. For more information, see
15 15 :ref:`config-rhoderc`.
16 16
17 17
18 18 API ACCESS FOR WEB VIEWS
19 19 ------------------------
20 20
21 21 API access can also be turned on for each web view in |RCE| that is
22 22 decorated with a `@LoginRequired` decorator. To enable API access, change
23 23 the standard login decorator to `@LoginRequired(api_access=True)`.
24 24
25 25 From |RCM| version 1.7.0 you can configure a white list
26 26 of views that have API access enabled by default. To enable these,
27 27 edit the |RCM| configuration ``.ini`` file. The default location is:
28 28
29 29 * |RCM| Pre-2.2.7 :file:`root/rhodecode/data/production.ini`
30 30 * |RCM| 3.0 :file:`/home/{user}/.rccontrol/{instance-id}/rhodecode.ini`
31 31
32 32 To configure the white list, edit this section of the file. In this
33 33 configuration example, API access is granted to the patch/diff raw file and
34 34 archive.
35 35
36 36 .. code-block:: ini
37 37
38 38 ## List of controllers (using glob syntax) that AUTH TOKENS could be used for access.
39 39 ## Adding ?auth_token = <token> to the url authenticates this request as if it
40 40 ## came from the the logged in user who own this authentication token.
41 41 ##
42 42 ## Syntax is <ControllerClass>:<function_pattern>.
43 43 ## The list should be "," separated and on a single line.
44 44 ##
45 45 api_access_controllers_whitelist = RepoCommitsView:repo_commit_raw,RepoCommitsView:repo_commit_patch,RepoCommitsView:repo_commit_download
46 46
47 47 After this change, a |RCE| view can be accessed without login by adding a
48 48 GET parameter ``?auth_token=<auth_token>`` to a url. For example to
49 49 access the raw diff.
50 50
51 51 .. code-block:: html
52 52
53 53 http://<server>/<repo>/changeset-diff/<sha>?auth_token=<auth_token>
54 54
55 55 By default this is only enabled on RSS/ATOM feed views. Exposing raw diffs is a
56 56 good way to integrate with 3rd party services like code review, or build farms
57 57 that could download archives.
58 58
59 59 API ACCESS
60 60 ----------
61 61
62 62 All clients are required to send JSON-RPC spec JSON data.
63 63
64 64 .. code-block:: bash
65 65
66 66 {
67 67 "id:"<id>",
68 68 "auth_token":"<auth_token>",
69 69 "method":"<method_name>",
70 70 "args":{"<arg_key>":"<arg_val>"}
71 71 }
72 72
73 73 Example call for auto pulling from remote repositories using curl:
74 74
75 75 .. code-block:: bash
76 76
77 77 curl https://server.com/_admin/api -X POST -H 'content-type:text/plain' --data-binary '{"id":1,
78 78 "auth_token":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull", "args":{"repoid":"CPython"}}'
79 79
80 80 Provide those parameters:
81 81 - **id** A value of any type, which is used to match the response with the
82 82 request that it is replying to.
83 83 - **auth_token** for access and permission validation.
84 84 - **method** is name of method to call
85 85 - **args** is an ``key:value`` list of arguments to pass to method
86 86
87 87 .. note::
88 88
89 89 To get your |authtoken|, from the |RCE| interface,
90 90 go to:
91 91 :menuselection:`username --> My account --> Auth tokens`
92 92
93 93 For security reasons you should always create a dedicated |authtoken| for
94 94 API use only.
95 95
96 96
97 97 The |RCE| API will always return a JSON-RPC response:
98 98
99 99 .. code-block:: bash
100 100
101 101 {
102 102 "id": <id>, # matching id sent by request
103 103 "result": "<result>"|null, # JSON formatted result, null if any errors
104 104 "error": "null"|<error_message> # JSON formatted error (if any)
105 105 }
106 106
107 107 All responses from API will be with `HTTP/1.0 200 OK` status code.
108 108 If there is an error when calling the API, the *error* key will contain a
109 109 failure description and the *result* will be `null`.
110 110
111 111 API CLIENT
112 112 ----------
113 113
114 114 To install the |RCE| API, see :ref:`install-tools`. To configure the API per
115 115 instance, see the :ref:`rc-tools` section as you need to configure a
116 116 :file:`~/.rhoderc` file with your |authtokens|.
117 117
118 118 Once you have set up your instance API access, use the following examples to
119 119 get started.
120 120
121 121 .. code-block:: bash
122 122
123 123 # Getting the 'rhodecode' repository
124 124 # from a RhodeCode Enterprise instance
125 125 rhodecode-api --instance-name=enterprise-1 get_repo repoid:rhodecode
126 126
127 127 Calling method get_repo => http://127.0.0.1:5000
128 128 Server response
129 129 {
130 130 <json data>
131 131 }
132 132
133 133 # Creating a new mercurial repository called 'brand-new'
134 134 # with a description 'Repo-description'
135 135 rhodecode-api --instance-name=enterprise-1 create_repo repo_name:brand-new repo_type:hg description:Repo-description
136 136 {
137 137 "error": null,
138 138 "id": 1110,
139 139 "result": {
140 140 "msg": "Created new repository `brand-new`",
141 141 "success": true,
142 142 "task": null
143 143 }
144 144 }
145 145
146 146 A broken example, what not to do.
147 147
148 148 .. code-block:: bash
149 149
150 150 # A call missing the required arguments
151 151 # and not specifying the instance
152 152 rhodecode-api get_repo
153 153
154 154 Calling method get_repo => http://127.0.0.1:5000
155 155 Server response
156 156 "Missing non optional `repoid` arg in JSON DATA"
157 157
158 158 You can specify pure JSON using the ``--format`` parameter.
159 159
160 160 .. code-block:: bash
161 161
162 162 rhodecode-api --format=json get_repo repoid:rhodecode
163 163
164 164 In such case only output that this function shows is pure JSON, we can use that
165 165 and pipe output to some json formatter.
166 166
167 167 If output is in pure JSON format, you can pipe output to a JSON formatter.
168 168
169 169 .. code-block:: bash
170 170
171 171 rhodecode-api --instance-name=enterprise-1 --format=json get_repo repoid:rhodecode | python -m json.tool
172 172
173 173 API METHODS
174 174 -----------
175 175
176 176 Each method by default required following arguments.
177 177
178 178 .. code-block:: bash
179 179
180 180 id : "<id_for_response>"
181 181 auth_token : "<auth_token>"
182 182 method : "<method name>"
183 183 args : {}
184 184
185 185 Use each **param** from docs and put it in args, Optional parameters
186 186 are not required in args.
187 187
188 188 .. code-block:: bash
189 189
190 190 args: {"repoid": "rhodecode"}
191 191
192 192 .. Note: From this point on things are generated by the script in
193 193 `scripts/fabfile.py`. To change things below, update the docstrings in the
194 194 ApiController.
195 195
196 196 .. --- API DEFS MARKER ---
197 197 .. toctree::
198 198
199 methods/views
199 200 methods/license-methods
200 201 methods/deprecated-methods
201 202 methods/gist-methods
202 203 methods/pull-request-methods
203 204 methods/repo-methods
204 205 methods/repo-group-methods
205 206 methods/server-methods
206 207 methods/user-methods
207 208 methods/user-group-methods
@@ -1,77 +1,77 b''
1 1 .. _deprecated-methods-ref:
2 2
3 3 deprecated methods
4 4 ==================
5 5
6 6 changeset_comment
7 7 -----------------
8 8
9 9 .. py:function:: changeset_comment(apiuser, repoid, revision, message, userid=<Optional:<OptionalAttr:apiuser>>, status=<Optional:None>)
10 10
11 11 .. deprecated:: 3.4.0
12 12
13 13 Please use method `comment_commit` instead.
14 14
15 15
16 16 Set a changeset comment, and optionally change the status of the
17 17 changeset.
18 18
19 19 This command can only be run using an |authtoken| with admin
20 20 permissions on the |repo|.
21 21
22 22 :param apiuser: This is filled automatically from the |authtoken|.
23 23 :type apiuser: AuthUser
24 24 :param repoid: Set the repository name or repository ID.
25 25 :type repoid: str or int
26 26 :param revision: Specify the revision for which to set a comment.
27 27 :type revision: str
28 28 :param message: The comment text.
29 29 :type message: str
30 30 :param userid: Set the user name of the comment creator.
31 31 :type userid: Optional(str or int)
32 32 :param status: Set the comment status. The following are valid options:
33 33 * not_reviewed
34 34 * approved
35 35 * rejected
36 36 * under_review
37 37 :type status: str
38 38
39 39 Example error output:
40 40
41 .. code-block:: javascript
41 .. code-block:: json
42 42
43 43 {
44 44 "id" : <id_given_in_input>,
45 45 "result" : {
46 46 "msg": "Commented on commit `<revision>` for repository `<repoid>`",
47 47 "status_change": null or <status>,
48 48 "success": true
49 49 },
50 50 "error" : null
51 51 }
52 52
53 53
54 54 get_locks
55 55 ---------
56 56
57 57 .. py:function:: get_locks(apiuser, userid=<Optional:<OptionalAttr:apiuser>>)
58 58
59 59 .. deprecated:: 4.0.0
60 60
61 61 Please use method `get_user_locks` instead.
62 62
63 63 None
64 64
65 65
66 66 show_ip
67 67 -------
68 68
69 69 .. py:function:: show_ip(apiuser, userid=<Optional:<OptionalAttr:apiuser>>)
70 70
71 71 .. deprecated:: 4.0.0
72 72
73 73 Please use method `get_ip` instead.
74 74
75 75 None
76 76
77 77
@@ -1,1024 +1,1028 b''
1 1 .. _repo-methods-ref:
2 2
3 3 repo methods
4 4 ============
5 5
6 6 add_field_to_repo
7 7 -----------------
8 8
9 9 .. py:function:: add_field_to_repo(apiuser, repoid, key, label=<Optional:''>, description=<Optional:''>)
10 10
11 11 Adds an extra field to a repository.
12 12
13 13 This command can only be run using an |authtoken| with at least
14 14 write permissions to the |repo|.
15 15
16 16 :param apiuser: This is filled automatically from the |authtoken|.
17 17 :type apiuser: AuthUser
18 18 :param repoid: Set the repository name or repository id.
19 19 :type repoid: str or int
20 20 :param key: Create a unique field key for this repository.
21 21 :type key: str
22 22 :param label:
23 23 :type label: Optional(str)
24 24 :param description:
25 25 :type description: Optional(str)
26 26
27 27
28 28 comment_commit
29 29 --------------
30 30
31 31 .. py:function:: comment_commit(apiuser, repoid, commit_id, message, status=<Optional:None>, comment_type=<Optional:u'note'>, resolves_comment_id=<Optional:None>, userid=<Optional:<OptionalAttr:apiuser>>)
32 32
33 33 Set a commit comment, and optionally change the status of the commit.
34 34
35 35 :param apiuser: This is filled automatically from the |authtoken|.
36 36 :type apiuser: AuthUser
37 37 :param repoid: Set the repository name or repository ID.
38 38 :type repoid: str or int
39 39 :param commit_id: Specify the commit_id for which to set a comment.
40 40 :type commit_id: str
41 41 :param message: The comment text.
42 42 :type message: str
43 43 :param status: (**Optional**) status of commit, one of: 'not_reviewed',
44 44 'approved', 'rejected', 'under_review'
45 45 :type status: str
46 46 :param comment_type: Comment type, one of: 'note', 'todo'
47 47 :type comment_type: Optional(str), default: 'note'
48 48 :param userid: Set the user name of the comment creator.
49 49 :type userid: Optional(str or int)
50 50
51 51 Example error output:
52 52
53 53 .. code-block:: bash
54 54
55 55 {
56 56 "id" : <id_given_in_input>,
57 57 "result" : {
58 58 "msg": "Commented on commit `<commit_id>` for repository `<repoid>`",
59 59 "status_change": null or <status>,
60 60 "success": true
61 61 },
62 62 "error" : null
63 63 }
64 64
65 65
66 66 create_repo
67 67 -----------
68 68
69 .. py:function:: create_repo(apiuser, repo_name, repo_type, owner=<Optional:<OptionalAttr:apiuser>>, description=<Optional:''>, private=<Optional:False>, clone_uri=<Optional:None>, landing_rev=<Optional:'rev:tip'>, enable_statistics=<Optional:False>, enable_locking=<Optional:False>, enable_downloads=<Optional:False>, copy_permissions=<Optional:False>)
69 .. py:function:: create_repo(apiuser, repo_name, repo_type, owner=<Optional:<OptionalAttr:apiuser>>, description=<Optional:''>, private=<Optional:False>, clone_uri=<Optional:None>, push_uri=<Optional:None>, landing_rev=<Optional:'rev:tip'>, enable_statistics=<Optional:False>, enable_locking=<Optional:False>, enable_downloads=<Optional:False>, copy_permissions=<Optional:False>)
70 70
71 71 Creates a repository.
72 72
73 73 * If the repository name contains "/", repository will be created inside
74 74 a repository group or nested repository groups
75 75
76 76 For example "foo/bar/repo1" will create |repo| called "repo1" inside
77 77 group "foo/bar". You have to have permissions to access and write to
78 78 the last repository group ("bar" in this example)
79 79
80 80 This command can only be run using an |authtoken| with at least
81 81 permissions to create repositories, or write permissions to
82 82 parent repository groups.
83 83
84 84 :param apiuser: This is filled automatically from the |authtoken|.
85 85 :type apiuser: AuthUser
86 86 :param repo_name: Set the repository name.
87 87 :type repo_name: str
88 88 :param repo_type: Set the repository type; 'hg','git', or 'svn'.
89 89 :type repo_type: str
90 90 :param owner: user_id or username
91 91 :type owner: Optional(str)
92 92 :param description: Set the repository description.
93 93 :type description: Optional(str)
94 94 :param private: set repository as private
95 95 :type private: bool
96 96 :param clone_uri: set clone_uri
97 97 :type clone_uri: str
98 :param push_uri: set push_uri
99 :type push_uri: str
98 100 :param landing_rev: <rev_type>:<rev>
99 101 :type landing_rev: str
100 102 :param enable_locking:
101 103 :type enable_locking: bool
102 104 :param enable_downloads:
103 105 :type enable_downloads: bool
104 106 :param enable_statistics:
105 107 :type enable_statistics: bool
106 108 :param copy_permissions: Copy permission from group in which the
107 109 repository is being created.
108 110 :type copy_permissions: bool
109 111
110 112
111 113 Example output:
112 114
113 115 .. code-block:: bash
114 116
115 117 id : <id_given_in_input>
116 118 result: {
117 119 "msg": "Created new repository `<reponame>`",
118 120 "success": true,
119 121 "task": "<celery task id or None if done sync>"
120 122 }
121 123 error: null
122 124
123 125
124 126 Example error output:
125 127
126 128 .. code-block:: bash
127 129
128 130 id : <id_given_in_input>
129 131 result : null
130 132 error : {
131 133 'failed to create repository `<repo_name>`'
132 134 }
133 135
134 136
135 137 delete_repo
136 138 -----------
137 139
138 140 .. py:function:: delete_repo(apiuser, repoid, forks=<Optional:''>)
139 141
140 142 Deletes a repository.
141 143
142 144 * When the `forks` parameter is set it's possible to detach or delete
143 145 forks of deleted repository.
144 146
145 147 This command can only be run using an |authtoken| with admin
146 148 permissions on the |repo|.
147 149
148 150 :param apiuser: This is filled automatically from the |authtoken|.
149 151 :type apiuser: AuthUser
150 152 :param repoid: Set the repository name or repository ID.
151 153 :type repoid: str or int
152 154 :param forks: Set to `detach` or `delete` forks from the |repo|.
153 155 :type forks: Optional(str)
154 156
155 157 Example error output:
156 158
157 159 .. code-block:: bash
158 160
159 161 id : <id_given_in_input>
160 162 result: {
161 163 "msg": "Deleted repository `<reponame>`",
162 164 "success": true
163 165 }
164 166 error: null
165 167
166 168
167 169 fork_repo
168 170 ---------
169 171
170 172 .. py:function:: fork_repo(apiuser, repoid, fork_name, owner=<Optional:<OptionalAttr:apiuser>>, description=<Optional:''>, private=<Optional:False>, clone_uri=<Optional:None>, landing_rev=<Optional:'rev:tip'>, copy_permissions=<Optional:False>)
171 173
172 174 Creates a fork of the specified |repo|.
173 175
174 176 * If the fork_name contains "/", fork will be created inside
175 177 a repository group or nested repository groups
176 178
177 179 For example "foo/bar/fork-repo" will create fork called "fork-repo"
178 180 inside group "foo/bar". You have to have permissions to access and
179 181 write to the last repository group ("bar" in this example)
180 182
181 183 This command can only be run using an |authtoken| with minimum
182 184 read permissions of the forked repo, create fork permissions for an user.
183 185
184 186 :param apiuser: This is filled automatically from the |authtoken|.
185 187 :type apiuser: AuthUser
186 188 :param repoid: Set repository name or repository ID.
187 189 :type repoid: str or int
188 190 :param fork_name: Set the fork name, including it's repository group membership.
189 191 :type fork_name: str
190 192 :param owner: Set the fork owner.
191 193 :type owner: str
192 194 :param description: Set the fork description.
193 195 :type description: str
194 196 :param copy_permissions: Copy permissions from parent |repo|. The
195 197 default is False.
196 198 :type copy_permissions: bool
197 199 :param private: Make the fork private. The default is False.
198 200 :type private: bool
199 201 :param landing_rev: Set the landing revision. The default is tip.
200 202
201 203 Example output:
202 204
203 205 .. code-block:: bash
204 206
205 207 id : <id_for_response>
206 208 api_key : "<api_key>"
207 209 args: {
208 210 "repoid" : "<reponame or repo_id>",
209 211 "fork_name": "<forkname>",
210 212 "owner": "<username or user_id = Optional(=apiuser)>",
211 213 "description": "<description>",
212 214 "copy_permissions": "<bool>",
213 215 "private": "<bool>",
214 216 "landing_rev": "<landing_rev>"
215 217 }
216 218
217 219 Example error output:
218 220
219 221 .. code-block:: bash
220 222
221 223 id : <id_given_in_input>
222 224 result: {
223 225 "msg": "Created fork of `<reponame>` as `<forkname>`",
224 226 "success": true,
225 227 "task": "<celery task id or None if done sync>"
226 228 }
227 229 error: null
228 230
229 231
230 232 get_repo
231 233 --------
232 234
233 235 .. py:function:: get_repo(apiuser, repoid, cache=<Optional:True>)
234 236
235 237 Gets an existing repository by its name or repository_id.
236 238
237 239 The members section so the output returns users groups or users
238 240 associated with that repository.
239 241
240 242 This command can only be run using an |authtoken| with admin rights,
241 243 or users with at least read rights to the |repo|.
242 244
243 245 :param apiuser: This is filled automatically from the |authtoken|.
244 246 :type apiuser: AuthUser
245 247 :param repoid: The repository name or repository id.
246 248 :type repoid: str or int
247 249 :param cache: use the cached value for last changeset
248 250 :type: cache: Optional(bool)
249 251
250 252 Example output:
251 253
252 254 .. code-block:: bash
253 255
254 256 {
255 257 "error": null,
256 258 "id": <repo_id>,
257 259 "result": {
258 260 "clone_uri": null,
259 261 "created_on": "timestamp",
260 262 "description": "repo description",
261 263 "enable_downloads": false,
262 264 "enable_locking": false,
263 265 "enable_statistics": false,
264 266 "followers": [
265 267 {
266 268 "active": true,
267 269 "admin": false,
268 270 "api_key": "****************************************",
269 271 "api_keys": [
270 272 "****************************************"
271 273 ],
272 274 "email": "user@example.com",
273 275 "emails": [
274 276 "user@example.com"
275 277 ],
276 278 "extern_name": "rhodecode",
277 279 "extern_type": "rhodecode",
278 280 "firstname": "username",
279 281 "ip_addresses": [],
280 282 "language": null,
281 283 "last_login": "2015-09-16T17:16:35.854",
282 284 "lastname": "surname",
283 285 "user_id": <user_id>,
284 286 "username": "name"
285 287 }
286 288 ],
287 289 "fork_of": "parent-repo",
288 290 "landing_rev": [
289 291 "rev",
290 292 "tip"
291 293 ],
292 294 "last_changeset": {
293 295 "author": "User <user@example.com>",
294 296 "branch": "default",
295 297 "date": "timestamp",
296 298 "message": "last commit message",
297 299 "parents": [
298 300 {
299 301 "raw_id": "commit-id"
300 302 }
301 303 ],
302 304 "raw_id": "commit-id",
303 305 "revision": <revision number>,
304 306 "short_id": "short id"
305 307 },
306 308 "lock_reason": null,
307 309 "locked_by": null,
308 310 "locked_date": null,
309 311 "owner": "owner-name",
310 312 "permissions": [
311 313 {
312 314 "name": "super-admin-name",
313 315 "origin": "super-admin",
314 316 "permission": "repository.admin",
315 317 "type": "user"
316 318 },
317 319 {
318 320 "name": "owner-name",
319 321 "origin": "owner",
320 322 "permission": "repository.admin",
321 323 "type": "user"
322 324 },
323 325 {
324 326 "name": "user-group-name",
325 327 "origin": "permission",
326 328 "permission": "repository.write",
327 329 "type": "user_group"
328 330 }
329 331 ],
330 332 "private": true,
331 333 "repo_id": 676,
332 334 "repo_name": "user-group/repo-name",
333 335 "repo_type": "hg"
334 336 }
335 337 }
336 338
337 339
338 340 get_repo_changeset
339 341 ------------------
340 342
341 343 .. py:function:: get_repo_changeset(apiuser, repoid, revision, details=<Optional:'basic'>)
342 344
343 345 Returns information about a changeset.
344 346
345 347 Additionally parameters define the amount of details returned by
346 348 this function.
347 349
348 350 This command can only be run using an |authtoken| with admin rights,
349 351 or users with at least read rights to the |repo|.
350 352
351 353 :param apiuser: This is filled automatically from the |authtoken|.
352 354 :type apiuser: AuthUser
353 355 :param repoid: The repository name or repository id
354 356 :type repoid: str or int
355 357 :param revision: revision for which listing should be done
356 358 :type revision: str
357 359 :param details: details can be 'basic|extended|full' full gives diff
358 360 info details like the diff itself, and number of changed files etc.
359 361 :type details: Optional(str)
360 362
361 363
362 364 get_repo_changesets
363 365 -------------------
364 366
365 367 .. py:function:: get_repo_changesets(apiuser, repoid, start_rev, limit, details=<Optional:'basic'>)
366 368
367 369 Returns a set of commits limited by the number starting
368 370 from the `start_rev` option.
369 371
370 372 Additional parameters define the amount of details returned by this
371 373 function.
372 374
373 375 This command can only be run using an |authtoken| with admin rights,
374 376 or users with at least read rights to |repos|.
375 377
376 378 :param apiuser: This is filled automatically from the |authtoken|.
377 379 :type apiuser: AuthUser
378 380 :param repoid: The repository name or repository ID.
379 381 :type repoid: str or int
380 382 :param start_rev: The starting revision from where to get changesets.
381 383 :type start_rev: str
382 384 :param limit: Limit the number of commits to this amount
383 385 :type limit: str or int
384 386 :param details: Set the level of detail returned. Valid option are:
385 387 ``basic``, ``extended`` and ``full``.
386 388 :type details: Optional(str)
387 389
388 390 .. note::
389 391
390 392 Setting the parameter `details` to the value ``full`` is extensive
391 393 and returns details like the diff itself, and the number
392 394 of changed files.
393 395
394 396
395 397 get_repo_nodes
396 398 --------------
397 399
398 400 .. py:function:: get_repo_nodes(apiuser, repoid, revision, root_path, ret_type=<Optional:'all'>, details=<Optional:'basic'>, max_file_bytes=<Optional:None>)
399 401
400 402 Returns a list of nodes and children in a flat list for a given
401 403 path at given revision.
402 404
403 405 It's possible to specify ret_type to show only `files` or `dirs`.
404 406
405 407 This command can only be run using an |authtoken| with admin rights,
406 408 or users with at least read rights to |repos|.
407 409
408 410 :param apiuser: This is filled automatically from the |authtoken|.
409 411 :type apiuser: AuthUser
410 412 :param repoid: The repository name or repository ID.
411 413 :type repoid: str or int
412 414 :param revision: The revision for which listing should be done.
413 415 :type revision: str
414 416 :param root_path: The path from which to start displaying.
415 417 :type root_path: str
416 418 :param ret_type: Set the return type. Valid options are
417 419 ``all`` (default), ``files`` and ``dirs``.
418 420 :type ret_type: Optional(str)
419 421 :param details: Returns extended information about nodes, such as
420 422 md5, binary, and or content. The valid options are ``basic`` and
421 423 ``full``.
422 424 :type details: Optional(str)
423 425 :param max_file_bytes: Only return file content under this file size bytes
424 426 :type details: Optional(int)
425 427
426 428 Example output:
427 429
428 430 .. code-block:: bash
429 431
430 432 id : <id_given_in_input>
431 433 result: [
432 434 {
433 435 "name" : "<name>"
434 436 "type" : "<type>",
435 437 "binary": "<true|false>" (only in extended mode)
436 438 "md5" : "<md5 of file content>" (only in extended mode)
437 439 },
438 440 ...
439 441 ]
440 442 error: null
441 443
442 444
443 445 get_repo_refs
444 446 -------------
445 447
446 448 .. py:function:: get_repo_refs(apiuser, repoid)
447 449
448 450 Returns a dictionary of current references. It returns
449 451 bookmarks, branches, closed_branches, and tags for given repository
450 452
451 453 It's possible to specify ret_type to show only `files` or `dirs`.
452 454
453 455 This command can only be run using an |authtoken| with admin rights,
454 456 or users with at least read rights to |repos|.
455 457
456 458 :param apiuser: This is filled automatically from the |authtoken|.
457 459 :type apiuser: AuthUser
458 460 :param repoid: The repository name or repository ID.
459 461 :type repoid: str or int
460 462
461 463 Example output:
462 464
463 465 .. code-block:: bash
464 466
465 467 id : <id_given_in_input>
466 468 "result": {
467 469 "bookmarks": {
468 470 "dev": "5611d30200f4040ba2ab4f3d64e5b06408a02188",
469 471 "master": "367f590445081d8ec8c2ea0456e73ae1f1c3d6cf"
470 472 },
471 473 "branches": {
472 474 "default": "5611d30200f4040ba2ab4f3d64e5b06408a02188",
473 475 "stable": "367f590445081d8ec8c2ea0456e73ae1f1c3d6cf"
474 476 },
475 477 "branches_closed": {},
476 478 "tags": {
477 479 "tip": "5611d30200f4040ba2ab4f3d64e5b06408a02188",
478 480 "v4.4.0": "1232313f9e6adac5ce5399c2a891dc1e72b79022",
479 481 "v4.4.1": "cbb9f1d329ae5768379cdec55a62ebdd546c4e27",
480 482 "v4.4.2": "24ffe44a27fcd1c5b6936144e176b9f6dd2f3a17",
481 483 }
482 484 }
483 485 error: null
484 486
485 487
486 488 get_repo_settings
487 489 -----------------
488 490
489 491 .. py:function:: get_repo_settings(apiuser, repoid, key=<Optional:None>)
490 492
491 493 Returns all settings for a repository. If key is given it only returns the
492 494 setting identified by the key or null.
493 495
494 496 :param apiuser: This is filled automatically from the |authtoken|.
495 497 :type apiuser: AuthUser
496 498 :param repoid: The repository name or repository id.
497 499 :type repoid: str or int
498 500 :param key: Key of the setting to return.
499 501 :type: key: Optional(str)
500 502
501 503 Example output:
502 504
503 505 .. code-block:: bash
504 506
505 507 {
506 508 "error": null,
507 509 "id": 237,
508 510 "result": {
509 511 "extensions_largefiles": true,
510 512 "extensions_evolve": true,
511 513 "hooks_changegroup_push_logger": true,
512 514 "hooks_changegroup_repo_size": false,
513 515 "hooks_outgoing_pull_logger": true,
514 516 "phases_publish": "True",
515 517 "rhodecode_hg_use_rebase_for_merging": true,
516 518 "rhodecode_pr_merge_enabled": true,
517 519 "rhodecode_use_outdated_comments": true
518 520 }
519 521 }
520 522
521 523
522 524 get_repos
523 525 ---------
524 526
525 527 .. py:function:: get_repos(apiuser, root=<Optional:None>, traverse=<Optional:True>)
526 528
527 529 Lists all existing repositories.
528 530
529 531 This command can only be run using an |authtoken| with admin rights,
530 532 or users with at least read rights to |repos|.
531 533
532 534 :param apiuser: This is filled automatically from the |authtoken|.
533 535 :type apiuser: AuthUser
534 536 :param root: specify root repository group to fetch repositories.
535 537 filters the returned repositories to be members of given root group.
536 538 :type root: Optional(None)
537 539 :param traverse: traverse given root into subrepositories. With this flag
538 540 set to False, it will only return top-level repositories from `root`.
539 541 if root is empty it will return just top-level repositories.
540 542 :type traverse: Optional(True)
541 543
542 544
543 545 Example output:
544 546
545 547 .. code-block:: bash
546 548
547 549 id : <id_given_in_input>
548 550 result: [
549 551 {
550 552 "repo_id" : "<repo_id>",
551 553 "repo_name" : "<reponame>"
552 554 "repo_type" : "<repo_type>",
553 555 "clone_uri" : "<clone_uri>",
554 556 "private": : "<bool>",
555 557 "created_on" : "<datetimecreated>",
556 558 "description" : "<description>",
557 559 "landing_rev": "<landing_rev>",
558 560 "owner": "<repo_owner>",
559 561 "fork_of": "<name_of_fork_parent>",
560 562 "enable_downloads": "<bool>",
561 563 "enable_locking": "<bool>",
562 564 "enable_statistics": "<bool>",
563 565 },
564 566 ...
565 567 ]
566 568 error: null
567 569
568 570
569 571 grant_user_group_permission
570 572 ---------------------------
571 573
572 574 .. py:function:: grant_user_group_permission(apiuser, repoid, usergroupid, perm)
573 575
574 576 Grant permission for a user group on the specified repository,
575 577 or update existing permissions.
576 578
577 579 This command can only be run using an |authtoken| with admin
578 580 permissions on the |repo|.
579 581
580 582 :param apiuser: This is filled automatically from the |authtoken|.
581 583 :type apiuser: AuthUser
582 584 :param repoid: Set the repository name or repository ID.
583 585 :type repoid: str or int
584 586 :param usergroupid: Specify the ID of the user group.
585 587 :type usergroupid: str or int
586 588 :param perm: Set the user group permissions using the following
587 589 format: (repository.(none|read|write|admin))
588 590 :type perm: str
589 591
590 592 Example output:
591 593
592 594 .. code-block:: bash
593 595
594 596 id : <id_given_in_input>
595 597 result : {
596 598 "msg" : "Granted perm: `<perm>` for group: `<usersgroupname>` in repo: `<reponame>`",
597 599 "success": true
598 600
599 601 }
600 602 error : null
601 603
602 604 Example error output:
603 605
604 606 .. code-block:: bash
605 607
606 608 id : <id_given_in_input>
607 609 result : null
608 610 error : {
609 611 "failed to edit permission for user group: `<usergroup>` in repo `<repo>`'
610 612 }
611 613
612 614
613 615 grant_user_permission
614 616 ---------------------
615 617
616 618 .. py:function:: grant_user_permission(apiuser, repoid, userid, perm)
617 619
618 620 Grant permissions for the specified user on the given repository,
619 621 or update existing permissions if found.
620 622
621 623 This command can only be run using an |authtoken| with admin
622 624 permissions on the |repo|.
623 625
624 626 :param apiuser: This is filled automatically from the |authtoken|.
625 627 :type apiuser: AuthUser
626 628 :param repoid: Set the repository name or repository ID.
627 629 :type repoid: str or int
628 630 :param userid: Set the user name.
629 631 :type userid: str
630 632 :param perm: Set the user permissions, using the following format
631 633 ``(repository.(none|read|write|admin))``
632 634 :type perm: str
633 635
634 636 Example output:
635 637
636 638 .. code-block:: bash
637 639
638 640 id : <id_given_in_input>
639 641 result: {
640 642 "msg" : "Granted perm: `<perm>` for user: `<username>` in repo: `<reponame>`",
641 643 "success": true
642 644 }
643 645 error: null
644 646
645 647
646 648 invalidate_cache
647 649 ----------------
648 650
649 651 .. py:function:: invalidate_cache(apiuser, repoid, delete_keys=<Optional:False>)
650 652
651 653 Invalidates the cache for the specified repository.
652 654
653 655 This command can only be run using an |authtoken| with admin rights to
654 656 the specified repository.
655 657
656 658 This command takes the following options:
657 659
658 660 :param apiuser: This is filled automatically from |authtoken|.
659 661 :type apiuser: AuthUser
660 662 :param repoid: Sets the repository name or repository ID.
661 663 :type repoid: str or int
662 664 :param delete_keys: This deletes the invalidated keys instead of
663 665 just flagging them.
664 666 :type delete_keys: Optional(``True`` | ``False``)
665 667
666 668 Example output:
667 669
668 670 .. code-block:: bash
669 671
670 672 id : <id_given_in_input>
671 673 result : {
672 674 'msg': Cache for repository `<repository name>` was invalidated,
673 675 'repository': <repository name>
674 676 }
675 677 error : null
676 678
677 679 Example error output:
678 680
679 681 .. code-block:: bash
680 682
681 683 id : <id_given_in_input>
682 684 result : null
683 685 error : {
684 686 'Error occurred during cache invalidation action'
685 687 }
686 688
687 689
688 690 lock
689 691 ----
690 692
691 693 .. py:function:: lock(apiuser, repoid, locked=<Optional:None>, userid=<Optional:<OptionalAttr:apiuser>>)
692 694
693 695 Sets the lock state of the specified |repo| by the given user.
694 696 From more information, see :ref:`repo-locking`.
695 697
696 698 * If the ``userid`` option is not set, the repository is locked to the
697 699 user who called the method.
698 700 * If the ``locked`` parameter is not set, the current lock state of the
699 701 repository is displayed.
700 702
701 703 This command can only be run using an |authtoken| with admin rights to
702 704 the specified repository.
703 705
704 706 This command takes the following options:
705 707
706 708 :param apiuser: This is filled automatically from the |authtoken|.
707 709 :type apiuser: AuthUser
708 710 :param repoid: Sets the repository name or repository ID.
709 711 :type repoid: str or int
710 712 :param locked: Sets the lock state.
711 713 :type locked: Optional(``True`` | ``False``)
712 714 :param userid: Set the repository lock to this user.
713 715 :type userid: Optional(str or int)
714 716
715 717 Example error output:
716 718
717 719 .. code-block:: bash
718 720
719 721 id : <id_given_in_input>
720 722 result : {
721 723 'repo': '<reponame>',
722 724 'locked': <bool: lock state>,
723 725 'locked_since': <int: lock timestamp>,
724 726 'locked_by': <username of person who made the lock>,
725 727 'lock_reason': <str: reason for locking>,
726 728 'lock_state_changed': <bool: True if lock state has been changed in this request>,
727 729 'msg': 'Repo `<reponame>` locked by `<username>` on <timestamp>.'
728 730 or
729 731 'msg': 'Repo `<repository name>` not locked.'
730 732 or
731 733 'msg': 'User `<user name>` set lock state for repo `<repository name>` to `<new lock state>`'
732 734 }
733 735 error : null
734 736
735 737 Example error output:
736 738
737 739 .. code-block:: bash
738 740
739 741 id : <id_given_in_input>
740 742 result : null
741 743 error : {
742 744 'Error occurred locking repository `<reponame>`'
743 745 }
744 746
745 747
746 748 maintenance
747 749 -----------
748 750
749 751 .. py:function:: maintenance(apiuser, repoid)
750 752
751 753 Triggers a maintenance on the given repository.
752 754
753 755 This command can only be run using an |authtoken| with admin
754 756 rights to the specified repository. For more information,
755 757 see :ref:`config-token-ref`.
756 758
757 759 This command takes the following options:
758 760
759 761 :param apiuser: This is filled automatically from the |authtoken|.
760 762 :type apiuser: AuthUser
761 763 :param repoid: The repository name or repository ID.
762 764 :type repoid: str or int
763 765
764 766 Example output:
765 767
766 768 .. code-block:: bash
767 769
768 770 id : <id_given_in_input>
769 771 result : {
770 772 "msg": "executed maintenance command",
771 773 "executed_actions": [
772 774 <action_message>, <action_message2>...
773 775 ],
774 776 "repository": "<repository name>"
775 777 }
776 778 error : null
777 779
778 780 Example error output:
779 781
780 782 .. code-block:: bash
781 783
782 784 id : <id_given_in_input>
783 785 result : null
784 786 error : {
785 787 "Unable to execute maintenance on `<reponame>`"
786 788 }
787 789
788 790
789 791 pull
790 792 ----
791 793
792 .. py:function:: pull(apiuser, repoid)
794 .. py:function:: pull(apiuser, repoid, remote_uri=<Optional:None>)
793 795
794 796 Triggers a pull on the given repository from a remote location. You
795 797 can use this to keep remote repositories up-to-date.
796 798
797 799 This command can only be run using an |authtoken| with admin
798 800 rights to the specified repository. For more information,
799 801 see :ref:`config-token-ref`.
800 802
801 803 This command takes the following options:
802 804
803 805 :param apiuser: This is filled automatically from the |authtoken|.
804 806 :type apiuser: AuthUser
805 807 :param repoid: The repository name or repository ID.
806 808 :type repoid: str or int
809 :param remote_uri: Optional remote URI to pass in for pull
810 :type remote_uri: str
807 811
808 812 Example output:
809 813
810 814 .. code-block:: bash
811 815
812 816 id : <id_given_in_input>
813 817 result : {
814 "msg": "Pulled from `<repository name>`"
818 "msg": "Pulled from url `<remote_url>` on repo `<repository name>`"
815 819 "repository": "<repository name>"
816 820 }
817 821 error : null
818 822
819 823 Example error output:
820 824
821 825 .. code-block:: bash
822 826
823 827 id : <id_given_in_input>
824 828 result : null
825 829 error : {
826 "Unable to pull changes from `<reponame>`"
830 "Unable to push changes from `<remote_url>`"
827 831 }
828 832
829 833
830 834 remove_field_from_repo
831 835 ----------------------
832 836
833 837 .. py:function:: remove_field_from_repo(apiuser, repoid, key)
834 838
835 839 Removes an extra field from a repository.
836 840
837 841 This command can only be run using an |authtoken| with at least
838 842 write permissions to the |repo|.
839 843
840 844 :param apiuser: This is filled automatically from the |authtoken|.
841 845 :type apiuser: AuthUser
842 846 :param repoid: Set the repository name or repository ID.
843 847 :type repoid: str or int
844 848 :param key: Set the unique field key for this repository.
845 849 :type key: str
846 850
847 851
848 852 revoke_user_group_permission
849 853 ----------------------------
850 854
851 855 .. py:function:: revoke_user_group_permission(apiuser, repoid, usergroupid)
852 856
853 857 Revoke the permissions of a user group on a given repository.
854 858
855 859 This command can only be run using an |authtoken| with admin
856 860 permissions on the |repo|.
857 861
858 862 :param apiuser: This is filled automatically from the |authtoken|.
859 863 :type apiuser: AuthUser
860 864 :param repoid: Set the repository name or repository ID.
861 865 :type repoid: str or int
862 866 :param usergroupid: Specify the user group ID.
863 867 :type usergroupid: str or int
864 868
865 869 Example output:
866 870
867 871 .. code-block:: bash
868 872
869 873 id : <id_given_in_input>
870 874 result: {
871 875 "msg" : "Revoked perm for group: `<usersgroupname>` in repo: `<reponame>`",
872 876 "success": true
873 877 }
874 878 error: null
875 879
876 880
877 881 revoke_user_permission
878 882 ----------------------
879 883
880 884 .. py:function:: revoke_user_permission(apiuser, repoid, userid)
881 885
882 886 Revoke permission for a user on the specified repository.
883 887
884 888 This command can only be run using an |authtoken| with admin
885 889 permissions on the |repo|.
886 890
887 891 :param apiuser: This is filled automatically from the |authtoken|.
888 892 :type apiuser: AuthUser
889 893 :param repoid: Set the repository name or repository ID.
890 894 :type repoid: str or int
891 895 :param userid: Set the user name of revoked user.
892 896 :type userid: str or int
893 897
894 898 Example error output:
895 899
896 900 .. code-block:: bash
897 901
898 902 id : <id_given_in_input>
899 903 result: {
900 904 "msg" : "Revoked perm for user: `<username>` in repo: `<reponame>`",
901 905 "success": true
902 906 }
903 907 error: null
904 908
905 909
906 910 set_repo_settings
907 911 -----------------
908 912
909 913 .. py:function:: set_repo_settings(apiuser, repoid, settings)
910 914
911 915 Update repository settings. Returns true on success.
912 916
913 917 :param apiuser: This is filled automatically from the |authtoken|.
914 918 :type apiuser: AuthUser
915 919 :param repoid: The repository name or repository id.
916 920 :type repoid: str or int
917 921 :param settings: The new settings for the repository.
918 922 :type: settings: dict
919 923
920 924 Example output:
921 925
922 926 .. code-block:: bash
923 927
924 928 {
925 929 "error": null,
926 930 "id": 237,
927 931 "result": true
928 932 }
929 933
930 934
931 935 strip
932 936 -----
933 937
934 938 .. py:function:: strip(apiuser, repoid, revision, branch)
935 939
936 940 Strips the given revision from the specified repository.
937 941
938 942 * This will remove the revision and all of its decendants.
939 943
940 944 This command can only be run using an |authtoken| with admin rights to
941 945 the specified repository.
942 946
943 947 This command takes the following options:
944 948
945 949 :param apiuser: This is filled automatically from the |authtoken|.
946 950 :type apiuser: AuthUser
947 951 :param repoid: The repository name or repository ID.
948 952 :type repoid: str or int
949 953 :param revision: The revision you wish to strip.
950 954 :type revision: str
951 955 :param branch: The branch from which to strip the revision.
952 956 :type branch: str
953 957
954 958 Example output:
955 959
956 960 .. code-block:: bash
957 961
958 962 id : <id_given_in_input>
959 963 result : {
960 964 "msg": "'Stripped commit <commit_hash> from repo `<repository name>`'"
961 965 "repository": "<repository name>"
962 966 }
963 967 error : null
964 968
965 969 Example error output:
966 970
967 971 .. code-block:: bash
968 972
969 973 id : <id_given_in_input>
970 974 result : null
971 975 error : {
972 976 "Unable to strip commit <commit_hash> from repo `<repository name>`"
973 977 }
974 978
975 979
976 980 update_repo
977 981 -----------
978 982
979 .. py:function:: update_repo(apiuser, repoid, repo_name=<Optional:None>, owner=<Optional:<OptionalAttr:apiuser>>, description=<Optional:''>, private=<Optional:False>, clone_uri=<Optional:None>, landing_rev=<Optional:'rev:tip'>, fork_of=<Optional:None>, enable_statistics=<Optional:False>, enable_locking=<Optional:False>, enable_downloads=<Optional:False>, fields=<Optional:''>)
983 .. py:function:: update_repo(apiuser, repoid, repo_name=<Optional:None>, owner=<Optional:<OptionalAttr:apiuser>>, description=<Optional:''>, private=<Optional:False>, clone_uri=<Optional:None>, push_uri=<Optional:None>, landing_rev=<Optional:'rev:tip'>, fork_of=<Optional:None>, enable_statistics=<Optional:False>, enable_locking=<Optional:False>, enable_downloads=<Optional:False>, fields=<Optional:''>)
980 984
981 985 Updates a repository with the given information.
982 986
983 987 This command can only be run using an |authtoken| with at least
984 988 admin permissions to the |repo|.
985 989
986 990 * If the repository name contains "/", repository will be updated
987 991 accordingly with a repository group or nested repository groups
988 992
989 993 For example repoid=repo-test name="foo/bar/repo-test" will update |repo|
990 994 called "repo-test" and place it inside group "foo/bar".
991 995 You have to have permissions to access and write to the last repository
992 996 group ("bar" in this example)
993 997
994 998 :param apiuser: This is filled automatically from the |authtoken|.
995 999 :type apiuser: AuthUser
996 1000 :param repoid: repository name or repository ID.
997 1001 :type repoid: str or int
998 1002 :param repo_name: Update the |repo| name, including the
999 1003 repository group it's in.
1000 1004 :type repo_name: str
1001 1005 :param owner: Set the |repo| owner.
1002 1006 :type owner: str
1003 1007 :param fork_of: Set the |repo| as fork of another |repo|.
1004 1008 :type fork_of: str
1005 1009 :param description: Update the |repo| description.
1006 1010 :type description: str
1007 1011 :param private: Set the |repo| as private. (True | False)
1008 1012 :type private: bool
1009 1013 :param clone_uri: Update the |repo| clone URI.
1010 1014 :type clone_uri: str
1011 1015 :param landing_rev: Set the |repo| landing revision. Default is ``rev:tip``.
1012 1016 :type landing_rev: str
1013 1017 :param enable_statistics: Enable statistics on the |repo|, (True | False).
1014 1018 :type enable_statistics: bool
1015 1019 :param enable_locking: Enable |repo| locking.
1016 1020 :type enable_locking: bool
1017 1021 :param enable_downloads: Enable downloads from the |repo|, (True | False).
1018 1022 :type enable_downloads: bool
1019 1023 :param fields: Add extra fields to the |repo|. Use the following
1020 1024 example format: ``field_key=field_val,field_key2=fieldval2``.
1021 1025 Escape ', ' with \,
1022 1026 :type fields: str
1023 1027
1024 1028
@@ -1,412 +1,418 b''
1 1 .. _user-group-methods-ref:
2 2
3 3 user_group methods
4 4 ==================
5 5
6 6 add_user_to_user_group
7 7 ----------------------
8 8
9 9 .. py:function:: add_user_to_user_group(apiuser, usergroupid, userid)
10 10
11 11 Adds a user to a `user group`. If the user already exists in the group
12 12 this command will return false.
13 13
14 14 This command can only be run using an |authtoken| with admin rights to
15 15 the specified user group.
16 16
17 17 This command takes the following options:
18 18
19 19 :param apiuser: This is filled automatically from the |authtoken|.
20 20 :type apiuser: AuthUser
21 21 :param usergroupid: Set the name of the `user group` to which a
22 22 user will be added.
23 23 :type usergroupid: int
24 24 :param userid: Set the `user_id` of the user to add to the group.
25 25 :type userid: int
26 26
27 27 Example output:
28 28
29 29 .. code-block:: bash
30 30
31 31 id : <id_given_in_input>
32 32 result : {
33 33 "success": True|False # depends on if member is in group
34 34 "msg": "added member `<username>` to user group `<groupname>` |
35 35 User is already in that group"
36 36
37 37 }
38 38 error : null
39 39
40 40 Example error output:
41 41
42 42 .. code-block:: bash
43 43
44 44 id : <id_given_in_input>
45 45 result : null
46 46 error : {
47 47 "failed to add member to user group `<user_group_name>`"
48 48 }
49 49
50 50
51 51 create_user_group
52 52 -----------------
53 53
54 .. py:function:: create_user_group(apiuser, group_name, description=<Optional:''>, owner=<Optional:<OptionalAttr:apiuser>>, active=<Optional:True>)
54 .. py:function:: create_user_group(apiuser, group_name, description=<Optional:''>, owner=<Optional:<OptionalAttr:apiuser>>, active=<Optional:True>, sync=<Optional:None>)
55 55
56 56 Creates a new user group.
57 57
58 58 This command can only be run using an |authtoken| with admin rights to
59 59 the specified repository.
60 60
61 61 This command takes the following options:
62 62
63 63 :param apiuser: This is filled automatically from the |authtoken|.
64 64 :type apiuser: AuthUser
65 65 :param group_name: Set the name of the new user group.
66 66 :type group_name: str
67 67 :param description: Give a description of the new user group.
68 68 :type description: str
69 69 :param owner: Set the owner of the new user group.
70 70 If not set, the owner is the |authtoken| user.
71 71 :type owner: Optional(str or int)
72 72 :param active: Set this group as active.
73 73 :type active: Optional(``True`` | ``False``)
74 :param sync: Set enabled or disabled the automatically sync from
75 external authentication types like ldap.
76 :type sync: Optional(``True`` | ``False``)
74 77
75 78 Example output:
76 79
77 80 .. code-block:: bash
78 81
79 82 id : <id_given_in_input>
80 83 result: {
81 84 "msg": "created new user group `<groupname>`",
82 85 "user_group": <user_group_object>
83 86 }
84 87 error: null
85 88
86 89 Example error output:
87 90
88 91 .. code-block:: bash
89 92
90 93 id : <id_given_in_input>
91 94 result : null
92 95 error : {
93 96 "user group `<group name>` already exist"
94 97 or
95 98 "failed to create group `<group name>`"
96 99 }
97 100
98 101
99 102 delete_user_group
100 103 -----------------
101 104
102 105 .. py:function:: delete_user_group(apiuser, usergroupid)
103 106
104 107 Deletes the specified `user group`.
105 108
106 109 This command can only be run using an |authtoken| with admin rights to
107 110 the specified repository.
108 111
109 112 This command takes the following options:
110 113
111 114 :param apiuser: filled automatically from apikey
112 115 :type apiuser: AuthUser
113 116 :param usergroupid:
114 117 :type usergroupid: int
115 118
116 119 Example output:
117 120
118 121 .. code-block:: bash
119 122
120 123 id : <id_given_in_input>
121 124 result : {
122 125 "msg": "deleted user group ID:<user_group_id> <user_group_name>"
123 126 }
124 127 error : null
125 128
126 129 Example error output:
127 130
128 131 .. code-block:: bash
129 132
130 133 id : <id_given_in_input>
131 134 result : null
132 135 error : {
133 136 "failed to delete user group ID:<user_group_id> <user_group_name>"
134 137 or
135 138 "RepoGroup assigned to <repo_groups_list>"
136 139 }
137 140
138 141
139 142 get_user_group
140 143 --------------
141 144
142 145 .. py:function:: get_user_group(apiuser, usergroupid)
143 146
144 147 Returns the data of an existing user group.
145 148
146 149 This command can only be run using an |authtoken| with admin rights to
147 150 the specified repository.
148 151
149 152 :param apiuser: This is filled automatically from the |authtoken|.
150 153 :type apiuser: AuthUser
151 154 :param usergroupid: Set the user group from which to return data.
152 155 :type usergroupid: str or int
153 156
154 157 Example error output:
155 158
156 159 .. code-block:: bash
157 160
158 161 {
159 162 "error": null,
160 163 "id": <id>,
161 164 "result": {
162 165 "active": true,
163 166 "group_description": "group description",
164 167 "group_name": "group name",
165 168 "permissions": [
166 169 {
167 170 "name": "owner-name",
168 171 "origin": "owner",
169 172 "permission": "usergroup.admin",
170 173 "type": "user"
171 174 },
172 175 {
173 176 {
174 177 "name": "user name",
175 178 "origin": "permission",
176 179 "permission": "usergroup.admin",
177 180 "type": "user"
178 181 },
179 182 {
180 183 "name": "user group name",
181 184 "origin": "permission",
182 185 "permission": "usergroup.write",
183 186 "type": "user_group"
184 187 }
185 188 ],
186 189 "permissions_summary": {
187 190 "repositories": {
188 191 "aa-root-level-repo-1": "repository.admin"
189 192 },
190 193 "repositories_groups": {}
191 194 },
192 195 "owner": "owner name",
193 196 "users": [],
194 197 "users_group_id": 2
195 198 }
196 199 }
197 200
198 201
199 202 get_user_groups
200 203 ---------------
201 204
202 205 .. py:function:: get_user_groups(apiuser)
203 206
204 207 Lists all the existing user groups within RhodeCode.
205 208
206 209 This command can only be run using an |authtoken| with admin rights to
207 210 the specified repository.
208 211
209 212 This command takes the following options:
210 213
211 214 :param apiuser: This is filled automatically from the |authtoken|.
212 215 :type apiuser: AuthUser
213 216
214 217 Example error output:
215 218
216 219 .. code-block:: bash
217 220
218 221 id : <id_given_in_input>
219 222 result : [<user_group_obj>,...]
220 223 error : null
221 224
222 225
223 226 grant_user_group_permission_to_user_group
224 227 -----------------------------------------
225 228
226 229 .. py:function:: grant_user_group_permission_to_user_group(apiuser, usergroupid, sourceusergroupid, perm)
227 230
228 231 Give one user group permissions to another user group.
229 232
230 233 :param apiuser: This is filled automatically from the |authtoken|.
231 234 :type apiuser: AuthUser
232 235 :param usergroupid: Set the user group on which to edit permissions.
233 236 :type usergroupid: str or int
234 237 :param sourceusergroupid: Set the source user group to which
235 238 access/permissions will be granted.
236 239 :type sourceusergroupid: str or int
237 240 :param perm: (usergroup.(none|read|write|admin))
238 241 :type perm: str
239 242
240 243 Example output:
241 244
242 245 .. code-block:: bash
243 246
244 247 id : <id_given_in_input>
245 248 result : {
246 249 "msg": "Granted perm: `<perm_name>` for user group: `<source_user_group_name>` in user group: `<user_group_name>`",
247 250 "success": true
248 251 }
249 252 error : null
250 253
251 254
252 255 grant_user_permission_to_user_group
253 256 -----------------------------------
254 257
255 258 .. py:function:: grant_user_permission_to_user_group(apiuser, usergroupid, userid, perm)
256 259
257 260 Set permissions for a user in a user group.
258 261
259 262 :param apiuser: This is filled automatically from the |authtoken|.
260 263 :type apiuser: AuthUser
261 264 :param usergroupid: Set the user group to edit permissions on.
262 265 :type usergroupid: str or int
263 266 :param userid: Set the user from whom you wish to set permissions.
264 267 :type userid: str
265 268 :param perm: (usergroup.(none|read|write|admin))
266 269 :type perm: str
267 270
268 271 Example output:
269 272
270 273 .. code-block:: bash
271 274
272 275 id : <id_given_in_input>
273 276 result : {
274 277 "msg": "Granted perm: `<perm_name>` for user: `<username>` in user group: `<user_group_name>`",
275 278 "success": true
276 279 }
277 280 error : null
278 281
279 282
280 283 remove_user_from_user_group
281 284 ---------------------------
282 285
283 286 .. py:function:: remove_user_from_user_group(apiuser, usergroupid, userid)
284 287
285 288 Removes a user from a user group.
286 289
287 290 * If the specified user is not in the group, this command will return
288 291 `false`.
289 292
290 293 This command can only be run using an |authtoken| with admin rights to
291 294 the specified user group.
292 295
293 296 :param apiuser: This is filled automatically from the |authtoken|.
294 297 :type apiuser: AuthUser
295 298 :param usergroupid: Sets the user group name.
296 299 :type usergroupid: str or int
297 300 :param userid: The user you wish to remove from |RCE|.
298 301 :type userid: str or int
299 302
300 303 Example output:
301 304
302 305 .. code-block:: bash
303 306
304 307 id : <id_given_in_input>
305 308 result: {
306 309 "success": True|False, # depends on if member is in group
307 310 "msg": "removed member <username> from user group <groupname> |
308 311 User wasn't in group"
309 312 }
310 313 error: null
311 314
312 315
313 316 revoke_user_group_permission_from_user_group
314 317 --------------------------------------------
315 318
316 319 .. py:function:: revoke_user_group_permission_from_user_group(apiuser, usergroupid, sourceusergroupid)
317 320
318 321 Revoke the permissions that one user group has to another.
319 322
320 323 :param apiuser: This is filled automatically from the |authtoken|.
321 324 :type apiuser: AuthUser
322 325 :param usergroupid: Set the user group on which to edit permissions.
323 326 :type usergroupid: str or int
324 327 :param sourceusergroupid: Set the user group from which permissions
325 328 are revoked.
326 329 :type sourceusergroupid: str or int
327 330
328 331 Example output:
329 332
330 333 .. code-block:: bash
331 334
332 335 id : <id_given_in_input>
333 336 result : {
334 337 "msg": "Revoked perm for user group: `<user_group_name>` in user group: `<target_user_group_name>`",
335 338 "success": true
336 339 }
337 340 error : null
338 341
339 342
340 343 revoke_user_permission_from_user_group
341 344 --------------------------------------
342 345
343 346 .. py:function:: revoke_user_permission_from_user_group(apiuser, usergroupid, userid)
344 347
345 348 Revoke a users permissions in a user group.
346 349
347 350 :param apiuser: This is filled automatically from the |authtoken|.
348 351 :type apiuser: AuthUser
349 352 :param usergroupid: Set the user group from which to revoke the user
350 353 permissions.
351 354 :type: usergroupid: str or int
352 355 :param userid: Set the userid of the user whose permissions will be
353 356 revoked.
354 357 :type userid: str
355 358
356 359 Example output:
357 360
358 361 .. code-block:: bash
359 362
360 363 id : <id_given_in_input>
361 364 result : {
362 365 "msg": "Revoked perm for user: `<username>` in user group: `<user_group_name>`",
363 366 "success": true
364 367 }
365 368 error : null
366 369
367 370
368 371 update_user_group
369 372 -----------------
370 373
371 .. py:function:: update_user_group(apiuser, usergroupid, group_name=<Optional:''>, description=<Optional:''>, owner=<Optional:None>, active=<Optional:True>)
374 .. py:function:: update_user_group(apiuser, usergroupid, group_name=<Optional:''>, description=<Optional:''>, owner=<Optional:None>, active=<Optional:True>, sync=<Optional:None>)
372 375
373 376 Updates the specified `user group` with the details provided.
374 377
375 378 This command can only be run using an |authtoken| with admin rights to
376 379 the specified repository.
377 380
378 381 :param apiuser: This is filled automatically from the |authtoken|.
379 382 :type apiuser: AuthUser
380 383 :param usergroupid: Set the id of the `user group` to update.
381 384 :type usergroupid: str or int
382 385 :param group_name: Set the new name the `user group`
383 386 :type group_name: str
384 387 :param description: Give a description for the `user group`
385 388 :type description: str
386 389 :param owner: Set the owner of the `user group`.
387 390 :type owner: Optional(str or int)
388 391 :param active: Set the group as active.
389 392 :type active: Optional(``True`` | ``False``)
393 :param sync: Set enabled or disabled the automatically sync from
394 external authentication types like ldap.
395 :type sync: Optional(``True`` | ``False``)
390 396
391 397 Example output:
392 398
393 399 .. code-block:: bash
394 400
395 401 id : <id_given_in_input>
396 402 result : {
397 403 "msg": 'updated user group ID:<user group id> <user group name>',
398 404 "user_group": <user_group_object>
399 405 }
400 406 error : null
401 407
402 408 Example error output:
403 409
404 410 .. code-block:: bash
405 411
406 412 id : <id_given_in_input>
407 413 result : null
408 414 error : {
409 415 "failed to update user group `<user group name>`"
410 416 }
411 417
412 418
General Comments 0
You need to be logged in to leave comments. Login now