Commit 61b57a7c authored by Brian Krische's avatar Brian Krische Committed by Tim Olshansky

Add method to share and un-share project with a group. (#218)

* Add method to share and un-share project with a group.

* Add another method to delete shared group link with ID numbers only.
parent ea2c1c38
......@@ -2786,6 +2786,48 @@ public class GitlabAPI {
return Arrays.asList(response);
}
/**
* Share a project with a group.
*
* @param accessLevel The permissions level to grant the group.
* @param group The group to share with.
* @param project The project to be shared.
* @param expiration Share expiration date in ISO 8601 format: 2016-09-26 or {@code null}.
* @throws IOException on gitlab api call error
*/
public void shareProjectWithGroup(GitlabAccessLevel accessLevel, String expiration, GitlabGroup group, GitlabProject project) throws IOException {
Query query = new Query()
.append("group_id", group.getId().toString())
.append("group_access", String.valueOf(accessLevel.accessValue))
.appendIf("expires_at", expiration);
String tailUrl = GitlabProject.URL + "/" + project.getId() + "/share" + query.toString();
dispatch().to(tailUrl, Void.class);
}
/**
* Delete a shared project link within a group.
*
* @param group The group.
* @param project The project.
* @throws IOException on gitlab api call error
*/
public void deleteSharedProjectGroupLink(GitlabGroup group, GitlabProject project) throws IOException {
deleteSharedProjectGroupLink(group.getId(), project.getId());
}
/**
* Delete a shared project link within a group.
*
* @param groupId The group id number.
* @param projectId The project id number.
* @throws IOException on gitlab api call error
*/
public void deleteSharedProjectGroupLink(int groupId, int projectId) throws IOException {
String tailUrl = GitlabProject.URL + "/" + projectId + "/share/" + groupId;
retrieve().method("DELETE").to(tailUrl, Void.class);
}
/**
* Set the User-Agent header for the requests.
*
......
Markdown is supported
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