diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-12-04 12:09:25 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-12-08 00:27:39 +0100 |
commit | 0a5e742023c7ee832c2b52de93e1c27cf76c34f4 (patch) | |
tree | c40f1635946bcd16d332bc29e7174b06e080fc28 /sonar-ws | |
parent | e59a159c447807f3793bc093c73b6307c4a26251 (diff) | |
download | sonarqube-0a5e742023c7ee832c2b52de93e1c27cf76c34f4.tar.gz sonarqube-0a5e742023c7ee832c2b52de93e1c27cf76c34f4.zip |
SONAR-6900 New WS api/qualitygates/project_status quality gate details of an analysis
Diffstat (limited to 'sonar-ws')
7 files changed, 188 insertions, 8 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java index d172f4bbf88..0435aed90a8 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java @@ -23,6 +23,7 @@ package org.sonarqube.ws.client; import org.sonarqube.ws.client.component.ComponentsService; import org.sonarqube.ws.client.issue.IssuesService; import org.sonarqube.ws.client.permission.PermissionsService; +import org.sonarqube.ws.client.qualitygate.QualityGatesService; import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; import org.sonarqube.ws.client.usertoken.UserTokensService; @@ -38,6 +39,7 @@ public class HttpWsClient implements WsClient { private final QualityProfilesService qualityProfilesService; private final IssuesService issuesService; private final UserTokensService userTokensService; + private final QualityGatesService qualityGatesService; private final WsConnector wsConnector; public HttpWsClient(WsConnector wsConnector) { @@ -47,6 +49,7 @@ public class HttpWsClient implements WsClient { this.qualityProfilesService = new QualityProfilesService(wsConnector); this.issuesService = new IssuesService(wsConnector); this.userTokensService = new UserTokensService(wsConnector); + this.qualityGatesService = new QualityGatesService(wsConnector); } @Override @@ -78,4 +81,9 @@ public class HttpWsClient implements WsClient { public UserTokensService userTokens() { return userTokensService; } + + @Override + public QualityGatesService qualityGates() { + return qualityGatesService; + } } 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 3f980d7c591..67e088c46be 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 @@ -22,6 +22,7 @@ package org.sonarqube.ws.client; import org.sonarqube.ws.client.component.ComponentsService; import org.sonarqube.ws.client.issue.IssuesService; import org.sonarqube.ws.client.permission.PermissionsService; +import org.sonarqube.ws.client.qualitygate.QualityGatesService; import org.sonarqube.ws.client.qualityprofile.QualityProfilesService; import org.sonarqube.ws.client.usertoken.UserTokensService; @@ -39,5 +40,7 @@ public interface WsClient { UserTokensService userTokens(); + QualityGatesService qualityGates(); + WsConnector wsConnector(); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygate/ProjectStatusWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygate/ProjectStatusWsRequest.java new file mode 100644 index 00000000000..b9d435ff065 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygate/ProjectStatusWsRequest.java @@ -0,0 +1,34 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.qualitygate; + +public class ProjectStatusWsRequest { + private String taskId; + + public String getAnalysisId() { + return taskId; + } + + public ProjectStatusWsRequest setAnalysisId(String taskId) { + this.taskId = taskId; + return this; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygate/QualityGatesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygate/QualityGatesService.java new file mode 100644 index 00000000000..404619e1814 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygate/QualityGatesService.java @@ -0,0 +1,39 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.qualitygate; + +import org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse; +import org.sonarqube.ws.client.BaseService; +import org.sonarqube.ws.client.GetRequest; +import org.sonarqube.ws.client.WsConnector; + +public class QualityGatesService extends BaseService { + + public QualityGatesService(WsConnector wsConnector) { + super(wsConnector, "api/qualitygates"); + } + + public ProjectStatusWsResponse projectStatus(ProjectStatusWsRequest request) { + return call(new GetRequest(path("project_status")) + .setParam("analysisId", request.getAnalysisId()), + ProjectStatusWsResponse.parser()); + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygate/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygate/package-info.java new file mode 100644 index 00000000000..084636cef47 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygate/package-info.java @@ -0,0 +1,26 @@ + +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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. + */ + +@ParametersAreNonnullByDefault +package org.sonarqube.ws.client.qualitygate; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-ws/src/main/protobuf/ws-ce.proto b/sonar-ws/src/main/protobuf/ws-ce.proto index b6d930a8f02..9c27b02f4c9 100644 --- a/sonar-ws/src/main/protobuf/ws-ce.proto +++ b/sonar-ws/src/main/protobuf/ws-ce.proto @@ -61,14 +61,15 @@ message Task { optional string componentKey = 4; optional string componentName = 5; optional string componentQualifier = 6; - optional TaskStatus status = 7; - optional string submittedAt = 8; - optional string submitterLogin = 9; - optional string startedAt = 10; - optional string executedAt = 11; - optional bool isLastExecuted = 12; - optional int64 executionTimeMs = 13; - optional bool logs = 14; + optional string analysisId = 7; + optional TaskStatus status = 8; + optional string submittedAt = 9; + optional string submitterLogin = 10; + optional string startedAt = 11; + optional string executedAt = 12; + optional bool isLastExecuted = 13; + optional int64 executionTimeMs = 14; + optional bool logs = 15; } enum TaskStatus { diff --git a/sonar-ws/src/main/protobuf/ws-qualitygates.proto b/sonar-ws/src/main/protobuf/ws-qualitygates.proto new file mode 100644 index 00000000000..f4669419d86 --- /dev/null +++ b/sonar-ws/src/main/protobuf/ws-qualitygates.proto @@ -0,0 +1,69 @@ +// SonarQube, open source software quality management tool. +// Copyright (C) 2008-2015 SonarSource +// mailto:contact AT sonarsource DOT com +// +// SonarQube 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. +// +// SonarQube 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. + +syntax = "proto2"; + +package sonarqube.ws.qualitygate; + +import "ws-commons.proto"; + +option java_package = "org.sonarqube.ws"; +option java_outer_classname = "WsQualityGates"; +option optimize_for = SPEED; + +// GET api/qualitygates/project_status +message ProjectStatusWsResponse { + optional ProjectStatus projectStatus = 1; + + message ProjectStatus { + optional Status status = 1; + repeated Condition conditions = 2; + repeated Period periods = 3; + } + + message Condition { + optional Status status = 1; + optional string metricKey = 2; + optional Comparator comparator = 3; + optional int32 periodIndex = 4; + optional string warningThreshold = 5; + optional string errorThreshold = 6; + optional string actualValue = 7; + } + + message Period { + optional int32 index = 1; + optional string mode = 2; + optional string date = 3; + optional string parameter = 4; + } + + enum Status { + OK = 1; + WARN = 2; + ERROR = 3; + NONE = 4; + } + + enum Comparator { + GT = 1; + LT = 2; + EQ = 3; + NE = 4; + } +} |