diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2019-10-10 16:37:30 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-11-06 10:04:26 +0100 |
commit | ab573e2a2597785da80ac461a1c0a3722e5dfdbc (patch) | |
tree | a7833b89a2a7148fe75104faf015df2605867831 /sonar-ws | |
parent | 87faff43bcc6dcd1f2ddc6b51ba8eaf7e65ed034 (diff) | |
download | sonarqube-ab573e2a2597785da80ac461a1c0a3722e5dfdbc.tar.gz sonarqube-ab573e2a2597785da80ac461a1c0a3722e5dfdbc.zip |
SONAR-12512 Allow project binding on multiple GitHub instances
Diffstat (limited to 'sonar-ws')
7 files changed, 379 insertions, 28 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/AlmSettingsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/AlmSettingsService.java index 3392f021f7a..b461504d061 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/AlmSettingsService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/AlmSettingsService.java @@ -38,45 +38,57 @@ public class AlmSettingsService extends BaseService { } /** - * * This is a GET request. - * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/list_definitions">Further information about this action online (including a response example)</a> + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/count_binding">Further information about this action online (including a response example)</a> * @since 8.1 */ - public AlmSettings.ListDefinitionsWsResponse listDefinitions() { + public AlmSettings.CountBindingWsResponse countBinding(CountBindingRequest request) { return call( - new GetRequest(path("list_definitions")), - AlmSettings.ListDefinitionsWsResponse.parser()); + new GetRequest(path("count_binding")) + .setParam("almSetting", request.getAlmSetting()) + .setMediaType(MediaTypes.JSON), + AlmSettings.CountBindingWsResponse.parser()); } /** * * This is a POST request. - * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/create_github">Further information about this action online (including a response example)</a> + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/create_azure">Further information about this action online (including a response example)</a> * @since 8.1 */ - public void createGithub(CreateGithubRequest request) { + public void createAzure(CreateAzureRequest request) { call( - new PostRequest(path("create_github")) - .setParam("appId", request.getAppId()) + new PostRequest(path("create_azure")) .setParam("key", request.getKey()) - .setParam("privateKey", request.getPrivateKey()) - .setParam("url", request.getUrl()) + .setParam("personalAccessToken", request.getPersonalAccessToken()) .setMediaType(MediaTypes.JSON)).content(); } /** * * This is a POST request. - * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/update_github">Further information about this action online (including a response example)</a> + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/create_bitbucket">Further information about this action online (including a response example)</a> * @since 8.1 */ - public void updateGithub(UpdateGithubRequest request) { + public void createBitbucket(CreateBitbucketRequest request) { call( - new PostRequest(path("update_github")) + new PostRequest(path("create_bitbucket")) + .setParam("key", request.getKey()) + .setParam("url", request.getUrl()) + .setParam("personalAccessToken", request.getPersonalAccessToken()) + .setMediaType(MediaTypes.JSON)).content(); + } + + /** + * This is a POST request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/create_github">Further information about this action online (including a response example)</a> + * @since 8.1 + */ + public void createGithub(CreateGithubRequest request) { + call( + new PostRequest(path("create_github")) .setParam("appId", request.getAppId()) .setParam("key", request.getKey()) - .setParam("newKey", request.getNewKey()) .setParam("privateKey", request.getPrivateKey()) .setParam("url", request.getUrl()) .setMediaType(MediaTypes.JSON)).content(); @@ -95,17 +107,68 @@ public class AlmSettingsService extends BaseService { .setMediaType(MediaTypes.JSON)).content(); } + + /** + * This is a POST request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/delete_binding">Further information about this action online (including a response example)</a> + * @since 8.1 + */ + public void deleteBinding(DeleteBindingRequest request) { + call( + new PostRequest(path("delete_binding")) + .setParam("project", request.getProject()) + .setMediaType(MediaTypes.JSON)).content(); + } + + /** + * This is a GET request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/get_binding">Further information about this action online (including a response example)</a> + * @since 8.1 + */ + public AlmSettings.GetBindingWsResponse getBinding(GetGithubBindingRequest request) { + return call( + new GetRequest(path("get_binding")) + .setParam("project", request.getProject()) + .setMediaType(MediaTypes.JSON), + AlmSettings.GetBindingWsResponse.parser()); + } + + /** + * This is a GET request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/list">Further information about this action online (including a response example)</a> + * @since 8.1 + */ + public AlmSettings.ListWsResponse list(ListRequest request) { + return call( + new GetRequest(path("list")) + .setParam("project", request.getProject()) + .setMediaType(MediaTypes.JSON), + AlmSettings.ListWsResponse.parser()); + } + /** * + * This is a GET request. + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/list_definitions">Further information about this action online (including a response example)</a> + * @since 8.1 + */ + public AlmSettings.ListDefinitionsWsResponse listDefinitions() { + return call( + new GetRequest(path("list_definitions")), + AlmSettings.ListDefinitionsWsResponse.parser()); + } + + /** * This is a POST request. - * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/create_azure">Further information about this action online (including a response example)</a> + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/set_github_binding">Further information about this action online (including a response example)</a> * @since 8.1 */ - public void createAzure(CreateAzureRequest request) { + public void setGithubBinding(SetGithubBindingRequest request) { call( - new PostRequest(path("create_azure")) - .setParam("key", request.getKey()) - .setParam("personalAccessToken", request.getPersonalAccessToken()) + new PostRequest(path("set_github_binding")) + .setParam("almSetting", request.getAlmSetting()) + .setParam("project", request.getProject()) + .setParam("repository", request.getRepository()) .setMediaType(MediaTypes.JSON)).content(); } @@ -127,13 +190,14 @@ public class AlmSettingsService extends BaseService { /** * * This is a POST request. - * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/create_bitbucket">Further information about this action online (including a response example)</a> + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/update_bitbucket">Further information about this action online (including a response example)</a> * @since 8.1 */ - public void createBitbucket(CreateBitbucketRequest request) { + public void updateBitbucket(UpdateBitbucketRequest request) { call( - new PostRequest(path("create_bitbucket")) + new PostRequest(path("update_bitbucket")) .setParam("key", request.getKey()) + .setParam("newKey", request.getNewKey()) .setParam("url", request.getUrl()) .setParam("personalAccessToken", request.getPersonalAccessToken()) .setMediaType(MediaTypes.JSON)).content(); @@ -142,17 +206,17 @@ public class AlmSettingsService extends BaseService { /** * * This is a POST request. - * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/update_bitbucket">Further information about this action online (including a response example)</a> + * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/update_github">Further information about this action online (including a response example)</a> * @since 8.1 */ - public void updateBitbucket(UpdateBitbucketRequest request) { + public void updateGithub(UpdateGithubRequest request) { call( - new PostRequest(path("update_bitbucket")) + new PostRequest(path("update_github")) + .setParam("appId", request.getAppId()) .setParam("key", request.getKey()) .setParam("newKey", request.getNewKey()) + .setParam("privateKey", request.getPrivateKey()) .setParam("url", request.getUrl()) - .setParam("personalAccessToken", request.getPersonalAccessToken()) .setMediaType(MediaTypes.JSON)).content(); } - } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/CountBindingRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/CountBindingRequest.java new file mode 100644 index 00000000000..2a6b3e2ffc8 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/CountBindingRequest.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 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.almsettings; + +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/alm_settings/count_binding">Further information about this action online (including a response example)</a> + * @since 8.1 + */ +@Generated("sonar-ws-generator") +public class CountBindingRequest { + + private String almSetting; + + /** + * This is a mandatory parameter. + */ + public CountBindingRequest setAlmSetting(String almSetting) { + this.almSetting = almSetting; + return this; + } + + public String getAlmSetting() { + return almSetting; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/DeleteBindingRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/DeleteBindingRequest.java new file mode 100644 index 00000000000..0f0ff571c87 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/DeleteBindingRequest.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 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.almsettings; + +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/alm_settings/delete_binding">Further information about this action online (including a response example)</a> + * @since 8.1 + */ +@Generated("sonar-ws-generator") +public class DeleteBindingRequest { + + private String project; + + /** + * This is a mandatory parameter. + */ + public DeleteBindingRequest 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/almsettings/GetGithubBindingRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/GetGithubBindingRequest.java new file mode 100644 index 00000000000..d38e17c58ec --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/GetGithubBindingRequest.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 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.almsettings; + +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/alm_settings/get_github_binding">Further information about this action online (including a response example)</a> + * @since 8.1 + */ +@Generated("sonar-ws-generator") +public class GetGithubBindingRequest { + + private String project; + + /** + * This is a mandatory parameter. + */ + public GetGithubBindingRequest 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/almsettings/ListRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/ListRequest.java new file mode 100644 index 00000000000..7aa215f1828 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/ListRequest.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 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.almsettings; + +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/alm_settings/list">Further information about this action online (including a response example)</a> + * @since 8.1 + */ +@Generated("sonar-ws-generator") +public class ListRequest { + + private String project; + + /** + * This is a mandatory parameter. + */ + 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/almsettings/SetGithubBindingRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/SetGithubBindingRequest.java new file mode 100644 index 00000000000..cc8a489ef03 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/SetGithubBindingRequest.java @@ -0,0 +1,72 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 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.almsettings; + +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/alm_settings/set_github_binding">Further information about this action online (including a response example)</a> + * @since 8.1 + */ +@Generated("sonar-ws-generator") +public class SetGithubBindingRequest { + + private String almSetting; + private String project; + private String repository; + + /** + * This is a mandatory parameter. + */ + public SetGithubBindingRequest setAlmSetting(String almSetting) { + this.almSetting = almSetting; + return this; + } + + public String getAlmSetting() { + return almSetting; + } + + /** + * This is a mandatory parameter. + */ + public SetGithubBindingRequest setProject(String project) { + this.project = project; + return this; + } + + public String getProject() { + return project; + } + + /** + * This is a mandatory parameter. + */ + public SetGithubBindingRequest setRepository(String repository) { + this.repository = repository; + return this; + } + + public String getRepository() { + return repository; + } +} diff --git a/sonar-ws/src/main/protobuf/ws-alm_settings.proto b/sonar-ws/src/main/protobuf/ws-alm_settings.proto index aca6db28614..ce1c9b825fb 100644 --- a/sonar-ws/src/main/protobuf/ws-alm_settings.proto +++ b/sonar-ws/src/main/protobuf/ws-alm_settings.proto @@ -48,3 +48,34 @@ message AlmSettingBitbucket { optional string url = 2; optional string personalAccessToken = 3; } + +// WS api/alm_settings/get_binding +message GetBindingWsResponse { + optional string key = 1; + optional Alm alm = 2; + optional string repository = 3; + optional string url = 4; +} + +enum Alm { + github = 0; + azure = 1; + bitbucket = 2; +} + +// WS api/alm_settings/list +message ListWsResponse { + repeated AlmSetting almSettings = 1; +} + +message AlmSetting { + optional string key = 1; + optional Alm alm = 2; + optional string url = 3; +} + +// WS api/alm_settings/count_binding +message CountBindingWsResponse { + optional string key = 1; + optional int64 projects = 2; +} |