/** * Create issue * * @param user * @param repository * @param issue * @return created issue * @throws IOException */ public Issue createIssue(String user, String repository, Issue issue) throws IOException { Assert.notNull("User cannot be null", user); // $NON-NLS-1$ Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS); uri.append('/').append(user).append('/').append(repository); uri.append(IGitHubConstants.SEGMENT_ISSUES); Map<Object, Object> params = createIssueMap(issue, true); return this.client.post(uri.toString(), params, Issue.class); }
/** * Get issue * * @param user * @param repository * @param id * @return issue * @throws IOException */ public Issue getIssue(String user, String repository, String id) throws IOException { Assert.notNull("User cannot be null", user); // $NON-NLS-1$ Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$ Assert.notNull("Id cannot be null", id); // $NON-NLS-1$ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS); uri.append('/').append(user).append('/').append(repository); uri.append(IGitHubConstants.SEGMENT_ISSUES); uri.append('/').append(id); GitHubRequest request = createRequest().setUri(uri).setType(Issue.class); return (Issue) client.get(request).getBody(); }
/** * Delete the issue comment with the given id * * @param user * @param repository * @param comment * @throws IOException */ public void deleteComment(String user, String repository, String comment) throws IOException { Assert.notNull("User cannot be null", user); // $NON-NLS-1$ Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$ Assert.notNull("Comment cannot be null", comment); // $NON-NLS-1$ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS); uri.append('/').append(user).append('/').append(repository); uri.append(IGitHubConstants.SEGMENT_ISSUES); uri.append(IGitHubConstants.SEGMENT_COMMENTS); uri.append('/').append(comment); client.delete(uri.toString()); }
/** * Get bulk issues request * * @param user * @param repository * @param filterData * @param start * @param size * @return paged request */ protected PagedRequest<Issue> createIssuesRequest( String user, String repository, Map<String, String> filterData, int start, int size) { Assert.notNull("User cannot be null", user); // $NON-NLS-1$ Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS); uri.append('/').append(user).append('/').append(repository); uri.append(IGitHubConstants.SEGMENT_ISSUES); PagedRequest<Issue> request = createPagedRequest(start, size); request.setParams(filterData).setUri(uri); request.setType(new TypeToken<List<Issue>>() {}.getType()); return request; }
/** * Get an issue's comments * * @param user * @param repository * @param id * @return list of matching issues * @throws IOException */ public List<Comment> getComments(String user, String repository, String id) throws IOException { Assert.notNull("User cannot be null", user); // $NON-NLS-1$ Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$ Assert.notNull("Id cannot be null", id); // $NON-NLS-1$ StringBuilder builder = new StringBuilder(IGitHubConstants.SEGMENT_REPOS); builder.append('/').append(user).append('/').append(repository); builder.append(IGitHubConstants.SEGMENT_ISSUES); builder.append('/').append(id); builder.append(IGitHubConstants.SEGMENT_COMMENTS); PagedRequest<Comment> request = createPagedRequest(); request.setUri(builder.toString()).setType(new TypeToken<List<Comment>>() {}.getType()); return getAll(request); }
/** * Edit issue * * @param user * @param repository * @param issue * @return created issue * @throws IOException */ public Issue editIssue(String user, String repository, Issue issue) throws IOException { Assert.notNull("User cannot be null", user); // $NON-NLS-1$ Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$ Assert.notNull("Issue cannot be null", issue); // $NON-NLS-1$ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS); uri.append('/').append(user).append('/').append(repository); uri.append(IGitHubConstants.SEGMENT_ISSUES); uri.append('/').append(issue.getNumber()); Map<Object, Object> params = createIssueMap(issue, false); String state = issue.getState(); if (state != null) params.put(FILTER_STATE, state); return this.client.post(uri.toString(), params, Issue.class); }
/** * Create comment on specified issue id * * @param user * @param repository * @param issueId * @param comment * @return created issue * @throws IOException */ public Comment createComment(String user, String repository, String issueId, String comment) throws IOException { Assert.notNull("User cannot be null", user); // $NON-NLS-1$ Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$ Assert.notNull("Issue id cannot be null", issueId); // $NON-NLS-1$ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS); uri.append('/').append(user).append('/').append(repository); uri.append(IGitHubConstants.SEGMENT_ISSUES); uri.append('/').append(issueId); uri.append(IGitHubConstants.SEGMENT_COMMENTS); Map<String, String> params = new HashMap<String, String>(1, 1); params.put(FIELD_BODY, comment); return this.client.post(uri.toString(), params, Comment.class); }