Skip to content

Commit

Permalink
Misc code clean-up.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmessner committed Nov 30, 2017
1 parent 6456679 commit a85c0ec
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/gitlab4j/api/Constants.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.gitlab4j.api;

import org.gitlab4j.api.utils.JacksonJsonEnumHelper;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import org.gitlab4j.api.utils.JacksonJsonEnumHelper;

public interface Constants {

Expand Down
13 changes: 9 additions & 4 deletions src/main/java/org/gitlab4j/api/GitLabApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public String getApiNamespace() {
private GroupApi groupApi;
private IssuesApi issuesApi;
private MergeRequestApi mergeRequestApi;
private MileStonesApi mileStonesApi;
private MilestonesApi milestonesApi;
private NamespaceApi namespaceApi;
private PipelineApi pipelineApi;
private ProjectApi projectApi;
Expand Down Expand Up @@ -324,7 +324,7 @@ public GitLabApi(ApiVersion apiVersion, String hostUrl, TokenType tokenType, Str
jobApi = new JobApi(this);
labelsApi = new LabelsApi(this);
mergeRequestApi = new MergeRequestApi(this);
mileStonesApi = new MileStonesApi(this);
milestonesApi = new MilestonesApi(this);
namespaceApi = new NamespaceApi(this);
notesApi = new NotesApi(this);
pipelineApi = new PipelineApi(this);
Expand Down Expand Up @@ -547,8 +547,13 @@ public MergeRequestApi getMergeRequestApi() {
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;
}

/**
Expand Down
21 changes: 16 additions & 5 deletions src/main/java/org/gitlab4j/api/LabelsApi.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
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.Response;
import java.util.List;

import org.gitlab4j.api.models.Label;

public class LabelsApi extends AbstractApi {
public LabelsApi(GitLabApi gitLabApi) {
super(gitLabApi);
}

public List<Label> getLabels(Integer projectId) throws GitLabApiException {

if (projectId == null) {
throw new RuntimeException("projectId cannot be null");
}

Response response = get(javax.ws.rs.core.Response.Status.OK, getDefaultPerPageParam(), "projects", projectId, "labels");
return (response.readEntity(new GenericType<List<Label>>() {
}));
}

public List<Label> getLabels(Integer projectId, int page, int perPage) throws GitLabApiException {

if (projectId == 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>>() {
}));
}
Expand All @@ -42,10 +47,12 @@ public Label createLabel(Integer projectId, String name, String color, Integer p
}

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");
}
GitLabApiForm formData = new GitLabApiForm()

GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true)
.withParam("color", color, true)
.withParam("description", description)
Expand All @@ -63,9 +70,11 @@ public Label updateLabelColor(Integer projectId, String name, String color, Stri
}

public Label updateLabel(Integer projectId, String name, String newName, String color, String description, Integer priority) throws GitLabApiException {

if (projectId == null) {
throw new RuntimeException("projectId cannot be null");
}

GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true)
.withParam("new_name", newName)
Expand All @@ -77,9 +86,11 @@ public Label updateLabel(Integer projectId, String name, String newName, String
}

public void deleteLabel(Integer projectId, String name) throws GitLabApiException {

if (projectId == null) {
throw new RuntimeException("projectId cannot be null");
}

GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true);
Response.Status expectedStatus = (isApiVersion(GitLabApi.ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
Expand Down
55 changes: 52 additions & 3 deletions src/main/java/org/gitlab4j/api/NotesApi.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,67 @@
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.Response;
import java.util.Date;
import java.util.List;

import org.gitlab4j.api.models.Note;

public class NotesApi extends AbstractApi {

public NotesApi(GitLabApi 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
*
Expand Down

0 comments on commit a85c0ec

Please sign in to comment.