Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions src/main/java/org/gitlab4j/api/GroupApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,26 @@ public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessL
addSamlGroupLink(groupIdOrPath, samlGroupName, groupAccess.toValue());
}

/**
* Adds an SAML group link.
*
* <pre><code>GitLab Endpoint: POST /groups/:id/saml_group_links</code></pre>
*
* @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
* @param memberRoleId the id of the custom member role to assign
* @throws GitLabApiException if any exception occurs
*/
public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessLevel groupAccess, int memberRoleId) throws GitLabApiException {

if (groupAccess == null) {
throw new RuntimeException("groupAccess cannot be null or empty");
}

addSamlGroupLink(groupIdOrPath, samlGroupName, groupAccess.toValue(), memberRoleId);
}

/**
* Adds an SAML group link.
*
Expand All @@ -1326,9 +1346,25 @@ public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessL
* @throws GitLabApiException if any exception occurs
*/
public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, Integer groupAccess) throws GitLabApiException {
addSamlGroupLink(groupIdOrPath, samlGroupName, groupAccess, null);
}

/**
* Adds an SAML group link.
*
* <pre><code>GitLab Endpoint: POST /groups/:id/saml_group_links</code></pre>
*
* @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
* @param memberRoleId the id of the custom member role to assign
* @throws GitLabApiException if any exception occurs
*/
public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, Integer groupAccess, Integer memberRoleId) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("saml_group_name", samlGroupName, true)
.withParam("access_level", groupAccess, true);
.withParam("access_level", groupAccess, true)
.withParam("member_role_id", memberRoleId);
post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "saml_group_links");
}

Expand Down Expand Up @@ -1888,7 +1924,7 @@ public Group setGroupAvatar(Object groupIdOrPath, File avatarFile) throws GitLab
* Only working with GitLab 14.0 and above.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/avatar</code></pre>
*
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @return an InputStream to read the raw file from
* @throws GitLabApiException if any exception occurs
Expand Down Expand Up @@ -2141,7 +2177,7 @@ public GroupAccessToken createGroupAccessToken(Object groupIdOrPath, String name
public GroupAccessToken rotateGroupAccessToken(Object groupIdOrPath, Long tokenId) throws GitLabApiException {
return rotateGroupAccessToken(groupIdOrPath, tokenId, null);
}


/**
* Rotate a group access token. Revokes the previous token and creates a new token that expires in one week.
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/gitlab4j/api/models/SamlGroupLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class SamlGroupLink implements Serializable {

private AccessLevel accessLevel;

private int memberRoleId;

public String getName() {
return name;
}
Expand All @@ -28,6 +30,14 @@ public void setAccessLevel(AccessLevel aAccessLevel) {
accessLevel = aAccessLevel;
}

public int getMemberRoleId() {
return memberRoleId;
}

public void setMemberRoleId(int aMemberRoleId) {
memberRoleId = aMemberRoleId;
}

@Override
public String toString() {
return (JacksonJson.toJsonString(this));
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/org/gitlab4j/api/saml-group-link.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"access_level": 30,
"name": "A_GITLAB_DEVELOPER"
"name": "A_GITLAB_DEVELOPER",
"member_role_id": 6
}