diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2018-05-23 19:19:51 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-05-28 20:20:45 +0200 |
commit | 0f0c3b73cc423fe90d6f4b97d6e73fe7bcdc485d (patch) | |
tree | 22375a631d9ebbf013bd874dd8eafc20954a75b9 /sonar-ws/src/main/java/org/sonarqube | |
parent | aff59ce2552d4a9071f7bd9d08f1fb4365843b05 (diff) | |
download | sonarqube-0f0c3b73cc423fe90d6f4b97d6e73fe7bcdc485d.tar.gz sonarqube-0f0c3b73cc423fe90d6f4b97d6e73fe7bcdc485d.zip |
SONAR-10713 Badges can only be used on projects, long living branches and applications
Diffstat (limited to 'sonar-ws/src/main/java/org/sonarqube')
6 files changed, 257 insertions, 4 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 bdbbbf90c62..4a078808d03 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 @@ -43,6 +43,7 @@ import org.sonarqube.ws.client.permissions.PermissionsService; import org.sonarqube.ws.client.plugins.PluginsService; import org.sonarqube.ws.client.profiles.ProfilesService; import org.sonarqube.ws.client.projectanalyses.ProjectAnalysesService; +import org.sonarqube.ws.client.projectbadges.ProjectBadgesService; import org.sonarqube.ws.client.projectbranches.ProjectBranchesService; import org.sonarqube.ws.client.projectlinks.ProjectLinksService; import org.sonarqube.ws.client.projectpullrequests.ProjectPullRequestsService; @@ -101,6 +102,7 @@ class DefaultWsClient implements WsClient { private final PluginsService pluginsService; private final ProfilesService profilesService; private final ProjectAnalysesService projectAnalysesService; + private final ProjectBadgesService projectBadgesService; private final ProjectBranchesService projectBranchesService; private final ProjectLinksService projectLinksService; private final ProjectPullRequestsService projectPullRequestsService; @@ -152,6 +154,7 @@ class DefaultWsClient implements WsClient { this.pluginsService = new PluginsService(wsConnector); this.profilesService = new ProfilesService(wsConnector); this.projectAnalysesService = new ProjectAnalysesService(wsConnector); + this.projectBadgesService = new ProjectBadgesService(wsConnector); this.projectBranchesService = new ProjectBranchesService(wsConnector); this.projectLinksService = new ProjectLinksService(wsConnector); this.projectPullRequestsService = new ProjectPullRequestsService(wsConnector); @@ -296,6 +299,11 @@ class DefaultWsClient implements WsClient { } @Override + public ProjectBadgesService projectBadges() { + return projectBadgesService; + } + + @Override public ProjectBranchesService projectBranches() { return projectBranchesService; } 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 79ca15098c2..362ee5cdd1b 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 @@ -20,9 +20,9 @@ package org.sonarqube.ws.client; import javax.annotation.Generated; - import org.sonarqube.ws.client.analysisreports.AnalysisReportsService; import org.sonarqube.ws.client.authentication.AuthenticationService; +import org.sonarqube.ws.client.batch.BatchService; import org.sonarqube.ws.client.ce.CeService; import org.sonarqube.ws.client.components.ComponentsService; import org.sonarqube.ws.client.custommeasures.CustomMeasuresService; @@ -43,11 +43,12 @@ import org.sonarqube.ws.client.permissions.PermissionsService; import org.sonarqube.ws.client.plugins.PluginsService; import org.sonarqube.ws.client.profiles.ProfilesService; import org.sonarqube.ws.client.projectanalyses.ProjectAnalysesService; +import org.sonarqube.ws.client.projectbadges.ProjectBadgesService; import org.sonarqube.ws.client.projectbranches.ProjectBranchesService; import org.sonarqube.ws.client.projectlinks.ProjectLinksService; import org.sonarqube.ws.client.projectpullrequests.ProjectPullRequestsService; -import org.sonarqube.ws.client.projecttags.ProjectTagsService; import org.sonarqube.ws.client.projects.ProjectsService; +import org.sonarqube.ws.client.projecttags.ProjectTagsService; import org.sonarqube.ws.client.properties.PropertiesService; import org.sonarqube.ws.client.qualitygates.QualitygatesService; import org.sonarqube.ws.client.qualityprofiles.QualityprofilesService; @@ -63,11 +64,10 @@ import org.sonarqube.ws.client.timemachine.TimemachineService; import org.sonarqube.ws.client.updatecenter.UpdatecenterService; import org.sonarqube.ws.client.usergroups.UserGroupsService; import org.sonarqube.ws.client.userproperties.UserPropertiesService; -import org.sonarqube.ws.client.usertokens.UserTokensService; import org.sonarqube.ws.client.users.UsersService; +import org.sonarqube.ws.client.usertokens.UserTokensService; import org.sonarqube.ws.client.webhooks.WebhooksService; import org.sonarqube.ws.client.webservices.WebservicesService; -import org.sonarqube.ws.client.batch.BatchService; /** * Allows to request the web services of SonarQube server. Instance is provided by @@ -136,6 +136,8 @@ public interface WsClient { ProjectAnalysesService projectAnalyses(); + ProjectBadgesService projectBadges(); + ProjectBranchesService projectBranches(); ProjectLinksService projectLinks(); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/MeasureRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/MeasureRequest.java new file mode 100644 index 00000000000..4dc8d38071c --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/MeasureRequest.java @@ -0,0 +1,87 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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.projectbadges; + +import javax.annotation.Generated; + +/** + * This is part of the internal API. + * This is a POST request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/project_badges/measure">Further information about this action online (including a response example)</a> + * @since 7.1 + */ +@Generated("sonar-ws-generator") +public class MeasureRequest { + + private String branch; + private String metric; + private String project; + + /** + * Example value: "feature/my_branch" + */ + public MeasureRequest setBranch(String branch) { + this.branch = branch; + return this; + } + + public String getBranch() { + return branch; + } + + /** + * This is a mandatory parameter. + * Possible values: + * <ul> + * <li>"bugs"</li> + * <li>"code_smells"</li> + * <li>"coverage"</li> + * <li>"duplicated_lines_density"</li> + * <li>"ncloc"</li> + * <li>"sqale_rating"</li> + * <li>"alert_status"</li> + * <li>"reliability_rating"</li> + * <li>"security_rating"</li> + * <li>"sqale_index"</li> + * <li>"vulnerabilities"</li> + * </ul> + */ + public MeasureRequest setMetric(String metric) { + this.metric = metric; + return this; + } + + public String getMetric() { + return metric; + } + + /** + * This is a mandatory parameter. + * Example value: "my_project" + */ + public MeasureRequest setProject(String project) { + this.project = project; + return this; + } + + public String getProject() { + return project; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/ProjectBadgesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/ProjectBadgesService.java new file mode 100644 index 00000000000..a9e82db111a --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/ProjectBadgesService.java @@ -0,0 +1,70 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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.projectbadges; + +import javax.annotation.Generated; +import org.sonarqube.ws.MediaTypes; +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/project_badges">Further information about this web service online</a> + */ +@Generated("sonar-ws-generator") +public class ProjectBadgesService extends BaseService { + + public ProjectBadgesService(WsConnector wsConnector) { + super(wsConnector, "api/project_badges"); + } + + /** + * + * This is part of the internal API. + * This is a GET request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/project_badges/measure">Further information about this action online (including a response example)</a> + * @since 7.1 + */ + public String measure(MeasureRequest request) { + return call( + new GetRequest(path("measure")) + .setParam("branch", request.getBranch()) + .setParam("metric", request.getMetric()) + .setParam("project", request.getProject()) + .setMediaType(MediaTypes.JSON) + ).content(); + } + + /** + * + * This is part of the internal API. + * This is a GET request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/project_badges/quality_gate">Further information about this action online (including a response example)</a> + * @since 7.1 + */ + public String qualityGate(QualityGateRequest request) { + return call( + new GetRequest(path("quality_gate")) + .setParam("branch", request.getBranch()) + .setParam("project", request.getProject()) + .setMediaType(MediaTypes.JSON) + ).content(); + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/QualityGateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/QualityGateRequest.java new file mode 100644 index 00000000000..202804039cd --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/QualityGateRequest.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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.projectbadges; + +import javax.annotation.Generated; + +/** + * This is part of the internal API. + * This is a POST request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/project_badges/quality_gate">Further information about this action online (including a response example)</a> + * @since 7.1 + */ +@Generated("sonar-ws-generator") +public class QualityGateRequest { + + private String branch; + private String project; + + /** + * Example value: "feature/my_branch" + */ + public QualityGateRequest setBranch(String branch) { + this.branch = branch; + return this; + } + + public String getBranch() { + return branch; + } + + /** + * This is a mandatory parameter. + * Example value: "my_project" + */ + public QualityGateRequest setProject(String project) { + this.project = project; + return this; + } + + public String getProject() { + return project; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/package-info.java new file mode 100644 index 00000000000..6587f213bb8 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/package-info.java @@ -0,0 +1,26 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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. + */ +@ParametersAreNonnullByDefault +@Generated("sonar-ws-generator") +package org.sonarqube.ws.client.projectbadges; + +import javax.annotation.Generated; +import javax.annotation.ParametersAreNonnullByDefault; + |