From d26ae08181c850dd82c5d6886589118510322d7e Mon Sep 17 00:00:00 2001 From: Greg Messner Date: Wed, 11 Jul 2018 09:31:30 -0700 Subject: [PATCH] Fixed issue with addLdapGroupLink() (#223). --- src/main/java/org/gitlab4j/api/GroupApi.java | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/GroupApi.java b/src/main/java/org/gitlab4j/api/GroupApi.java index 8ab41b83..b4aef7c0 100644 --- a/src/main/java/org/gitlab4j/api/GroupApi.java +++ b/src/main/java/org/gitlab4j/api/GroupApi.java @@ -760,11 +760,31 @@ public class GroupApi extends AbstractApi { * @throws GitLabApiException if any exception occurs */ public void addLdapGroupLink(Object groupIdOrPath, String cn, AccessLevel groupAccess, String provider) throws GitLabApiException { + + if (groupAccess == null) { + throw new RuntimeException("groupAccess cannot be null or empty"); + } + + addLdapGroupLink(groupIdOrPath, cn, groupAccess.toValue(), provider); + } + + /** + * Adds an LDAP group link. + * + *
GitLab Endpoint: POST /groups/:id/ldap_group_links
+ * + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path + * @param cn the CN of a LDAP group + * @param groupAccess the minimum access level for members of the LDAP group + * @param provider the LDAP provider for the LDAP group + * @throws GitLabApiException if any exception occurs + */ + public void addLdapGroupLink(Object groupIdOrPath, String cn, Integer groupAccess, String provider) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("cn", cn, true) - .withParam("group_Access", groupAccess, true) + .withParam("group_access", groupAccess, true) .withParam("provider", provider, true); - post(Response.Status.NO_CONTENT, formData, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links"); + post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links"); } /** -- GitLab