From 4aaebff02491ab87fec3df8e3a9b83e37ef5c963 Mon Sep 17 00:00:00 2001 From: Jacek Date: Wed, 18 Dec 2019 10:58:08 +0100 Subject: [PATCH] SONAR-12723 Generate hotspots WS lib --- .../sonarqube/ws/client/DefaultWsClient.java | 8 + .../org/sonarqube/ws/client/WsClient.java | 3 + .../ws/client/hotspots/AddCommentRequest.java | 61 ++++++ .../ws/client/hotspots/AssignRequest.java | 74 +++++++ .../client/hotspots/ChangeStatusRequest.java | 95 +++++++++ .../ws/client/hotspots/HotspotsService.java | 127 ++++++++++++ .../ws/client/hotspots/SearchRequest.java | 186 ++++++++++++++++++ .../ws/client/hotspots/ShowRequest.java | 47 +++++ .../ws/client/hotspots/package-info.java | 25 +++ 9 files changed, 626 insertions(+) create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/AddCommentRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/AssignRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/ChangeStatusRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/HotspotsService.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/SearchRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/ShowRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/package-info.java 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 26b228052e7..e79a30533af 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.editions.EditionsService; import org.sonarqube.ws.client.emails.EmailsService; import org.sonarqube.ws.client.favorites.FavoritesService; import org.sonarqube.ws.client.governancereports.GovernanceReportsService; +import org.sonarqube.ws.client.hotspots.HotspotsService; import org.sonarqube.ws.client.issues.IssuesService; import org.sonarqube.ws.client.l10n.L10nService; import org.sonarqube.ws.client.languages.LanguagesService; @@ -98,6 +99,7 @@ class DefaultWsClient implements WsClient { private final EmailsService emailsService; private final FavoritesService favoritesService; private final GovernanceReportsService governanceReportsService; + private final HotspotsService hotspotsService; private final IssuesService issuesService; private final L10nService l10nService; private final LanguagesService languagesService; @@ -155,6 +157,7 @@ class DefaultWsClient implements WsClient { this.emailsService = new EmailsService(wsConnector); this.favoritesService = new FavoritesService(wsConnector); this.governanceReportsService = new GovernanceReportsService(wsConnector); + this.hotspotsService = new HotspotsService(wsConnector); this.issuesService = new IssuesService(wsConnector); this.l10nService = new L10nService(wsConnector); this.languagesService = new LanguagesService(wsConnector); @@ -268,6 +271,11 @@ class DefaultWsClient implements WsClient { return governanceReportsService; } + @Override + public HotspotsService hotspots() { + return hotspotsService; + } + @Override public IssuesService issues() { return issuesService; 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 3750817c07c..f00373232bf 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.editions.EditionsService; import org.sonarqube.ws.client.emails.EmailsService; import org.sonarqube.ws.client.favorites.FavoritesService; import org.sonarqube.ws.client.governancereports.GovernanceReportsService; +import org.sonarqube.ws.client.hotspots.HotspotsService; import org.sonarqube.ws.client.issues.IssuesService; import org.sonarqube.ws.client.l10n.L10nService; import org.sonarqube.ws.client.languages.LanguagesService; @@ -123,6 +124,8 @@ public interface WsClient { GovernanceReportsService governanceReports(); + HotspotsService hotspots(); + IssuesService issues(); L10nService l10n(); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/AddCommentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/AddCommentRequest.java new file mode 100644 index 00000000000..c549971a9a1 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/AddCommentRequest.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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.hotspots; + +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 + */ +@Generated("sonar-ws-generator") +public class AddCommentRequest { + + private String comment; + private String hotspot; + + /** + * This is a mandatory parameter. + * Example value: "This is safe because user input is validated by the calling code" + */ + public AddCommentRequest setComment(String comment) { + this.comment = comment; + return this; + } + + public String getComment() { + return comment; + } + + /** + * This is a mandatory parameter. + * Example value: "AU-TpxcA-iU5OvuD2FL0" + */ + public AddCommentRequest setHotspot(String hotspot) { + this.hotspot = hotspot; + return this; + } + + public String getHotspot() { + return hotspot; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/AssignRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/AssignRequest.java new file mode 100644 index 00000000000..f5cf99d8eb0 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/AssignRequest.java @@ -0,0 +1,74 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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.hotspots; + +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.2 + */ +@Generated("sonar-ws-generator") +public class AssignRequest { + + private String assignee; + private String comment; + private String hotspot; + + /** + * This is a mandatory parameter. + * Example value: "admin" + */ + public AssignRequest setAssignee(String assignee) { + this.assignee = assignee; + return this; + } + + public String getAssignee() { + return assignee; + } + + /** + * Example value: "Hey Bob! Could you please have a look and confirm my assertion that we are safe here, please" + */ + public AssignRequest setComment(String comment) { + this.comment = comment; + return this; + } + + public String getComment() { + return comment; + } + + /** + * This is a mandatory parameter. + * Example value: "AU-Tpxb--iU5OvuD2FLy" + */ + public AssignRequest setHotspot(String hotspot) { + this.hotspot = hotspot; + return this; + } + + public String getHotspot() { + return hotspot; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/ChangeStatusRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/ChangeStatusRequest.java new file mode 100644 index 00000000000..c24e7406de5 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/ChangeStatusRequest.java @@ -0,0 +1,95 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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.hotspots; + +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 + */ +@Generated("sonar-ws-generator") +public class ChangeStatusRequest { + + private String comment; + private String hotspot; + private String resolution; + private String status; + + /** + * Example value: "This is safe because user input is validated by the calling code" + */ + public ChangeStatusRequest setComment(String comment) { + this.comment = comment; + return this; + } + + public String getComment() { + return comment; + } + + /** + * This is a mandatory parameter. + * Example value: "AU-TpxcA-iU5OvuD2FL0" + */ + public ChangeStatusRequest setHotspot(String hotspot) { + this.hotspot = hotspot; + return this; + } + + public String getHotspot() { + return hotspot; + } + + /** + * Possible values: + * + */ + public ChangeStatusRequest setResolution(String resolution) { + this.resolution = resolution; + return this; + } + + public String getResolution() { + return resolution; + } + + /** + * This is a mandatory parameter. + * Possible values: + * + */ + public ChangeStatusRequest setStatus(String status) { + this.status = status; + return this; + } + + public String getStatus() { + return status; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/HotspotsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/HotspotsService.java new file mode 100644 index 00000000000..be4ec96dc3e --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/HotspotsService.java @@ -0,0 +1,127 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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.hotspots; + +import java.util.stream.Collectors; +import javax.annotation.Generated; +import org.sonarqube.ws.Hotspots; +import org.sonarqube.ws.MediaTypes; +import org.sonarqube.ws.client.BaseService; +import org.sonarqube.ws.client.GetRequest; +import org.sonarqube.ws.client.PostRequest; +import org.sonarqube.ws.client.WsConnector; + +/** + * @see Further information about this web service online + */ +@Generated("sonar-ws-generator") +public class HotspotsService extends BaseService { + + public HotspotsService(WsConnector wsConnector) { + super(wsConnector, "api/hotspots"); + } + + /** + * + * 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 + */ + public void addComment(AddCommentRequest request) { + call( + new PostRequest(path("add_comment")) + .setParam("comment", request.getComment()) + .setParam("hotspot", request.getHotspot()) + .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 8.2 + */ + public void assign(AssignRequest request) { + call( + new PostRequest(path("assign")) + .setParam("assignee", request.getAssignee()) + .setParam("comment", request.getComment()) + .setParam("hotspot", request.getHotspot()) + .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 8.1 + */ + public void changeStatus(ChangeStatusRequest request) { + call( + new PostRequest(path("change_status")) + .setParam("comment", request.getComment()) + .setParam("hotspot", request.getHotspot()) + .setParam("resolution", request.getResolution()) + .setParam("status", request.getStatus()) + .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 8.1 + */ + public Hotspots.SearchWsResponse search(SearchRequest request) { + return call( + new GetRequest(path("search")) + .setParam("branch", request.getBranch()) + .setParam("hotspots", request.getHotspots() == null ? null : request.getHotspots().stream().collect(Collectors.joining(","))) + .setParam("onlyMine", request.getOnlyMine()) + .setParam("p", request.getP()) + .setParam("projectKey", request.getProjectKey()) + .setParam("ps", request.getPs()) + .setParam("pullRequest", request.getPullRequest()) + .setParam("resolution", request.getResolution()) + .setParam("sinceLeakPeriod", request.getSinceLeakPeriod()) + .setParam("status", request.getStatus()) + .setMediaType(MediaTypes.JSON), + Hotspots.SearchWsResponse.parser()); + } + + /** + * + * This is part of the internal API. + * This is a GET request. + * @see Further information about this action online (including a response example) + * @since 8.1 + */ + public Hotspots.ShowWsResponse show(ShowRequest request) { + return call( + new GetRequest(path("show")) + .setParam("hotspot", request.getHotspot()) + .setMediaType(MediaTypes.JSON), + Hotspots.ShowWsResponse.parser()); + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/SearchRequest.java new file mode 100644 index 00000000000..e20a33c5d4a --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/SearchRequest.java @@ -0,0 +1,186 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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.hotspots; + +import java.util.List; +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 + */ +@Generated("sonar-ws-generator") +public class SearchRequest { + + private String branch; + private List hotspots; + private String onlyMine; + private String p; + private String projectKey; + private String ps; + private String pullRequest; + private String resolution; + private String sinceLeakPeriod; + private String status; + + /** + * This is part of the internal API. + * Example value: "feature/my_branch" + */ + public SearchRequest setBranch(String branch) { + this.branch = branch; + return this; + } + + public String getBranch() { + return branch; + } + + /** + * Example value: "my_project" + */ + public SearchRequest setHotspots(List hotspots) { + this.hotspots = hotspots; + return this; + } + + public List getHotspots() { + return hotspots; + } + + /** + * Possible values: + *
    + *
  • "true"
  • + *
  • "false"
  • + *
  • "yes"
  • + *
  • "no"
  • + *
+ */ + public SearchRequest setOnlyMine(String onlyMine) { + this.onlyMine = onlyMine; + return this; + } + + public String getOnlyMine() { + return onlyMine; + } + + /** + * Example value: "42" + */ + public SearchRequest setP(String p) { + this.p = p; + return this; + } + + public String getP() { + return p; + } + + /** + * Example value: "my_project" + */ + public SearchRequest setProjectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + + public String getProjectKey() { + return projectKey; + } + + /** + * Example value: "20" + */ + public SearchRequest setPs(String ps) { + this.ps = ps; + return this; + } + + public String getPs() { + return ps; + } + + /** + * This is part of the internal API. + * Example value: "5461" + */ + public SearchRequest setPullRequest(String pullRequest) { + this.pullRequest = pullRequest; + return this; + } + + public String getPullRequest() { + return pullRequest; + } + + /** + * Possible values: + *
    + *
  • "FIXED"
  • + *
  • "SAFE"
  • + *
+ */ + public SearchRequest setResolution(String resolution) { + this.resolution = resolution; + return this; + } + + public String getResolution() { + return resolution; + } + + /** + * Possible values: + *
    + *
  • "true"
  • + *
  • "false"
  • + *
  • "yes"
  • + *
  • "no"
  • + *
+ */ + public SearchRequest setSinceLeakPeriod(String sinceLeakPeriod) { + this.sinceLeakPeriod = sinceLeakPeriod; + return this; + } + + public String getSinceLeakPeriod() { + return sinceLeakPeriod; + } + + /** + * Possible values: + *
    + *
  • "TO_REVIEW"
  • + *
  • "REVIEWED"
  • + *
+ */ + public SearchRequest setStatus(String status) { + this.status = status; + return this; + } + + public String getStatus() { + return status; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/ShowRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/ShowRequest.java new file mode 100644 index 00000000000..17c449ebe06 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/ShowRequest.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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.hotspots; + +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 + */ +@Generated("sonar-ws-generator") +public class ShowRequest { + + private String hotspot; + + /** + * This is a mandatory parameter. + * Example value: "AU-TpxcA-iU5OvuD2FL0" + */ + public ShowRequest setHotspot(String hotspot) { + this.hotspot = hotspot; + return this; + } + + public String getHotspot() { + return hotspot; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/package-info.java new file mode 100644 index 00000000000..aca64aef453 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/hotspots/package-info.java @@ -0,0 +1,25 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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. + */ +@ParametersAreNonnullByDefault +@Generated("sonar-ws-generator") +package org.sonarqube.ws.client.hotspots; + +import javax.annotation.Generated; +import javax.annotation.ParametersAreNonnullByDefault; -- 2.39.5