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

Mods to support IssuesApi (#69)

parent 7abd37b4
......@@ -143,7 +143,28 @@ public interface Constants {
}
}
/** Enum to use for specifying the state of a merge request update. */
/** Enum to use for specifying the scope when calling the various get issue methods. */
public enum IssueScope {
CREATED_BY_ME, ASSIGNED_TO_ME, ALL;
private static JacksonJsonEnumHelper<IssueScope> enumHelper = new JacksonJsonEnumHelper<>(IssueScope.class);
@JsonCreator
public static IssueScope forValue(String value) { return enumHelper.forValue(value); }
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@Override
public String toString() {
return (enumHelper.toString(this));
}
}
/** Enum to use for specifying the state of a merge request or issue update. */
public enum StateEvent {
CLOSE, REOPEN;
......@@ -165,6 +186,29 @@ public interface Constants {
}
}
/** Enum to used to store the state of an issue. */
public enum IssueState {
OPENED, CLOSED, REOPENED;
private static JacksonJsonEnumHelper<IssueState> enumHelper = new JacksonJsonEnumHelper<>(IssueState.class);
@JsonCreator
public static IssueState forValue(String value) {
return enumHelper.forValue(value);
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@Override
public String toString() {
return (enumHelper.toString(this));
}
}
/** Enum to use for specifying the event action_type. */
public enum ActionType {
......
......@@ -31,6 +31,7 @@ public class GitLabApi {
private CommitsApi commitsApi;
private DeployKeysApi deployKeysApi;
private GroupApi groupApi;
private IssuesApi issuesApi;
private MergeRequestApi mergeRequestApi;
private NamespaceApi namespaceApi;
private PipelineApi pipelineApi;
......@@ -183,19 +184,20 @@ public class GitLabApi {
apiClient = new GitLabApiClient(apiVersion, hostUrl, privateToken, secretToken, clientConfigProperties);
commitsApi = new CommitsApi(this);
deployKeysApi = new DeployKeysApi(this);
eventsApi = new EventsApi(this);
groupApi = new GroupApi(this);
issuesApi = new IssuesApi(this);
jobApi = new JobApi(this);
mergeRequestApi = new MergeRequestApi(this);
namespaceApi = new NamespaceApi(this);
notesApi = new NotesApi(this);
pipelineApi = new PipelineApi(this);
projectApi = new ProjectApi(this);
repositoryApi = new RepositoryApi(this);
repositoryFileApi = new RepositoryFileApi(this);
servicesApi = new ServicesApi(this);
sessoinApi = new SessionApi(this);
userApi = new UserApi(this);
repositoryFileApi = new RepositoryFileApi(this);
jobApi = new JobApi(this);
notesApi = new NotesApi(this);
eventsApi = new EventsApi(this);
}
/**
......@@ -305,6 +307,46 @@ public class GitLabApi {
return (deployKeysApi);
}
/**
* Gets the EventsApi instance owned by this GitLabApi instance. The EventsApi is used
* to perform all events related API calls.
*
* @return the EventsApi instance owned by this GitLabApi instance
*/
public EventsApi getEventsApi() {
return (eventsApi);
}
/**
* Gets the GroupApi instance owned by this GitLabApi instance. The GroupApi is used
* to perform all group related API calls.
*
* @return the GroupApi instance owned by this GitLabApi instance
*/
public GroupApi getGroupApi() {
return (groupApi);
}
/**
* Gets the IssuesApi instance owned by this GitLabApi instance. The IssuesApi is used
* to perform all iossue related API calls.
*
* @return the CommitsApi instance owned by this GitLabApi instance
*/
public IssuesApi getIssuesApi() {
return (issuesApi);
}
/**
* Gets the JobApi instance owned by this GitLabApi instance. The JobApi is used
* to perform all jobs related API calls.
*
* @return the JobsApi instance owned by this GitLabApi instance
*/
public JobApi getJobApi() {
return (jobApi);
}
/**
* Gets the MergeRequestApi instance owned by this GitLabApi instance. The MergeRequestApi is used
* to perform all merge request related API calls.
......@@ -330,13 +372,13 @@ public class GitLabApi {
}
/**
* Gets the GroupApi instance owned by this GitLabApi instance. The GroupApi is used
* to perform all group related API calls.
* Gets the NotesApi instance owned by this GitLabApi instance. The NotesApi is used
* to perform all notes related API calls.
*
* @return the GroupApi instance owned by this GitLabApi instance
* @return the NotesApi instance owned by this GitLabApi instance
*/
public GroupApi getGroupApi() {
return (groupApi);
public NotesApi getNotesApi() {
return (notesApi);
}
/**
......@@ -408,34 +450,4 @@ public class GitLabApi {
public UserApi getUserApi() {
return (userApi);
}
/**
* Gets the JobApi instance owned by this GitLabApi instance. The JobApi is used
* to perform all jobs related API calls.
*
* @return the JobsApi instance owned by this GitLabApi instance
*/
public JobApi getJobApi() {
return (jobApi);
}
/**
* Gets the NotesApi instance owned by this GitLabApi instance. The NotesApi is used
* to perform all notes related API calls.
*
* @return the NotesApi instance owned by this GitLabApi instance
*/
public NotesApi getNotesApi() {
return (notesApi);
}
/**
* Gets the EventsApi instance owned by this GitLabApi instance. The EventsApi is used
* to perform all events related API calls.
*
* @return the EventsApi instance owned by this GitLabApi instance
*/
public EventsApi getEventsApi() {
return (eventsApi);
}
}
......@@ -1225,6 +1225,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* @param projectId the project ID to get the issues for
* @return a list of project's issues
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#getIssues(Integer)}
*/
public List<Issue> getIssues(Integer projectId) throws GitLabApiException {
Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", projectId, "issues");
......@@ -1241,6 +1242,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* @param perPage the number of issues per page
* @return the list of issues in the specified range
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#getIssues(Integer, int, int)}
*/
public List<Issue> getIssues(Integer projectId, int page, int perPage) throws GitLabApiException {
Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "projects", projectId, "issues");
......@@ -1256,6 +1258,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* @param itemsPerPage the number of issues per page
* @return the list of issues in the specified range
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#getIssues(Integer, int)}
*/
public Pager<Issue> getIssues(Integer projectId, int itemsPerPage) throws GitLabApiException {
return (new Pager<Issue>(this, Issue.class, itemsPerPage, null, "projects", projectId, "issues"));
......@@ -1270,6 +1273,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* @param issueId the internal ID of a project's issue
* @return the specified Issue instance
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#getIssue(Integer, Integer)}
*/
public Issue getIssue(Integer projectId, Integer issueId) throws GitLabApiException {
Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", projectId, "issues", issueId);
......@@ -1284,6 +1288,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* @param projectId the project ID to delete the issue from
* @param issueId the internal ID of a project's issue
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link IssuesApi#deleteIssue(Integer, Integer)}
*/
public void deleteIssue(Integer projectId, Integer issueId) throws GitLabApiException {
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
......
......@@ -8,6 +8,8 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.gitlab4j.api.Constants.IssueState;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Issue {
......@@ -22,13 +24,14 @@ public class Issue {
private Integer iid;
private List<String> labels;
private Milestone milestone;
private Integer project_id;
private String state;
private Integer projectId;
private IssueState state;
private Boolean subscribed;
private String title;
private Date updatedAt;
private Integer userNotesCount;
private String webUrl;
private TimeStats timeStats;
public Assignee getAssignee() {
return assignee;
......@@ -110,19 +113,19 @@ public class Issue {
this.milestone = milestone;
}
public Integer getProject_id() {
return project_id;
public Integer getProjectId() {
return projectId;
}
public void setProject_id(Integer project_id) {
this.project_id = project_id;
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public String getState() {
public IssueState getState() {
return state;
}
public void setState(String state) {
public void setState(IssueState state) {
this.state = state;
}
......@@ -165,4 +168,12 @@ public class Issue {
public void setWebUrl(String webUrl) {
this.webUrl = webUrl;
}
public TimeStats getTimeStats() {
return timeStats;
}
public void setTimeStats(TimeStats timeStats) {
this.timeStats = timeStats;
}
}
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