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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 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. .setParam("me", request.getMe()),
  75. AssignResponse.parser());
  76. }
  77. /**
  78. *
  79. * This is part of the internal API.
  80. * This is a GET request.
  81. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/authors">Further information about this action online (including a response example)</a>
  82. * @since 5.1
  83. */
  84. public AuthorsResponse authors(AuthorsRequest request) {
  85. return call(
  86. new GetRequest(path("authors"))
  87. .setParam("organization", request.getOrganization())
  88. .setParam("project", request.getProject())
  89. .setParam("ps", request.getPs())
  90. .setParam("q", request.getQ()),
  91. AuthorsResponse.parser());
  92. }
  93. /**
  94. *
  95. * This is part of the internal API.
  96. * This is a POST request.
  97. * @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>
  98. * @since 3.7
  99. */
  100. public BulkChangeWsResponse bulkChange(BulkChangeRequest request) {
  101. return call(
  102. new PostRequest(path("bulk_change"))
  103. .setParam("add_tags", request.getAddTags())
  104. .setParam("assign", request.getAssign() == null ? null : request.getAssign().stream().collect(Collectors.joining(",")))
  105. .setParam("comment", request.getComment() == null ? null : request.getComment().stream().collect(Collectors.joining(",")))
  106. .setParam("do_transition", request.getDoTransition())
  107. .setParam("issues", request.getIssues() == null ? null : request.getIssues().stream().collect(Collectors.joining(",")))
  108. .setParam("plan", request.getPlan() == null ? null : request.getPlan().stream().collect(Collectors.joining(",")))
  109. .setParam("remove_tags", request.getRemoveTags())
  110. .setParam("sendNotifications", request.getSendNotifications())
  111. .setParam("set_severity", request.getSetSeverity() == null ? null : request.getSetSeverity().stream().collect(Collectors.joining(",")))
  112. .setParam("set_type", request.getSetType() == null ? null : request.getSetType().stream().collect(Collectors.joining(","))),
  113. BulkChangeWsResponse.parser());
  114. }
  115. /**
  116. *
  117. * This is part of the internal API.
  118. * This is a GET request.
  119. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/changelog">Further information about this action online (including a response example)</a>
  120. * @since 4.1
  121. */
  122. public ChangelogWsResponse changelog(ChangelogRequest request) {
  123. return call(
  124. new GetRequest(path("changelog"))
  125. .setParam("issue", request.getIssue()),
  126. ChangelogWsResponse.parser());
  127. }
  128. /**
  129. *
  130. * This is part of the internal API.
  131. * This is a GET request.
  132. * @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>
  133. * @since 5.1
  134. */
  135. public String componentTags(ComponentTagsRequest request) {
  136. return call(
  137. new GetRequest(path("component_tags"))
  138. .setParam("componentUuid", request.getComponentUuid())
  139. .setParam("createdAfter", request.getCreatedAfter())
  140. .setParam("ps", request.getPs())
  141. .setMediaType(MediaTypes.JSON)
  142. ).content();
  143. }
  144. /**
  145. *
  146. * This is part of the internal API.
  147. * This is a POST request.
  148. * @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>
  149. * @since 3.6
  150. */
  151. public DeleteCommentResponse deleteComment(DeleteCommentRequest request) {
  152. return call(
  153. new PostRequest(path("delete_comment"))
  154. .setParam("comment", request.getComment()),
  155. DeleteCommentResponse.parser());
  156. }
  157. /**
  158. *
  159. * This is part of the internal API.
  160. * This is a POST request.
  161. * @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>
  162. * @since 3.6
  163. */
  164. public DoTransitionResponse doTransition(DoTransitionRequest request) {
  165. return call(
  166. new PostRequest(path("do_transition"))
  167. .setParam("issue", request.getIssue())
  168. .setParam("transition", request.getTransition()),
  169. DoTransitionResponse.parser());
  170. }
  171. /**
  172. *
  173. * This is part of the internal API.
  174. * This is a POST request.
  175. * @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>
  176. * @since 3.6
  177. */
  178. public String editComment(EditCommentRequest request) {
  179. return call(
  180. new PostRequest(path("edit_comment"))
  181. .setParam("comment", request.getComment())
  182. .setParam("text", request.getText())
  183. .setMediaType(MediaTypes.JSON)
  184. ).content();
  185. }
  186. /**
  187. *
  188. * This is part of the internal API.
  189. * This is a GET request.
  190. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/search">Further information about this action online (including a response example)</a>
  191. * @since 3.6
  192. */
  193. public SearchWsResponse search(SearchRequest request) {
  194. return call(
  195. new GetRequest(path("search"))
  196. .setParam("additionalFields", request.getAdditionalFields() == null ? null : request.getAdditionalFields().stream().collect(Collectors.joining(",")))
  197. .setParam("asc", request.getAsc())
  198. .setParam("assigned", request.getAssigned())
  199. .setParam("assignees", request.getAssignees() == null ? null : request.getAssignees().stream().collect(Collectors.joining(",")))
  200. .setParam("author", request.getAuthor())
  201. .setParam("authors", request.getAuthors() == null ? null : request.getAuthors().stream().collect(Collectors.joining(",")))
  202. .setParam("branch", request.getBranch())
  203. .setParam("componentKeys", request.getComponentKeys() == null ? null : request.getComponentKeys().stream().collect(Collectors.joining(",")))
  204. .setParam("componentRootUuids", request.getComponentRootUuids())
  205. .setParam("componentRoots", request.getComponentRoots())
  206. .setParam("componentUuids", request.getComponentUuids() == null ? null : request.getComponentUuids().stream().collect(Collectors.joining(",")))
  207. .setParam("components", request.getComponents())
  208. .setParam("createdAfter", request.getCreatedAfter())
  209. .setParam("createdAt", request.getCreatedAt())
  210. .setParam("createdBefore", request.getCreatedBefore())
  211. .setParam("createdInLast", request.getCreatedInLast())
  212. .setParam("cwe", request.getCwe() == null ? null : request.getCwe().stream().collect(Collectors.joining(",")))
  213. .setParam("directories", request.getDirectories() == null ? null : request.getDirectories().stream().collect(Collectors.joining(",")))
  214. .setParam("facetMode", request.getFacetMode())
  215. .setParam("facets", request.getFacets() == null ? null : request.getFacets().stream().collect(Collectors.joining(",")))
  216. .setParam("fileUuids", request.getFileUuids() == null ? null : request.getFileUuids().stream().collect(Collectors.joining(",")))
  217. .setParam("issues", request.getIssues() == null ? null : request.getIssues().stream().collect(Collectors.joining(",")))
  218. .setParam("languages", request.getLanguages() == null ? null : request.getLanguages().stream().collect(Collectors.joining(",")))
  219. .setParam("moduleUuids", request.getModuleUuids() == null ? null : request.getModuleUuids().stream().collect(Collectors.joining(",")))
  220. .setParam("onComponentOnly", request.getOnComponentOnly())
  221. .setParam("organization", request.getOrganization())
  222. .setParam("owaspTop10", request.getOwaspTop10() == null ? null : request.getOwaspTop10().stream().collect(Collectors.joining(",")))
  223. .setParam("p", request.getP())
  224. .setParam("projects", request.getProjects() == null ? null : request.getProjects().stream().collect(Collectors.joining(",")))
  225. .setParam("ps", request.getPs())
  226. .setParam("pullRequest", request.getPullRequest())
  227. .setParam("resolutions", request.getResolutions() == null ? null : request.getResolutions().stream().collect(Collectors.joining(",")))
  228. .setParam("resolved", request.getResolved())
  229. .setParam("rules", request.getRules() == null ? null : request.getRules().stream().collect(Collectors.joining(",")))
  230. .setParam("s", request.getS())
  231. .setParam("sansTop25", request.getSansTop25() == null ? null : request.getSansTop25().stream().collect(Collectors.joining(",")))
  232. .setParam("severities", request.getSeverities() == null ? null : request.getSeverities().stream().collect(Collectors.joining(",")))
  233. .setParam("sinceLeakPeriod", request.getSinceLeakPeriod())
  234. .setParam("statuses", request.getStatuses() == null ? null : request.getStatuses().stream().collect(Collectors.joining(",")))
  235. .setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(",")))
  236. .setParam("types", request.getTypes() == null ? null : request.getTypes().stream().collect(Collectors.joining(","))),
  237. SearchWsResponse.parser());
  238. }
  239. /**
  240. *
  241. * This is part of the internal API.
  242. * This is a POST request.
  243. * @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>
  244. * @since 3.6
  245. */
  246. public SetSeverityResponse setSeverity(SetSeverityRequest request) {
  247. return call(
  248. new PostRequest(path("set_severity"))
  249. .setParam("issue", request.getIssue())
  250. .setParam("severity", request.getSeverity()),
  251. SetSeverityResponse.parser());
  252. }
  253. /**
  254. *
  255. * This is part of the internal API.
  256. * This is a POST request.
  257. * @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>
  258. * @since 5.1
  259. */
  260. public SetTagsResponse setTags(SetTagsRequest request) {
  261. return call(
  262. new PostRequest(path("set_tags"))
  263. .setParam("issue", request.getIssue())
  264. .setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(","))),
  265. SetTagsResponse.parser());
  266. }
  267. /**
  268. *
  269. * This is part of the internal API.
  270. * This is a POST request.
  271. * @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>
  272. * @since 5.5
  273. */
  274. public SetTypeResponse setType(SetTypeRequest request) {
  275. return call(
  276. new PostRequest(path("set_type"))
  277. .setParam("issue", request.getIssue())
  278. .setParam("type", request.getType()),
  279. SetTypeResponse.parser());
  280. }
  281. /**
  282. *
  283. * This is part of the internal API.
  284. * This is a GET request.
  285. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/tags">Further information about this action online (including a response example)</a>
  286. * @since 5.1
  287. */
  288. public TagsResponse tags(TagsRequest request) {
  289. return call(
  290. new GetRequest(path("tags"))
  291. .setParam("organization", request.getOrganization())
  292. .setParam("project", request.getProject())
  293. .setParam("ps", request.getPs())
  294. .setParam("q", request.getQ()),
  295. TagsResponse.parser());
  296. }
  297. }