Commit 78c69df7 authored by Michal Augustýn's avatar Michal Augustýn Committed by Greg Messner
Browse files

Project archiving and unarchiving (#152)

* project archiving and unarchiving
* expected response for archive and unarchive fixed
* remove unnecessary preconditions for archiving test
parent 408e644a
...@@ -1853,4 +1853,34 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -1853,4 +1853,34 @@ public class ProjectApi extends AbstractApi implements Constants {
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT); Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
delete(expectedStatus, null, "projects", projectId, "share", groupId); delete(expectedStatus, null, "projects", projectId, "share", groupId);
} }
/**
* Archive a project
*
* POST /projects/:id/archive
*
* @param projectId the ID of the project to archive, required
* @return the archived GitLab Project
* @throws GitLabApiException if any exception occurs
*/
public Project archiveProject(Integer projectId)
throws GitLabApiException {
Response response = post(Response.Status.CREATED, (new GitLabApiForm()), "projects", projectId, "archive");
return (response.readEntity(Project.class));
}
/**
* Unarchive a project
*
* POST /projects/:id/unarchive
*
* @param projectId the ID of the project to unarchive, required
* @return the unarchived GitLab Project
* @throws GitLabApiException if any exception occurs
*/
public Project unarchiveProject(Integer projectId)
throws GitLabApiException {
Response response = post(Response.Status.CREATED, (new GitLabApiForm()), "projects", projectId, "unarchive");
return (response.readEntity(Project.class));
}
} }
...@@ -440,6 +440,15 @@ public class TestProjectApi { ...@@ -440,6 +440,15 @@ public class TestProjectApi {
gitLabApi.getProjectApi().unshareProject(project.getId(), shareGroup.getId()); gitLabApi.getProjectApi().unshareProject(project.getId(), shareGroup.getId());
} }
@Test
public void testArchiveProject() throws GitLabApiException {
Project project = gitLabApi.getProjectApi().getProject(TEST_NAMESPACE, TEST_PROJECT_NAME);
assertNotNull(project);
assertEquals(true, gitLabApi.getProjectApi().archiveProject(project.getId()).getArchived());
assertEquals(false, gitLabApi.getProjectApi().unarchiveProject(project.getId()).getArchived());
}
@Test @Test
public void testGetOptionalProject() throws GitLabApiException { public void testGetOptionalProject() throws GitLabApiException {
......
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