aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorNolwenn Cadic <98824442+Nolwenn-cadic-sonarsource@users.noreply.github.com>2024-08-23 11:40:21 +0200
committersonartech <sonartech@sonarsource.com>2024-08-23 20:02:33 +0000
commite0864f31ef49e1c87d1550be20388ea8293a55cb (patch)
treec3a786d9d43553ce07cd574ff948bdcebc826ec3 /sonar-ws
parentb80a57a23ecf821ce3b5c78b77bce4a20ef235e1 (diff)
downloadsonarqube-e0864f31ef49e1c87d1550be20388ea8293a55cb.tar.gz
sonarqube-e0864f31ef49e1c87d1550be20388ea8293a55cb.zip
SONAR-22807 Provisioning of permissions uses custom mapping
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/AddOrModifyGitlabPermissionMappingRequest.java (renamed from sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/AddGitlabPermissionMappingRequest.java)2
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/GitlabPermissionService.java17
2 files changed, 15 insertions, 4 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/AddGitlabPermissionMappingRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/AddOrModifyGitlabPermissionMappingRequest.java
index 655bba02172..8b76299522c 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/AddGitlabPermissionMappingRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/AddOrModifyGitlabPermissionMappingRequest.java
@@ -21,6 +21,6 @@ package org.sonarqube.ws.client.gitlab.provisioning.permissions;
import org.sonarqube.ws.client.github.provisioning.permissions.SonarqubePermissions;
-public record AddGitlabPermissionMappingRequest(String gitlabRole, SonarqubePermissions permissions) {
+public record AddOrModifyGitlabPermissionMappingRequest(String gitlabRole, SonarqubePermissions permissions) {
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/GitlabPermissionService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/GitlabPermissionService.java
index bad74534d58..9fda4266957 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/GitlabPermissionService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/gitlab/provisioning/permissions/GitlabPermissionService.java
@@ -20,11 +20,14 @@
package org.sonarqube.ws.client.gitlab.provisioning.permissions;
import com.google.gson.Gson;
+import java.util.Locale;
import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.client.BaseService;
+import org.sonarqube.ws.client.PatchRequest;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsConnector;
import org.sonarqube.ws.client.WsResponse;
+import org.sonarqube.ws.client.github.provisioning.permissions.SonarqubePermissions;
public class GitlabPermissionService extends BaseService {
@@ -32,14 +35,22 @@ public class GitlabPermissionService extends BaseService {
super(wsConnector, "api/v2");
}
- public void addPermissionMapping(AddGitlabPermissionMappingRequest addLabPermissionMappingRequest) {
+ public void addPermissionMapping(AddOrModifyGitlabPermissionMappingRequest addLabPermissionMappingRequest) {
callEndpointToAddPermissionMapping(addLabPermissionMappingRequest).close();
}
- private WsResponse callEndpointToAddPermissionMapping(AddGitlabPermissionMappingRequest addGitlabPermissionMappingRequest) {
+ private WsResponse callEndpointToAddPermissionMapping(AddOrModifyGitlabPermissionMappingRequest addOrModifyGitlabPermissionMappingRequest) {
return call(
new PostRequest(path("dop-translation/gitlab-permission-mappings"))
- .setBody(new Gson().toJson(addGitlabPermissionMappingRequest))
+ .setBody(new Gson().toJson(addOrModifyGitlabPermissionMappingRequest))
.setMediaType(MediaTypes.JSON));
}
+
+ public void modifyPermissionMapping(String role, SonarqubePermissions permissions) {
+ call(
+ new PatchRequest(path("dop-translation/gitlab-permission-mappings/" + role.toLowerCase(Locale.getDefault())))
+ .setBody(new Gson().toJson(new AddOrModifyGitlabPermissionMappingRequest(role, permissions)))
+ .setContentType("application/merge-patch+json")
+ .setMediaType(MediaTypes.JSON)).close();
+ }
}