Skip to content

Commit 158abc0

Browse files
committed
Added fork project support (#98).
1 parent ed46ded commit 158abc0

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/main/java/org/gitlab4j/api/ProjectApi.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,60 @@ public void deleteProject(Project project) throws GitLabApiException {
830830
deleteProject(project.getId());
831831
}
832832

833+
/**
834+
* Forks a project into the user namespace of the authenticated user or the one provided.
835+
*
836+
* POST /projects/:id/fork
837+
*
838+
* @param id the ID of the project to fork
839+
* @param namespace path of the namespace that the project will be forked to
840+
* @throws GitLabApiException if any exception occurs
841+
*/
842+
public void forkProject(Integer id, String namespace) throws GitLabApiException {
843+
GitLabApiForm formData = new GitLabApiForm().withParam("namespace", namespace, true);
844+
post(Response.Status.OK, formData, "projects", id, "fork");
845+
}
846+
847+
/**
848+
* Forks a project into the user namespace of the authenticated user or the one provided.
849+
*
850+
* POST /projects/:id/fork
851+
*
852+
* @param project the project to fork
853+
* @param namespace path of the namespace that the project will be forked to
854+
* @throws GitLabApiException if any exception occurs
855+
*/
856+
public void forkProject(Project project, String namespace) throws GitLabApiException {
857+
forkProject(project.getId(), namespace);
858+
}
859+
860+
/**
861+
* Forks a project into the user namespace of the authenticated user or the one provided.
862+
*
863+
* POST /projects/:id/fork
864+
*
865+
* @param id the ID of the project to fork
866+
* @param namespaceId ID of the namespace that the project will be forked to
867+
* @throws GitLabApiException if any exception occurs
868+
*/
869+
public void forkProject(Integer id, Integer namespaceId) throws GitLabApiException {
870+
GitLabApiForm formData = new GitLabApiForm().withParam("namespace", namespaceId, true);
871+
post(Response.Status.OK, formData, "projects", id, "fork");
872+
}
873+
874+
/**
875+
* Forks a project into the user namespace of the authenticated user or the one provided.
876+
*
877+
* POST /projects/:id/fork
878+
*
879+
* @param project the project to fork
880+
* @param namespaceId ID of the namespace that the project will be forked to
881+
* @throws GitLabApiException if any exception occurs
882+
*/
883+
public void forkProject(Project project, Integer namespaceId) throws GitLabApiException {
884+
forkProject(project.getId(), namespaceId);
885+
}
886+
833887
/**
834888
* Get a list of project team members.
835889
*

0 commit comments

Comments
 (0)