aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-04-19 16:31:19 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-04-21 01:23:38 +0200
commitdf26dc012a326999578e4fca3d8430ae1bc0ff5d (patch)
treea46072f651effed8527d3d1f26faba26b689806f /sonar-ws
parentb53cc3cb38c77de88c1d55377968a13c7ab4df66 (diff)
downloadsonarqube-df26dc012a326999578e4fca3d8430ae1bc0ff5d.tar.gz
sonarqube-df26dc012a326999578e4fca3d8430ae1bc0ff5d.zip
SONAR-7553 WS api/ce/activity_status display background tasks related metrics for UI
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/ce/ActivityStatusWsRequest.java71
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java10
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeWsParameters.java1
-rw-r--r--sonar-ws/src/main/protobuf/ws-ce.proto6
4 files changed, 88 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/ActivityStatusWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/ActivityStatusWsRequest.java
new file mode 100644
index 00000000000..66407145b75
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/ActivityStatusWsRequest.java
@@ -0,0 +1,71 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.ce;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+public class ActivityStatusWsRequest {
+ private final String componentId;
+ private final String componentKey;
+
+ private ActivityStatusWsRequest(Builder builder) {
+ this.componentId = builder.componentId;
+ this.componentKey = builder.componentKey;
+ }
+
+ @CheckForNull
+ public String getComponentId() {
+ return componentId;
+ }
+
+ @CheckForNull
+ public String getComponentKey() {
+ return componentKey;
+ }
+
+ public static Builder newBuilder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String componentId;
+ private String componentKey;
+
+ private Builder() {
+ // enforce newBuilder() use for instantiation
+ }
+
+ public Builder setComponentId(@Nullable String componentId) {
+ this.componentId = componentId;
+ return this;
+ }
+
+ public Builder setComponentKey(@Nullable String componentKey) {
+ this.componentKey = componentKey;
+ return this;
+ }
+
+ public ActivityStatusWsRequest build() {
+ return new ActivityStatusWsRequest(this);
+ }
+ }
+}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java
index 1871cd800d9..460ddb53faa 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeService.java
@@ -28,6 +28,7 @@ import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.WsConnector;
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID;
+import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_KEY;
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_MAX_EXECUTED_AT;
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_MIN_SUBMITTED_AT;
import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_ONLY_CURRENTS;
@@ -71,4 +72,13 @@ public class CeService extends BaseService {
public WsCe.TaskResponse task(String id) {
return call(new GetRequest(path("task")).setParam("id", id), WsCe.TaskResponse.parser());
}
+
+ public WsCe.ActivityStatusWsResponse activityStatus(ActivityStatusWsRequest request) {
+ return call(
+ new GetRequest(path("activity_status"))
+ .setParam(PARAM_COMPONENT_ID, request.getComponentId())
+ .setParam(PARAM_COMPONENT_KEY, request.getComponentKey()),
+ WsCe.ActivityStatusWsResponse.parser());
+ }
+
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeWsParameters.java
index 3b4fc97e4f1..e2254619a2a 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeWsParameters.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/CeWsParameters.java
@@ -22,6 +22,7 @@ package org.sonarqube.ws.client.ce;
public class CeWsParameters {
public static final String PARAM_COMPONENT_ID = "componentId";
+ public static final String PARAM_COMPONENT_KEY = "componentKey";
public static final String PARAM_COMPONENT_QUERY = "componentQuery";
public static final String PARAM_TYPE = "type";
public static final String PARAM_STATUS = "status";
diff --git a/sonar-ws/src/main/protobuf/ws-ce.proto b/sonar-ws/src/main/protobuf/ws-ce.proto
index 126122a0561..4440851e45a 100644
--- a/sonar-ws/src/main/protobuf/ws-ce.proto
+++ b/sonar-ws/src/main/protobuf/ws-ce.proto
@@ -44,6 +44,12 @@ message ActivityResponse {
repeated Task tasks = 2;
}
+// GET api/ce/activity_status
+message ActivityStatusWsResponse {
+ optional int32 pending = 1;
+ optional int32 failing = 2;
+}
+
// GET api/ce/project
message ProjectResponse {
repeated Task queue = 1;