|
3 | 3 | import org.gitlab4j.api.GitLabApi.ApiVersion; |
4 | 4 | import org.gitlab4j.api.models.CustomAttribute; |
5 | 5 | import org.gitlab4j.api.models.ImpersonationToken; |
| 6 | +import org.gitlab4j.api.models.Project; |
6 | 7 | import org.gitlab4j.api.models.ImpersonationToken.Scope; |
7 | 8 | import org.gitlab4j.api.models.SshKey; |
8 | 9 | import org.gitlab4j.api.models.User; |
9 | 10 |
|
10 | 11 | import javax.ws.rs.core.Form; |
11 | 12 | import javax.ws.rs.core.GenericType; |
12 | 13 | import javax.ws.rs.core.Response; |
| 14 | + |
| 15 | +import java.io.File; |
13 | 16 | import java.util.Date; |
14 | 17 | import java.util.List; |
15 | 18 | import java.util.Objects; |
@@ -995,4 +998,19 @@ private GitLabApiForm createGitLabApiForm() { |
995 | 998 | GitLabApiForm formData = new GitLabApiForm(); |
996 | 999 | return (customAttributesEnabled ? formData.withParam("with_custom_attributes", true) : formData); |
997 | 1000 | } |
| 1001 | + |
| 1002 | + /** |
| 1003 | + * Uploads and sets the user's avatar for the specified user. |
| 1004 | + * |
| 1005 | + * <pre><code>PUT /users/:id</code></pre> |
| 1006 | + * |
| 1007 | + * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance |
| 1008 | + * @param avatarFile the File instance of the avatar file to upload |
| 1009 | + * @return the updated User instance |
| 1010 | + * @throws GitLabApiException if any exception occurs |
| 1011 | + */ |
| 1012 | + public User setUserAvatar(final Object userIdOrUsername, File avatarFile) throws GitLabApiException { |
| 1013 | + Response response = putUpload(Response.Status.OK, "avatar", avatarFile, "users", getUserIdOrUsername(userIdOrUsername)); |
| 1014 | + return (response.readEntity(User.class)); |
| 1015 | + } |
998 | 1016 | } |
0 commit comments