Skip to content

Commit 542913f

Browse files
author
Jan Henrik Wiesner
committed
Added support for listing LDAP group links
1 parent 7d1d6b1 commit 542913f

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.gitlab4j.api.models.GroupFilter;
2323
import org.gitlab4j.api.models.GroupParams;
2424
import org.gitlab4j.api.models.GroupProjectsFilter;
25+
import org.gitlab4j.api.models.LdapGroupLink;
2526
import org.gitlab4j.api.models.Member;
2627
import org.gitlab4j.api.models.Project;
2728
import org.gitlab4j.api.models.Variable;
@@ -1177,6 +1178,20 @@ public void ldapSync(Object groupIdOrPath) throws GitLabApiException {
11771178
post(Response.Status.NO_CONTENT, (Form)null, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_sync");
11781179
}
11791180

1181+
/**
1182+
* Get the list of LDAP group links.
1183+
*
1184+
* <pre><code>GitLab Endpoint: GET /groups/:id/ldap_group_links</code></pre>
1185+
*
1186+
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
1187+
* @return a list of LDAP group links
1188+
* @throws GitLabApiException if any exception occurs
1189+
*/
1190+
public List<LdapGroupLink> getLdapGroupLinks(Object groupIdOrPath) throws GitLabApiException {
1191+
Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links");
1192+
return (response.readEntity(new GenericType<List<LdapGroupLink>>() {}));
1193+
}
1194+
11801195
/**
11811196
* Adds an LDAP group link.
11821197
*
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
package org.gitlab4j.api.models;
3+
4+
import org.gitlab4j.api.utils.JacksonJson;
5+
6+
public class LdapGroupLink {
7+
8+
// The GitLab REST API documentation (https://docs.gitlab.com/ee/api/groups.html#list-ldap-group-links)
9+
// does not specify the attributes which are returned for a LDAP group link :-/.
10+
// This are the attributes returned by our GitLab instance (15.10.2-ee).
11+
// These seem fine because they match with the attributes which you can pass when adding a LDAP group link :-).
12+
13+
private String cn;
14+
15+
private AccessLevel groupAccess;
16+
17+
private String provider;
18+
19+
private String filter;
20+
21+
public String getCn() {
22+
return cn;
23+
}
24+
25+
public void setCn(String aCn) {
26+
cn = aCn;
27+
}
28+
29+
public AccessLevel getGroupAccess() {
30+
return groupAccess;
31+
}
32+
33+
public void setGroupAccess(AccessLevel aGroupAccess) {
34+
groupAccess = aGroupAccess;
35+
}
36+
37+
public String getProvider() {
38+
return provider;
39+
}
40+
41+
public void setProvider(String aProvider) {
42+
provider = aProvider;
43+
}
44+
45+
public String getFilter() {
46+
return filter;
47+
}
48+
49+
public void setFilter(String aFilter) {
50+
filter = aFilter;
51+
}
52+
53+
@Override
54+
public String toString() {
55+
return (JacksonJson.toJsonString(this));
56+
}
57+
}

0 commit comments

Comments
 (0)