diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2018-02-14 15:54:21 +0100 |
---|---|---|
committer | Guillaume Jambet <guillaume.jambet@gmail.com> | 2018-03-01 15:21:05 +0100 |
commit | bad30545b5ed235f7778c00baedbbe0e41006049 (patch) | |
tree | f6b9e864dcbe2d0c0d2eca070a73a01d734caeef /sonar-ws | |
parent | 5caae9b3367cdad3c31d2ed8a7031efd8dfe71c3 (diff) | |
download | sonarqube-bad30545b5ed235f7778c00baedbbe0e41006049.tar.gz sonarqube-bad30545b5ed235f7778c00baedbbe0e41006049.zip |
SONAR-10345 Add IT's for webhooks management
Diffstat (limited to 'sonar-ws')
5 files changed, 340 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/CreateRequest.java new file mode 100644 index 00000000000..2162c20f54e --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/CreateRequest.java @@ -0,0 +1,89 @@ +/* + * 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.webhooks; + +import java.util.List; +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/webhooks/create">Further information about this action online (including a response example)</a> + * @since 7.1 + */ +@Generated("sonar-ws-generator") +public class CreateRequest { + + private String name; + private String organization; + private String project; + private String url; + + /** + * This is a mandatory parameter. + * Example value: "My Webhook" + */ + public CreateRequest setName(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + /** + * This is part of the internal API. + * Example value: "my-org" + */ + public CreateRequest setOrganization(String organization) { + this.organization = organization; + return this; + } + + public String getOrganization() { + return organization; + } + + /** + * Example value: "my_project" + */ + public CreateRequest setProject(String project) { + this.project = project; + return this; + } + + public String getProject() { + return project; + } + + /** + * This is a mandatory parameter. + * Example value: "https://www.my-webhook-listener.com/sonar" + */ + public CreateRequest setUrl(String url) { + this.url = url; + return this; + } + + public String getUrl() { + return url; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/DeleteRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/DeleteRequest.java new file mode 100644 index 00000000000..aab9cea892a --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/DeleteRequest.java @@ -0,0 +1,48 @@ +/* + * 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.webhooks; + +import java.util.List; +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/webhooks/delete">Further information about this action online (including a response example)</a> + * @since 7.1 + */ +@Generated("sonar-ws-generator") +public class DeleteRequest { + + private String webhook; + + /** + * This is a mandatory parameter. + * Example value: "my_project" + */ + public DeleteRequest setWebhook(String webhook) { + this.webhook = webhook; + return this; + } + + public String getWebhook() { + return webhook; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/ListRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/ListRequest.java new file mode 100644 index 00000000000..d56a8804e2f --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/ListRequest.java @@ -0,0 +1,61 @@ +/* + * 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.webhooks; + +import java.util.List; +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/webhooks/list">Further information about this action online (including a response example)</a> + * @since 7.1 + */ +@Generated("sonar-ws-generator") +public class ListRequest { + + private String organization; + private String project; + + /** + * This is part of the internal API. + * Example value: "my-org" + */ + public ListRequest setOrganization(String organization) { + this.organization = organization; + return this; + } + + public String getOrganization() { + return organization; + } + + /** + * Example value: "my_project" + */ + public ListRequest 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/webhooks/UpdateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/UpdateRequest.java new file mode 100644 index 00000000000..64b8ad6811f --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/UpdateRequest.java @@ -0,0 +1,76 @@ +/* + * 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.webhooks; + +import java.util.List; +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/webhooks/update">Further information about this action online (including a response example)</a> + * @since 7.1 + */ +@Generated("sonar-ws-generator") +public class UpdateRequest { + + private String name; + private String url; + private String webhook; + + /** + * This is a mandatory parameter. + * Example value: "My Webhook" + */ + public UpdateRequest setName(String name) { + this.name = name; + return this; + } + + public String getName() { + return name; + } + + /** + * This is a mandatory parameter. + * Example value: "https://www.my-webhook-listener.com/sonar" + */ + public UpdateRequest setUrl(String url) { + this.url = url; + return this; + } + + public String getUrl() { + return url; + } + + /** + * This is a mandatory parameter. + * Example value: "my_project" + */ + public UpdateRequest setWebhook(String webhook) { + this.webhook = webhook; + return this; + } + + public String getWebhook() { + return webhook; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/WebhooksService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/WebhooksService.java index 9f8b4587acc..7eb3b34a329 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/WebhooksService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/webhooks/WebhooksService.java @@ -26,8 +26,10 @@ import org.sonarqube.ws.client.BaseService; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsConnector; +import org.sonarqube.ws.Webhooks.CreateWsResponse; import org.sonarqube.ws.Webhooks.DeliveriesWsResponse; import org.sonarqube.ws.Webhooks.DeliveryWsResponse; +import org.sonarqube.ws.Webhooks.ListWsResponse; /** * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks">Further information about this web service online</a> @@ -42,6 +44,38 @@ public class WebhooksService extends BaseService { /** * * This is part of the internal API. + * This is a POST request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/create">Further information about this action online (including a response example)</a> + * @since 7.1 + */ + public CreateWsResponse create(CreateRequest request) { + return call( + new PostRequest(path("create")) + .setParam("name", request.getName()) + .setParam("organization", request.getOrganization()) + .setParam("project", request.getProject()) + .setParam("url", request.getUrl()), + CreateWsResponse.parser()); + } + + /** + * + * This is part of the internal API. + * This is a POST request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/delete">Further information about this action online (including a response example)</a> + * @since 7.1 + */ + public void delete(DeleteRequest request) { + call( + new PostRequest(path("delete")) + .setParam("webhook", request.getWebhook()) + .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/webhooks/deliveries">Further information about this action online (including a response example)</a> * @since 6.2 @@ -67,4 +101,36 @@ public class WebhooksService extends BaseService { .setParam("deliveryId", request.getDeliveryId()), DeliveryWsResponse.parser()); } + + /** + * + * This is part of the internal API. + * This is a GET request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/list">Further information about this action online (including a response example)</a> + * @since 7.1 + */ + public ListWsResponse list(ListRequest request) { + return call( + new GetRequest(path("list")) + .setParam("organization", request.getOrganization()) + .setParam("project", request.getProject()), + ListWsResponse.parser()); + } + + /** + * + * This is part of the internal API. + * This is a POST request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/webhooks/update">Further information about this action online (including a response example)</a> + * @since 7.1 + */ + public void update(UpdateRequest request) { + call( + new PostRequest(path("update")) + .setParam("name", request.getName()) + .setParam("url", request.getUrl()) + .setParam("webhook", request.getWebhook()) + .setMediaType(MediaTypes.JSON) + ).content(); + } } |