diff --git a/src/main/java/org/gitlab4j/api/GroupApi.java b/src/main/java/org/gitlab4j/api/GroupApi.java index 507949ff73de71f810035c314afb1c3d1c1ab018..9a90e1b5957a81e388396473ee1c942aba26c8be 100644 --- a/src/main/java/org/gitlab4j/api/GroupApi.java +++ b/src/main/java/org/gitlab4j/api/GroupApi.java @@ -3,6 +3,7 @@ package org.gitlab4j.api; import java.util.Date; import java.util.List; import java.util.Optional; +import java.util.stream.Stream; import javax.ws.rs.core.Form; import javax.ws.rs.core.GenericType; @@ -28,20 +29,19 @@ public class GroupApi extends AbstractApi { /** * Get a list of groups. (As user: my groups, as admin: all groups) * - * GET /groups + *
GitLab Endpoint: GET /groups
*
* @return the list of groups viewable by the authenticated user
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /groups
*
* @param page the page to get
* @param perPage the number of Group instances per page
@@ -56,7 +56,7 @@ public class GroupApi extends AbstractApi {
/**
* Get a Pager of groups. (As user: my groups, as admin: all groups)
*
- * GET /groups
+ * GitLab Endpoint: GET /groups
*
* @param itemsPerPage the number of Group instances that will be fetched per page
* @return the list of groups viewable by the authenticated user
@@ -66,6 +66,18 @@ public class GroupApi extends AbstractApi {
return (new PagerGitLab Endpoint: GET /groups
+ *
+ * @return a Stream of groups viewable by the authenticated user
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGET /groups/:id/subgroups
GitLab Endpoint: GET /groups/:id/subgroups
*
* @param groupId the group ID to get the sub groups for
* @return a List<Group> containing the group's sub-groups
@@ -118,13 +139,42 @@ public class GroupApi extends AbstractApi {
* @since GitLab 10.3.0
*/
public ListGitLab Endpoint: GET /groups/:id/subgroups
+ *
+ * @param groupId the group ID to get the sub groups for
+ * @param itemsPerPage the number of Group instances that will be fetched per page
+ * @return a Pager containing matching Group instances
+ * @throws GitLabApiException if any exception occurs
+ * @since GitLab 10.3.0
+ */
+ public PagerGitLab Endpoint: GET /groups/:id/subgroups
+ *
+ * @param groupId the group ID to get the sub groups for
+ * @return a Stream<Group> containing the group's sub-groups
+ * @throws GitLabApiException if any exception occurs
+ * @since GitLab 10.3.0
+ */
+ public StreamGET /groups/:id/subgroups
GitLab Endpoint: GET /groups/:id/subgroups
*
* @param groupId the group ID to get the sub groups for
* @param skipGroups skip the group IDs passed
@@ -140,13 +190,13 @@ public class GroupApi extends AbstractApi {
*/
public ListGET /groups/:id/subgroups
GitLab Endpoint: GET /groups/:id/subgroups
*
* @param groupId the group ID to get the sub groups for
* @param skipGroups skip the group IDs passed
@@ -182,22 +232,7 @@ public class GroupApi extends AbstractApi {
/**
* Get a Pager of visible direct subgroups in this group.
*
- * GET /groups/:id/subgroups
GET /groups/:id/subgroups
GitLab Endpoint: GET /groups/:id/subgroups
*
* @param groupId the group ID to get the sub groups for
* @param skipGroups skip the group IDs passed
@@ -225,10 +260,32 @@ public class GroupApi extends AbstractApi {
return (new PagerGitLab Endpoint: GET /groups/:id/subgroups
+ *
+ * @param groupId the group ID to get the sub groups for
+ * @param skipGroups skip the group IDs passed
+ * @param allAvailable show all the groups you have access to (defaults to false for authenticated users)
+ * @param search return the list of authorized groups matching the search criteria
+ * @param orderBy order groups by NAME or PATH. Default is NAME
+ * @param sortOrder order groups in ASC or DESC order. Default is ASC
+ * @param statistics include group statistics (admins only)
+ * @param owned limit to groups owned by the current user
+ * @return a Stream<Group> of the matching subgroups
+ * @throws GitLabApiException if any exception occurs
+ * @since GitLab 10.3.0
+ */
+ public StreamGitLab Endpoint: GET /groups/:id/projects
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param filter the GroupProjectsFilter instance holding the filter values for the query
@@ -236,15 +293,13 @@ public class GroupApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /groups/:id/projects
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param filter the GroupProjectsFilter instance holding the filter values for the query
@@ -257,100 +312,101 @@ public class GroupApi extends AbstractApi {
return (new PagerGitLab Endpoint: GET /groups/:id/projects
+ *
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
+ * @param filter the GroupProjectsFilter instance holding the filter values for the query
+ * @return a Stream containing Project instances that belong to the group and match the provided filter
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /groups/:id/projects
*
- * @param groupId the group ID to list the projects for
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @return a list of projects belonging to the specified group ID
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /groups/:id/projects
*
- * @param groupId the group ID to list the projects for
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param page the page to get
* @param perPage the number of Project instances per page
* @return a list of projects belonging to the specified group ID in the specified page range
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /groups/:id/projects
*
- * @param groupId the group ID to list the projects for
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param itemsPerPage the number of Project instances that will be fetched per page
* @return a Pager of projects belonging to the specified group ID
* @throws GitLabApiException if any exception occurs
*/
- public PagerGitLab Endpoint: GET /groups/:id/projects
*
- * @param groupId the group ID to get
- * @return the Group instance for the specified group ID
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
+ * @return a Stream of projects belonging to the specified group ID
* @throws GitLabApiException if any exception occurs
*/
- public Group getGroup(Integer groupId) throws GitLabApiException {
- return getGroup(groupId.toString());
- }
-
- /**
- * Get all details of a group as an Optional instance.
- *
- * GET /groups/:id
- *
- * @param groupId the group ID to get
- * @return the Group for the specified group ID as an Optional instance
- */
- public OptionalGitLab Endpoint: GET /groups/:id
*
- * @param groupPath the path of the group to get details for
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @return the Group instance for the specified group path
* @throws GitLabApiException if any exception occurs
*/
- public Group getGroup(String groupPath) throws GitLabApiException {
- Response response = get(Response.Status.OK, null, "groups", urlEncode(groupPath));
+ public Group getGroup(Object groupIdOrPath) throws GitLabApiException {
+ Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath));
return (response.readEntity(Group.class));
}
/**
* Get all details of a group as an Optional instance.
*
- * GET /groups/:id
+ * GitLab Endpoint: GET /groups/:id
*
- * @param groupPath the path of the group to get details for
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @return the Group for the specified group path as an Optional instance
*/
- public OptionalGitLab Endpoint: POST /groups
*
* @param name the name of the group to add
* @param path the path for the group
@@ -391,7 +447,7 @@ public class GroupApi extends AbstractApi {
/**
* Creates a new project group. Available only for users who can create groups.
*
- * POST /groups
+ * GitLab Endpoint: POST /groups
*
* @param name the name of the group to add
* @param path the path for the group
@@ -421,7 +477,7 @@ public class GroupApi extends AbstractApi {
/**
* Updates a project group. Available only for users who can create groups.
*
- * PUT /groups
+ * GitLab Endpoint: PUT /groups
*
* @param group to update
* @return updated group instance
@@ -441,11 +497,11 @@ public class GroupApi extends AbstractApi {
}
/**
- * Updates a project group. Available only for users who can create groups.
+ * Updates a project group. Available only for users who can create groups.
*
- * PUT /groups
+ * GitLab Endpoint: PUT /groups
*
- * @param groupId the ID of the group to update
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param name the name of the group to add
* @param path the path for the group
* @param description (optional) - The group's description
@@ -456,7 +512,7 @@ public class GroupApi extends AbstractApi {
* @return the updated Group instance
* @throws GitLabApiException if any exception occurs
*/
- public Group updateGroup(Integer groupId, String name, String path, String description, Visibility visibility,
+ public Group updateGroup(Object groupIdOrPath, String name, String path, String description, Visibility visibility,
Boolean lfsEnabled, Boolean requestAccessEnabled, Integer parentId) throws GitLabApiException {
Form formData = new GitLabApiForm()
@@ -467,14 +523,14 @@ public class GroupApi extends AbstractApi {
.withParam("lfs_enabled", lfsEnabled)
.withParam("request_access_enabled", requestAccessEnabled)
.withParam("parent_id", isApiVersion(ApiVersion.V3) ? null : parentId);
- Response response = put(Response.Status.OK, formData.asMap(), "groups", groupId);
+ Response response = put(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath));
return (response.readEntity(Group.class));
}
/**
* Creates a new project group. Available only for users who can create groups.
*
- * POST /groups
+ * GitLab Endpoint: POST /groups
*
* @param name the name of the group to add
* @param path the path for the group
@@ -513,9 +569,9 @@ public class GroupApi extends AbstractApi {
/**
* Updates a project group. Available only for users who can create groups.
*
- * PUT /groups
+ * GitLab Endpoint: PUT /groups
*
- * @param groupId the ID of the group to update
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param name the name of the group to add
* @param path the path for the group
* @param description (optional) - The group's description
@@ -528,10 +584,10 @@ public class GroupApi extends AbstractApi {
* @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
* @return the updated Group instance
* @throws GitLabApiException if any exception occurs
- * @deprecated Will be removed in version 5.0, replaced by {@link #updateGroup(Integer, String, String, String,
+ * @deprecated Will be removed in version 5.0, replaced by {@link #updateGroup(Object, String, String, String,
* Visibility, Boolean, Boolean, Integer)}
*/
- public Group updateGroup(Integer groupId, String name, String path, String description, Boolean membershipLock,
+ public Group updateGroup(Object groupIdOrPath, String name, String path, String description, Boolean membershipLock,
Boolean shareWithGroupLock, Visibility visibility, Boolean lfsEnabled, Boolean requestAccessEnabled,
Integer parentId, Integer sharedRunnersMinutesLimit) throws GitLabApiException {
@@ -546,111 +602,106 @@ public class GroupApi extends AbstractApi {
.withParam("request_access_enabled", requestAccessEnabled)
.withParam("parent_id", parentId)
.withParam("shared_runners_minutes_limit", sharedRunnersMinutesLimit);
- Response response = put(Response.Status.OK, formData.asMap(), "groups", groupId);
+ Response response = put(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath));
return (response.readEntity(Group.class));
}
/**
* Removes group with all projects inside.
*
- * DELETE /groups/:id
+ * GitLab Endpoint: DELETE /groups/:id
*
- * @param groupId the group ID to delete
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @throws GitLabApiException if any exception occurs
*/
- public void deleteGroup(Integer groupId) throws GitLabApiException {
-
- if (groupId == null) {
- throw new RuntimeException("groupId cannot be null");
- }
-
+ public void deleteGroup(Object groupIdOrPath) throws GitLabApiException {
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
- delete(expectedStatus, null, "groups", groupId);
- }
-
- /**
- * Removes group with all projects inside.
- *
- * DELETE /groups/:id
- *
- * @param group the Group instance to delete
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteGroup(Group group) throws GitLabApiException {
- deleteGroup(group.getId());
+ delete(expectedStatus, null, "groups", getGroupIdOrPath(groupIdOrPath));
}
/**
* Get a list of group members viewable by the authenticated user.
*
- * GET /groups/:id/members
+ * GitLab Endpoint: GET /groups/:id/members
*
- * @param groupId the group ID to list the members for
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @return a list of group members viewable by the authenticated user
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /groups/:id/members
*
- * @param groupId the group ID to list the members for
+ *@param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param page the page to get
* @param perPage the number of Member instances per page
* @return a list of group members viewable by the authenticated user in the specified page range
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /groups/:id/members
*
- * @param groupId the group ID to list the members for
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param itemsPerPage the number of Member instances that will be fetched per page
* @return a list of group members viewable by the authenticated user
* @throws GitLabApiException if any exception occurs
*/
- public PagerGitLab Endpoint: GET /groups/:id/members
+ *
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
+ * @return a Stream of group members viewable by the authenticated user
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /groups/:id/members/:id
*
- * @param groupId the group ID to get the member for
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param userId the member ID of the member to get
* @return a member viewable by the authenticated user
* @throws GitLabApiException if any exception occurs
*/
- public Member getMember(int groupId, int userId) throws GitLabApiException {
- Response response = get(Response.Status.OK, getDefaultPerPageParam(), "groups", groupId, "members", userId);
+ public Member getMember(Object groupIdOrPath, int userId) throws GitLabApiException {
+ Response response = get(Response.Status.OK, getDefaultPerPageParam(), "groups", getGroupIdOrPath(groupIdOrPath), "members", userId);
return (response.readEntity(new GenericTypeGitLab Endpoint: GET /groups/:id/members/:id
*
- * @param groupId the group ID to get the member for
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param userId the member ID of the member to get
* @return a member viewable by the authenticated user as an Optional instance
*/
- public OptionalGitLab Endpoint: POST /groups/:id/members
*
- * @param groupId the project ID to add the member to, required
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param userId the user ID of the member to add, required
* @param accessLevel the access level for the new member, required
* @return a Member instance for the added user
* @throws GitLabApiException if any exception occurs
*/
- public Member addMember(Integer groupId, Integer userId, Integer accessLevel) throws GitLabApiException {
- return (addMember(groupId, userId, accessLevel, null));
+ public Member addMember(Object groupIdOrPath, Integer userId, Integer accessLevel) throws GitLabApiException {
+ return (addMember(groupIdOrPath, userId, accessLevel, null));
}
/**
* Adds a user to the list of group members.
*
- * POST /groups/:id/members
+ * GitLab Endpoint: POST /groups/:id/members
*
- * @param groupId the project ID to add the member to, required
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param userId the user ID of the member to add, required
* @param accessLevel the access level for the new member, required
* @return a Member instance for the added user
* @throws GitLabApiException if any exception occurs
*/
- public Member addMember(Integer groupId, Integer userId, AccessLevel accessLevel) throws GitLabApiException {
- return (addMember(groupId, userId, accessLevel.toValue(), null));
+ public Member addMember(Object groupIdOrPath, Integer userId, AccessLevel accessLevel) throws GitLabApiException {
+ return (addMember(groupIdOrPath, userId, accessLevel.toValue(), null));
}
/**
* Adds a user to the list of group members.
*
- * POST /groups/:id/members
+ * GitLab Endpoint: POST /groups/:id/members
*
- * @param groupId the project ID to add the member to, required
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param userId the user ID of the member to add, required
* @param accessLevel the access level for the new member, required
* @param expiresAt the date the membership in the group will expire, optional
* @return a Member instance for the added user
* @throws GitLabApiException if any exception occurs
*/
- public Member addMember(Integer groupId, Integer userId, AccessLevel accessLevel, Date expiresAt) throws GitLabApiException {
- return (addMember(groupId, userId, accessLevel.toValue(), expiresAt));
+ public Member addMember(Object groupIdOrPath, Integer userId, AccessLevel accessLevel, Date expiresAt) throws GitLabApiException {
+ return (addMember(groupIdOrPath, userId, accessLevel.toValue(), expiresAt));
}
/**
* Adds a user to the list of group members.
*
- * POST /groups/:id/members
+ * GitLab Endpoint: POST /groups/:id/members
*
- * @param groupId the project ID to add the member to, required
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param userId the user ID of the member to add, required
* @param accessLevel the access level for the new member, required
* @param expiresAt the date the membership in the group will expire, optional
* @return a Member instance for the added user
* @throws GitLabApiException if any exception occurs
*/
- public Member addMember(Integer groupId, Integer userId, Integer accessLevel, Date expiresAt) throws GitLabApiException {
+ public Member addMember(Object groupIdOrPath, Integer userId, Integer accessLevel, Date expiresAt) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("user_id", userId, true)
.withParam("access_level", accessLevel, true)
.withParam("expires_at", expiresAt, false);
- Response response = post(Response.Status.CREATED, formData, "groups", groupId, "members");
+ Response response = post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "members");
return (response.readEntity(Member.class));
}
/**
* Updates a member of a group.
*
- * PUT /groups/:groupId/members/:userId
+ * GitLab Endpoint: PUT /groups/:groupId/members/:userId
*
- * @param groupId the group ID the member belongs to, required
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param userId the user ID of the member to update, required
* @param accessLevel the new access level for the member, required
* @return the updated member
* @throws GitLabApiException if any exception occurs
*/
- public Member updateMember(Integer groupId, Integer userId, Integer accessLevel) throws GitLabApiException {
- return (updateMember(groupId, userId, accessLevel, null));
+ public Member updateMember(Object groupIdOrPath, Integer userId, Integer accessLevel) throws GitLabApiException {
+ return (updateMember(groupIdOrPath, userId, accessLevel, null));
}
/**
* Updates a member of a group.
*
- * PUT /groups/:groupId/members/:userId
+ * GitLab Endpoint: PUT /groups/:groupId/members/:userId
*
- * @param groupId the group ID the member belongs to, required
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param userId the user ID of the member to update, required
* @param accessLevel the new access level for the member, required
* @return the updated member
* @throws GitLabApiException if any exception occurs
*/
- public Member updateMember(Integer groupId, Integer userId, AccessLevel accessLevel) throws GitLabApiException {
- return (updateMember(groupId, userId, accessLevel.toValue(), null));
+ public Member updateMember(Object groupIdOrPath, Integer userId, AccessLevel accessLevel) throws GitLabApiException {
+ return (updateMember(groupIdOrPath, userId, accessLevel.toValue(), null));
}
/**
* Updates a member of a group.
*
- * PUT /groups/:groupId/members/:userId
+ * GitLab Endpoint: PUT /groups/:groupId/members/:userId
*
- * @param groupId the group ID the member belongs to, required
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param userId the user ID of the member to update, required
* @param accessLevel the new access level for the member, required
* @param expiresAt the date the membership in the group will expire, optional
* @return the updated member
* @throws GitLabApiException if any exception occurs
*/
- public Member updateMember(Integer groupId, Integer userId, AccessLevel accessLevel, Date expiresAt) throws GitLabApiException {
- return (updateMember(groupId, userId, accessLevel.toValue(), expiresAt));
+ public Member updateMember(Object groupIdOrPath, Integer userId, AccessLevel accessLevel, Date expiresAt) throws GitLabApiException {
+ return (updateMember(groupIdOrPath, userId, accessLevel.toValue(), expiresAt));
}
/**
* Updates a member of a group.
*
- * PUT /groups/:groupId/members/:userId
+ * GitLab Endpoint: PUT /groups/:groupId/members/:userId
*
- * @param groupId the group ID the member belongs to, required
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param userId the user ID of the member to update, required
* @param accessLevel the new access level for the member, required
* @param expiresAt the date the membership in the group will expire, optional
* @return the updated member
* @throws GitLabApiException if any exception occurs
*/
- public Member updateMember(Integer groupId, Integer userId, Integer accessLevel, Date expiresAt) throws GitLabApiException {
+ public Member updateMember(Object groupIdOrPath, Integer userId, Integer accessLevel, Date expiresAt) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("access_level", accessLevel, true)
.withParam("expires_at", expiresAt, false);
- Response response = put(Response.Status.OK, formData.asMap(), "groups", groupId, "members", userId);
+ Response response = put(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "members", userId);
return (response.readEntity(Member.class));
}
/**
* Removes member from the group.
*
- * DELETE /groups/:id/members/:user_id
+ * GitLab Endpoint: DELETE /groups/:id/members/:user_id
*
- * @param groupId the group ID to remove the member from
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param userId the user ID of the member to remove
* @throws GitLabApiException if any exception occurs
*/
- public void removeMember(Integer groupId, Integer userId) throws GitLabApiException {
+ public void removeMember(Object groupIdOrPath, Integer userId) throws GitLabApiException {
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
- delete(expectedStatus, null, "groups", groupId, "members", userId);
+ delete(expectedStatus, null, "groups", getGroupIdOrPath(groupIdOrPath), "members", userId);
}
/**
diff --git a/src/main/java/org/gitlab4j/api/IssuesApi.java b/src/main/java/org/gitlab4j/api/IssuesApi.java
index f4478192fe3d4637b92c222e0b5c41c1e4e2a433..1ca5ad2e8ab732e4f3013018f4ba24943695517c 100644
--- a/src/main/java/org/gitlab4j/api/IssuesApi.java
+++ b/src/main/java/org/gitlab4j/api/IssuesApi.java
@@ -26,6 +26,7 @@ package org.gitlab4j.api;
import java.util.Date;
import java.util.List;
import java.util.Optional;
+import java.util.stream.Stream;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
@@ -48,21 +49,21 @@ public class IssuesApi extends AbstractApi implements Constants {
}
/**
- * Get all issues the authenticated user has access to. Only returns issues created by the current user. Only returns the first page
+ * Get all issues the authenticated user has access to. Only returns issues created by the current user.
*
- * GET /issues
+ * GitLab Endpoint: GET /issues
*
* @return a list of user's issues
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /issues
*
* @param page the page to get
* @param perPage the number of issues per page
@@ -77,7 +78,7 @@ public class IssuesApi extends AbstractApi implements Constants {
/**
* Get a Pager of all issues the authenticated user has access to. Only returns issues created by the current user.
*
- * GET /issues
+ * GitLab Endpoint: GET /issues
*r
* @param itemsPerPage the number of issues per page
* @return the list of issues in the specified range
@@ -87,69 +88,94 @@ public class IssuesApi extends AbstractApi implements Constants {
return (new PagerGitLab Endpoint: GET /issues
+ *
+ * @return a Stream of user's issues
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /projects/:id/issues
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @return a list of project's issues
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /projects/:id/issues
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param page the page to get
* @param perPage the number of issues per page
* @return the list of issues in the specified range
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /projects/:id/issues
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param itemsPerPage the number of issues per page
* @return the list of issues in the specified range
* @throws GitLabApiException if any exception occurs
*/
- public PagerGitLab Endpoint: GET /projects/:id/issues
*
- * @param projectIdOrPath The ID or URL-encoded path of the project owned by the authenticated user.
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
+ * @return a Stream of project's issues
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /projects/:id/issues
+ *
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings
* @return the list of issues in the specified range.
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /projects/:id/issues
*
- * @param projectIdOrPath The ID or URL-encoded path of the project owned by the authenticated user.
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
* @param page the page to get.
* @param perPage the number of projects per page.
@@ -157,7 +183,6 @@ public class IssuesApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /projects/:id/issues
*
- * @param projectIdOrPath The ID or URL-encoded path of the project owned by the authenticated user.
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
* @param itemsPerPage the number of Project instances that will be fetched per page.
* @return the list of issues in the specified range.
* @throws GitLabApiException if any exception occurs
*/
public PagerGitLab Endpoint: GET /projects/:id/issues
+ *
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
+ * @param filter {@link IssueFilter} a IssueFilter instance with the filter settings
+ * @return a Stream of issues in the specified range.
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /issues
*
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings
* @return the list of issues in the specified range.
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /issues
*
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
* @param page the page to get.
@@ -208,7 +245,6 @@ public class IssuesApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /issues
*
* @param filter {@link IssueFilter} a IssueFilter instance with the filter settings.
* @param itemsPerPage the number of Project instances that will be fetched per page.
@@ -226,43 +262,51 @@ public class IssuesApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs
*/
public PagerGitLab Endpoint: GET /issues
+ *
+ * @param filter {@link IssueFilter} a IssueFilter instance with the filter settings
+ * @return the list of issues in the specified range.
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /projects/:id/issues/:issue_iid
*
- * @param projectId the project ID to get the issue for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueId the internal ID of a project's issue
* @return the specified Issue instance
* @throws GitLabApiException if any exception occurs
*/
- public Issue getIssue(Integer projectId, Integer issueId) throws GitLabApiException {
-
- if (projectId == null) {
- throw new RuntimeException("projectId cannot be null");
- }
-
- Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", projectId, "issues", issueId);
+ public Issue getIssue(Object projectIdOrPath, Integer issueId) throws GitLabApiException {
+ Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueId);
return (response.readEntity(Issue.class));
}
/**
* Get a single project issue as an Optional instance.
*
- * GET /projects/:id/issues/:issue_iid
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid
*
- * @param projectId the project ID to get the issue for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueId the internal ID of a project's issue
* @return the specified Issue as an Optional instance
*/
- public OptionalGitLab Endpoint: POST /projects/:id/issues
*
- * @param projectId the ID of the project owned by the authenticated user, required
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param title the title of an issue, required
* @param description the description of an issue, optional
* @return an instance of Issue
* @throws GitLabApiException if any exception occurs
*/
- public Issue createIssue(Integer projectId, String title, String description) throws GitLabApiException {
- return (createIssue(projectId, title, description, null, null, null, null, null, null, null, null));
+ public Issue createIssue(Object projectIdOrPath, String title, String description) throws GitLabApiException {
+ return (createIssue(projectIdOrPath, title, description, null, null, null, null, null, null, null, null));
}
/**
* Create an issue for the project.
*
- * POST /projects/:id/issues
+ * GitLab Endpoint: POST /projects/:id/issues
*
- * @param projectId the ID of the project owned by the authenticated user, required
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param title the issue title of an issue, required
* @param description the description of an issue, optional
* @param confidential set the issue to be confidential, default is false, optional
@@ -304,13 +348,9 @@ public class IssuesApi extends AbstractApi implements Constants {
* @return an instance of Issue
* @throws GitLabApiException if any exception occurs
*/
- public Issue createIssue(Integer projectId, String title, String description, Boolean confidential, ListGitLab Endpoint: PUT /projects/:id/issues/:issue_iid
*
- * @param projectId the ID of the project owned by the authenticated user, required
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param issueIid the issue IID to update, required
* @return an instance of the updated Issue
* @throws GitLabApiException if any exception occurs
*/
- public Issue closeIssue(Integer projectId, Integer issueIid) throws GitLabApiException {
-
- if (projectId == null) {
- throw new RuntimeException("project ID cannot be null");
- }
+ public Issue closeIssue(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
GitLabApiForm formData = new GitLabApiForm().withParam("state_event", StateEvent.CLOSE);
- Response response = put(Response.Status.OK, formData.asMap(), "projects", projectId, "issues", issueIid);
+ Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid);
return (response.readEntity(Issue.class));
}
/**
* Updates an existing project issue. This call can also be used to mark an issue as closed.
*
- * PUT /projects/:id/issues/:issue_iid
+ * GitLab Endpoint: PUT /projects/:id/issues/:issue_iid
*
- * @param projectId the ID of the project owned by the authenticated user, required
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param issueIid the issue IID to update, required
* @param title the title of an issue, optional
* @param description the description of an issue, optional
@@ -370,13 +406,9 @@ public class IssuesApi extends AbstractApi implements Constants {
* @return an instance of the updated Issue
* @throws GitLabApiException if any exception occurs
*/
- public Issue updateIssue(Integer projectId, Integer issueIid, String title, String description, Boolean confidential, ListGitLab Endpoint: DELETE /projects/:id/issues/:issue_iid
*
- * @param projectId the project ID to delete the issue from
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param issueIid the internal ID of a project's issue
* @throws GitLabApiException if any exception occurs
*/
- public void deleteIssue(Integer projectId, Integer issueIid) throws GitLabApiException {
-
- if (projectId == null) {
- throw new RuntimeException("projectId cannot be null");
- }
+ public void deleteIssue(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
- delete(expectedStatus, getDefaultPerPageParam(), "projects", projectId, "issues", issueIid);
+ delete(expectedStatus, getDefaultPerPageParam(), "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid);
}
/**
* Sets an estimated time of work in this issue
*
- * POST /projects/:id/issues/:issue_iid/time_estimate
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/time_estimate
*
- * @param projectId the project ID that owns the issue
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param issueIid the internal ID of a project's issue
* @param duration estimated time in seconds
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
- public TimeStats estimateTime(Integer projectId, Integer issueIid, int duration) throws GitLabApiException {
- return (estimateTime(projectId, issueIid, new Duration(duration)));
+ public TimeStats estimateTime(Object projectIdOrPath, Integer issueIid, int duration) throws GitLabApiException {
+ return (estimateTime(projectIdOrPath, issueIid, new Duration(duration)));
}
/**
* Sets an estimated time of work in this issue
*
- * POST /projects/:id/issues/:issue_iid/time_estimate
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/time_estimate
*
- * @param projectId the project ID that owns the issue
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param issueIid the internal ID of a project's issue
* @param duration Human readable format, e.g. 3h30m
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
- public TimeStats estimateTime(Integer projectId, Integer issueIid, String duration) throws GitLabApiException {
- return (estimateTime(projectId, issueIid, new Duration(duration)));
+ public TimeStats estimateTime(Object projectIdOrPath, Integer issueIid, String duration) throws GitLabApiException {
+ return (estimateTime(projectIdOrPath, issueIid, new Duration(duration)));
}
/**
* Sets an estimated time of work in this issue
*
- * POST /projects/:id/issues/:issue_iid/time_estimate
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/time_estimate
*
- * @param projectId the project ID that owns the issue
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the internal ID of a project's issue
* @param duration set the estimate of time to this duration
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
- public TimeStats estimateTime(Integer projectId, Integer issueIid, Duration duration) throws GitLabApiException {
-
- if (projectId == null) {
- throw new RuntimeException("projectId cannot be null");
- }
+ public TimeStats estimateTime(Object projectIdOrPath, Integer issueIid, Duration duration) throws GitLabApiException {
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
@@ -472,80 +496,74 @@ public class IssuesApi extends AbstractApi implements Constants {
String durationString = (duration != null ? DurationUtils.toString(duration.getSeconds(), false) : null);
GitLabApiForm formData = new GitLabApiForm().withParam("duration", durationString, true);
- Response response = post(Response.Status.OK, formData.asMap(), "projects", projectId, "issues", issueIid, "time_estimate");
+ Response response = post(Response.Status.OK, formData.asMap(),
+ "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "time_estimate");
return (response.readEntity(TimeStats.class));
}
/**
* Resets the estimated time for this issue to 0 seconds.
*
- * POST /projects/:id/issues/:issue_iid/reset_time_estimate
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/reset_time_estimate
*
- * @param projectId the project ID that owns the issue
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the internal ID of a project's issue
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
- public TimeStats resetEstimatedTime(Integer projectId, Integer issueIid) throws GitLabApiException {
-
- if (projectId == null) {
- throw new RuntimeException("projectId cannot be null");
- }
+ public TimeStats resetEstimatedTime(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
- Response response = post(Response.Status.OK, new GitLabApiForm().asMap(), "projects", projectId, "issues", issueIid, "reset_time_estimate");
+ Response response = post(Response.Status.OK, new GitLabApiForm().asMap(), "projects",
+ getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "reset_time_estimate");
return (response.readEntity(TimeStats.class));
}
/**
* Adds spent time for this issue
*
- * POST /projects/:id/issues/:issue_iid/add_spent_time
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/add_spent_time
*
- * @param projectId the project ID that owns the issue
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the internal ID of a project's issue
* @param duration the duration in seconds
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
- public TimeStats addSpentTime(Integer projectId, Integer issueIid, int duration) throws GitLabApiException {
- return (addSpentTime(projectId, issueIid, new Duration(duration)));
+ public TimeStats addSpentTime(Object projectIdOrPath, Integer issueIid, int duration) throws GitLabApiException {
+ return (addSpentTime(projectIdOrPath, issueIid, new Duration(duration)));
}
/**
* Adds spent time for this issue
*
- * POST /projects/:id/issues/:issue_iid/add_spent_time
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/add_spent_time
*
- * @param projectId the project ID to delete the issue from
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the internal ID of a project's issue
* @param duration Human readable format, e.g. 3h30m
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
- public TimeStats addSpentTime(Integer projectId, Integer issueIid, String duration) throws GitLabApiException {
- return (addSpentTime(projectId, issueIid, new Duration(duration)));
+ public TimeStats addSpentTime(Object projectIdOrPath, Integer issueIid, String duration) throws GitLabApiException {
+ return (addSpentTime(projectIdOrPath, issueIid, new Duration(duration)));
}
/**
* Adds spent time for this issue
*
- * POST /projects/:id/issues/:issue_iid/add_spent_time
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/add_spent_time
*
- * @param projectId the project ID to delete the issue from
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the internal ID of a project's issue
* @param duration the duration of time spent
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
- public TimeStats addSpentTime(Integer projectId, Integer issueIid, Duration duration) throws GitLabApiException {
-
- if (projectId == null) {
- throw new RuntimeException("projectId cannot be null");
- }
+ public TimeStats addSpentTime(Object projectIdOrPath, Integer issueIid, Duration duration) throws GitLabApiException {
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
@@ -554,70 +572,65 @@ public class IssuesApi extends AbstractApi implements Constants {
String durationString = (duration != null ? DurationUtils.toString(duration.getSeconds(), false) : null);
GitLabApiForm formData = new GitLabApiForm().withParam("duration", durationString, true);
- Response response = post(Response.Status.CREATED, formData.asMap(), "projects", projectId, "issues", issueIid, "add_spent_time");
+ Response response = post(Response.Status.CREATED, formData.asMap(),
+ "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "add_spent_time");
return (response.readEntity(TimeStats.class));
}
/**
* Resets the total spent time for this issue to 0 seconds.
*
- * POST /projects/:id/issues/:issue_iid/reset_spent_time
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/reset_spent_time
*
- * @param projectId the project ID that owns the issue
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the internal ID of a project's issue
* @return a TimeSTats instance
* @throws GitLabApiException if any exception occurs
*/
- public TimeStats resetSpentTime(Integer projectId, Integer issueIid) throws GitLabApiException {
-
- if (projectId == null) {
- throw new RuntimeException("projectId cannot be null");
- }
+ public TimeStats resetSpentTime(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
- Response response = post(Response.Status.OK, new GitLabApiForm().asMap(), "projects", projectId, "issues", issueIid, "reset_spent_time");
+ Response response = post(Response.Status.OK, new GitLabApiForm().asMap(),
+ "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "reset_spent_time");
return (response.readEntity(TimeStats.class));
}
/**
* Get time tracking stats.
*
- * GET /projects/:id/issues/:issue_iid/time_stats
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/time_stats
*
- * @param projectId the project ID that owns the issue
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the internal ID of a project's issue
* @return a TimeStats instance
* @throws GitLabApiException if any exception occurs
*/
- public TimeStats getTimeTrackingStats(Integer projectId, Integer issueIid) throws GitLabApiException {
-
- if (projectId == null) {
- throw new RuntimeException("projectId cannot be null");
- }
+ public TimeStats getTimeTrackingStats(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
- Response response = get(Response.Status.OK, new GitLabApiForm().asMap(), "projects", projectId, "issues", issueIid, "time_stats");
+ Response response = get(Response.Status.OK, new GitLabApiForm().asMap(),
+ "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "time_stats");
return (response.readEntity(TimeStats.class));
}
/**
* Get time tracking stats as an Optional instance
*
- * GET /projects/:id/issues/:issue_iid/time_stats
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/time_stats
*
- * @param projectId the project ID that owns the issue
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the internal ID of a project's issue
* @return a TimeStats as an Optional instance
*/
- public OptionalGitLab Endpoint: GET /projects/:id/issues/:issue_iid/closed_by
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the internal ID of a project's issue
@@ -634,13 +647,13 @@ public class IssuesApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /projects/:id/issues/:issue_iid/closed_by
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the internal ID of a project's issue
@@ -658,7 +671,7 @@ public class IssuesApi extends AbstractApi implements Constants {
/**
* Get a Pager containing all the merge requests that will close issue when merged.
*
- * GET /projects/:id/issues/:issue_iid/closed_by
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/closed_by
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the internal ID of a project's issue
@@ -670,4 +683,18 @@ public class IssuesApi extends AbstractApi implements Constants {
return new PagerGitLab Endpoint: GET /projects/:id/issues/:issue_iid/closed_by
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param issueIid the internal ID of a project's issue
+ * @return a List containing all the merge requests what will close the issue when merged.
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the issue ID to get the notes for
* @return a list of the issues's notes
* @throws GitLabApiException if any exception occurs
- * @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Integer, Integer)}
+ * @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object, Integer)}
*/
- public ListGitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the issue IID to get the notes for
* @param page the page to get
* @param perPage the number of notes per page
* @return the list of notes in the specified range
* @throws GitLabApiException if any exception occurs
- * @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Integer, Integer, int, int)}
+ * @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object, Integer, int, int)}
*/
- public ListGitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the issue IID to get the notes for
* @param itemsPerPage the number of notes per page
* @return the list of notes in the specified range
* @throws GitLabApiException if any exception occurs
- * @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Integer, Integer, int)}
+ * @deprecated As of release 4.7.0, replaced by {@link #getIssueNotes(Object, Integer, int)}
*/
- public PagerGitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the issue ID to get the notes for
* @return a list of the issues's notes
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the issue IID to get the notes for
* @param page the page to get
* @param perPage the number of notes per page
* @return the list of notes in the specified range
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param issueIid the issue IID to get the notes for
* @param itemsPerPage the number of notes per page
* @return the list of notes in the specified range
* @throws GitLabApiException if any exception occurs
*/
- public PagerGitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes
+ *
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
+ * @param issueIid the issue ID to get the notes for
+ * @return a Stream of the issues's notes
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the issue ID to get the notes for
* @return a list of the merge request's notes
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the issue ID to get the notes for
* @param sortOrder return merge request notes sorted in the specified sort order, default is DESC
* @param orderBy return merge request notes ordered by CREATED_AT or UPDATED_AT, default is CREATED_AT
* @return a list of the merge request's notes
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the merge request IID to get the notes for
* @param page the page to get
* @param perPage the number of notes per page
* @return the list of notes in the specified range
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the merge request IID to get the notes for
* @param sortOrder return merge request notes sorted in the specified sort order, default is DESC
* @param orderBy return merge request notes ordered by CREATED_AT or UPDATED_AT, default is CREATED_AT
@@ -266,7 +276,7 @@ public class NotesApi extends AbstractApi {
* @return the list of notes in the specified range
* @throws GitLabApiException if any exception occurs
*/
- public ListGitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the merge request IID to get the notes for
* @param itemsPerPage the number of notes per page
* @return the list of notes in the specified range
* @throws GitLabApiException if any exception occurs
*/
- public PagerGitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes
+ *
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
+ * @param mergeRequestIid the issue ID to get the notes for
+ * @return a Stream of the merge request's notes
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes
*
- * @param projectId the project ID to get the issues for
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the merge request IID to get the notes for
* @param sortOrder return merge request notes sorted in the specified sort order, default is DESC
* @param orderBy return merge request notes ordered by CREATED_AT or UPDATED_AT, default is CREATED_AT
@@ -306,7 +331,7 @@ public class NotesApi extends AbstractApi {
* @return the list of notes in the specified range
* @throws GitLabApiException if any exception occurs
*/
- public PagerGitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes
+ *
+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
+ * @param mergeRequestIid the issue ID to get the notes for
+ * @param sortOrder return merge request notes sorted in the specified sort order, default is DESC
+ * @param orderBy return merge request notes ordered by CREATED_AT or UPDATED_AT, default is CREATED_AT
+ * @return a Stream of the merge request's notes
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /projects/:id/repository/tags
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @return the list of tags for the specified project ID
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /projects/:id/repository/tags
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param page the page to get
@@ -60,7 +59,7 @@ public class TagsApi extends AbstractApi {
/**
* Get a list of repository tags from a project, sorted by name in reverse alphabetical order.
*
- * GET /projects/:id/repository/tags
+ * GitLab Endpoint: GET /projects/:id/repository/tags
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param itemsPerPage the number of Project instances that will be fetched per page
@@ -71,10 +70,23 @@ public class TagsApi extends AbstractApi {
return (new PagerGitLab Endpoint: GET /projects/:id/repository/tags
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @return a Stream of tags for the specified project ID
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /projects/:id/repository/tags/:tagName
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param tagName the name of the tag to fetch the info for
@@ -89,7 +101,7 @@ public class TagsApi extends AbstractApi {
/**
* Get an Optional instance holding a Tag instance of a specific repository tag determined by its name.
*
- * GET /projects/:id/repository/tags/:tagName
+ * GitLab Endpoint: GET /projects/:id/repository/tags/:tagName
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param tagName the name of the tag to fetch the info for
@@ -107,7 +119,7 @@ public class TagsApi extends AbstractApi {
/**
* Creates a tag on a particular ref of the given project. A message and release notes are optional.
*
- * POST /projects/:id/repository/tags
+ * GitLab Endpoint: POST /projects/:id/repository/tags
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param tagName The name of the tag Must be unique for the project
@@ -134,7 +146,7 @@ public class TagsApi extends AbstractApi {
* release notes are optional. This method is the same as {@link #createTag(Object, String, String, String, String)},
* but instead allows the release notes to be supplied in a file.
*
- * POST /projects/:id/repository/tags
+ * GitLab Endpoint: POST /projects/:id/repository/tags
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param tagName the name of the tag, must be unique for the project
@@ -163,7 +175,7 @@ public class TagsApi extends AbstractApi {
/**
* Deletes the tag from a project with the specified tag name.
*
- * DELETE /projects/:id/repository/tags/:tag_name
+ * GitLab Endpoint: DELETE /projects/:id/repository/tags/:tag_name
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param tagName The name of the tag to delete
@@ -177,7 +189,7 @@ public class TagsApi extends AbstractApi {
/**
* Add release notes to the existing git tag.
*
- * POST /projects/:id/repository/tags/:tagName/release
+ * GitLab Endpoint: POST /projects/:id/repository/tags/:tagName/release
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param tagName the name of a tag
@@ -195,7 +207,7 @@ public class TagsApi extends AbstractApi {
/**
* Updates the release notes of a given release.
*
- * PUT /projects/:id/repository/tags/:tagName/release
+ * GitLab Endpoint: PUT /projects/:id/repository/tags/:tagName/release
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param tagName the name of a tag
diff --git a/src/main/java/org/gitlab4j/api/UserApi.java b/src/main/java/org/gitlab4j/api/UserApi.java
index e366ed0927e7f661cecddcc27f8696d09fad8e2c..01dbeded1442cfd6fa87a3ae5ab7b75634665676 100644
--- a/src/main/java/org/gitlab4j/api/UserApi.java
+++ b/src/main/java/org/gitlab4j/api/UserApi.java
@@ -14,6 +14,7 @@ import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
+import java.util.stream.Stream;
/**
* This class provides an entry point to all the GitLab API users calls.
@@ -41,23 +42,21 @@ public class UserApi extends AbstractApi {
}
/**
- * Get a list of users. Only returns the first page
- * - * GET /users + * Get a list of users. * - * @return a list of Users, this list will only contain the first 100 users in the system. + *
GitLab Endpoint: GET /users
+ *
+ * @return a list of Users
* @throws GitLabApiException if any exception occurs
*/
public List- * GET /users + * + *
GitLab Endpoint: GET /users
*
* @param page the page to get
* @param perPage the number of users per page
@@ -66,14 +65,13 @@ public class UserApi extends AbstractApi {
*/
public List- * GET /users + * + *
GitLab Endpoint: GET /users
*
* @param itemsPerPage the number of User instances that will be fetched per page
* @return a Pager of User
@@ -84,28 +82,35 @@ public class UserApi extends AbstractApi {
}
/**
- * Get a list of active users. Only returns the first page
- * - * GET /users?active=true + * Get a Stream of users. + * + *
GitLab Endpoint: GET /users
+ *
+ * @return a Stream of Users.
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamGitLab Endpoint: GET /users?active=true
*
- * @return a list of active Users, this list will only contain the first 100 users in the system.
+ * @return a list of active Users
* @throws GitLabApiException if any exception occurs
*/
public List- * GET /users?active=true * - * @param page the page to get + *
GitLab Endpoint: GET /users?active=true
+ *
+ * @param page the page to get
* @param perPage the number of users per page
* @return the list of active Users in the specified range
* @throws GitLabApiException if any exception occurs
@@ -116,14 +121,13 @@ public class UserApi extends AbstractApi {
.withParam(PAGE_PARAM, page)
.withParam(PER_PAGE_PARAM, perPage);
Response response = get(Response.Status.OK, formData.asMap(), "users");
- return (response.readEntity(new GenericType- * GET /users?active=true + * + *
GitLab Endpoint: GET /users?active=true
*
* @param itemsPerPage the number of active User instances that will be fetched per page
* @return a Pager of active User
@@ -134,10 +138,22 @@ public class UserApi extends AbstractApi {
return (new PagerGitLab Endpoint: GET /users?active=true
+ *
+ * @return a Stream of active Users
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Stream- * POST /users/:id/block + * + *
GitLab Endpoint: POST /users/:id/block
*
* @param userId the ID of the user to block
* @throws GitLabApiException if any exception occurs
@@ -156,8 +172,8 @@ public class UserApi extends AbstractApi {
/**
* Unblocks the specified user. Available only for admin.
- * - * POST /users/:id/unblock + * + *
GitLab Endpoint: POST /users/:id/unblock
*
* @param userId the ID of the user to unblock
* @throws GitLabApiException if any exception occurs
@@ -176,26 +192,21 @@ public class UserApi extends AbstractApi {
}
/**
- * Get a list of blocked users. Only returns the first page
- * - * GET /users?blocked=true + * Get a list of blocked users. * - * @return a list of blocked Users, this list will only contain the first 100 users in the system. + *
GitLab Endpoint: GET /users?blocked=true
+ *
+ * @return a list of blocked Users
* @throws GitLabApiException if any exception occurs
*/
public List- * GET /users?blocked=true + * + *
GitLab Endpoint: GET /users?blocked=true
*
* @param page the page to get
* @param perPage the number of users per page
@@ -208,14 +219,13 @@ public class UserApi extends AbstractApi {
.withParam(PAGE_PARAM, page)
.withParam(PER_PAGE_PARAM, perPage);
Response response = get(Response.Status.OK, formData.asMap(), "users");
- return (response.readEntity(new GenericType- * GET /users?blocked=true + * + *
GitLab Endpoint: GET /users?blocked=true
*
* @param itemsPerPage the number of blocked User instances that will be fetched per page
* @return a Pager of blocked User
@@ -226,10 +236,22 @@ public class UserApi extends AbstractApi {
return (new PagerGitLab Endpoint: GET /users?blocked=true
+ *
+ * @return a Stream of blocked Users
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Stream- * GET /users/:id + * + *
GitLab Endpoint: GET /users/:id
*
* @param userId the ID of the user to get
* @return the User instance for the specified user ID
@@ -243,8 +265,8 @@ public class UserApi extends AbstractApi {
/**
* Get a single user as an Optional instance.
- * - * GET /users/:id + * + *
GitLab Endpoint: GET /users/:id
*
* @param userId the ID of the user to get
* @return the User for the specified user ID as an Optional instance
@@ -259,10 +281,10 @@ public class UserApi extends AbstractApi {
/**
* Lookup a user by username.
- * - * NOTE: This is for admin users only. - *
- * GET /users?username=:username + * + *
NOTE: This is for admin users only.
+ * + *GitLab Endpoint: GET /users?username=:username
*
* @param username the username of the user to get
* @return the User instance for the specified username
@@ -271,17 +293,16 @@ public class UserApi extends AbstractApi {
public User getUser(String username) throws GitLabApiException {
GitLabApiForm formData = createGitLabApiForm().withParam("username", username, true);
Response response = get(Response.Status.OK, formData.asMap(), "users");
- List- * NOTE: This is for admin users only. - *
- * GET /users?username=:username + * + *
NOTE: This is for admin users only.
+ * + *GitLab Endpoint: GET /users?username=:username
*
* @param username the username of the user to get
* @return the User for the specified username as an Optional instance
@@ -296,26 +317,21 @@ public class UserApi extends AbstractApi {
/**
* Search users by Email or username
- * - * GET /users?search=:email_or_username + * + *
GitLab Endpoint: GET /users?search=:email_or_username
*
* @param emailOrUsername the email or username to search for
* @return the User List with the email or username like emailOrUsername
* @throws GitLabApiException if any exception occurs
*/
public List- * GET /users?search=:email_or_username + * + *
GitLab Endpoint: GET /users?search=:email_or_username
*
* @param emailOrUsername the email or username to search for
* @param page the page to get
@@ -335,8 +351,8 @@ public class UserApi extends AbstractApi {
/**
* Search users by Email or username and return a Pager
- * - * GET /users?search=:email_or_username + * + *
GitLab Endpoint: GET /users?search=:email_or_username
*
* @param emailOrUsername the email or username to search for
* @param itemsPerPage the number of Project instances that will be fetched per page
@@ -348,16 +364,29 @@ public class UserApi extends AbstractApi {
return (new PagerGitLab Endpoint: GET /users?search=:email_or_username
+ *
+ * @param emailOrUsername the email or username to search for
+ * @return a Stream of User instances with the email or username like emailOrUsername
+ * @throws GitLabApiException if any exception occurs
+ */
+ public StreamCreates a new user. Note only administrators can create new users. - * Either password or reset_password should be specified (reset_password takes priority). - *
- * If both the User object's projectsLimit and the parameter projectsLimit is specified + * Either password or reset_password should be specified (reset_password takes priority).
+ * + *If both the User object's projectsLimit and the parameter projectsLimit is specified * the parameter will take precedence.
* - *POST /users- *
- * The following properties of the provided User instance can be set during creation:
email (required) - Email
+ * GitLab Endpoint: POST /users
+ *
+ * The following properties of the provided User instance can be set during creation:
email (required) - Email
* username (required) - Username
* name (required) - Name
* skype (optional) - Skype ID
@@ -394,9 +423,9 @@ public class UserApi extends AbstractApi {
* Creates a new user. Note only administrators can create new users.
* Either password or resetPassword should be specified (resetPassword takes priority).
*
- * POST /users
- *
- * The following properties of the provided User instance can be set during creation:
email (required) - Email
+ * GitLab Endpoint: POST /users
+ *
+ * The following properties of the provided User instance can be set during creation:
email (required) - Email
* username (required) - Username
* name (required) - Name
* skype (optional) - Skype ID
@@ -431,9 +460,9 @@ public class UserApi extends AbstractApi {
/**
* Modifies an existing user. Only administrators can change attributes of a user.
*
- * PUT /users
- *
- * The following properties of the provided User instance can be set during update:
email (required) - Email
+ * GitLab Endpoint: PUT /users
+ *
+ * The following properties of the provided User instance can be set during update:
email (required) - Email
* username (required) - Username
* name (required) - Name
* skype (optional) - Skype ID
@@ -467,9 +496,9 @@ public class UserApi extends AbstractApi {
/**
* Modifies an existing user. Only administrators can change attributes of a user.
*
- * PUT /users/:id
- *
- * The following properties of the provided User instance can be set during update:
email (required) - Email
+ * GitLab Endpoint: PUT /users/:id
+ *
+ * The following properties of the provided User instance can be set during update:
email (required) - Email
* username (required) - Username
* name (required) - Name
* skype (optional) - Skype ID
@@ -505,67 +534,36 @@ public class UserApi extends AbstractApi {
/**
* Deletes a user. Available only for administrators.
- *
- * DELETE /users/:id
*
- * @param userId the user ID to delete
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteUser(Integer userId) throws GitLabApiException {
- deleteUser(userId, null);
- }
-
- /**
- * Deletes a user. Available only for administrators.
- *
- * DELETE /users/:id
+ *
GitLab Endpoint: DELETE /users/:id
*
- * @param userId the user ID to delete
- * @param hardDelete If true, contributions that would usually be moved to the
- * ghost user will be deleted instead, as well as groups owned solely by this user
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @throws GitLabApiException if any exception occurs
*/
- public void deleteUser(Integer userId, Boolean hardDelete) throws GitLabApiException {
-
- if (userId == null) {
- throw new RuntimeException("userId cannot be null");
- }
-
- GitLabApiForm formData = new GitLabApiForm().withParam("hard_delete ", hardDelete);
- Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
- delete(expectedStatus, formData.asMap(), "users", userId);
+ public void deleteUser(Object userIdOrUsername) throws GitLabApiException {
+ deleteUser(userIdOrUsername, null);
}
/**
* Deletes a user. Available only for administrators.
- *
- * DELETE /users/:id
*
- * @param user the User instance to delete
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteUser(User user) throws GitLabApiException {
- deleteUser(user.getId(), null);
- }
-
- /**
- * Deletes a user. Available only for administrators.
- *
- * DELETE /users/:id
+ *
GitLab Endpoint: DELETE /users/:id
*
- * @param user the User instance to delete
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @param hardDelete If true, contributions that would usually be moved to the
* ghost user will be deleted instead, as well as groups owned solely by this user
* @throws GitLabApiException if any exception occurs
*/
- public void deleteUser(User user, Boolean hardDelete) throws GitLabApiException {
- deleteUser(user.getId(), hardDelete);
+ public void deleteUser(Object userIdOrUsername, Boolean hardDelete) throws GitLabApiException {
+ GitLabApiForm formData = new GitLabApiForm().withParam("hard_delete ", hardDelete);
+ Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
+ delete(expectedStatus, formData.asMap(), "users", getUserIdOrUsername(userIdOrUsername));
}
/**
* Get currently authenticated user.
- *
- * GET /user
+ *
+ *
GitLab Endpoint: GET /user
*
* @return the User instance for the currently authenticated user
* @throws GitLabApiException if any exception occurs
@@ -577,24 +575,23 @@ public class UserApi extends AbstractApi {
/**
* Get a list of currently authenticated user's SSH keys.
- *
- * GET /user/keys
+ *
+ *
GitLab Endpoint: GET /user/keys
*
* @return a list of currently authenticated user's SSH keys
* @throws GitLabApiException if any exception occurs
*/
public List getSshKeys() throws GitLabApiException {
Response response = get(Response.Status.OK, getDefaultPerPageParam(), "user", "keys");
- return (response.readEntity(new GenericType>() {
- }));
+ return (response.readEntity(new GenericType>() {}));
}
/**
* Get a list of a specified user's SSH keys. Available only for admin users.
- *
- * GET /users/:id/keys
*
- * @param userId the ID of the user to get SSH keys for
+ *
GitLab Endpoint: GET /users/:id/keys
+ *
+ * @param userId the user ID to get the SSH keys for
* @return a list of a specified user's SSH keys
* @throws GitLabApiException if any exception occurs
*/
@@ -605,14 +602,10 @@ public class UserApi extends AbstractApi {
}
Response response = get(Response.Status.OK, getDefaultPerPageParam(), "users", userId, "keys");
- List keys = response.readEntity(new GenericType>() {
- });
- if (keys == null) {
- return (keys);
- }
+ List keys = response.readEntity(new GenericType>() {});
- for (SshKey key : keys) {
- key.setUserId(userId);
+ if (keys != null) {
+ keys.forEach(key -> key.setUserId(userId));
}
return (keys);
@@ -620,8 +613,8 @@ public class UserApi extends AbstractApi {
/**
* Get a single SSH Key.
- *
- * GET /user/keys/:key_id
+ *
+ *
GitLab Endpoint: GET /user/keys/:key_id
*
* @param keyId the ID of the SSH key.
* @return an SshKey instance holding the info on the SSH key specified by keyId
@@ -634,8 +627,8 @@ public class UserApi extends AbstractApi {
/**
* Get a single SSH Key as an Optional instance.
- *
- * GET /user/keys/:key_id
+ *
+ *
GitLab Endpoint: GET /user/keys/:key_id
*
* @param keyId the ID of the SSH key
* @return an SshKey as an Optional instance holding the info on the SSH key specified by keyId
@@ -650,8 +643,8 @@ public class UserApi extends AbstractApi {
/**
* Creates a new key owned by the currently authenticated user.
- *
- * POST /user/keys
+ *
+ *
GitLab Endpoint: POST /user/keys
*
* @param title the new SSH Key's title
* @param key the new SSH key
@@ -666,8 +659,8 @@ public class UserApi extends AbstractApi {
/**
* Create new key owned by specified user. Available only for admin users.
- *
- * POST /users/:id/keys
+ *
+ *
GitLab Endpoint: POST /users/:id/keys
*
* @param userId the ID of the user to add the SSH key for
* @param title the new SSH Key's title
@@ -694,8 +687,8 @@ public class UserApi extends AbstractApi {
/**
* Deletes key owned by currently authenticated user. This is an idempotent function and calling it
* on a key that is already deleted or not available results in success.
- *
- * DELETE /user/keys/:key_id
+ *
+ *
GitLab Endpoint: DELETE /user/keys/:key_id
*
* @param keyId the key ID to delete
* @throws GitLabApiException if any exception occurs
@@ -712,100 +705,86 @@ public class UserApi extends AbstractApi {
/**
* Deletes key owned by a specified user. Available only for admin users.
- *
- * DELETE /users/:id/keys/:key_id
*
- * @param userId the user ID of the user to delete the key for
+ *
GitLab Endpoint: DELETE /users/:id/keys/:key_id
+ *
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @param keyId the key ID to delete
* @throws GitLabApiException if any exception occurs
*/
- public void deleteSshKey(Integer userId, Integer keyId) throws GitLabApiException {
-
- if (userId == null) {
- throw new RuntimeException("userId cannot be null");
- }
+ public void deleteSshKey(Object userIdOrUsername, Integer keyId) throws GitLabApiException {
if (keyId == null) {
throw new RuntimeException("keyId cannot be null");
}
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
- delete(expectedStatus, null, "users", userId, "keys", keyId);
+ delete(expectedStatus, null, "users", getUserIdOrUsername(userIdOrUsername), "keys", keyId);
}
/**
* Get a list of a specified user's impersonation tokens. Available only for admin users.
- *
- * GET /users/:id/impersonation_tokens
*
- * @param userId the ID of the user to get impersonation tokens for
+ *
GitLab Endpoint: GET /users/:id/impersonation_tokens
+ *
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @return a list of a specified user's impersonation tokens
* @throws GitLabApiException if any exception occurs
*/
- public List getImpersonationTokens(Integer userId) throws GitLabApiException {
- return (getImpersonationTokens(userId, null));
+ public List getImpersonationTokens(Object userIdOrUsername) throws GitLabApiException {
+ return (getImpersonationTokens(userIdOrUsername, null));
}
/**
* Get a list of a specified user's impersonation tokens. Available only for admin users.
- *
- * GET /users/:id/impersonation_tokens
*
- * @param userId the ID of the user to get impersonation tokens for
+ *
GitLab Endpoint: GET /users/:id/impersonation_tokens
+ *
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @param state the state of impersonation tokens to list (ALL, ACTIVE, INACTIVE)
* @return a list of a specified user's impersonation tokens
* @throws GitLabApiException if any exception occurs
*/
- public List getImpersonationTokens(Integer userId, ImpersonationState state) throws GitLabApiException {
-
- if (userId == null) {
- throw new RuntimeException("userId cannot be null");
- }
-
+ public List getImpersonationTokens(Object userIdOrUsername, ImpersonationState state) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("state", state)
.withParam(PER_PAGE_PARAM, getDefaultPerPage());
- Response response = get(Response.Status.OK, formData.asMap(), "users", userId, "impersonation_tokens");
- return (response.readEntity(new GenericType>() {
- }));
+ Response response = get(Response.Status.OK, formData.asMap(), "users", getUserIdOrUsername(userIdOrUsername), "impersonation_tokens");
+ return (response.readEntity(new GenericType>() {}));
}
/**
* Get an impersonation token of a user. Available only for admin users.
- *
- * GET /users/:user_id/impersonation_tokens/:impersonation_token_id
*
- * @param userId the ID of the user to get SSH keys for
+ *
GitLab Endpoint: GET /users/:user_id/impersonation_tokens/:impersonation_token_id
+ *
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @param tokenId the impersonation token ID to get
* @return the specified impersonation token
* @throws GitLabApiException if any exception occurs
*/
- public ImpersonationToken getImpersonationToken(Integer userId, Integer tokenId) throws GitLabApiException {
-
- if (userId == null) {
- throw new RuntimeException("userId cannot be null");
- }
+ public ImpersonationToken getImpersonationToken(Object userIdOrUsername, Integer tokenId) throws GitLabApiException {
if (tokenId == null) {
throw new RuntimeException("tokenId cannot be null");
}
- Response response = get(Response.Status.OK, null, "users", userId, "impersonation_tokens", tokenId);
+ Response response = get(Response.Status.OK, null, "users", getUserIdOrUsername(userIdOrUsername), "impersonation_tokens", tokenId);
return (response.readEntity(ImpersonationToken.class));
}
/**
* Get an impersonation token of a user as an Optional instance. Available only for admin users.
- *
- * GET /users/:user_id/impersonation_tokens/:impersonation_token_id
*
- * @param userId the ID of the user to get SSH keys for
+ *
GitLab Endpoint: GET /users/:user_id/impersonation_tokens/:impersonation_token_id
+ *
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @param tokenId the impersonation token ID to get
* @return the specified impersonation token as an Optional instance
*/
- public Optional getOptionalImpersonationToken(Integer userId, Integer tokenId) {
+ public Optional getOptionalImpersonationToken(Object userIdOrUsername, Integer tokenId) {
try {
- return (Optional.ofNullable(getImpersonationToken(userId, tokenId)));
+ return (Optional.ofNullable(getImpersonationToken(userIdOrUsername, tokenId)));
} catch (GitLabApiException glae) {
return (GitLabApi.createOptionalFromException(glae));
}
@@ -813,21 +792,17 @@ public class UserApi extends AbstractApi {
/**
* Create an impersonation token. Available only for admin users.
- *
- * POST /users/:user_id/impersonation_tokens
*
- * @param userId the ID of the user to get SSH keys for
- * @param name the name of the impersonation token, required
+ *
GitLab Endpoint: POST /users/:user_id/impersonation_tokens
+ *
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
+ * @param name the name of the impersonation token, required
* @param expiresAt the expiration date of the impersonation token, optional
- * @param scopes an array of scopes of the impersonation token
+ * @param scopes an array of scopes of the impersonation token
* @return the created ImpersonationToken instance
* @throws GitLabApiException if any exception occurs
*/
- public ImpersonationToken createImpersonationToken(Integer userId, String name, Date expiresAt, Scope[] scopes) throws GitLabApiException {
-
- if (userId == null) {
- throw new RuntimeException("userId cannot be null");
- }
+ public ImpersonationToken createImpersonationToken(Object userIdOrUsername, String name, Date expiresAt, Scope[] scopes) throws GitLabApiException {
if (scopes == null || scopes.length == 0) {
throw new RuntimeException("scopes cannot be null or empty");
@@ -841,31 +816,27 @@ public class UserApi extends AbstractApi {
formData.withParam("scopes[]", scope.toString());
}
- Response response = post(Response.Status.CREATED, formData, "users", userId, "impersonation_tokens");
+ Response response = post(Response.Status.CREATED, formData, "users", getUserIdOrUsername(userIdOrUsername), "impersonation_tokens");
return (response.readEntity(ImpersonationToken.class));
}
/**
* Revokes an impersonation token. Available only for admin users.
- *
- * DELETE /users/:user_id/impersonation_tokens/:impersonation_token_id
*
- * @param userId the user ID of the user to revoke the impersonation token for
+ *
GitLab Endpoint: DELETE /users/:user_id/impersonation_tokens/:impersonation_token_id
+ *
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @param tokenId the impersonation token ID to revoke
* @throws GitLabApiException if any exception occurs
*/
- public void revokeImpersonationToken(Integer userId, Integer tokenId) throws GitLabApiException {
-
- if (userId == null) {
- throw new RuntimeException("userId cannot be null");
- }
+ public void revokeImpersonationToken(Object userIdOrUsername, Integer tokenId) throws GitLabApiException {
if (tokenId == null) {
throw new RuntimeException("tokenId cannot be null");
}
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
- delete(expectedStatus, null, "users", userId, "impersonation_tokens", tokenId);
+ delete(expectedStatus, null, "users", getUserIdOrUsername(userIdOrUsername), "impersonation_tokens", tokenId);
}
/**
@@ -878,11 +849,13 @@ public class UserApi extends AbstractApi {
* @return the populated Form instance
*/
Form userToForm(User user, Integer projectsLimit, CharSequence password, Boolean resetPassword, boolean create) {
+
if (create) {
if ((password == null || password.toString().trim().isEmpty()) && !resetPassword) {
throw new IllegalArgumentException("either password or reset_password must be set");
}
}
+
projectsLimit = (projectsLimit == null) ? user.getProjectsLimit() : projectsLimit;
String skipConfirmationFeildName = create ? "skip_confirmation" : "skip_reconfirmation";
@@ -912,31 +885,29 @@ public class UserApi extends AbstractApi {
/**
* Creates custom attribute for the given user
*
- * @param userId to set the customAttributes for
- * @param customAttribute to set
- * @return createdCustomAttribute
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
+ * @param customAttribute the custom attribute to set
+ * @return the created CustomAttribute
* @throws GitLabApiException on failure while setting customAttributes
*/
- public CustomAttribute createCustomAttribute(final Integer userId, final CustomAttribute customAttribute) throws GitLabApiException {
+ public CustomAttribute createCustomAttribute(final Object userIdOrUsername, final CustomAttribute customAttribute) throws GitLabApiException {
if (Objects.isNull(customAttribute)) {
throw new IllegalArgumentException("CustomAttributes can't be null");
}
- return createCustomAttribute(userId, customAttribute.getKey(), customAttribute.getValue());
+ return createCustomAttribute(userIdOrUsername, customAttribute.getKey(), customAttribute.getValue());
}
/**
* Creates custom attribute for the given user
*
- * @param userId to set the customAttributes for
- * @param key for the customAttribute
- * @param value for the customAttribute
- * @return createdCustomAttribute
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
+ * @param key for the customAttribute
+ * @param value or the customAttribute
+ * @return the created CustomAttribute
* @throws GitLabApiException on failure while setting customAttributes
*/
- public CustomAttribute createCustomAttribute(final Integer userId, final String key, final String value) throws GitLabApiException {
- if (Objects.isNull(userId)) {
- throw new IllegalArgumentException("UserId can't be null.");
- }
+ public CustomAttribute createCustomAttribute(final Object userIdOrUsername, final String key, final String value) throws GitLabApiException {
+
if (Objects.isNull(key) || key.trim().isEmpty()) {
throw new IllegalArgumentException("Key can't be null or empty");
}
@@ -944,73 +915,73 @@ public class UserApi extends AbstractApi {
throw new IllegalArgumentException("Value can't be null or empty");
}
- GitLabApiForm formData = new GitLabApiForm()
- .withParam("value", value);
- Response response = put(Response.Status.OK, formData.asMap(), "users", userId, "custom_attributes", key);
+ GitLabApiForm formData = new GitLabApiForm().withParam("value", value);
+ Response response = put(Response.Status.OK, formData.asMap(),
+ "users", getUserIdOrUsername(userIdOrUsername), "custom_attributes", key);
return (response.readEntity(CustomAttribute.class));
}
/**
* Change custom attribute for the given user
*
- * @param userId to change the customAttributes for
- * @param customAttribute to change
- * @return changedCustomAttribute
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
+ * @param customAttribute the custome attribute to change
+ * @return the changed CustomAttribute
* @throws GitLabApiException on failure while changing customAttributes
*/
- public CustomAttribute changeCustomAttribute(final Integer userId, final CustomAttribute customAttribute) throws GitLabApiException {
+ public CustomAttribute changeCustomAttribute(final Object userIdOrUsername, final CustomAttribute customAttribute) throws GitLabApiException {
+
if (Objects.isNull(customAttribute)) {
throw new IllegalArgumentException("CustomAttributes can't be null");
}
//changing & creating custom attributes is the same call in gitlab api
// -> https://docs.gitlab.com/ce/api/custom_attributes.html#set-custom-attribute
- return createCustomAttribute(userId, customAttribute.getKey(), customAttribute.getValue());
+ return createCustomAttribute(userIdOrUsername, customAttribute.getKey(), customAttribute.getValue());
}
/**
* Changes custom attribute for the given user
*
- * @param userId to change the customAttribute for
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @param key for the customAttribute
* @param value for the customAttribute
* @return changedCustomAttribute
* @throws GitLabApiException on failure while changing customAttributes
*/
- public CustomAttribute changeCustomAttribute(final Integer userId, final String key, final String value) throws GitLabApiException {
- return createCustomAttribute(userId, key, value);
+ public CustomAttribute changeCustomAttribute(final Object userIdOrUsername, final String key, final String value) throws GitLabApiException {
+ return createCustomAttribute(userIdOrUsername, key, value);
}
/**
* Delete a custom attribute for the given user
*
- * @param userId to delete the customAttribute for
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @param customAttribute to remove
* @throws GitLabApiException on failure while deleting customAttributes
*/
- public void deleteCustomAttribute(final Integer userId, final CustomAttribute customAttribute) throws GitLabApiException {
+ public void deleteCustomAttribute(final Object userIdOrUsername, final CustomAttribute customAttribute) throws GitLabApiException {
if (Objects.isNull(customAttribute)) {
throw new IllegalArgumentException("customAttributes can't be null");
}
- deleteCustomAttribute(userId, customAttribute.getKey());
+ deleteCustomAttribute(userIdOrUsername, customAttribute.getKey());
}
/**
* Delete a custom attribute for the given user
*
- * @param userId to delete the customAttribute for
+ * @param userIdOrUsername the user in the form of an Integer(ID), String(username), or User instance
* @param key of the customAttribute to remove
* @throws GitLabApiException on failure while deleting customAttributes
*/
- public void deleteCustomAttribute(final Integer userId, final String key) throws GitLabApiException {
- if (Objects.isNull(userId)) {
- throw new IllegalArgumentException("UserId can't be null");
- }
+ public void deleteCustomAttribute(final Object userIdOrUsername, final String key) throws GitLabApiException {
+
if (Objects.isNull(key) || key.trim().isEmpty()) {
throw new IllegalArgumentException("Key can't be null or empty");
}
- delete(Response.Status.OK, null, "users", userId, "custom_attributes", key);
+
+ delete(Response.Status.OK, null, "users", getUserIdOrUsername(userIdOrUsername), "custom_attributes", key);
}
/**