Search in sources :

Example 6 with Issue

use of org.gitlab4j.api.models.Issue in project choerodon-starters by open-hand.

the class IssuesApi method updateIssue.

/**
 * Updates an existing project issue. This call can also be used to mark an issue as closed.
 * <p>
 * PUT /projects/:id/issues/:issue_iid
 *
 * @param projectId    the ID of the project owned by the authenticated user, required
 * @param issueIid     the issue IID to update, required
 * @param title        the title of an issue, optional
 * @param description  the description of an issue, optional
 * @param confidential set the issue to be confidential, default is false, optional
 * @param assigneeIds  the IDs of the users to assign issue, optional
 * @param milestoneId  the ID of a milestone to assign issue, optional
 * @param labels       comma-separated label names for an issue, optional
 * @param stateEvent   the state event of an issue. Set close to close the issue and reopen to reopen it, optional
 * @param updatedAt    sets the updated date, requires admin or project owner rights, optional
 * @param dueDate      the due date, optional
 * @return an instance of the updated Issue
 * @throws GitLabApiException if any exception occurs
 */
public Issue updateIssue(Integer projectId, Integer issueIid, String title, String description, Boolean confidential, List<Integer> assigneeIds, Integer milestoneId, String labels, StateEvent stateEvent, Date updatedAt, Date dueDate) throws GitLabApiException {
    if (projectId == null) {
        throw new RuntimeException("project ID cannot be null");
    }
    if (issueIid == null) {
        throw new RuntimeException("issue IID cannot be null");
    }
    GitLabApiForm formData = new GitLabApiForm().withParam("title", title, true).withParam("description", description).withParam("confidential", confidential).withParam("assignee_ids", assigneeIds).withParam("milestone_id", milestoneId).withParam("labels", labels).withParam("state_event", stateEvent).withParam("updated_at", updatedAt).withParam("due_date", dueDate);
    Response response = put(Response.Status.OK, formData.asMap(), "projects", projectId, "issues", issueIid);
    return (response.readEntity(Issue.class));
}
Also used : Response(javax.ws.rs.core.Response) Issue(org.gitlab4j.api.models.Issue)

Example 7 with Issue

use of org.gitlab4j.api.models.Issue in project choerodon-starters by open-hand.

the class IssuesApi method closeIssue.

/**
 * Closes an existing project issue.
 * <p>
 * PUT /projects/:id/issues/:issue_iid
 *
 * @param projectId the ID of the project owned by the authenticated user, required
 * @param issueIid  the issue IID to update, required
 * @return an instance of the updated Issue
 * @throws GitLabApiException if any exception occurs
 */
public Issue closeIssue(Integer projectId, Integer issueIid) throws GitLabApiException {
    if (projectId == null) {
        throw new RuntimeException("project ID cannot be null");
    }
    if (issueIid == null) {
        throw new RuntimeException("issue IID cannot be null");
    }
    GitLabApiForm formData = new GitLabApiForm().withParam("state_event", StateEvent.CLOSE);
    Response response = put(Response.Status.OK, formData.asMap(), "projects", projectId, "issues", issueIid);
    return (response.readEntity(Issue.class));
}
Also used : Response(javax.ws.rs.core.Response) Issue(org.gitlab4j.api.models.Issue)

Example 8 with Issue

use of org.gitlab4j.api.models.Issue in project choerodon-starters by open-hand.

the class IssuesApi method createIssue.

/**
 * Create an issue for the project.
 * <p>
 * POST /projects/:id/issues
 *
 * @param projectId               the ID of the project owned by the authenticated user, required
 * @param title                   the issue title of an issue, required
 * @param description             the description of an issue, optional
 * @param confidential            set the issue to be confidential, default is false, optional
 * @param assigneeIds             the IDs of the users to assign issue, optional
 * @param milestoneId             the ID of a milestone to assign issue, optional
 * @param labels                  comma-separated label names for an issue, optional
 * @param createdAt               the date the issue was created at, optional
 * @param dueDate                 the due date, optional
 * @param mergeRequestToResolveId the IID of a merge request in which to resolve all issues. This will fill the issue with a default
 *                                description and mark all discussions as resolved. When passing a description or title, these values will take precedence over the default values. Optional
 * @param discussionToResolveId   the ID of a discussion to resolve. This will fill in the issue with a default description and mark the discussion as resolved.
 *                                Use in combination with merge_request_to_resolve_discussions_of. Optional
 * @return an instance of Issue
 * @throws GitLabApiException if any exception occurs
 */
public Issue createIssue(Integer projectId, String title, String description, Boolean confidential, List<Integer> assigneeIds, Integer milestoneId, String labels, Date createdAt, Date dueDate, Integer mergeRequestToResolveId, Integer discussionToResolveId) throws GitLabApiException {
    if (projectId == null) {
        throw new RuntimeException("projectId cannot be null");
    }
    GitLabApiForm formData = new GitLabApiForm().withParam("title", title, true).withParam("description", description).withParam("confidential", confidential).withParam("assignee_ids", assigneeIds).withParam("milestone_id", milestoneId).withParam("labels", labels).withParam("created_at", createdAt).withParam("due_date", dueDate).withParam("merge_request_to_resolve_discussions_of", mergeRequestToResolveId).withParam("discussion_to_resolve", discussionToResolveId);
    Response response = post(Response.Status.CREATED, formData, "projects", projectId, "issues");
    return (response.readEntity(Issue.class));
}
Also used : Response(javax.ws.rs.core.Response) Issue(org.gitlab4j.api.models.Issue)

Example 9 with Issue

use of org.gitlab4j.api.models.Issue in project dash-licenses by eclipse.

the class GitLabSupport method createReviews.

public void createReviews(List<LicenseData> needsReview, PrintWriter output) {
    execute(connection -> {
        var count = 0;
        for (LicenseData licenseData : needsReview) {
            if (count >= MAXIMUM_REVIEWS)
                break;
            count++;
            output.println(String.format("Setting up a review for %s.", licenseData.getId().toString()));
            if (!licenseData.getId().isValid()) {
                output.println(" - Don't know what to do with this.");
                continue;
            }
            Stream<ExtendedContentData> extendedData = dataService.findFor(licenseData.getId());
            /*
				 * Ideally, we need a way to "create if does not already exist" feature in the
				 * GitLab API. But since we don't have that, we'll leverage the expectation that
				 * concurrent requests to review the same content will be relatively rare (there
				 * is some risk that between asking if we have an existing issue for a review
				 * for a particular bit of content and creating a new one, that somebody else
				 * might be doing the same). Our expectation is that the potential additional
				 * churn on the backend should require significantly less effort than that
				 * required to prevent rare duplication.
				 */
            try {
                GitLabReview review = new GitLabReview(settings.getProjectId(), licenseData, extendedData);
                Issue existing = connection.findIssue(review);
                if (existing != null) {
                    output.println(String.format(" - Existing: %s", existing.getWebUrl()));
                    continue;
                }
                Issue created = connection.createIssue(review);
                if (created == null) {
                    output.println(" - An error occurred while attempting to create a review request");
                    // TODO If we break creating a review, then don't try to create any more.
                    break;
                }
                output.println(String.format(" - Created: %s", created.getWebUrl()));
                output.flush();
            } catch (GitLabApiException e) {
                throw new RuntimeException(e);
            }
        }
        if (count < needsReview.size()) {
            output.println();
            output.println("More content needs to be reviewed.");
            output.printf("For now, however, this experimental feature only submits the first %d.\n", count);
            output.println();
        }
    });
}
Also used : Issue(org.gitlab4j.api.models.Issue) LicenseData(org.eclipse.dash.licenses.LicenseData) GitLabApiException(org.gitlab4j.api.GitLabApiException) ExtendedContentData(org.eclipse.dash.licenses.extended.ExtendedContentData)

Aggregations

Issue (org.gitlab4j.api.models.Issue)9 GitLabApiException (org.gitlab4j.api.GitLabApiException)5 Response (javax.ws.rs.core.Response)4 Comment (de.catma.document.comment.Comment)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 LicenseData (org.eclipse.dash.licenses.LicenseData)2 ExtendedContentData (org.eclipse.dash.licenses.extended.ExtendedContentData)2 IssuesApi (org.gitlab4j.api.IssuesApi)2 IssueFilter (org.gitlab4j.api.models.IssueFilter)2 Author (org.gitlab4j.api.models.Author)1 Ticket (org.ndx.agile.architecture.base.enhancers.tickets.Ticket)1