Skip to content

Commit d26ae08

Browse files
committed
Fixed issue with addLdapGroupLink() (#223).
1 parent 5775439 commit d26ae08

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,31 @@ public void ldapSync(Object groupIdOrPath) throws GitLabApiException {
760760
* @throws GitLabApiException if any exception occurs
761761
*/
762762
public void addLdapGroupLink(Object groupIdOrPath, String cn, AccessLevel groupAccess, String provider) throws GitLabApiException {
763+
764+
if (groupAccess == null) {
765+
throw new RuntimeException("groupAccess cannot be null or empty");
766+
}
767+
768+
addLdapGroupLink(groupIdOrPath, cn, groupAccess.toValue(), provider);
769+
}
770+
771+
/**
772+
* Adds an LDAP group link.
773+
*
774+
* <pre><code>GitLab Endpoint: POST /groups/:id/ldap_group_links</code></pre>
775+
*
776+
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
777+
* @param cn the CN of a LDAP group
778+
* @param groupAccess the minimum access level for members of the LDAP group
779+
* @param provider the LDAP provider for the LDAP group
780+
* @throws GitLabApiException if any exception occurs
781+
*/
782+
public void addLdapGroupLink(Object groupIdOrPath, String cn, Integer groupAccess, String provider) throws GitLabApiException {
763783
GitLabApiForm formData = new GitLabApiForm()
764784
.withParam("cn", cn, true)
765-
.withParam("group_Access", groupAccess, true)
785+
.withParam("group_access", groupAccess, true)
766786
.withParam("provider", provider, true);
767-
post(Response.Status.NO_CONTENT, formData, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links");
787+
post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links");
768788
}
769789

770790
/**

0 commit comments

Comments
 (0)