|
42 | 42 | import org.gitlab4j.api.models.Issue;
|
43 | 43 | import org.gitlab4j.api.models.Member;
|
44 | 44 | import org.gitlab4j.api.models.Project;
|
| 45 | +import org.gitlab4j.api.models.ProjectFilter; |
45 | 46 | import org.gitlab4j.api.models.ProjectHook;
|
46 | 47 | import org.gitlab4j.api.models.ProjectUser;
|
47 | 48 | import org.gitlab4j.api.models.PushRules;
|
@@ -464,6 +465,56 @@ public Pager<Project> getStarredProjects(int itemsPerPage) throws GitLabApiExcep
|
464 | 465 | return (new Pager<Project>(this, Project.class, itemsPerPage, formData.asMap(), "projects"));
|
465 | 466 | }
|
466 | 467 |
|
| 468 | + /** |
| 469 | + * Get a list of visible projects owned by the given user. |
| 470 | + * |
| 471 | + * <pre><code>GET /users/:user_id/projects</code></pre> |
| 472 | + * |
| 473 | + * @param userIdOrUsername the user ID, username of the user, or a User instance holding the user ID or username |
| 474 | + * @param filter the ProjectFilter instance holding the filter values for the query |
| 475 | + * @return a list of visible projects owned by the given use |
| 476 | + * @throws GitLabApiException if any exception occurs |
| 477 | + */ |
| 478 | + public List<Project> getUserProjects(Object userIdOrUsername, ProjectFilter filter) throws GitLabApiException { |
| 479 | + return (getUserProjects(userIdOrUsername, filter, 1, getDefaultPerPage())); |
| 480 | + } |
| 481 | + |
| 482 | + /** |
| 483 | + * Get a list of visible projects owned by the given user in the specified page range. |
| 484 | + * |
| 485 | + * <pre><code>GET /users/:user_id/projects</code></pre> |
| 486 | + * |
| 487 | + * @param userIdOrUsername the user ID, username of the user, or a User instance holding the user ID or username |
| 488 | + * @param filter the ProjectFilter instance holding the filter values for the query |
| 489 | + * @param page the page to get |
| 490 | + * @param perPage the number of projects per page |
| 491 | + * @return a list of visible projects owned by the given use |
| 492 | + * @throws GitLabApiException if any exception occurs |
| 493 | + */ |
| 494 | + public List<Project> getUserProjects(Object userIdOrUsername, ProjectFilter filter, int page, int perPage) throws GitLabApiException { |
| 495 | + GitLabApiForm formData = filter.getQueryParams(page, perPage); |
| 496 | + Response response = get(Response.Status.OK, formData.asMap(), |
| 497 | + "users", getUserIdOrUsername(userIdOrUsername), "projects"); |
| 498 | + return (response.readEntity(new GenericType<List<Project>>() {})); |
| 499 | + } |
| 500 | + |
| 501 | + /** |
| 502 | + * Get a Pager of visible projects owned by the given user. |
| 503 | + * |
| 504 | + * <pre><code>GET /users/:user_id/projects</code></pre> |
| 505 | + * |
| 506 | + * @param userIdOrUsername the user ID, username of the user, or a User instance holding the user ID or username |
| 507 | + * @param filter the ProjectFilter instance holding the filter values for the query |
| 508 | + * @param itemsPerPage the number of Project instances that will be fetched per page |
| 509 | + * @return a Pager of visible projects owned by the given use |
| 510 | + * @throws GitLabApiException if any exception occurs |
| 511 | + */ |
| 512 | + public Pager<Project> getUserProjects(Object userIdOrUsername, ProjectFilter filter, int itemsPerPage) throws GitLabApiException { |
| 513 | + GitLabApiForm formData = filter.getQueryParams(); |
| 514 | + return (new Pager<Project>(this, Project.class, itemsPerPage, formData.asMap(), |
| 515 | + "users", getUserIdOrUsername(userIdOrUsername), "projects")); |
| 516 | + } |
| 517 | + |
467 | 518 | /**
|
468 | 519 | * Get a specific project, which is owned by the authentication user.
|
469 | 520 | *
|
|
0 commit comments