diff --git a/src/main/java/org/gitlab4j/api/GroupApi.java b/src/main/java/org/gitlab4j/api/GroupApi.java index 559894a8..6c106bab 100644 --- a/src/main/java/org/gitlab4j/api/GroupApi.java +++ b/src/main/java/org/gitlab4j/api/GroupApi.java @@ -28,6 +28,7 @@ import org.gitlab4j.api.models.LdapGroupLink; import org.gitlab4j.api.models.Member; import org.gitlab4j.api.models.Project; +import org.gitlab4j.api.models.SamlGroupLink; import org.gitlab4j.api.models.Variable; import org.gitlab4j.api.models.Visibility; import org.gitlab4j.api.utils.ISO8601; @@ -1183,9 +1184,9 @@ public void ldapSync(Object groupIdOrPath) throws GitLabApiException { /** * Get the list of LDAP group links. - * + * *
GitLab Endpoint: GET /groups/:id/ldap_group_links
- *
+ *
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @return a list of LDAP group links
* @throws GitLabApiException if any exception occurs
@@ -1275,6 +1276,74 @@ public void deleteLdapGroupLink(Object groupIdOrPath, String cn, String provider
delete(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links", provider, cn);
}
+ /**
+ * Get the list of SAML group links.
+ *
+ * GitLab Endpoint: GET /groups/:id/saml_group_links
+ *
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
+ * @return a list of SAML group links
+ * @throws GitLabApiException if any exception occurs
+ */
+ public ListGitLab Endpoint: POST /groups/:id/saml_group_links
+ *
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
+ * @param samlGroupName the name of the SAML group
+ * @param groupAccess the minimum access level for members of the SAML group
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessLevel groupAccess) throws GitLabApiException {
+
+ if (groupAccess == null) {
+ throw new RuntimeException("groupAccess cannot be null or empty");
+ }
+
+ addSamlGroupLink(groupIdOrPath, samlGroupName, groupAccess.toValue());
+ }
+
+ /**
+ * Adds an SAML group link.
+ *
+ * GitLab Endpoint: POST /groups/:id/saml_group_links
+ *
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
+ * @param samlGroupName the name of the SAML group
+ * @param groupAccess the minimum access level for members of the SAML group
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, Integer groupAccess) throws GitLabApiException {
+ GitLabApiForm formData = new GitLabApiForm()
+ .withParam("saml_group_name", samlGroupName, true)
+ .withParam("access_level", groupAccess, true);
+ post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "saml_group_links");
+ }
+
+ /**
+ * Deletes an SAML group link.
+ *
+ * GitLab Endpoint: DELETE /groups/:id/saml_group_links/:cn
+ *
+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
+ * @param samlGroupName the name of the SAML group to delete
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void deleteSamlGroupLink(Object groupIdOrPath, String samlGroupName) throws GitLabApiException {
+
+ if (samlGroupName == null || samlGroupName.trim().isEmpty()) {
+ throw new RuntimeException("samlGroupName cannot be null or empty");
+ }
+
+ delete(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "saml_group_links", samlGroupName);
+ }
+
/**
* Get list of a group’s variables.
*
@@ -1961,7 +2030,7 @@ public void deleteCustomAttribute(final Object groupIdOrPath, final String key)
delete(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "custom_attributes", key);
}
-
+
/**
* Lists group iterations.
*
diff --git a/src/main/java/org/gitlab4j/api/models/SamlGroupLink.java b/src/main/java/org/gitlab4j/api/models/SamlGroupLink.java
new file mode 100644
index 00000000..2d85058d
--- /dev/null
+++ b/src/main/java/org/gitlab4j/api/models/SamlGroupLink.java
@@ -0,0 +1,32 @@
+
+package org.gitlab4j.api.models;
+
+import org.gitlab4j.api.utils.JacksonJson;
+
+public class SamlGroupLink {
+
+ private String name;
+
+ private AccessLevel accessLevel;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String aName) {
+ this.name = aName;
+ }
+
+ public AccessLevel getAccessLevel() {
+ return accessLevel;
+ }
+
+ public void setAccessLevel(AccessLevel aAccessLevel) {
+ accessLevel = aAccessLevel;
+ }
+
+ @Override
+ public String toString() {
+ return (JacksonJson.toJsonString(this));
+ }
+}
diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
index fcffc9de..d5fb0e61 100644
--- a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
+++ b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
@@ -117,6 +117,7 @@
import org.gitlab4j.api.models.RepositoryFile;
import org.gitlab4j.api.models.Runner;
import org.gitlab4j.api.models.RunnerDetail;
+import org.gitlab4j.api.models.SamlGroupLink;
import org.gitlab4j.api.models.SearchBlob;
import org.gitlab4j.api.models.Snippet;
import org.gitlab4j.api.models.SshKey;
@@ -808,6 +809,12 @@ public void testLdapGroupLink() throws Exception {
assertTrue(compareJson(link, "ldap-group-link.json"));
}
+ @Test
+ public void testSamlGroupLink() throws Exception {
+ SamlGroupLink link = unmarshalResource(SamlGroupLink.class, "saml-group-link.json");
+ assertTrue(compareJson(link, "saml-group-link.json"));
+ }
+
@Test
public void testSearchBlobs() throws Exception {
List