Search in sources :

Example 31 with MergeRequest

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

the class MergeRequestApi method updateMergeRequest.

/**
 * Updates an existing merge request. You can change branches, title, or even close the MR.
 * <p>
 * PUT /projects/:id/merge_requests/:merge_request_id
 *
 * @param projectId      the ID of a project
 * @param mergeRequestId the ID of the merge request to update
 * @param sourceBranch   the source branch
 * @param targetBranch   the target branch
 * @param title          the title for the merge request
 * @param description    the description of the merge request
 * @param assigneeId     the Assignee user ID, optional
 * @return the updated merge request
 * @throws GitLabApiException if any exception occurs
 * @deprecated as of release 4.4.3
 */
@Deprecated
public MergeRequest updateMergeRequest(Integer projectId, Integer mergeRequestId, String sourceBranch, String targetBranch, String title, String description, Integer assigneeId) throws GitLabApiException {
    if (projectId == null) {
        throw new GitLabApiException("projectId cannot be null");
    }
    if (mergeRequestId == null) {
        throw new GitLabApiException("mergeRequestId cannot be null");
    }
    Form formData = new Form();
    addFormParam(formData, "source_branch", sourceBranch, false);
    addFormParam(formData, "target_branch", targetBranch, false);
    addFormParam(formData, "title", title, false);
    addFormParam(formData, "description", description, false);
    addFormParam(formData, "assignee_id", assigneeId, false);
    Response response = put(Response.Status.OK, formData.asMap(), "projects", projectId, "merge_requests", mergeRequestId);
    return (response.readEntity(MergeRequest.class));
}
Also used : Response(javax.ws.rs.core.Response) MergeRequest(org.gitlab4j.api.models.MergeRequest) Form(javax.ws.rs.core.Form)

Example 32 with MergeRequest

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

the class MergeRequestApi method approveMergeRequest.

/**
 * Approve a merge request.
 * <p>
 * Note: This API endpoint is only available on 8.9 EE and above.
 * <p>
 * POST /projects/:id/merge_requests/:merge_request_iid/approve
 *
 * @param projectId      the project ID of the merge request
 * @param mergeRequestId the internal ID of the merge request
 * @param sha            the HEAD of the merge request, optional
 * @return a MergeRequest instance with approval information included
 * @throws GitLabApiException if any exception occurs
 */
public MergeRequest approveMergeRequest(Integer projectId, Integer mergeRequestId, String sha) throws GitLabApiException {
    if (projectId == null) {
        throw new GitLabApiException("projectId cannot be null");
    }
    if (mergeRequestId == null) {
        throw new GitLabApiException("mergeRequestId cannot be null");
    }
    Form formData = new GitLabApiForm().withParam("sha", sha);
    Response response = post(Response.Status.OK, formData, "projects", projectId, "merge_requests", mergeRequestId, "approve");
    return (response.readEntity(MergeRequest.class));
}
Also used : Response(javax.ws.rs.core.Response) MergeRequest(org.gitlab4j.api.models.MergeRequest) Form(javax.ws.rs.core.Form)

Aggregations

MergeRequest (org.gitlab4j.api.models.MergeRequest)32 GitLabProjectId (org.finos.legend.sdlc.server.gitlab.GitLabProjectId)25 LegendSDLCServerException (org.finos.legend.sdlc.server.error.LegendSDLCServerException)22 GitLabApiException (org.gitlab4j.api.GitLabApiException)17 MergeRequestApi (org.gitlab4j.api.MergeRequestApi)15 RepositoryApi (org.gitlab4j.api.RepositoryApi)9 ProjectFileAccessProvider (org.finos.legend.sdlc.server.project.ProjectFileAccessProvider)7 DiffRef (org.gitlab4j.api.models.DiffRef)7 Response (javax.ws.rs.core.Response)6 GitLabApi (org.gitlab4j.api.GitLabApi)6 List (java.util.List)5 Form (javax.ws.rs.core.Form)5 Project (org.finos.legend.sdlc.domain.model.project.Project)5 ProjectType (org.finos.legend.sdlc.domain.model.project.ProjectType)5 Review (org.finos.legend.sdlc.domain.model.review.Review)5 Entity (org.finos.legend.sdlc.domain.model.entity.Entity)4 Workspace (org.finos.legend.sdlc.domain.model.project.workspace.Workspace)4 ProjectStructure (org.finos.legend.sdlc.server.project.ProjectStructure)2 Branch (org.gitlab4j.api.models.Branch)2 MergeRequestParams (org.gitlab4j.api.models.MergeRequestParams)2