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.

ProjectsService.java 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2021 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.projects;
  21. import java.util.stream.Collectors;
  22. import javax.annotation.Generated;
  23. import org.sonarqube.ws.MediaTypes;
  24. import org.sonarqube.ws.Projects.CreateWsResponse;
  25. import org.sonarqube.ws.Projects.SearchMyProjectsWsResponse;
  26. import org.sonarqube.ws.Projects.SearchWsResponse;
  27. import org.sonarqube.ws.client.BaseService;
  28. import org.sonarqube.ws.client.GetRequest;
  29. import org.sonarqube.ws.client.PostRequest;
  30. import org.sonarqube.ws.client.WsConnector;
  31. /**
  32. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/projects">Further information about this web service online</a>
  33. */
  34. @Generated("sonar-ws-generator")
  35. public class ProjectsService extends BaseService {
  36. public ProjectsService(WsConnector wsConnector) {
  37. super(wsConnector, "api/projects");
  38. }
  39. /**
  40. *
  41. * This is part of the internal API.
  42. * This is a POST request.
  43. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/projects/bulk_delete">Further information about this action online (including a response example)</a>
  44. * @since 5.2
  45. */
  46. public void bulkDelete(BulkDeleteRequest request) {
  47. call(
  48. new PostRequest(path("bulk_delete"))
  49. .setParam("analyzedBefore", request.getAnalyzedBefore())
  50. .setParam("onProvisionedOnly", request.getOnProvisionedOnly())
  51. .setParam("projects", request.getProjects() == null ? null : request.getProjects().stream().collect(Collectors.joining(",")))
  52. .setParam("q", request.getQ())
  53. .setParam("qualifiers", request.getQualifiers() == null ? null : request.getQualifiers().stream().collect(Collectors.joining(",")))
  54. .setParam("visibility", request.getVisibility())
  55. .setMediaType(MediaTypes.JSON)
  56. ).content();
  57. }
  58. /**
  59. *
  60. * This is part of the internal API.
  61. * This is a POST request.
  62. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/projects/create">Further information about this action online (including a response example)</a>
  63. * @since 4.0
  64. */
  65. public CreateWsResponse create(CreateRequest request) {
  66. return call(
  67. new PostRequest(path("create"))
  68. .setParam("branch", request.getBranch())
  69. .setParam("name", request.getName())
  70. .setParam("project", request.getProject())
  71. .setParam("visibility", request.getVisibility()),
  72. CreateWsResponse.parser());
  73. }
  74. /**
  75. *
  76. * This is part of the internal API.
  77. * This is a POST request.
  78. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/projects/delete">Further information about this action online (including a response example)</a>
  79. * @since 5.2
  80. */
  81. public void delete(DeleteRequest request) {
  82. call(
  83. new PostRequest(path("delete"))
  84. .setParam("project", request.getProject())
  85. .setMediaType(MediaTypes.JSON)
  86. ).content();
  87. }
  88. /**
  89. *
  90. * This is part of the internal API.
  91. * This is a GET request.
  92. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/projects/search">Further information about this action online (including a response example)</a>
  93. * @since 6.3
  94. */
  95. public SearchWsResponse search(SearchRequest request) {
  96. return call(
  97. new GetRequest(path("search"))
  98. .setParam("analyzedBefore", request.getAnalyzedBefore())
  99. .setParam("onProvisionedOnly", request.getOnProvisionedOnly())
  100. .setParam("p", request.getP())
  101. .setParam("projects", request.getProjects() == null ? null : request.getProjects().stream().collect(Collectors.joining(",")))
  102. .setParam("ps", request.getPs())
  103. .setParam("q", request.getQ())
  104. .setParam("qualifiers", request.getQualifiers() == null ? null : request.getQualifiers().stream().collect(Collectors.joining(",")))
  105. .setParam("visibility", request.getVisibility()),
  106. SearchWsResponse.parser());
  107. }
  108. /**
  109. *
  110. * This is part of the internal API.
  111. * This is a GET request.
  112. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/projects/search_my_projects">Further information about this action online (including a response example)</a>
  113. * @since 6.0
  114. */
  115. public SearchMyProjectsWsResponse searchMyProjects(SearchMyProjectsRequest request) {
  116. return call(
  117. new GetRequest(path("search_my_projects"))
  118. .setParam("p", request.getP())
  119. .setParam("ps", request.getPs()),
  120. SearchMyProjectsWsResponse.parser());
  121. }
  122. /**
  123. *
  124. * This is part of the internal API.
  125. * This is a POST request.
  126. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/projects/update_key">Further information about this action online (including a response example)</a>
  127. * @since 6.1
  128. */
  129. public void updateKey(UpdateKeyRequest request) {
  130. call(
  131. new PostRequest(path("update_key"))
  132. .setParam("from", request.getFrom())
  133. .setParam("to", request.getTo())
  134. .setMediaType(MediaTypes.JSON)
  135. ).content();
  136. }
  137. /**
  138. *
  139. * This is part of the internal API.
  140. * This is a POST request.
  141. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/projects/update_visibility">Further information about this action online (including a response example)</a>
  142. * @since 6.4
  143. */
  144. public void updateVisibility(UpdateVisibilityRequest request) {
  145. call(
  146. new PostRequest(path("update_visibility"))
  147. .setParam("project", request.getProject())
  148. .setParam("visibility", request.getVisibility())
  149. .setMediaType(MediaTypes.JSON)
  150. ).content();
  151. }
  152. /**
  153. *
  154. * This is part of the internal API.
  155. * This is a POST request.
  156. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/projects/update_default_visibility">Further information about this action online (including a response example)</a>
  157. * @since 6.4
  158. */
  159. public void updateDefaultVisibility(UpdateDefaultVisibilityRequest request) {
  160. call(
  161. new PostRequest(path("update_default_visibility"))
  162. .setParam("projectVisibility", request.getProjectVisibility())
  163. .setMediaType(MediaTypes.JSON)
  164. ).content();
  165. }
  166. }