aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws/src/main/java
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2021-11-30 11:01:21 +0100
committersonartech <sonartech@sonarsource.com>2021-12-07 20:03:17 +0000
commit05f25e35b7b489874e8c0cf24ea70196dee90ddb (patch)
tree51e524eafd5b24d2c6a9594ce2a643848936050b /sonar-ws/src/main/java
parent645467493df74d9569cd27d8ffd3da993ab5595c (diff)
downloadsonarqube-05f25e35b7b489874e8c0cf24ea70196dee90ddb.tar.gz
sonarqube-05f25e35b7b489874e8c0cf24ea70196dee90ddb.zip
SONAR-15688 add prometheus web API endpoint
Diffstat (limited to 'sonar-ws/src/main/java')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java8
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java3
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/monitoring/MonitoringService.java58
3 files changed, 69 insertions, 0 deletions
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 8fceccd3b64..b53d9d2728d 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
@@ -40,6 +40,7 @@ import org.sonarqube.ws.client.l10n.L10nService;
import org.sonarqube.ws.client.languages.LanguagesService;
import org.sonarqube.ws.client.measures.MeasuresService;
import org.sonarqube.ws.client.metrics.MetricsService;
+import org.sonarqube.ws.client.monitoring.MonitoringService;
import org.sonarqube.ws.client.navigation.NavigationService;
import org.sonarqube.ws.client.newcodeperiods.NewCodePeriodsService;
import org.sonarqube.ws.client.notifications.NotificationsService;
@@ -104,6 +105,7 @@ class DefaultWsClient implements WsClient {
private final LanguagesService languagesService;
private final MeasuresService measuresService;
private final MetricsService metricsService;
+ private final MonitoringService monitoringService;
private final NavigationService navigationService;
private final NewCodePeriodsService newCodePeriodsService;
private final NotificationsService notificationsService;
@@ -161,6 +163,7 @@ class DefaultWsClient implements WsClient {
this.languagesService = new LanguagesService(wsConnector);
this.measuresService = new MeasuresService(wsConnector);
this.metricsService = new MetricsService(wsConnector);
+ this.monitoringService = new MonitoringService(wsConnector);
this.navigationService = new NavigationService(wsConnector);
this.newCodePeriodsService = new NewCodePeriodsService(wsConnector);
this.notificationsService = new NotificationsService(wsConnector);
@@ -299,6 +302,11 @@ class DefaultWsClient implements WsClient {
}
@Override
+ public MonitoringService monitoring() {
+ return monitoringService;
+ }
+
+ @Override
public NavigationService navigation() {
return navigationService;
}
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 657bc93ac85..675340f6b21 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
@@ -40,6 +40,7 @@ import org.sonarqube.ws.client.l10n.L10nService;
import org.sonarqube.ws.client.languages.LanguagesService;
import org.sonarqube.ws.client.measures.MeasuresService;
import org.sonarqube.ws.client.metrics.MetricsService;
+import org.sonarqube.ws.client.monitoring.MonitoringService;
import org.sonarqube.ws.client.navigation.NavigationService;
import org.sonarqube.ws.client.newcodeperiods.NewCodePeriodsService;
import org.sonarqube.ws.client.notifications.NotificationsService;
@@ -202,4 +203,6 @@ public interface WsClient {
BatchService batch();
SecurityReportsService securityReports();
+
+ MonitoringService monitoring();
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/monitoring/MonitoringService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/monitoring/MonitoringService.java
new file mode 100644
index 00000000000..bae9ce50185
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/monitoring/MonitoringService.java
@@ -0,0 +1,58 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 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.monitoring;
+
+import javax.annotation.Generated;
+import org.sonarqube.ws.client.BaseService;
+import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.WsConnector;
+
+/**
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/monitoring">Further information about this web service online</a>
+ */
+@Generated("sonar-ws-generator")
+public class MonitoringService extends BaseService {
+
+ private String bearerToken;
+
+ public MonitoringService(WsConnector wsConnector) {
+ super(wsConnector, "api/monitoring");
+ }
+
+ /**
+ *
+ * This is a GET request.
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/monitoring/metrics">Further information about this action online (including a response example)</a>
+ * @since 9.3
+ * @return
+ */
+ public String metrics(String mediaType) {
+ GetRequest request = new GetRequest(path("metrics")).setMediaType(mediaType);
+ if (bearerToken != null && !bearerToken.isEmpty()) {
+ request.setHeader("Authorization", "Bearer " + bearerToken);
+ }
+ return call(request).content();
+ }
+
+ public MonitoringService withBearerToken(String bearerToken) {
+ this.bearerToken = bearerToken;
+ return this;
+ }
+}