From 26b26898865e90dcf772130d8224e1278d5dc8de Mon Sep 17 00:00:00 2001 From: Pierre Guillot <50145663+pierre-guillot-sonarsource@users.noreply.github.com> Date: Wed, 16 Oct 2019 14:03:34 +0200 Subject: SONAR-12515 Allow configuration of multiple Azure instances --- .../ws/client/almsettings/AlmSettingsService.java | 54 ++++++++++++---- .../ws/client/almsettings/CreateAzureRequest.java | 59 ++++++++++++++++++ .../ws/client/almsettings/CreateGithubRequest.java | 1 - .../ws/client/almsettings/UpdateAzureRequest.java | 71 ++++++++++++++++++++++ sonar-ws/src/main/protobuf/ws-alm_settings.proto | 6 ++ 5 files changed, 178 insertions(+), 13 deletions(-) create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/CreateAzureRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/UpdateAzureRequest.java (limited to 'sonar-ws/src') 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 04b802c6741..85b2f8ac393 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 @@ -37,6 +37,18 @@ public class AlmSettingsService extends BaseService { super(wsConnector, "api/alm_settings"); } + /** + * + * This is a GET request. + * @see Further information about this action online (including a response example) + * @since 8.1 + */ + public AlmSettings.ListDefinitionsWsResponse listDefinitions() { + return call( + new GetRequest(path("list_definitions")), + AlmSettings.ListDefinitionsWsResponse.parser()); + } + /** * * This is a POST request. @@ -53,6 +65,23 @@ public class AlmSettingsService extends BaseService { .setMediaType(MediaTypes.JSON)).content(); } + /** + * + * This is a POST request. + * @see Further information about this action online (including a response example) + * @since 8.1 + */ + public void updateGithub(UpdateGithubRequest request) { + call( + 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()) + .setMediaType(MediaTypes.JSON)).content(); + } + /** * * This is a POST request. @@ -68,30 +97,31 @@ public class AlmSettingsService extends BaseService { /** * - * This is a GET request. - * @see Further information about this action online (including a response example) + * This is a POST request. + * @see Further information about this action online (including a response example) * @since 8.1 */ - public AlmSettings.ListDefinitionsWsResponse listDefinitions() { - return call( - new GetRequest(path("list_definitions")), - AlmSettings.ListDefinitionsWsResponse.parser()); + public void createAzure(CreateAzureRequest request) { + call( + new PostRequest(path("create_azure")) + .setParam("key", request.getKey()) + .setParam("personalAccessToken", request.getPersonalAccessToken()) + .setMediaType(MediaTypes.JSON)).content(); } /** * * This is a POST request. - * @see Further information about this action online (including a response example) + * @see Further information about this action online (including a response example) * @since 8.1 */ - public void updateGithub(UpdateGithubRequest request) { + public void updateAzure(UpdateAzureRequest request) { call( - new PostRequest(path("update_github")) - .setParam("appId", request.getAppId()) + new PostRequest(path("update_azure")) .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/CreateAzureRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/CreateAzureRequest.java new file mode 100644 index 00000000000..b3f586975b8 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/CreateAzureRequest.java @@ -0,0 +1,59 @@ +/* + * 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 a POST request. + * @see Further information about this action online (including a response example) + * @since 8.1 + */ +@Generated("sonar-ws-generator") +public class CreateAzureRequest { + + private String key; + private String personalAccessToken; + + /** + * This is a mandatory parameter. + */ + public CreateAzureRequest setKey(String key) { + this.key = key; + return this; + } + + public String getKey() { + return key; + } + + /** + * This is a mandatory parameter. + */ + public CreateAzureRequest setPersonalAccessToken(String personalAccessToken) { + this.personalAccessToken = personalAccessToken; + return this; + } + + public String getPersonalAccessToken() { + return personalAccessToken; + } + +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/CreateGithubRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/CreateGithubRequest.java index ad8edf7ac52..0db264fa4c4 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/CreateGithubRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/CreateGithubRequest.java @@ -22,7 +22,6 @@ package org.sonarqube.ws.client.almsettings; import javax.annotation.Generated; /** - * This is part of the internal API. * This is a POST request. * @see Further information about this action online (including a response example) * @since 8.1 diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/UpdateAzureRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/UpdateAzureRequest.java new file mode 100644 index 00000000000..f6428ee7289 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almsettings/UpdateAzureRequest.java @@ -0,0 +1,71 @@ +/* + * 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 a POST request. + * @see Further information about this action online (including a response example) + * @since 8.1 + */ +@Generated("sonar-ws-generator") +public class UpdateAzureRequest { + + private String key; + private String newKey; + private String personalAccessToken; + + public String getKey() { + return key; + } + + /** + * This is a mandatory parameter. + */ + public UpdateAzureRequest setKey(String key) { + this.key = key; + return this; + } + + public String getNewKey() { + return newKey; + } + + /** + */ + public UpdateAzureRequest setNewKey(String newKey) { + this.newKey = newKey; + return this; + } + + public String getPersonalAccessToken() { + return personalAccessToken; + } + + /** + * This is a mandatory parameter. + */ + public UpdateAzureRequest setPersonalAccessToken(String personalAccessToken) { + this.personalAccessToken = personalAccessToken; + return this; + } + +} diff --git a/sonar-ws/src/main/protobuf/ws-alm_settings.proto b/sonar-ws/src/main/protobuf/ws-alm_settings.proto index ba67e11017e..e7ba035cd23 100644 --- a/sonar-ws/src/main/protobuf/ws-alm_settings.proto +++ b/sonar-ws/src/main/protobuf/ws-alm_settings.proto @@ -27,6 +27,7 @@ option optimize_for = SPEED; // WS api/alm_settings/list_definitions message ListDefinitionsWsResponse { repeated AlmSettingGithub github = 1; + repeated AlmSettingAzure azure = 2; } message AlmSettingGithub { @@ -36,3 +37,8 @@ message AlmSettingGithub { optional string privateKey = 4; } +message AlmSettingAzure { + optional string key = 1; + optional string personalAccessToken = 2; +} + -- cgit v1.2.3