@@ -1664,4 +1664,38 @@ public String getRawSnippetContent(Integer projectId, Integer snippetId) throws
16641664 Response response = get (Response .Status .OK , null , "projects" , projectId , "snippets" , snippetId , "raw" );
16651665 return (response .readEntity (String .class ));
16661666 }
1667+
1668+ /**
1669+ * Share a project with the specified group.
1670+ *
1671+ * POST /projects/:id/share
1672+ *
1673+ * @param projectId the ID of the project to share, required
1674+ * @param groupId the ID of the group to share with, required
1675+ * @param accessLevel the permissions level to grant the group, required
1676+ * @param expiresAt the share expiration date, optional
1677+ * @throws GitLabApiException if any exception occurs
1678+ */
1679+ public void shareProject (Integer projectId , Integer groupId , AccessLevel accessLevel , Date expiresAt )
1680+ throws GitLabApiException {
1681+ GitLabApiForm formData = new GitLabApiForm ()
1682+ .withParam ("group_id" , groupId , true )
1683+ .withParam ("group_access" , accessLevel .toValue (), true )
1684+ .withParam ("expires_at" , expiresAt );
1685+ post (Response .Status .CREATED , formData , "projects" , projectId , "share" );
1686+ }
1687+
1688+ /**
1689+ * Unshare the project from the group.
1690+ *
1691+ * DELETE /projects/:id/share/:group_id
1692+ *
1693+ * @param projectId the ID of the project to unshare, required
1694+ * @param groupId the ID of the group to unshare, required
1695+ * @throws GitLabApiException if any exception occurs
1696+ */
1697+ public void unshareProject (Integer projectId , Integer groupId ) throws GitLabApiException {
1698+ Response .Status expectedStatus = (isApiVersion (ApiVersion .V3 ) ? Response .Status .OK : Response .Status .NO_CONTENT );
1699+ delete (expectedStatus , null , "projects" , projectId , "share" , groupId );
1700+ }
16671701}
0 commit comments