aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-01-12 12:45:48 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-01-20 12:45:58 +0100
commite678c88a913dd1eacb0c334ad87769a8d120c3b3 (patch)
tree41a2b19f0238ad9886a03d29b5794dbb1bdb0d9b /sonar-ws
parentec96c3e2c8e33bc40e519a7b9566cfb2e9338b52 (diff)
downloadsonarqube-e678c88a913dd1eacb0c334ad87769a8d120c3b3.tar.gz
sonarqube-e678c88a913dd1eacb0c334ad87769a8d120c3b3.zip
SONAR-7134 WS api/measures/component
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentWsRequest.java70
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java20
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java19
-rw-r--r--sonar-ws/src/main/protobuf/ws-measures.proto7
4 files changed, 109 insertions, 7 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentWsRequest.java
new file mode 100644
index 00000000000..df6a800f9d5
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentWsRequest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.measure;
+
+import java.util.List;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+public class ComponentWsRequest {
+ private String componentId;
+ private String componentKey;
+ private List<String> metricKeys;
+ private List<String> additionalFields;
+
+ @CheckForNull
+ public String getComponentId() {
+ return componentId;
+ }
+
+ public ComponentWsRequest setComponentId(@Nullable String componentId) {
+ this.componentId = componentId;
+ return this;
+ }
+
+ @CheckForNull
+ public String getComponentKey() {
+ return componentKey;
+ }
+
+ public ComponentWsRequest setComponentKey(@Nullable String componentKey) {
+ this.componentKey = componentKey;
+ return this;
+ }
+
+ public List<String> getMetricKeys() {
+ return metricKeys;
+ }
+
+ public ComponentWsRequest setMetricKeys(@Nullable List<String> metricKeys) {
+ this.metricKeys = metricKeys;
+ return this;
+ }
+
+ @CheckForNull
+ public List<String> getAdditionalFields() {
+ return additionalFields;
+ }
+
+ public ComponentWsRequest setAdditionalFields(@Nullable List<String> additionalFields) {
+ this.additionalFields = additionalFields;
+ return this;
+ }
+}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java
index 01a9bf7b59d..7fb0019e03f 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java
@@ -19,16 +19,20 @@
*/
package org.sonarqube.ws.client.measure;
-import org.sonarqube.ws.WsMeasures;
+import org.sonarqube.ws.WsMeasures.ComponentTreeWsResponse;
+import org.sonarqube.ws.WsMeasures.ComponentWsResponse;
import org.sonarqube.ws.client.BaseService;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.WsConnector;
+import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_COMPONENT;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_COMPONENT_TREE;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.CONTROLLER_MEASURES;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BASE_COMPONENT_ID;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BASE_COMPONENT_KEY;
+import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT_ID;
+import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT_KEY;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_QUALIFIERS;
@@ -39,7 +43,7 @@ public class MeasuresService extends BaseService {
super(wsConnector, CONTROLLER_MEASURES);
}
- public WsMeasures.ComponentTreeWsResponse componentTree(ComponentTreeWsRequest request) {
+ public ComponentTreeWsResponse componentTree(ComponentTreeWsRequest request) {
GetRequest getRequest = new GetRequest(path(ACTION_COMPONENT_TREE))
.setParam(PARAM_BASE_COMPONENT_ID, request.getBaseComponentId())
.setParam(PARAM_BASE_COMPONENT_KEY, request.getBaseComponentKey())
@@ -54,6 +58,16 @@ public class MeasuresService extends BaseService {
.setParam("asc", request.getAsc())
.setParam(PARAM_METRIC_SORT, request.getMetricSort());
- return call(getRequest, WsMeasures.ComponentTreeWsResponse.parser());
+ return call(getRequest, ComponentTreeWsResponse.parser());
+ }
+
+ public ComponentWsResponse component(ComponentWsRequest request) {
+ GetRequest getRequest = new GetRequest(path(ACTION_COMPONENT))
+ .setParam(PARAM_COMPONENT_ID, request.getComponentId())
+ .setParam(PARAM_COMPONENT_KEY, request.getComponentKey())
+ .setParam(PARAM_ADDITIONAL_FIELDS, inlineMultipleParamValue(request.getAdditionalFields()))
+ .setParam(PARAM_METRIC_KEYS, inlineMultipleParamValue(request.getMetricKeys()));
+
+ return call(getRequest, ComponentWsResponse.parser());
}
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java
index 3f7c9adc52f..5874c4ab8e0 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java
@@ -20,22 +20,33 @@
package org.sonarqube.ws.client.measure;
-public class MeasuresWsParameters {
- private MeasuresWsParameters() {
- // static constants only
- }
+import com.google.common.collect.ImmutableSortedSet;
+import java.util.Set;
+public class MeasuresWsParameters {
public static final String CONTROLLER_MEASURES = "api/measures";
// actions
public static final String ACTION_COMPONENT_TREE = "component_tree";
+ public static final String ACTION_COMPONENT = "component";
// parameters
public static final String PARAM_BASE_COMPONENT_ID = "baseComponentId";
+
public static final String PARAM_BASE_COMPONENT_KEY = "baseComponentKey";
public static final String PARAM_STRATEGY = "strategy";
public static final String PARAM_QUALIFIERS = "qualifiers";
public static final String PARAM_METRIC_KEYS = "metricKeys";
public static final String PARAM_METRIC_SORT = "metricSort";
public static final String PARAM_ADDITIONAL_FIELDS = "additionalFields";
+ public static final String PARAM_COMPONENT_ID = "componentId";
+ public static final String PARAM_COMPONENT_KEY = "componentKey";
+ public static final String ADDITIONAL_METRICS = "metrics";
+
+ public static final String ADDITIONAL_PERIODS = "periods";
+ public static final Set<String> ADDITIONAL_FIELDS = ImmutableSortedSet.of(ADDITIONAL_METRICS, ADDITIONAL_PERIODS);
+
+ private MeasuresWsParameters() {
+ // static constants only
+ }
}
diff --git a/sonar-ws/src/main/protobuf/ws-measures.proto b/sonar-ws/src/main/protobuf/ws-measures.proto
index 6014576568f..eec10749c8f 100644
--- a/sonar-ws/src/main/protobuf/ws-measures.proto
+++ b/sonar-ws/src/main/protobuf/ws-measures.proto
@@ -35,6 +35,13 @@ message ComponentTreeWsResponse {
optional Periods periods = 5;
}
+// WS api/measures/component
+message ComponentWsResponse {
+ optional Component component = 1;
+ optional Metrics metrics = 2;
+ optional Periods periods = 3;
+}
+
message Component {
optional string id = 1;
optional string key = 2;