Commit a85c0ec1 authored by Greg Messner's avatar Greg Messner
Browse files

Misc code clean-up.

parent 6456679d
package org.gitlab4j.api; package org.gitlab4j.api;
import org.gitlab4j.api.utils.JacksonJsonEnumHelper;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonValue;
import org.gitlab4j.api.utils.JacksonJsonEnumHelper;
public interface Constants { public interface Constants {
......
...@@ -34,7 +34,7 @@ public class GitLabApi { ...@@ -34,7 +34,7 @@ public class GitLabApi {
private GroupApi groupApi; private GroupApi groupApi;
private IssuesApi issuesApi; private IssuesApi issuesApi;
private MergeRequestApi mergeRequestApi; private MergeRequestApi mergeRequestApi;
private MileStonesApi mileStonesApi; private MilestonesApi milestonesApi;
private NamespaceApi namespaceApi; private NamespaceApi namespaceApi;
private PipelineApi pipelineApi; private PipelineApi pipelineApi;
private ProjectApi projectApi; private ProjectApi projectApi;
...@@ -324,7 +324,7 @@ public class GitLabApi { ...@@ -324,7 +324,7 @@ public class GitLabApi {
jobApi = new JobApi(this); jobApi = new JobApi(this);
labelsApi = new LabelsApi(this); labelsApi = new LabelsApi(this);
mergeRequestApi = new MergeRequestApi(this); mergeRequestApi = new MergeRequestApi(this);
mileStonesApi = new MileStonesApi(this); milestonesApi = new MilestonesApi(this);
namespaceApi = new NamespaceApi(this); namespaceApi = new NamespaceApi(this);
notesApi = new NotesApi(this); notesApi = new NotesApi(this);
pipelineApi = new PipelineApi(this); pipelineApi = new PipelineApi(this);
...@@ -547,8 +547,13 @@ public class GitLabApi { ...@@ -547,8 +547,13 @@ public class GitLabApi {
return (mergeRequestApi); return (mergeRequestApi);
} }
public MileStonesApi getMileStonesApi() { /**
return mileStonesApi; * Gets the MilsestonesApi instance owned by this GitLabApi instance.
*
* @return the MilsestonesApi instance owned by this GitLabApi instance
*/
public MilestonesApi getMilestonesApi() {
return milestonesApi;
} }
/** /**
......
package org.gitlab4j.api; package org.gitlab4j.api;
import org.gitlab4j.api.models.Label; import java.util.List;
import javax.ws.rs.core.GenericType; import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List;
import org.gitlab4j.api.models.Label;
public class LabelsApi extends AbstractApi { public class LabelsApi extends AbstractApi {
public LabelsApi(GitLabApi gitLabApi) { public LabelsApi(GitLabApi gitLabApi) {
...@@ -12,19 +13,23 @@ public class LabelsApi extends AbstractApi { ...@@ -12,19 +13,23 @@ public class LabelsApi extends AbstractApi {
} }
public List<Label> getLabels(Integer projectId) throws GitLabApiException { public List<Label> getLabels(Integer projectId) throws GitLabApiException {
if (projectId == null) { if (projectId == null) {
throw new RuntimeException("projectId cannot be null"); throw new RuntimeException("projectId cannot be null");
} }
Response response = get(javax.ws.rs.core.Response.Status.OK, getDefaultPerPageParam(), "projects", projectId, "labels"); Response response = get(javax.ws.rs.core.Response.Status.OK, getDefaultPerPageParam(), "projects", projectId, "labels");
return (response.readEntity(new GenericType<List<Label>>() { return (response.readEntity(new GenericType<List<Label>>() {
})); }));
} }
public List<Label> getLabels(Integer projectId, int page, int perPage) throws GitLabApiException { public List<Label> getLabels(Integer projectId, int page, int perPage) throws GitLabApiException {
if (projectId == null) { if (projectId == null) {
throw new RuntimeException("projectId cannot be null"); throw new RuntimeException("projectId cannot be null");
} }
Response response = get(javax.ws.rs.core.Response.Status.OK, getPageQueryParams(page, perPage), "projects", projectId, "labels");
Response response = get(javax.ws.rs.core.Response.Status.OK, getPageQueryParams(page, perPage), "projects", projectId, "labels");
return (response.readEntity(new GenericType<List<Label>>() { return (response.readEntity(new GenericType<List<Label>>() {
})); }));
} }
...@@ -42,10 +47,12 @@ public class LabelsApi extends AbstractApi { ...@@ -42,10 +47,12 @@ public class LabelsApi extends AbstractApi {
} }
public Label createLabel(Integer projectId, String name, String color, String description, Integer priority) throws GitLabApiException { public Label createLabel(Integer projectId, String name, String color, String description, Integer priority) throws GitLabApiException {
if (projectId == null) {
if (projectId == null) {
throw new RuntimeException("projectId cannot be null"); throw new RuntimeException("projectId cannot be null");
} }
GitLabApiForm formData = new GitLabApiForm()
GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true) .withParam("name", name, true)
.withParam("color", color, true) .withParam("color", color, true)
.withParam("description", description) .withParam("description", description)
...@@ -63,9 +70,11 @@ public class LabelsApi extends AbstractApi { ...@@ -63,9 +70,11 @@ public class LabelsApi extends AbstractApi {
} }
public Label updateLabel(Integer projectId, String name, String newName, String color, String description, Integer priority) throws GitLabApiException { public Label updateLabel(Integer projectId, String name, String newName, String color, String description, Integer priority) throws GitLabApiException {
if (projectId == null) { if (projectId == null) {
throw new RuntimeException("projectId cannot be null"); throw new RuntimeException("projectId cannot be null");
} }
GitLabApiForm formData = new GitLabApiForm() GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true) .withParam("name", name, true)
.withParam("new_name", newName) .withParam("new_name", newName)
...@@ -77,9 +86,11 @@ public class LabelsApi extends AbstractApi { ...@@ -77,9 +86,11 @@ public class LabelsApi extends AbstractApi {
} }
public void deleteLabel(Integer projectId, String name) throws GitLabApiException { public void deleteLabel(Integer projectId, String name) throws GitLabApiException {
if (projectId == null) { if (projectId == null) {
throw new RuntimeException("projectId cannot be null"); throw new RuntimeException("projectId cannot be null");
} }
GitLabApiForm formData = new GitLabApiForm() GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true); .withParam("name", name, true);
Response.Status expectedStatus = (isApiVersion(GitLabApi.ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT); Response.Status expectedStatus = (isApiVersion(GitLabApi.ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
......
package org.gitlab4j.api; package org.gitlab4j.api;
import org.gitlab4j.api.models.Note; import java.util.Date;
import java.util.List;
import javax.ws.rs.core.GenericType; import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Date;
import java.util.List; import org.gitlab4j.api.models.Note;
public class NotesApi extends AbstractApi { public class NotesApi extends AbstractApi {
...@@ -13,6 +14,54 @@ public class NotesApi extends AbstractApi { ...@@ -13,6 +14,54 @@ public class NotesApi extends AbstractApi {
super(gitLabApi); super(gitLabApi);
} }
/**
* Get a list of the issues's notes. Only returns the first page
*
* GET /projects/:id/issues/:issue_iid/notes
*
* @param projectId the project ID to get the issues for
* @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)}
*/
public List<Note> getNotes(Integer projectId, Integer issueIid) throws GitLabApiException {
return (getIssueNotes(projectId, issueIid));
}
/**
* Get a list of the issue's notes using the specified page and per page settings.
*
* GET /projects/:id/issues/:issue_iid/notes
*
* @param projectId the project ID to get the issues for
* @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)}
*/
public List<Note> getNotes(Integer projectId, Integer issueIid, int page, int perPage) throws GitLabApiException {
return (getIssueNotes(projectId, issueIid, page, perPage));
}
/**
* Get a Pager of issues's notes.
*
* GET /projects/:id/issues/:issue_iid/notes
*
* @param projectId the project ID to get the issues for
* @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)}
*/
public Pager<Note> getNotes(Integer projectId, Integer issueIid, int itemsPerPage) throws GitLabApiException {
return (getIssueNotes(projectId, issueIid, itemsPerPage));
}
/** /**
* Get a list of the issues's notes. Only returns the first page * Get a list of the issues's notes. Only returns the first page
* *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment