You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ComponentsService.java 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2023 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonarqube.ws.client.components;
  21. import java.util.stream.Collectors;
  22. import javax.annotation.Generated;
  23. import org.sonarqube.ws.MediaTypes;
  24. import org.sonarqube.ws.client.BaseService;
  25. import org.sonarqube.ws.client.GetRequest;
  26. import org.sonarqube.ws.client.WsConnector;
  27. import org.sonarqube.ws.Components.SearchWsResponse;
  28. import org.sonarqube.ws.Components.SearchProjectsWsResponse;
  29. import org.sonarqube.ws.Components.ShowWsResponse;
  30. import org.sonarqube.ws.Components.SuggestionsWsResponse;
  31. import org.sonarqube.ws.Components.TreeWsResponse;
  32. /**
  33. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/components">Further information about this web service online</a>
  34. */
  35. @Generated("sonar-ws-generator")
  36. public class ComponentsService extends BaseService {
  37. public ComponentsService(WsConnector wsConnector) {
  38. super(wsConnector, "api/components");
  39. }
  40. /**
  41. *
  42. * This is part of the internal API.
  43. * This is a GET request.
  44. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/components/app">Further information about this action online (including a response example)</a>
  45. * @since 4.4
  46. */
  47. public String app(AppRequest request) {
  48. return call(
  49. new GetRequest(path("app"))
  50. .setParam("branch", request.getBranch())
  51. .setParam("component", request.getComponent())
  52. .setParam("pullRequest", request.getPullRequest())
  53. .setMediaType(MediaTypes.JSON)
  54. ).content();
  55. }
  56. /**
  57. *
  58. * This is part of the internal API.
  59. * This is a GET request.
  60. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/components/search">Further information about this action online (including a response example)</a>
  61. * @since 6.3
  62. */
  63. public SearchWsResponse search(SearchRequest request) {
  64. return call(
  65. new GetRequest(path("search"))
  66. .setParam("language", request.getLanguage())
  67. .setParam("p", request.getP())
  68. .setParam("ps", request.getPs())
  69. .setParam("q", request.getQ())
  70. .setParam("qualifiers", request.getQualifiers() == null ? null : request.getQualifiers().stream().collect(Collectors.joining(","))),
  71. SearchWsResponse.parser());
  72. }
  73. /**
  74. *
  75. * This is part of the internal API.
  76. * This is a GET request.
  77. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/components/search_projects">Further information about this action online (including a response example)</a>
  78. * @since 6.2
  79. */
  80. public SearchProjectsWsResponse searchProjects(SearchProjectsRequest request) {
  81. return call(
  82. new GetRequest(path("search_projects"))
  83. .setParam("asc", request.getAsc())
  84. .setParam("f", request.getF() == null ? null : request.getF().stream().collect(Collectors.joining(",")))
  85. .setParam("facets", request.getFacets() == null ? null : request.getFacets().stream().collect(Collectors.joining(",")))
  86. .setParam("filter", request.getFilter())
  87. .setParam("p", request.getP())
  88. .setParam("ps", request.getPs())
  89. .setParam("s", request.getS()),
  90. SearchProjectsWsResponse.parser());
  91. }
  92. /**
  93. *
  94. * This is part of the internal API.
  95. * This is a GET request.
  96. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/components/show">Further information about this action online (including a response example)</a>
  97. * @since 5.4
  98. */
  99. public ShowWsResponse show(ShowRequest request) {
  100. return call(
  101. new GetRequest(path("show"))
  102. .setParam("branch", request.getBranch())
  103. .setParam("component", request.getComponent())
  104. .setParam("pullRequest", request.getPullRequest()),
  105. ShowWsResponse.parser());
  106. }
  107. /**
  108. *
  109. * This is part of the internal API.
  110. * This is a GET request.
  111. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/components/suggestions">Further information about this action online (including a response example)</a>
  112. * @since 4.2
  113. */
  114. public SuggestionsWsResponse suggestions(SuggestionsRequest request) {
  115. return call(
  116. new GetRequest(path("suggestions"))
  117. .setParam("more", request.getMore())
  118. .setParam("recentlyBrowsed", request.getRecentlyBrowsed() == null ? null : request.getRecentlyBrowsed().stream().collect(Collectors.joining(",")))
  119. .setParam("s", request.getS()),
  120. SuggestionsWsResponse.parser());
  121. }
  122. /**
  123. *
  124. * This is part of the internal API.
  125. * This is a GET request.
  126. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/components/tree">Further information about this action online (including a response example)</a>
  127. * @since 5.4
  128. */
  129. public TreeWsResponse tree(TreeRequest request) {
  130. return call(
  131. new GetRequest(path("tree"))
  132. .setParam("asc", request.getAsc())
  133. .setParam("branch", request.getBranch())
  134. .setParam("component", request.getComponent())
  135. .setParam("p", request.getP())
  136. .setParam("ps", request.getPs())
  137. .setParam("pullRequest", request.getPullRequest())
  138. .setParam("q", request.getQ())
  139. .setParam("qualifiers", request.getQualifiers() == null ? null : request.getQualifiers().stream().collect(Collectors.joining(",")))
  140. .setParam("s", request.getS() == null ? null : request.getS().stream().collect(Collectors.joining(",")))
  141. .setParam("strategy", request.getStrategy()),
  142. TreeWsResponse.parser());
  143. }
  144. }