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.

IssuesService.java 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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.issues;
  21. import java.util.stream.Collectors;
  22. import javax.annotation.Generated;
  23. import org.sonarqube.ws.Issues.AddCommentResponse;
  24. import org.sonarqube.ws.Issues.AssignResponse;
  25. import org.sonarqube.ws.Issues.AuthorsResponse;
  26. import org.sonarqube.ws.Issues.BulkChangeWsResponse;
  27. import org.sonarqube.ws.Issues.ChangelogWsResponse;
  28. import org.sonarqube.ws.Issues.DeleteCommentResponse;
  29. import org.sonarqube.ws.Issues.DoTransitionResponse;
  30. import org.sonarqube.ws.Issues.SearchWsResponse;
  31. import org.sonarqube.ws.Issues.SetSeverityResponse;
  32. import org.sonarqube.ws.Issues.SetTagsResponse;
  33. import org.sonarqube.ws.Issues.SetTypeResponse;
  34. import org.sonarqube.ws.Issues.TagsResponse;
  35. import org.sonarqube.ws.MediaTypes;
  36. import org.sonarqube.ws.client.BaseService;
  37. import org.sonarqube.ws.client.GetRequest;
  38. import org.sonarqube.ws.client.PostRequest;
  39. import org.sonarqube.ws.client.WsConnector;
  40. /**
  41. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues">Further information about this web service online</a>
  42. */
  43. @Generated("sonar-ws-generator")
  44. public class IssuesService extends BaseService {
  45. public IssuesService(WsConnector wsConnector) {
  46. super(wsConnector, "api/issues");
  47. }
  48. /**
  49. *
  50. * This is part of the internal API.
  51. * This is a POST request.
  52. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/add_comment">Further information about this action online (including a response example)</a>
  53. * @since 3.6
  54. */
  55. public AddCommentResponse addComment(AddCommentRequest request) {
  56. return call(
  57. new PostRequest(path("add_comment"))
  58. .setParam("issue", request.getIssue())
  59. .setParam("text", request.getText()),
  60. AddCommentResponse.parser());
  61. }
  62. /**
  63. *
  64. * This is part of the internal API.
  65. * This is a POST request.
  66. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/assign">Further information about this action online (including a response example)</a>
  67. * @since 3.6
  68. */
  69. public AssignResponse assign(AssignRequest request) {
  70. return call(
  71. new PostRequest(path("assign"))
  72. .setParam("assignee", request.getAssignee())
  73. .setParam("issue", request.getIssue()),
  74. AssignResponse.parser());
  75. }
  76. /**
  77. *
  78. * This is part of the internal API.
  79. * This is a GET request.
  80. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/authors">Further information about this action online (including a response example)</a>
  81. * @since 5.1
  82. */
  83. public AuthorsResponse authors(AuthorsRequest request) {
  84. return call(
  85. new GetRequest(path("authors"))
  86. .setParam("project", request.getProject())
  87. .setParam("ps", request.getPs())
  88. .setParam("q", request.getQ()),
  89. AuthorsResponse.parser());
  90. }
  91. /**
  92. *
  93. * This is part of the internal API.
  94. * This is a POST request.
  95. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/bulk_change">Further information about this action online (including a response example)</a>
  96. * @since 3.7
  97. */
  98. public BulkChangeWsResponse bulkChange(BulkChangeRequest request) {
  99. return call(
  100. new PostRequest(path("bulk_change"))
  101. .setParam("add_tags", request.getAddTags())
  102. .setParam("assign", request.getAssign() == null ? null : request.getAssign().stream().collect(Collectors.joining(",")))
  103. .setParam("comment", request.getComment() == null ? null : request.getComment().stream().collect(Collectors.joining(",")))
  104. .setParam("do_transition", request.getDoTransition())
  105. .setParam("issues", request.getIssues() == null ? null : request.getIssues().stream().collect(Collectors.joining(",")))
  106. .setParam("remove_tags", request.getRemoveTags())
  107. .setParam("sendNotifications", request.getSendNotifications())
  108. .setParam("set_severity", request.getSetSeverity() == null ? null : request.getSetSeverity().stream().collect(Collectors.joining(",")))
  109. .setParam("set_type", request.getSetType() == null ? null : request.getSetType().stream().collect(Collectors.joining(","))),
  110. BulkChangeWsResponse.parser());
  111. }
  112. /**
  113. *
  114. * This is part of the internal API.
  115. * This is a GET request.
  116. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/changelog">Further information about this action online (including a response example)</a>
  117. * @since 4.1
  118. */
  119. public ChangelogWsResponse changelog(ChangelogRequest request) {
  120. return call(
  121. new GetRequest(path("changelog"))
  122. .setParam("issue", request.getIssue()),
  123. ChangelogWsResponse.parser());
  124. }
  125. /**
  126. *
  127. * This is part of the internal API.
  128. * This is a GET request.
  129. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/component_tags">Further information about this action online (including a response example)</a>
  130. * @since 5.1
  131. */
  132. public String componentTags(ComponentTagsRequest request) {
  133. return call(
  134. new GetRequest(path("component_tags"))
  135. .setParam("componentUuid", request.getComponentUuid())
  136. .setParam("createdAfter", request.getCreatedAfter())
  137. .setParam("ps", request.getPs())
  138. .setMediaType(MediaTypes.JSON)).content();
  139. }
  140. /**
  141. *
  142. * This is part of the internal API.
  143. * This is a POST request.
  144. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/delete_comment">Further information about this action online (including a response example)</a>
  145. * @since 3.6
  146. */
  147. public DeleteCommentResponse deleteComment(DeleteCommentRequest request) {
  148. return call(
  149. new PostRequest(path("delete_comment"))
  150. .setParam("comment", request.getComment()),
  151. DeleteCommentResponse.parser());
  152. }
  153. /**
  154. *
  155. * This is part of the internal API.
  156. * This is a POST request.
  157. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/do_transition">Further information about this action online (including a response example)</a>
  158. * @since 3.6
  159. */
  160. public DoTransitionResponse doTransition(DoTransitionRequest request) {
  161. return call(
  162. new PostRequest(path("do_transition"))
  163. .setParam("issue", request.getIssue())
  164. .setParam("transition", request.getTransition()),
  165. DoTransitionResponse.parser());
  166. }
  167. /**
  168. *
  169. * This is part of the internal API.
  170. * This is a POST request.
  171. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/edit_comment">Further information about this action online (including a response example)</a>
  172. * @since 3.6
  173. */
  174. public String editComment(EditCommentRequest request) {
  175. return call(
  176. new PostRequest(path("edit_comment"))
  177. .setParam("comment", request.getComment())
  178. .setParam("text", request.getText())
  179. .setMediaType(MediaTypes.JSON)).content();
  180. }
  181. /**
  182. *
  183. * This is part of the internal API.
  184. * This is a GET request.
  185. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/search">Further information about this action online (including a response example)</a>
  186. * @since 3.6
  187. */
  188. public SearchWsResponse search(SearchRequest request) {
  189. return call(
  190. new GetRequest(path("search"))
  191. .setParam("additionalFields", request.getAdditionalFields() == null ? null : request.getAdditionalFields().stream().collect(Collectors.joining(",")))
  192. .setParam("asc", request.getAsc())
  193. .setParam("assigned", request.getAssigned())
  194. .setParam("assignees", request.getAssignees() == null ? null : request.getAssignees().stream().collect(Collectors.joining(",")))
  195. .setParam("author", request.getAuthor())
  196. .setParam("branch", request.getBranch())
  197. .setParam("componentKeys", request.getComponentKeys() == null ? null : request.getComponentKeys().stream().collect(Collectors.joining(",")))
  198. .setParam("componentUuids", request.getComponentUuids() == null ? null : request.getComponentUuids().stream().collect(Collectors.joining(",")))
  199. .setParam("createdAfter", request.getCreatedAfter())
  200. .setParam("createdAt", request.getCreatedAt())
  201. .setParam("createdBefore", request.getCreatedBefore())
  202. .setParam("createdInLast", request.getCreatedInLast())
  203. .setParam("cwe", request.getCwe() == null ? null : request.getCwe().stream().collect(Collectors.joining(",")))
  204. .setParam("directories", request.getDirectories() == null ? null : request.getDirectories().stream().collect(Collectors.joining(",")))
  205. .setParam("facets", request.getFacets() == null ? null : request.getFacets().stream().collect(Collectors.joining(",")))
  206. .setParam("fileUuids", request.getFileUuids() == null ? null : request.getFileUuids().stream().collect(Collectors.joining(",")))
  207. .setParam("issues", request.getIssues() == null ? null : request.getIssues().stream().collect(Collectors.joining(",")))
  208. .setParam("languages", request.getLanguages() == null ? null : request.getLanguages().stream().collect(Collectors.joining(",")))
  209. .setParam("onComponentOnly", request.getOnComponentOnly())
  210. .setParam("owaspTop10", request.getOwaspTop10() == null ? null : request.getOwaspTop10().stream().collect(Collectors.joining(",")))
  211. .setParam("p", request.getP())
  212. .setParam("projects", request.getProjects() == null ? null : request.getProjects().stream().collect(Collectors.joining(",")))
  213. .setParam("ps", request.getPs())
  214. .setParam("pullRequest", request.getPullRequest())
  215. .setParam("resolutions", request.getResolutions() == null ? null : request.getResolutions().stream().collect(Collectors.joining(",")))
  216. .setParam("resolved", request.getResolved())
  217. .setParam("rules", request.getRules() == null ? null : request.getRules().stream().collect(Collectors.joining(",")))
  218. .setParam("s", request.getS())
  219. .setParam("sansTop25", request.getSansTop25() == null ? null : request.getSansTop25().stream().collect(Collectors.joining(",")))
  220. .setParam("sonarsourceSecurity", request.getSonarsourceSecurity() == null ? null : request.getSonarsourceSecurity().stream().collect(Collectors.joining(",")))
  221. .setParam("severities", request.getSeverities() == null ? null : request.getSeverities().stream().collect(Collectors.joining(",")))
  222. .setParam("sinceLeakPeriod", request.getSinceLeakPeriod())
  223. .setParam("statuses", request.getStatuses() == null ? null : request.getStatuses().stream().collect(Collectors.joining(",")))
  224. .setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(",")))
  225. .setParam("types", request.getTypes() == null ? null : request.getTypes().stream().collect(Collectors.joining(","))),
  226. SearchWsResponse.parser());
  227. }
  228. /**
  229. *
  230. * This is part of the internal API.
  231. * This is a POST request.
  232. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/set_severity">Further information about this action online (including a response example)</a>
  233. * @since 3.6
  234. */
  235. public SetSeverityResponse setSeverity(SetSeverityRequest request) {
  236. return call(
  237. new PostRequest(path("set_severity"))
  238. .setParam("issue", request.getIssue())
  239. .setParam("severity", request.getSeverity()),
  240. SetSeverityResponse.parser());
  241. }
  242. /**
  243. *
  244. * This is part of the internal API.
  245. * This is a POST request.
  246. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/set_tags">Further information about this action online (including a response example)</a>
  247. * @since 5.1
  248. */
  249. public SetTagsResponse setTags(SetTagsRequest request) {
  250. return call(
  251. new PostRequest(path("set_tags"))
  252. .setParam("issue", request.getIssue())
  253. .setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(","))),
  254. SetTagsResponse.parser());
  255. }
  256. /**
  257. *
  258. * This is part of the internal API.
  259. * This is a POST request.
  260. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/set_type">Further information about this action online (including a response example)</a>
  261. * @since 5.5
  262. */
  263. public SetTypeResponse setType(SetTypeRequest request) {
  264. return call(
  265. new PostRequest(path("set_type"))
  266. .setParam("issue", request.getIssue())
  267. .setParam("type", request.getType()),
  268. SetTypeResponse.parser());
  269. }
  270. /**
  271. *
  272. * This is part of the internal API.
  273. * This is a GET request.
  274. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/tags">Further information about this action online (including a response example)</a>
  275. * @since 5.1
  276. */
  277. public TagsResponse tags(TagsRequest request) {
  278. return call(
  279. new GetRequest(path("tags"))
  280. .setParam("project", request.getProject())
  281. .setParam("ps", request.getPs())
  282. .setParam("q", request.getQ()),
  283. TagsResponse.parser());
  284. }
  285. }