Skip to content

Commit a7fe866

Browse files
add member_role_id for saml group link (#1126)
1 parent bc35080 commit a7fe866

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

Diff for: src/main/java/org/gitlab4j/api/GroupApi.java

+39-3
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,26 @@ public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessL
13151315
addSamlGroupLink(groupIdOrPath, samlGroupName, groupAccess.toValue());
13161316
}
13171317

1318+
/**
1319+
* Adds an SAML group link.
1320+
*
1321+
* <pre><code>GitLab Endpoint: POST /groups/:id/saml_group_links</code></pre>
1322+
*
1323+
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
1324+
* @param samlGroupName the name of the SAML group
1325+
* @param groupAccess the minimum access level for members of the SAML group
1326+
* @param memberRoleId the id of the custom member role to assign
1327+
* @throws GitLabApiException if any exception occurs
1328+
*/
1329+
public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessLevel groupAccess, int memberRoleId) throws GitLabApiException {
1330+
1331+
if (groupAccess == null) {
1332+
throw new RuntimeException("groupAccess cannot be null or empty");
1333+
}
1334+
1335+
addSamlGroupLink(groupIdOrPath, samlGroupName, groupAccess.toValue(), memberRoleId);
1336+
}
1337+
13181338
/**
13191339
* Adds an SAML group link.
13201340
*
@@ -1326,9 +1346,25 @@ public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessL
13261346
* @throws GitLabApiException if any exception occurs
13271347
*/
13281348
public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, Integer groupAccess) throws GitLabApiException {
1349+
addSamlGroupLink(groupIdOrPath, samlGroupName, groupAccess, null);
1350+
}
1351+
1352+
/**
1353+
* Adds an SAML group link.
1354+
*
1355+
* <pre><code>GitLab Endpoint: POST /groups/:id/saml_group_links</code></pre>
1356+
*
1357+
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
1358+
* @param samlGroupName the name of the SAML group
1359+
* @param groupAccess the minimum access level for members of the SAML group
1360+
* @param memberRoleId the id of the custom member role to assign
1361+
* @throws GitLabApiException if any exception occurs
1362+
*/
1363+
public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, Integer groupAccess, Integer memberRoleId) throws GitLabApiException {
13291364
GitLabApiForm formData = new GitLabApiForm()
13301365
.withParam("saml_group_name", samlGroupName, true)
1331-
.withParam("access_level", groupAccess, true);
1366+
.withParam("access_level", groupAccess, true)
1367+
.withParam("member_role_id", memberRoleId);
13321368
post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "saml_group_links");
13331369
}
13341370

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

21462182
/**
21472183
* Rotate a group access token. Revokes the previous token and creates a new token that expires in one week.

Diff for: src/main/java/org/gitlab4j/api/models/SamlGroupLink.java

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class SamlGroupLink implements Serializable {
1212

1313
private AccessLevel accessLevel;
1414

15+
private int memberRoleId;
16+
1517
public String getName() {
1618
return name;
1719
}
@@ -28,6 +30,14 @@ public void setAccessLevel(AccessLevel aAccessLevel) {
2830
accessLevel = aAccessLevel;
2931
}
3032

33+
public int getMemberRoleId() {
34+
return memberRoleId;
35+
}
36+
37+
public void setMemberRoleId(int aMemberRoleId) {
38+
memberRoleId = aMemberRoleId;
39+
}
40+
3141
@Override
3242
public String toString() {
3343
return (JacksonJson.toJsonString(this));
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"access_level": 30,
3-
"name": "A_GITLAB_DEVELOPER"
3+
"name": "A_GITLAB_DEVELOPER",
4+
"member_role_id": 6
45
}

0 commit comments

Comments
 (0)