getIssueLabelEventsStream(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
+ return (getIssueLabelEvents(projectIdOrPath, issueIid, getDefaultPerPage()).stream());
+ }
+
+ /**
+ * Get a single label event for a specific project issue.
+ *
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/resource_label_events/:resource_label_event_id
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param issueIid the IID of the issue
+ * @param resourceLabelEventId the ID of a label event
+ * @return LabelEvent instance for the specified project issue
+ * @throws GitLabApiException if any exception occurs
+ */
+ public LabelEvent getIssueLabelEvent(Object projectIdOrPath, Integer issueIid, Integer resourceLabelEventId) throws GitLabApiException {
+ Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath),
+ "issues", issueIid, "resource_label_events", resourceLabelEventId);
+ return (response.readEntity(LabelEvent.class));
+ }
+
+ /**
+ * Get an Optional instance holding a LabelEvent for a specific project issue
+ *
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/resource_label_events/:resource_label_event_id
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param issueIid the IID of the issue
+ * @param resourceLabelEventId the ID of a label event
+ * @return an Optional instance with the specified LabelEvent as the value
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Optional getOptionalIssueLabelEvent(Object projectIdOrPath,
+ Integer issueIid, Integer resourceLabelEventId) throws GitLabApiException {
+
+ try {
+ return (Optional.ofNullable(getIssueLabelEvent(projectIdOrPath, issueIid, resourceLabelEventId)));
+ } catch (GitLabApiException glae) {
+ return (GitLabApi.createOptionalFromException(glae));
+ }
+ }
+
+ /**
+ * Gets a list of all label events for an epic.
+ *
+ * GitLab Endpoint: GET /projects/:id/epics/:epic_id/resource_label_events
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param epicId the ID of the epic
+ * @return a List of LabelEvent for the specified epic
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getEpicLabelEvents(Object projectIdOrPath, Integer epicId) throws GitLabApiException {
+ return (getEpicLabelEvents(projectIdOrPath, epicId, getDefaultPerPage()).all());
+ }
+
+ /**
+ * Gets a Pager of all label events for the specified epic.
+ *
+ * GitLab Endpoint: GET /projects/:id/epics/:epic_id/resource_label_events
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param epicId the ID of the epic
+ * @param itemsPerPage the number of LabelEvent instances that will be fetched per page
+ * @return the Pager of LabelEvent instances for the specified epic
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Pager getEpicLabelEvents(Object projectIdOrPath, Integer epicId, int itemsPerPage) throws GitLabApiException {
+ return (new Pager(this, LabelEvent.class, itemsPerPage, null,
+ "projects", getProjectIdOrPath(projectIdOrPath), "epics", epicId, "resource_label_events"));
+ }
+
+ /**
+ * Gets a Stream of all label events for he specified epic.
+ *
+ * GitLab Endpoint: GET /projects/:id/epics/:epic_id/resource_label_events
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param epicId the ID of the epic
+ * @return a Stream of LabelEvent for the specified epic
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Stream getEpicLabelEventsStream(Object projectIdOrPath, Integer epicId) throws GitLabApiException {
+ return (getEpicLabelEvents(projectIdOrPath, epicId, getDefaultPerPage()).stream());
+ }
+
+ /**
+ * Get a single label event for a specific epic label event.
+ *
+ * GitLab Endpoint: GET /projects/:id/epics/:epic_id/resource_label_events/:resource_label_event_id
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param epicId the ID of the epic
+ * @param resourceLabelEventId the ID of a label event
+ * @return LabelEvent instance for the specified epic label event
+ * @throws GitLabApiException if any exception occurs
+ */
+ public LabelEvent getEpicLabelEvent(Object projectIdOrPath, Integer epicId, Integer resourceLabelEventId) throws GitLabApiException {
+ Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath),
+ "epics", epicId, "resource_label_events", resourceLabelEventId);
+ return (response.readEntity(LabelEvent.class));
+ }
+
+ /**
+ * Get an Optional instance holding a LabelEvent for a specific epic label event.
+ *
+ * GitLab Endpoint: GET /projects/:id/epics/:epic_id/resource_label_events/:resource_label_event_id
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param epicId the ID of the epic
+ * @param resourceLabelEventId the ID of a label event
+ * @return an Optional instance with the specified LabelEvent as the value
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Optional getOptionalEpicLabelEvent(Object projectIdOrPath,
+ Integer epicId, Integer resourceLabelEventId) throws GitLabApiException {
+
+ try {
+ return (Optional.ofNullable(getEpicLabelEvent(projectIdOrPath, epicId, resourceLabelEventId)));
+ } catch (GitLabApiException glae) {
+ return (GitLabApi.createOptionalFromException(glae));
+ }
+ }
+
+ /**
+ * Gets a list of all label events for a merge request.
+ *
+ * GitLab Endpoint: GET /projects/:id/merge_requests/:epic_id/resource_label_events
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param mergeRequestIid the IID of the merge request
+ * @return a List of LabelEvent for the specified merge request
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getMergeRequestLabelEvents(Object projectIdOrPath, Integer mergeRequestIid) throws GitLabApiException {
+ return (getMergeRequestLabelEvents(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).all());
+ }
+
+ /**
+ * Gets a Pager of all label events for the specified merge request.
+ *
+ * GitLab Endpoint: GET /projects/:id/merge_requests/:epic_id/resource_label_events
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param mergeRequestIid the IID of the merge request
+ * @param itemsPerPage the number of LabelEvent instances that will be fetched per page
+ * @return the Pager of LabelEvent instances for the specified merge request
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Pager getMergeRequestLabelEvents(Object projectIdOrPath, Integer mergeRequestIid, int itemsPerPage) throws GitLabApiException {
+ return (new Pager(this, LabelEvent.class, itemsPerPage, null,
+ "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "resource_label_events"));
+ }
+
+ /**
+ * Gets a Stream of all label events for he specified merge request.
+ *
+ * GitLab Endpoint: GET /projects/:id/merge_requests/:issue_iid/resource_label_events
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param mergeRequestIid the IID of the merge request
+ * @return a Stream of LabelEvent for the specified merge request
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Stream getMergeRequestLabelEventsStream(Object projectIdOrPath, Integer mergeRequestIid) throws GitLabApiException {
+ return (getMergeRequestLabelEvents(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).stream());
+ }
+
+ /**
+ * Get a single label event for a specific merge request label event.
+ *
+ * GitLab Endpoint: GET /projects/:id/merge_requests/:epic_id/resource_label_events/:resource_label_event_id
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param mergeRequestIid the IID of the merge request
+ * @param resourceLabelEventId the ID of a label event
+ * @return LabelEvent instance for the specified epic label event
+ * @throws GitLabApiException if any exception occurs
+ */
+ public LabelEvent getMergeRequestLabelEvent(Object projectIdOrPath, Integer mergeRequestIid, Integer resourceLabelEventId) throws GitLabApiException {
+ Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath),
+ "merge_requests", mergeRequestIid, "resource_label_events", resourceLabelEventId);
+ return (response.readEntity(LabelEvent.class));
+ }
+
+ /**
+ * Get an Optional instance holding a LabelEvent for a specific merge request label event.
+ *
+ * GitLab Endpoint: GET /projects/:id/merge_requests/:issue_iid/resource_label_events/:resource_label_event_id
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
+ * @param mergeRequestIid the IID of the merge request
+ * @param resourceLabelEventId the ID of a label event
+ * @return an Optional instance with the specified LabelEvent as the value
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Optional getOptionalMergeRequestLabelEvent(Object projectIdOrPath,
+ Integer mergeRequestIid, Integer resourceLabelEventId) throws GitLabApiException {
+
+ try {
+ return (Optional.ofNullable(getMergeRequestLabelEvent(projectIdOrPath, mergeRequestIid, resourceLabelEventId)));
+ } catch (GitLabApiException glae) {
+ return (GitLabApi.createOptionalFromException(glae));
+ }
+ }
+}
diff --git a/src/main/java/org/gitlab4j/api/models/LabelEvent.java b/src/main/java/org/gitlab4j/api/models/LabelEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..191dd4c940aa68ee4b49b3b7a1f21b624b3a4a7b
--- /dev/null
+++ b/src/main/java/org/gitlab4j/api/models/LabelEvent.java
@@ -0,0 +1,103 @@
+package org.gitlab4j.api.models;
+
+import org.gitlab4j.api.utils.JacksonJson;
+import org.gitlab4j.api.utils.JacksonJsonEnumHelper;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+public class LabelEvent {
+
+ /** Enum to use for specifying the label event resource type. */
+ public enum ResourceType {
+
+ ISSUE, EPIC, MERGE_REQUEST;
+
+ private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ResourceType.class,
+ true, true);
+
+ @JsonCreator
+ public static ResourceType forValue(String value) {
+ return enumHelper.forValue(value);
+ }
+
+ @JsonValue
+ public String toValue() {
+ return (enumHelper.toString(this));
+ }
+
+ @Override
+ public String toString() {
+ return (enumHelper.toString(this));
+ }
+ }
+
+ private int id;
+ private User user;
+ private String createdAt;
+ private ResourceType resourceType;
+ private int resourceId;
+ private Label label;
+ private String action;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+ public String getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(String createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(ResourceType resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(int resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public Label getLabel() {
+ return label;
+ }
+
+ public void setLabel(Label label) {
+ this.label = label;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ @Override
+ public String toString() {
+ return (JacksonJson.toJsonString(this));
+ }
+}
diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
index f107ca09f1bda5c62f89dfaaa2ee7dd59f8c5331..1d42a82f08f3f604b1a8a4eb26c6230427dfe947 100644
--- a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
+++ b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
@@ -69,6 +69,7 @@ import org.gitlab4j.api.models.IssuesStatistics;
import org.gitlab4j.api.models.Job;
import org.gitlab4j.api.models.Key;
import org.gitlab4j.api.models.Label;
+import org.gitlab4j.api.models.LabelEvent;
import org.gitlab4j.api.models.Member;
import org.gitlab4j.api.models.MergeRequest;
import org.gitlab4j.api.models.Milestone;
@@ -289,6 +290,12 @@ public class TestGitLabApiBeans {
assertTrue(compareJson(issueLink, "issue-link.json"));
}
+ @Test
+ public void testLabelEvents() throws Exception {
+ List events = unmarshalResourceList(LabelEvent.class, "label-events.json");
+ assertTrue(compareJson(events, "label-events.json"));
+ }
+
@Test
public void testLinkedIssues() throws Exception {
List linkedIssues = unmarshalResourceList(Issue.class, "linked-issues.json");
diff --git a/src/test/resources/org/gitlab4j/api/label-events.json b/src/test/resources/org/gitlab4j/api/label-events.json
new file mode 100644
index 0000000000000000000000000000000000000000..c5ca4879604ecc73860ce8c259ff01a6b47f1d3a
--- /dev/null
+++ b/src/test/resources/org/gitlab4j/api/label-events.json
@@ -0,0 +1,128 @@
+[
+ {
+ "id": 142,
+ "user": {
+ "id": 1,
+ "name": "Administrator",
+ "username": "root",
+ "state": "active",
+ "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
+ "web_url": "http://gitlab.example.com/root"
+ },
+ "created_at": "2018-08-20T13:38:20.077Z",
+ "resource_type": "Issue",
+ "resource_id": 253,
+ "label": {
+ "id": 73,
+ "name": "a1",
+ "color": "#34495E",
+ "description": ""
+ },
+ "action": "add"
+ },
+ {
+ "id": 143,
+ "user": {
+ "id": 1,
+ "name": "Administrator",
+ "username": "root",
+ "state": "active",
+ "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
+ "web_url": "http://gitlab.example.com/root"
+ },
+ "created_at": "2018-08-20T13:38:20.077Z",
+ "resource_type": "Issue",
+ "resource_id": 253,
+ "label": {
+ "id": 74,
+ "name": "p1",
+ "color": "#0033CC",
+ "description": ""
+ },
+ "action": "remove"
+ },
+ {
+ "id": 106,
+ "user": {
+ "id": 1,
+ "name": "Administrator",
+ "username": "root",
+ "state": "active",
+ "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
+ "web_url": "http://gitlab.example.com/root"
+ },
+ "created_at": "2018-08-19T11:43:01.746Z",
+ "resource_type": "Epic",
+ "resource_id": 33,
+ "label": {
+ "id": 73,
+ "name": "a1",
+ "color": "#34495E",
+ "description": ""
+ },
+ "action": "add"
+ },
+ {
+ "id": 107,
+ "user": {
+ "id": 1,
+ "name": "Administrator",
+ "username": "root",
+ "state": "active",
+ "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
+ "web_url": "http://gitlab.example.com/root"
+ },
+ "created_at": "2018-08-19T11:43:01.746Z",
+ "resource_type": "Epic",
+ "resource_id": 33,
+ "label": {
+ "id": 37,
+ "name": "glabel2",
+ "color": "#A8D695",
+ "description": ""
+ },
+ "action": "add"
+ },
+ {
+ "id": 119,
+ "user": {
+ "id": 1,
+ "name": "Administrator",
+ "username": "root",
+ "state": "active",
+ "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
+ "web_url": "http://gitlab.example.com/root"
+ },
+ "created_at": "2018-08-20T06:17:28.394Z",
+ "resource_type": "MergeRequest",
+ "resource_id": 28,
+ "label": {
+ "id": 74,
+ "name": "p1",
+ "color": "#0033CC",
+ "description": ""
+ },
+ "action": "add"
+ },
+ {
+ "id": 120,
+ "user": {
+ "id": 1,
+ "name": "Administrator",
+ "username": "root",
+ "state": "active",
+ "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
+ "web_url": "http://gitlab.example.com/root"
+ },
+ "created_at": "2018-08-20T06:17:28.394Z",
+ "resource_type": "MergeRequest",
+ "resource_id": 28,
+ "label": {
+ "id": 41,
+ "name": "project",
+ "color": "#D1D100",
+ "description": ""
+ },
+ "action": "add"
+ }
+]
\ No newline at end of file