From b7f90fc1c4d20d202fd244b3db791884c6a37293 Mon Sep 17 00:00:00 2001 From: Aurelien Poscia Date: Fri, 26 May 2023 11:12:30 +0200 Subject: [PATCH] SONAR-19314 Add ITs for GitHub Enterprise provisioning --- .../sonarqube/ws/client/DefaultWsClient.java | 8 ++++ .../org/sonarqube/ws/client/WsClient.java | 3 ++ .../GithubProvisioningService.java | 42 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/githubprovisioning/GithubProvisioningService.java diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java index fc9df74e81f..50f5384554e 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java @@ -34,6 +34,7 @@ import org.sonarqube.ws.client.duplications.DuplicationsService; import org.sonarqube.ws.client.editions.EditionsService; import org.sonarqube.ws.client.emails.EmailsService; import org.sonarqube.ws.client.favorites.FavoritesService; +import org.sonarqube.ws.client.githubprovisioning.GithubProvisioningService; import org.sonarqube.ws.client.governancereports.GovernanceReportsService; import org.sonarqube.ws.client.hotspots.HotspotsService; import org.sonarqube.ws.client.issues.IssuesService; @@ -140,6 +141,7 @@ class DefaultWsClient implements WsClient { private final SecurityReportsService securityReportsService; private final RegulatoryReportsService regulatoryReportsService; private final SonarLintServerPushService sonarLintPushService; + private final GithubProvisioningService githubProvisioningService; DefaultWsClient(WsConnector wsConnector) { this.wsConnector = wsConnector; @@ -198,6 +200,7 @@ class DefaultWsClient implements WsClient { this.securityReportsService = new SecurityReportsService(wsConnector); this.sonarLintPushService = new SonarLintServerPushService(wsConnector); this.regulatoryReportsService = new RegulatoryReportsService(wsConnector); + this.githubProvisioningService = new GithubProvisioningService(wsConnector); } @Override @@ -416,6 +419,11 @@ class DefaultWsClient implements WsClient { return settingsService; } + @Override + public GithubProvisioningService githubProvisioning() { + return githubProvisioningService; + } + @Override public SourcesService sources() { return sourcesService; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java index 7ea98457bfa..d7ed0b38ad1 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java @@ -34,6 +34,7 @@ import org.sonarqube.ws.client.duplications.DuplicationsService; import org.sonarqube.ws.client.editions.EditionsService; import org.sonarqube.ws.client.emails.EmailsService; import org.sonarqube.ws.client.favorites.FavoritesService; +import org.sonarqube.ws.client.githubprovisioning.GithubProvisioningService; import org.sonarqube.ws.client.governancereports.GovernanceReportsService; import org.sonarqube.ws.client.hotspots.HotspotsService; import org.sonarqube.ws.client.issues.IssuesService; @@ -176,6 +177,8 @@ public interface WsClient { SettingsService settings(); + GithubProvisioningService githubProvisioning(); + SourcesService sources(); SupportService support(); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/githubprovisioning/GithubProvisioningService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/githubprovisioning/GithubProvisioningService.java new file mode 100644 index 00000000000..e172e153b97 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/githubprovisioning/GithubProvisioningService.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.ws.client.githubprovisioning; + +import org.sonarqube.ws.client.BaseService; +import org.sonarqube.ws.client.PostRequest; +import org.sonarqube.ws.client.WsConnector; + +public class GithubProvisioningService extends BaseService { + public GithubProvisioningService(WsConnector wsConnector) { + super(wsConnector, "api/github_provisioning"); + } + + public void enable() { + call( + new PostRequest(path("enable")) + ); + } + + public void disable() { + call( + new PostRequest(path("disable")) + ); + } +} -- 2.39.5