From 7525c90c3f489b47e902e5f8eecce2c9deab9658 Mon Sep 17 00:00:00 2001 From: Belen Pruvost Date: Thu, 21 Oct 2021 14:50:17 +0200 Subject: SONAR-15548 - Backend ITs for QG delegation --- .../ws/client/qualitygates/AddGroupRequest.java | 61 ++++++++++++ .../ws/client/qualitygates/AddUserRequest.java | 61 ++++++++++++ .../client/qualitygates/QualitygatesService.java | 101 ++++++++++++++++++++ .../ws/client/qualitygates/RemoveGroupRequest.java | 61 ++++++++++++ .../ws/client/qualitygates/RemoveUserRequest.java | 61 ++++++++++++ .../client/qualitygates/SearchGroupsRequest.java | 104 +++++++++++++++++++++ .../ws/client/qualitygates/SearchUsersRequest.java | 104 +++++++++++++++++++++ 7 files changed, 553 insertions(+) create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/AddGroupRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/AddUserRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/RemoveGroupRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/RemoveUserRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/SearchGroupsRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/SearchUsersRequest.java diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/AddGroupRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/AddGroupRequest.java new file mode 100644 index 00000000000..cf8aa7093f0 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/AddGroupRequest.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 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.qualitygates; + +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 9.2 + */ +@Generated("sonar-ws-generator") +public class AddGroupRequest { + + private String group; + private String qualityGate; + + /** + * This is a mandatory parameter. + * Example value: "sonar-administrators" + */ + public AddGroupRequest setGroup(String group) { + this.group = group; + return this; + } + + public String getGroup() { + return group; + } + + /** + * This is a mandatory parameter. + * Example value: "SonarSource Way" + */ + public AddGroupRequest setQualityGate(String qualityGate) { + this.qualityGate = qualityGate; + return this; + } + + public String getQualityGate() { + return qualityGate; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/AddUserRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/AddUserRequest.java new file mode 100644 index 00000000000..c2926d9b92c --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/AddUserRequest.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 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.qualitygates; + +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 9.2 + */ +@Generated("sonar-ws-generator") +public class AddUserRequest { + + private String login; + private String qualityGate; + + /** + * This is a mandatory parameter. + * Example value: "john.doe" + */ + public AddUserRequest setLogin(String login) { + this.login = login; + return this; + } + + public String getLogin() { + return login; + } + + /** + * This is a mandatory parameter. + * Example value: "SonarSource Way" + */ + public AddUserRequest setQualityGate(String qualityGate) { + this.qualityGate = qualityGate; + return this; + } + + public String getQualityGate() { + return qualityGate; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java index 04dc5a5dbea..1f7f34eb021 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java @@ -21,6 +21,7 @@ package org.sonarqube.ws.client.qualitygates; import javax.annotation.Generated; import org.sonarqube.ws.MediaTypes; +import org.sonarqube.ws.Qualitygates; import org.sonarqube.ws.Qualitygates.CreateConditionResponse; import org.sonarqube.ws.Qualitygates.CreateResponse; import org.sonarqube.ws.Qualitygates.GetByProjectResponse; @@ -282,4 +283,104 @@ public class QualitygatesService extends BaseService { .setParam("op", request.getOp()), UpdateConditionResponse.parser()); } + + /** + * + * This is part of the internal API. + * This is a POST request. + * @see Further information about this action online (including a response example) + * @since 9.2 + */ + public void addUser(AddUserRequest request) { + call( + new PostRequest(path("add_user")) + .setParam("login", request.getLogin()) + .setParam("gateName", request.getQualityGate()) + .setMediaType(MediaTypes.JSON) + ).content(); + } + + /** + * + * This is part of the internal API. + * This is a GET request. + * @see Further information about this action online (including a response example) + * @since 9.2 + */ + public Qualitygates.SearchUsersResponse searchUsers(SearchUsersRequest request) { + return call( + new GetRequest(path("search_users")) + .setParam("p", request.getP()) + .setParam("ps", request.getPs()) + .setParam("q", request.getQ()) + .setParam("gateName", request.getQualityGate()) + .setParam("selected", request.getSelected()), + Qualitygates.SearchUsersResponse.parser()); + } + + /** + * + * This is part of the internal API. + * This is a POST request. + * @see Further information about this action online (including a response example) + * @since 9.2 + */ + public void removeUser(RemoveUserRequest request) { + call( + new PostRequest(path("remove_user")) + .setParam("login", request.getLogin()) + .setParam("gateName", request.getQualityGate()) + .setMediaType(MediaTypes.JSON) + ).content(); + } + + /** + * + * This is part of the internal API. + * This is a POST request. + * @see Further information about this action online (including a response example) + * @since 9.2 + */ + public void addGroup(AddGroupRequest request) { + call( + new PostRequest(path("add_group")) + .setParam("groupName", request.getGroup()) + .setParam("gateName", request.getQualityGate()) + .setMediaType(MediaTypes.JSON) + ).content(); + } + + /** + * + * This is part of the internal API. + * This is a GET request. + * @see Further information about this action online (including a response example) + * @since 9.2 + */ + public Qualitygates.SearchGroupsResponse searchGroups(SearchGroupsRequest request) { + return call( + new GetRequest(path("search_groups")) + .setParam("p", request.getP()) + .setParam("ps", request.getPs()) + .setParam("q", request.getQ()) + .setParam("gateName", request.getQualityGate()) + .setParam("selected", request.getSelected()), + Qualitygates.SearchGroupsResponse.parser()); + } + + /** + * + * This is part of the internal API. + * This is a POST request. + * @see Further information about this action online (including a response example) + * @since 9.2 + */ + public void removeGroup(RemoveGroupRequest request) { + call( + new PostRequest(path("remove_group")) + .setParam("groupName", request.getGroup()) + .setParam("gateName", request.getQualityGate()) + .setMediaType(MediaTypes.JSON) + ).content(); + } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/RemoveGroupRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/RemoveGroupRequest.java new file mode 100644 index 00000000000..44f23a5ca5a --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/RemoveGroupRequest.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 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.qualitygates; + +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 9.2 + */ +@Generated("sonar-ws-generator") +public class RemoveGroupRequest { + + private String group; + private String qualityGate; + + /** + * This is a mandatory parameter. + * Example value: "sonar-administrators" + */ + public RemoveGroupRequest setGroup(String group) { + this.group = group; + return this; + } + + public String getGroup() { + return group; + } + + /** + * This is a mandatory parameter. + * Example value: "SonarSource Way" + */ + public RemoveGroupRequest setQualityGate(String qualityGate) { + this.qualityGate = qualityGate; + return this; + } + + public String getQualityGate() { + return qualityGate; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/RemoveUserRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/RemoveUserRequest.java new file mode 100644 index 00000000000..b3947fededc --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/RemoveUserRequest.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 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.qualitygates; + +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 9.2 + */ +@Generated("sonar-ws-generator") +public class RemoveUserRequest { + + private String login; + private String qualityGate; + + /** + * This is a mandatory parameter. + * Example value: "john.doe" + */ + public RemoveUserRequest setLogin(String login) { + this.login = login; + return this; + } + + public String getLogin() { + return login; + } + + /** + * This is a mandatory parameter. + * Example value: "Recommended quality gate" + */ + public RemoveUserRequest setQualityGate(String qualityGate) { + this.qualityGate = qualityGate; + return this; + } + + public String getQualityGate() { + return qualityGate; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/SearchGroupsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/SearchGroupsRequest.java new file mode 100644 index 00000000000..8570a7164c4 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/SearchGroupsRequest.java @@ -0,0 +1,104 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 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.qualitygates; + +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 9.2 + */ +@Generated("sonar-ws-generator") +public class SearchGroupsRequest { + + private String p; + private String ps; + private String q; + private String qualityGate; + private String selected; + + /** + * Example value: "42" + */ + public SearchGroupsRequest setP(String p) { + this.p = p; + return this; + } + + public String getP() { + return p; + } + + /** + * Example value: "20" + */ + public SearchGroupsRequest setPs(String ps) { + this.ps = ps; + return this; + } + + public String getPs() { + return ps; + } + + /** + * Example value: "sonar" + */ + public SearchGroupsRequest setQ(String q) { + this.q = q; + return this; + } + + public String getQ() { + return q; + } + + /** + * This is a mandatory parameter. + * Example value: "SonarSource Way" + */ + public SearchGroupsRequest setQualityGate(String qualityGate) { + this.qualityGate = qualityGate; + return this; + } + + public String getQualityGate() { + return qualityGate; + } + + /** + * Possible values: + * + */ + public SearchGroupsRequest setSelected(String selected) { + this.selected = selected; + return this; + } + + public String getSelected() { + return selected; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/SearchUsersRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/SearchUsersRequest.java new file mode 100644 index 00000000000..70fc44e04b6 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/SearchUsersRequest.java @@ -0,0 +1,104 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 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.qualitygates; + +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 9.2 + */ +@Generated("sonar-ws-generator") +public class SearchUsersRequest { + + private String p; + private String ps; + private String q; + private String qualityGate; + private String selected; + + /** + * Example value: "42" + */ + public SearchUsersRequest setP(String p) { + this.p = p; + return this; + } + + public String getP() { + return p; + } + + /** + * Example value: "20" + */ + public SearchUsersRequest setPs(String ps) { + this.ps = ps; + return this; + } + + public String getPs() { + return ps; + } + + /** + * Example value: "freddy" + */ + public SearchUsersRequest setQ(String q) { + this.q = q; + return this; + } + + public String getQ() { + return q; + } + + /** + * This is a mandatory parameter. + * Example value: "Recommended quality gate" + */ + public SearchUsersRequest setQualityGate(String qualityGate) { + this.qualityGate = qualityGate; + return this; + } + + public String getQualityGate() { + return qualityGate; + } + + /** + * Possible values: + * + */ + public SearchUsersRequest setSelected(String selected) { + this.selected = selected; + return this; + } + + public String getSelected() { + return selected; + } +} -- cgit v1.2.3