Skip to content

Commit a260cd3

Browse files
committed
Added updateUser() and javadoc cleanup.
1 parent cabccb4 commit a260cd3

File tree

1 file changed

+79
-47
lines changed

1 file changed

+79
-47
lines changed

src/main/java/org/gitlab4j/api/UserApi.java

+79-47
Original file line numberDiff line numberDiff line change
@@ -310,41 +310,40 @@ public Pager<User> findUsers(String emailOrUsername, int itemsPerPage) throws Gi
310310
}
311311

312312
/**
313-
* Creates a new user. Note only administrators can create new users.
313+
* <p>Creates a new user. Note only administrators can create new users.
314314
* Either password or reset_password should be specified (reset_password takes priority).
315315
*
316316
* If both the User object's projectsLimit and the parameter projectsLimit is specified
317-
* the parameter will take precedence.
317+
* the parameter will take precedence.</p>
318318
*
319-
* POST /users
319+
* <pre>POST /users</pre>
320320
*
321-
* email (required) - Email
322-
* password (optional) - Password
323-
* reset_password (optional) - Send user password reset link - true or false(default)
321+
* The following properties of the provided User instance can be set during creation:<pre><code> email (required) - Email
324322
* username (required) - Username
325323
* name (required) - Name
326324
* skype (optional) - Skype ID
327325
* linkedin (optional) - LinkedIn
328326
* twitter (optional) - Twitter account
329-
* website_url (optional) - Website URL
327+
* websiteUrl (optional) - Website URL
330328
* organization (optional) - Organization name
331-
* projects_limit (optional) - Number of projects user can create
332-
* extern_uid (optional) - External UID
329+
* projectsLimit (optional) - Number of projects user can create
330+
* externUid (optional) - External UID
333331
* provider (optional) - External provider name
334332
* bio (optional) - User's biography
335333
* location (optional) - User's location
336334
* admin (optional) - User is admin - true or false (default)
337-
* can_create_group (optional) - User can create groups - true or false
338-
* skip_confirmation (optional) - Skip confirmation - true or false (default)
335+
* canCreateGroup (optional) - User can create groups - true or false
336+
* skipConfirmation (optional) - Skip confirmation - true or false (default)
339337
* external (optional) - Flags the user as external - true or false(default)
340-
* avatar (optional) - Image file for user's avatar
341-
* shared_runners_minutes_limit (optional) - Pipeline minutes quota for this user
338+
* sharedRunnersMinutesLimit (optional) - Pipeline minutes quota for this user
339+
*</code></pre>
342340
*
343341
* @param user the User instance with the user info to create
344342
* @param password the password for the new user
345343
* @param projectsLimit the maximum number of project
346344
* @return created User instance
347345
* @throws GitLabApiException if any exception occurs
346+
* @deprecated Will be removed in version 5.0, replaced by {@link #createUser(User, CharSequence, boolean)}
348347
*/
349348
public User createUser(User user, CharSequence password, Integer projectsLimit) throws GitLabApiException {
350349
Form formData = userToForm(user, projectsLimit, password, null, true);
@@ -353,34 +352,30 @@ public User createUser(User user, CharSequence password, Integer projectsLimit)
353352
}
354353

355354
/**
356-
* Creates a new user. Note only administrators can create new users.
357-
* Either password or reset_password should be specified (reset_password takes priority).
358-
*
359-
* Creates a user with reset_password being <code>true</code>
355+
* <p>Creates a new user. Note only administrators can create new users.
356+
* Either password or resetPassword should be specified (resetPassword takes priority).</p>
360357
*
361-
* POST /users
358+
* <pre>POST /users</pre>
362359
*
363-
* email (required) - Email
364-
* password (optional) - Password
365-
* reset_password (optional) - Send user password reset link - true or false(default)
360+
* The following properties of the provided User instance can be set during creation:<pre><code> email (required) - Email
366361
* username (required) - Username
367362
* name (required) - Name
368363
* skype (optional) - Skype ID
369364
* linkedin (optional) - LinkedIn
370365
* twitter (optional) - Twitter account
371-
* website_url (optional) - Website URL
366+
* websiteUrl (optional) - Website URL
372367
* organization (optional) - Organization name
373-
* projects_limit (optional) - Number of projects user can create
374-
* extern_uid (optional) - External UID
368+
* projectsLimit (optional) - Number of projects user can create
369+
* externUid (optional) - External UID
375370
* provider (optional) - External provider name
376371
* bio (optional) - User's biography
377372
* location (optional) - User's location
378373
* admin (optional) - User is admin - true or false (default)
379-
* can_create_group (optional) - User can create groups - true or false
380-
* skip_confirmation (optional) - Skip confirmation - true or false (default)
374+
* canCreateGroup (optional) - User can create groups - true or false
375+
* skipConfirmation (optional) - Skip confirmation - true or false (default)
381376
* external (optional) - Flags the user as external - true or false(default)
382-
* avatar (optional) - Image file for user's avatar
383-
* shared_runners_minutes_limit (optional) - Pipeline minutes quota for this user
377+
* sharedRunnersMinutesLimit (optional) - Pipeline minutes quota for this user
378+
*</code></pre>
384379
*
385380
* @param user the User instance with the user info to create
386381
* @param password the password for the new user
@@ -394,38 +389,75 @@ public User createUser(User user, CharSequence password, boolean resetPassword)
394389
return (response.readEntity(User.class));
395390
}
396391

392+
/**
393+
* <p>Modifies an existing user. Only administrators can change attributes of a user.</p>
394+
*
395+
* <pre>PUT /users</pre>
396+
*
397+
* The following properties of the provided User instance can be set during update:<pre><code> email (required) - Email
398+
* username (required) - Username
399+
* name (required) - Name
400+
* skype (optional) - Skype ID
401+
* linkedin (optional) - LinkedIn
402+
* twitter (optional) - Twitter account
403+
* websiteUrl (optional) - Website URL
404+
* organization (optional) - Organization name
405+
* projectsLimit (optional) - Number of projects user can create
406+
* externUid (optional) - External UID
407+
* provider (optional) - External provider name
408+
* bio (optional) - User's biography
409+
* location (optional) - User's location
410+
* admin (optional) - User is admin - true or false (default)
411+
* canCreateGroup (optional) - User can create groups - true or false
412+
* skipConfirmation (optional) - Skip confirmation - true or false (default)
413+
* external (optional) - Flags the user as external - true or false(default)
414+
* sharedRunnersMinutesLimit (optional) - Pipeline minutes quota for this user
415+
*</code></pre>
416+
*
417+
* @param user the User instance with the user info to modify
418+
* @param password the new password for the user
419+
* @return the modified User instance
420+
* @throws GitLabApiException if any exception occurs
421+
*/
422+
public User updateUser(User user, CharSequence password) throws GitLabApiException {
423+
Form form = userToForm(user, null, password, false, false);
424+
Response response = put(Response.Status.OK, form.asMap(), "users", user.getId());
425+
return (response.readEntity(User.class));
426+
}
427+
397428
/**
398429
* Modifies an existing user. Only administrators can change attributes of a user.
399430
*
400-
* PUT /users/:id
401-
*
402-
* email - Email
403-
* username - Username
404-
* name - Name
405-
* password - Password
406-
* skype - Skype ID
407-
* linkedin - LinkedIn
408-
* twitter - Twitter account
409-
* website_url - Website URL
410-
* organization - Organization name
411-
* projects_limit - Limit projects each user can create
412-
* extern_uid - External UID
413-
* provider - External provider name
414-
* bio - User's biography
431+
* <pre>PUT /users/:id</pre>
432+
*
433+
* The following properties of the provided User instance can be set during update:<pre><code> email (required) - Email
434+
* username (required) - Username
435+
* name (required) - Name
436+
* skype (optional) - Skype ID
437+
* linkedin (optional) - LinkedIn
438+
* twitter (optional) - Twitter account
439+
* websiteUrl (optional) - Website URL
440+
* organization (optional) - Organization name
441+
* projectsLimit (optional) - Number of projects user can create
442+
* externUid (optional) - External UID
443+
* provider (optional) - External provider name
444+
* bio (optional) - User's biography
415445
* location (optional) - User's location
416446
* admin (optional) - User is admin - true or false (default)
417-
* can_create_group (optional) - User can create groups - true or false
418-
* skip_reconfirmation (optional) - Skip reconfirmation - true or false (default)
447+
* canCreateGroup (optional) - User can create groups - true or false
448+
* skipConfirmation (optional) - Skip confirmation - true or false (default)
419449
* external (optional) - Flags the user as external - true or false(default)
420-
* shared_runners_minutes_limit (optional) - Pipeline minutes quota for this user
421-
* avatar (optional) - Image file for user's avatar
450+
* sharedRunnersMinutesLimit (optional) - Pipeline minutes quota for this user
451+
*</code></pre>
422452
*
423453
* @param user the User instance with the user info to modify
424454
* @param password the new password for the user
425455
* @param projectsLimit the maximum number of project
426456
* @return the modified User instance
427457
* @throws GitLabApiException if any exception occurs
458+
* @deprecated Will be removed in version 5.0, replaced by {@link #updateUser(User, CharSequence)}
428459
*/
460+
@Deprecated
429461
public User modifyUser(User user, CharSequence password, Integer projectsLimit) throws GitLabApiException {
430462
Form form = userToForm(user, projectsLimit, password, false, false);
431463
Response response = put(Response.Status.OK, form.asMap(), "users", user.getId());

0 commit comments

Comments
 (0)