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 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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;
  24. import org.sonarqube.ws.Qualitygates.CreateConditionResponse;
  25. import org.sonarqube.ws.Qualitygates.CreateResponse;
  26. import org.sonarqube.ws.Qualitygates.GetByProjectResponse;
  27. import org.sonarqube.ws.Qualitygates.ListWsResponse;
  28. import org.sonarqube.ws.Qualitygates.ProjectStatusResponse;
  29. import org.sonarqube.ws.Qualitygates.SearchResponse;
  30. import org.sonarqube.ws.Qualitygates.ShowWsResponse;
  31. import org.sonarqube.ws.Qualitygates.UpdateConditionResponse;
  32. import org.sonarqube.ws.client.BaseService;
  33. import org.sonarqube.ws.client.GetRequest;
  34. import org.sonarqube.ws.client.PostRequest;
  35. import org.sonarqube.ws.client.WsConnector;
  36. /**
  37. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates">Further information about this web service online</a>
  38. */
  39. @Generated("sonar-ws-generator")
  40. public class QualitygatesService extends BaseService {
  41. public QualitygatesService(WsConnector wsConnector) {
  42. super(wsConnector, "api/qualitygates");
  43. }
  44. /**
  45. * This is part of the internal API.
  46. * This is a POST request.
  47. *
  48. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/copy">Further information about this action online (including a response example)</a>
  49. * @since 4.3
  50. */
  51. public void copy(CopyRequest request) {
  52. call(
  53. new PostRequest(path("copy"))
  54. .setParam("id", request.getId())
  55. .setParam("name", request.getName())
  56. .setMediaType(MediaTypes.JSON)).content();
  57. }
  58. /**
  59. * This is part of the internal API.
  60. * This is a POST request.
  61. *
  62. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/create">Further information about this action online (including a response example)</a>
  63. * @since 4.3
  64. */
  65. public CreateResponse create(CreateRequest request) {
  66. return call(
  67. new PostRequest(path("create"))
  68. .setParam("name", request.getName()),
  69. CreateResponse.parser());
  70. }
  71. /**
  72. * Use this for to use a JSON payload, useful to parse the quality gate as Long or String
  73. */
  74. public CreateResponse createJson(CreateRequest request) {
  75. return call(
  76. new PostRequest(path("create"))
  77. .setParam("name", request.getName()),
  78. new QualityGatesServiceCreateResponseJsonParser(), MediaTypes.JSON);
  79. }
  80. /**
  81. * This is part of the internal API.
  82. * This is a POST request.
  83. *
  84. * @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>
  85. * @since 4.3
  86. */
  87. public CreateConditionResponse createCondition(CreateConditionRequest request) {
  88. return call(
  89. new PostRequest(path("create_condition"))
  90. .setParam("error", request.getError())
  91. .setParam("gateId", request.getGateId())
  92. .setParam("metric", request.getMetric())
  93. .setParam("op", request.getOp()),
  94. CreateConditionResponse.parser());
  95. }
  96. /**
  97. * This is part of the internal API.
  98. * This is a POST request.
  99. *
  100. * @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>
  101. * @since 4.3
  102. */
  103. public void deleteCondition(DeleteConditionRequest request) {
  104. call(
  105. new PostRequest(path("delete_condition"))
  106. .setParam("id", request.getId())
  107. .setMediaType(MediaTypes.JSON)).content();
  108. }
  109. /**
  110. * This is part of the internal API.
  111. * This is a POST request.
  112. *
  113. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/deselect">Further information about this action online (including a response example)</a>
  114. * @since 4.3
  115. */
  116. public void deselect(DeselectRequest request) {
  117. call(
  118. new PostRequest(path("deselect"))
  119. .setParam("projectId", request.getProjectId())
  120. .setParam("projectKey", request.getProjectKey())
  121. .setMediaType(MediaTypes.JSON)).content();
  122. }
  123. /**
  124. * This is part of the internal API.
  125. * This is a POST request.
  126. *
  127. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/destroy">Further information about this action online (including a response example)</a>
  128. * @since 4.3
  129. */
  130. public void destroy(DestroyRequest request) {
  131. call(
  132. new PostRequest(path("destroy"))
  133. .setParam("id", request.getId())
  134. .setMediaType(MediaTypes.JSON)).content();
  135. }
  136. /**
  137. * This is part of the internal API.
  138. * This is a GET request.
  139. *
  140. * @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>
  141. * @since 6.1
  142. */
  143. public GetByProjectResponse getByProject(GetByProjectRequest request) {
  144. return call(
  145. new GetRequest(path("get_by_project"))
  146. .setParam("project", request.getProject()),
  147. GetByProjectResponse.parser());
  148. }
  149. /**
  150. * This is part of the internal API.
  151. * This is a GET request.
  152. *
  153. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/list">Further information about this action online (including a response example)</a>
  154. * @since 4.3
  155. */
  156. public ListWsResponse list(ListRequest request) {
  157. return call(
  158. new GetRequest(path("list")),
  159. ListWsResponse.parser());
  160. }
  161. /**
  162. * This is part of the internal API.
  163. * This is a GET request.
  164. *
  165. * @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>
  166. * @since 5.3
  167. */
  168. public ProjectStatusResponse projectStatus(ProjectStatusRequest request) {
  169. return call(
  170. new GetRequest(path("project_status"))
  171. .setParam("analysisId", request.getAnalysisId())
  172. .setParam("projectId", request.getProjectId())
  173. .setParam("projectKey", request.getProjectKey())
  174. .setParam("branch", request.getBranch())
  175. .setParam("pullRequest", request.getPullRequest()),
  176. ProjectStatusResponse.parser());
  177. }
  178. /**
  179. * This is part of the internal API.
  180. * This is a GET request.
  181. *
  182. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/application_status">Further information about this action online (including a response example)</a>
  183. * @since 2.0
  184. */
  185. public void applicationStatus(ApplicationStatusRequest request) {
  186. call(
  187. new GetRequest(path("application_status"))
  188. .setParam("application", request.getApplication())
  189. .setParam("branch", request.getBranch()));
  190. }
  191. /**
  192. * This is part of the internal API.
  193. * This is a POST request.
  194. *
  195. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/rename">Further information about this action online (including a response example)</a>
  196. * @since 4.3
  197. */
  198. public void rename(RenameRequest request) {
  199. call(
  200. new PostRequest(path("rename"))
  201. .setParam("id", request.getId())
  202. .setParam("name", request.getName())
  203. .setMediaType(MediaTypes.JSON)).content();
  204. }
  205. /**
  206. * This is part of the internal API.
  207. * This is a GET request.
  208. *
  209. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/search">Further information about this action online (including a response example)</a>
  210. * @since 4.3
  211. */
  212. public SearchResponse search(SearchRequest request) {
  213. return call(
  214. new GetRequest(path("search"))
  215. .setParam("gateId", request.getGateId())
  216. .setParam("page", request.getPage())
  217. .setParam("pageSize", request.getPageSize())
  218. .setParam("query", request.getQuery())
  219. .setParam("selected", request.getSelected()),
  220. SearchResponse.parser());
  221. }
  222. /**
  223. * This is part of the internal API.
  224. * This is a POST request.
  225. *
  226. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/select">Further information about this action online (including a response example)</a>
  227. * @since 4.3
  228. */
  229. public void select(SelectRequest request) {
  230. call(
  231. new PostRequest(path("select"))
  232. .setParam("gateId", request.getGateId())
  233. .setParam("projectId", request.getProjectId())
  234. .setParam("projectKey", request.getProjectKey())
  235. .setMediaType(MediaTypes.JSON)).content();
  236. }
  237. /**
  238. * This is part of the internal API.
  239. * This is a POST request.
  240. *
  241. * @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>
  242. * @since 4.3
  243. */
  244. public void setAsDefault(SetAsDefaultRequest request) {
  245. call(
  246. new PostRequest(path("set_as_default"))
  247. .setParam("id", request.getId())
  248. .setMediaType(MediaTypes.JSON)).content();
  249. }
  250. /**
  251. * This is part of the internal API.
  252. * This is a GET request.
  253. *
  254. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/show">Further information about this action online (including a response example)</a>
  255. * @since 4.3
  256. */
  257. public ShowWsResponse show(ShowRequest request) {
  258. return call(
  259. new GetRequest(path("show"))
  260. .setParam("id", request.getId())
  261. .setParam("name", request.getName()),
  262. ShowWsResponse.parser());
  263. }
  264. /**
  265. * This is part of the internal API.
  266. * This is a POST request.
  267. *
  268. * @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>
  269. * @since 4.3
  270. */
  271. public void updateCondition(UpdateConditionRequest request) {
  272. call(
  273. new PostRequest(path("update_condition"))
  274. .setParam("error", request.getError())
  275. .setParam("id", request.getId())
  276. .setParam("metric", request.getMetric())
  277. .setParam("op", request.getOp()),
  278. UpdateConditionResponse.parser());
  279. }
  280. /**
  281. * This is part of the internal API.
  282. * This is a POST request.
  283. *
  284. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/add_user">Further information about this action online (including a response example)</a>
  285. * @since 9.2
  286. */
  287. public void addUser(AddUserRequest request) {
  288. call(
  289. new PostRequest(path("add_user"))
  290. .setParam("login", request.getLogin())
  291. .setParam("gateName", request.getQualityGate())
  292. .setMediaType(MediaTypes.JSON)
  293. ).content();
  294. }
  295. /**
  296. * This is part of the internal API.
  297. * This is a GET request.
  298. *
  299. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/search_users">Further information about this action online (including a response example)</a>
  300. * @since 9.2
  301. */
  302. public Qualitygates.SearchUsersResponse searchUsers(SearchUsersRequest request) {
  303. return call(
  304. new GetRequest(path("search_users"))
  305. .setParam("p", request.getP())
  306. .setParam("ps", request.getPs())
  307. .setParam("q", request.getQ())
  308. .setParam("gateName", request.getQualityGate())
  309. .setParam("selected", request.getSelected()),
  310. Qualitygates.SearchUsersResponse.parser());
  311. }
  312. /**
  313. * This is part of the internal API.
  314. * This is a POST request.
  315. *
  316. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/remove_user">Further information about this action online (including a response example)</a>
  317. * @since 9.2
  318. */
  319. public void removeUser(RemoveUserRequest request) {
  320. call(
  321. new PostRequest(path("remove_user"))
  322. .setParam("login", request.getLogin())
  323. .setParam("gateName", request.getQualityGate())
  324. .setMediaType(MediaTypes.JSON)
  325. ).content();
  326. }
  327. /**
  328. * This is part of the internal API.
  329. * This is a POST request.
  330. *
  331. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/add_group">Further information about this action online (including a response example)</a>
  332. * @since 9.2
  333. */
  334. public void addGroup(AddGroupRequest request) {
  335. call(
  336. new PostRequest(path("add_group"))
  337. .setParam("groupName", request.getGroup())
  338. .setParam("gateName", request.getQualityGate())
  339. .setMediaType(MediaTypes.JSON)
  340. ).content();
  341. }
  342. /**
  343. * This is part of the internal API.
  344. * This is a GET request.
  345. *
  346. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/search_groups">Further information about this action online (including a response example)</a>
  347. * @since 9.2
  348. */
  349. public Qualitygates.SearchGroupsResponse searchGroups(SearchGroupsRequest request) {
  350. return call(
  351. new GetRequest(path("search_groups"))
  352. .setParam("p", request.getP())
  353. .setParam("ps", request.getPs())
  354. .setParam("q", request.getQ())
  355. .setParam("gateName", request.getQualityGate())
  356. .setParam("selected", request.getSelected()),
  357. Qualitygates.SearchGroupsResponse.parser());
  358. }
  359. /**
  360. * This is part of the internal API.
  361. * This is a POST request.
  362. *
  363. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/remove_group">Further information about this action online (including a response example)</a>
  364. * @since 9.2
  365. */
  366. public void removeGroup(RemoveGroupRequest request) {
  367. call(
  368. new PostRequest(path("remove_group"))
  369. .setParam("groupName", request.getGroup())
  370. .setParam("gateName", request.getQualityGate())
  371. .setMediaType(MediaTypes.JSON)
  372. ).content();
  373. }
  374. }