Skip to content

Commit a3ab79b

Browse files
profhenryJan Henrik Wiesnerjmini
authored
Added support for listing LDAP group links (#1015)
Co-authored-by: Jan Henrik Wiesner <[email protected]> Co-authored-by: Jeremie Bresson <[email protected]>
1 parent c393d43 commit a3ab79b

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
package org.gitlab4j.api.models;
3+
4+
import org.gitlab4j.api.utils.JacksonJson;
5+
6+
public class LdapGroupLink {
7+
8+
private String cn;
9+
10+
private AccessLevel groupAccess;
11+
12+
private String provider;
13+
14+
private String filter;
15+
16+
public String getCn() {
17+
return cn;
18+
}
19+
20+
public void setCn(String aCn) {
21+
cn = aCn;
22+
}
23+
24+
public AccessLevel getGroupAccess() {
25+
return groupAccess;
26+
}
27+
28+
public void setGroupAccess(AccessLevel aGroupAccess) {
29+
groupAccess = aGroupAccess;
30+
}
31+
32+
public String getProvider() {
33+
return provider;
34+
}
35+
36+
public void setProvider(String aProvider) {
37+
provider = aProvider;
38+
}
39+
40+
public String getFilter() {
41+
return filter;
42+
}
43+
44+
public void setFilter(String aFilter) {
45+
filter = aFilter;
46+
}
47+
48+
@Override
49+
public String toString() {
50+
return (JacksonJson.toJsonString(this));
51+
}
52+
}

src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import org.gitlab4j.api.models.Key;
8282
import org.gitlab4j.api.models.Label;
8383
import org.gitlab4j.api.models.LabelEvent;
84+
import org.gitlab4j.api.models.LdapGroupLink;
8485
import org.gitlab4j.api.models.Link;
8586
import org.gitlab4j.api.models.Member;
8687
import org.gitlab4j.api.models.MergeRequest;
@@ -771,6 +772,12 @@ public void testLabels() throws Exception {
771772
assertTrue(compareJson(labels, "labels.json"));
772773
}
773774

775+
@Test
776+
public void testLdapGroupLink() throws Exception {
777+
LdapGroupLink link = unmarshalResource(LdapGroupLink.class, "ldap-group-link.json");
778+
assertTrue(compareJson(link, "ldap-group-link.json"));
779+
}
780+
774781
@Test
775782
public void testSearchBlobs() throws Exception {
776783
List<SearchBlob> searchResults = unmarshalResourceList(SearchBlob.class, "wiki-blobs.json");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cn": "My Group",
3+
"group_access": 30,
4+
"provider": "tertiary",
5+
"filter": "(employeeType=developer)"
6+
}

0 commit comments

Comments
 (0)