diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-11-10 18:28:57 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-11-14 12:18:51 +0100 |
commit | 976aa63a8ee9bf1df31eb23d5085a67074f0d5e7 (patch) | |
tree | c397cfcabeb74f878588577f88fd8a86ac1c6e02 /sonar-ws | |
parent | fc8fa7830f47874a67f3a13b333d24a9ceafe856 (diff) | |
download | sonarqube-976aa63a8ee9bf1df31eb23d5085a67074f0d5e7.tar.gz sonarqube-976aa63a8ee9bf1df31eb23d5085a67074f0d5e7.zip |
SONAR-8353 add WS api/webhooks/deliveries
Diffstat (limited to 'sonar-ws')
6 files changed, 195 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 eff30072e0d..e75239fd506 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 @@ -34,6 +34,7 @@ import org.sonarqube.ws.client.rule.RulesService; import org.sonarqube.ws.client.setting.SettingsService; import org.sonarqube.ws.client.system.SystemService; import org.sonarqube.ws.client.usertoken.UserTokensService; +import org.sonarqube.ws.client.webhook.WebhooksService; /** * This class is not public anymore since version 5.5. It is @@ -59,6 +60,7 @@ class DefaultWsClient implements WsClient { private final ProjectLinksService projectLinksService; private final SettingsService settingsService; private final RootsService rootsService; + private final WebhooksService webhooksService; DefaultWsClient(WsConnector wsConnector) { this.wsConnector = wsConnector; @@ -77,6 +79,7 @@ class DefaultWsClient implements WsClient { this.projectLinksService = new ProjectLinksService(wsConnector); this.settingsService = new SettingsService(wsConnector); this.rootsService = new RootsService(wsConnector); + this.webhooksService = new WebhooksService(wsConnector); } @Override @@ -158,4 +161,9 @@ class DefaultWsClient implements WsClient { public RootsService rootService() { return rootsService; } + + @Override + public WebhooksService webhooks() { + return webhooksService; + } } 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 add8512bca2..d2317c16270 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 @@ -34,6 +34,7 @@ import org.sonarqube.ws.client.rule.RulesService; import org.sonarqube.ws.client.setting.SettingsService; import org.sonarqube.ws.client.system.SystemService; import org.sonarqube.ws.client.usertoken.UserTokensService; +import org.sonarqube.ws.client.webhook.WebhooksService; /** * Allows to request the web services of SonarQube server. Instance is provided by @@ -97,4 +98,9 @@ public interface WsClient { * @since 6.2 */ RootsService rootService(); + + /** + * @since 6.2 + */ + WebhooksService webhooks(); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/webhook/DeliveriesRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhook/DeliveriesRequest.java new file mode 100644 index 00000000000..af9ad99940c --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhook/DeliveriesRequest.java @@ -0,0 +1,73 @@ +/* + * 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.webhook; + +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + +public class DeliveriesRequest { + + private final String componentKey; + private final String ceTaskId; + + private DeliveriesRequest(Builder builder) { + this.componentKey = builder.componentKey; + this.ceTaskId = builder.ceTaskId; + } + + @CheckForNull + public String getComponentKey() { + return componentKey; + } + + @CheckForNull + public String getCeTaskId() { + return ceTaskId; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String componentKey; + private String ceTaskId; + + /** + * @see #builder() + */ + private Builder() { + } + + public Builder setComponentKey(@Nullable String s) { + this.componentKey = s; + return this; + } + + public Builder setCeTaskId(@Nullable String s) { + this.ceTaskId = s; + return this; + } + + public DeliveriesRequest build() { + return new DeliveriesRequest(this); + } + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/webhook/WebhooksService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhook/WebhooksService.java new file mode 100644 index 00000000000..67ee10aaf57 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhook/WebhooksService.java @@ -0,0 +1,42 @@ +/* + * 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.webhook; + +import org.sonarqube.ws.Webhooks; +import org.sonarqube.ws.client.BaseService; +import org.sonarqube.ws.client.GetRequest; +import org.sonarqube.ws.client.WsConnector; + +public class WebhooksService extends BaseService { + + public WebhooksService(WsConnector wsConnector) { + super(wsConnector, "api/webhooks"); + } + + /** + * @throws org.sonarqube.ws.client.HttpException if HTTP status code is not 2xx. + */ + public Webhooks.DeliveriesWsResponse deliveries(DeliveriesRequest request) { + GetRequest httpRequest = new GetRequest(path("deliveries")) + .setParam("componentKey", request.getComponentKey()) + .setParam("ceTaskId", request.getCeTaskId()); + return call(httpRequest, Webhooks.DeliveriesWsResponse.parser()); + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/webhook/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhook/package-info.java new file mode 100644 index 00000000000..c613c4a612f --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhook/package-info.java @@ -0,0 +1,24 @@ +/* + * 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. + */ +@ParametersAreNonnullByDefault +package org.sonarqube.ws.client.webhook; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-ws/src/main/protobuf/ws-webhooks.proto b/sonar-ws/src/main/protobuf/ws-webhooks.proto new file mode 100644 index 00000000000..4ef519c3b9b --- /dev/null +++ b/sonar-ws/src/main/protobuf/ws-webhooks.proto @@ -0,0 +1,42 @@ +// SonarQube, open source software quality management tool. +// Copyright (C) 2008-2016 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.webhooks; + +option java_package = "org.sonarqube.ws"; +option java_outer_classname = "Webhooks"; +option optimize_for = SPEED; + +// WS api/webhooks/deliveries +message DeliveriesWsResponse { + repeated Delivery deliveries = 1; +} + +message Delivery { + optional string id = 1; + optional string componentKey = 2; + optional string ceTaskId = 3; + optional string name = 4; + optional string url = 5; + optional string at = 6; + optional bool success = 7; + optional int32 httpStatus = 8; + optional int32 durationMs = 9; +} |