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.

QualitygatesService.java 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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.qualitygates;
  21. import javax.annotation.Generated;
  22. import org.sonarqube.ws.MediaTypes;
  23. import org.sonarqube.ws.Qualitygates.CreateConditionResponse;
  24. import org.sonarqube.ws.Qualitygates.CreateResponse;
  25. import org.sonarqube.ws.Qualitygates.GetByProjectResponse;
  26. import org.sonarqube.ws.Qualitygates.ListWsResponse;
  27. import org.sonarqube.ws.Qualitygates.ProjectStatusResponse;
  28. import org.sonarqube.ws.Qualitygates.SearchResponse;
  29. import org.sonarqube.ws.Qualitygates.ShowWsResponse;
  30. import org.sonarqube.ws.Qualitygates.UpdateConditionResponse;
  31. import org.sonarqube.ws.client.BaseService;
  32. import org.sonarqube.ws.client.GetRequest;
  33. import org.sonarqube.ws.client.PostRequest;
  34. import org.sonarqube.ws.client.WsConnector;
  35. /**
  36. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates">Further information about this web service online</a>
  37. */
  38. @Generated("sonar-ws-generator")
  39. public class QualitygatesService extends BaseService {
  40. public QualitygatesService(WsConnector wsConnector) {
  41. super(wsConnector, "api/qualitygates");
  42. }
  43. /**
  44. * This is part of the internal API.
  45. * This is a POST request.
  46. *
  47. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/copy">Further information about this action online (including a response example)</a>
  48. * @since 4.3
  49. */
  50. public void copy(CopyRequest request) {
  51. call(
  52. new PostRequest(path("copy"))
  53. .setParam("id", request.getId())
  54. .setParam("name", request.getName())
  55. .setMediaType(MediaTypes.JSON)).content();
  56. }
  57. /**
  58. * This is part of the internal API.
  59. * This is a POST request.
  60. *
  61. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/create">Further information about this action online (including a response example)</a>
  62. * @since 4.3
  63. */
  64. public CreateResponse create(CreateRequest request) {
  65. return call(
  66. new PostRequest(path("create"))
  67. .setParam("name", request.getName()),
  68. CreateResponse.parser());
  69. }
  70. /**
  71. * Use this for to use a JSON payload, useful to parse the quality gate as Long or String
  72. */
  73. public CreateResponse createJson(CreateRequest request) {
  74. return call(
  75. new PostRequest(path("create"))
  76. .setParam("name", request.getName()),
  77. new QualityGatesServiceCreateResponseJsonParser(), MediaTypes.JSON);
  78. }
  79. /**
  80. * This is part of the internal API.
  81. * This is a POST request.
  82. *
  83. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/create_condition">Further information about this action online (including a response example)</a>
  84. * @since 4.3
  85. */
  86. public CreateConditionResponse createCondition(CreateConditionRequest request) {
  87. return call(
  88. new PostRequest(path("create_condition"))
  89. .setParam("error", request.getError())
  90. .setParam("gateId", request.getGateId())
  91. .setParam("metric", request.getMetric())
  92. .setParam("op", request.getOp()),
  93. CreateConditionResponse.parser());
  94. }
  95. /**
  96. * This is part of the internal API.
  97. * This is a POST request.
  98. *
  99. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/delete_condition">Further information about this action online (including a response example)</a>
  100. * @since 4.3
  101. */
  102. public void deleteCondition(DeleteConditionRequest request) {
  103. call(
  104. new PostRequest(path("delete_condition"))
  105. .setParam("id", request.getId())
  106. .setMediaType(MediaTypes.JSON)).content();
  107. }
  108. /**
  109. * This is part of the internal API.
  110. * This is a POST request.
  111. *
  112. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/deselect">Further information about this action online (including a response example)</a>
  113. * @since 4.3
  114. */
  115. public void deselect(DeselectRequest request) {
  116. call(
  117. new PostRequest(path("deselect"))
  118. .setParam("projectId", request.getProjectId())
  119. .setParam("projectKey", request.getProjectKey())
  120. .setMediaType(MediaTypes.JSON)).content();
  121. }
  122. /**
  123. * This is part of the internal API.
  124. * This is a POST request.
  125. *
  126. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/destroy">Further information about this action online (including a response example)</a>
  127. * @since 4.3
  128. */
  129. public void destroy(DestroyRequest request) {
  130. call(
  131. new PostRequest(path("destroy"))
  132. .setParam("id", request.getId())
  133. .setMediaType(MediaTypes.JSON)).content();
  134. }
  135. /**
  136. * This is part of the internal API.
  137. * This is a GET request.
  138. *
  139. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/get_by_project">Further information about this action online (including a response example)</a>
  140. * @since 6.1
  141. */
  142. public GetByProjectResponse getByProject(GetByProjectRequest request) {
  143. return call(
  144. new GetRequest(path("get_by_project"))
  145. .setParam("project", request.getProject()),
  146. GetByProjectResponse.parser());
  147. }
  148. /**
  149. * This is part of the internal API.
  150. * This is a GET request.
  151. *
  152. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/list">Further information about this action online (including a response example)</a>
  153. * @since 4.3
  154. */
  155. public ListWsResponse list(ListRequest request) {
  156. return call(
  157. new GetRequest(path("list")),
  158. ListWsResponse.parser());
  159. }
  160. /**
  161. * This is part of the internal API.
  162. * This is a GET request.
  163. *
  164. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/project_status">Further information about this action online (including a response example)</a>
  165. * @since 5.3
  166. */
  167. public ProjectStatusResponse projectStatus(ProjectStatusRequest request) {
  168. return call(
  169. new GetRequest(path("project_status"))
  170. .setParam("analysisId", request.getAnalysisId())
  171. .setParam("projectId", request.getProjectId())
  172. .setParam("projectKey", request.getProjectKey())
  173. .setParam("branch", request.getBranch())
  174. .setParam("pullRequest", request.getPullRequest()),
  175. ProjectStatusResponse.parser());
  176. }
  177. /**
  178. * This is part of the internal API.
  179. * This is a POST request.
  180. *
  181. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/rename">Further information about this action online (including a response example)</a>
  182. * @since 4.3
  183. */
  184. public void rename(RenameRequest request) {
  185. call(
  186. new PostRequest(path("rename"))
  187. .setParam("id", request.getId())
  188. .setParam("name", request.getName())
  189. .setMediaType(MediaTypes.JSON)).content();
  190. }
  191. /**
  192. * This is part of the internal API.
  193. * This is a GET request.
  194. *
  195. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/search">Further information about this action online (including a response example)</a>
  196. * @since 4.3
  197. */
  198. public SearchResponse search(SearchRequest request) {
  199. return call(
  200. new GetRequest(path("search"))
  201. .setParam("gateId", request.getGateId())
  202. .setParam("page", request.getPage())
  203. .setParam("pageSize", request.getPageSize())
  204. .setParam("query", request.getQuery())
  205. .setParam("selected", request.getSelected()),
  206. SearchResponse.parser());
  207. }
  208. /**
  209. * This is part of the internal API.
  210. * This is a POST request.
  211. *
  212. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/select">Further information about this action online (including a response example)</a>
  213. * @since 4.3
  214. */
  215. public void select(SelectRequest request) {
  216. call(
  217. new PostRequest(path("select"))
  218. .setParam("gateId", request.getGateId())
  219. .setParam("projectId", request.getProjectId())
  220. .setParam("projectKey", request.getProjectKey())
  221. .setMediaType(MediaTypes.JSON)).content();
  222. }
  223. /**
  224. * This is part of the internal API.
  225. * This is a POST request.
  226. *
  227. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/set_as_default">Further information about this action online (including a response example)</a>
  228. * @since 4.3
  229. */
  230. public void setAsDefault(SetAsDefaultRequest request) {
  231. call(
  232. new PostRequest(path("set_as_default"))
  233. .setParam("id", request.getId())
  234. .setMediaType(MediaTypes.JSON)).content();
  235. }
  236. /**
  237. * This is part of the internal API.
  238. * This is a GET request.
  239. *
  240. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/show">Further information about this action online (including a response example)</a>
  241. * @since 4.3
  242. */
  243. public ShowWsResponse show(ShowRequest request) {
  244. return call(
  245. new GetRequest(path("show"))
  246. .setParam("id", request.getId())
  247. .setParam("name", request.getName()),
  248. ShowWsResponse.parser());
  249. }
  250. /**
  251. * This is part of the internal API.
  252. * This is a POST request.
  253. *
  254. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/update_condition">Further information about this action online (including a response example)</a>
  255. * @since 4.3
  256. */
  257. public void updateCondition(UpdateConditionRequest request) {
  258. call(
  259. new PostRequest(path("update_condition"))
  260. .setParam("error", request.getError())
  261. .setParam("id", request.getId())
  262. .setParam("metric", request.getMetric())
  263. .setParam("op", request.getOp()),
  264. UpdateConditionResponse.parser());
  265. }
  266. }