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.

ViewsService.java 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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.views;
  21. import java.util.stream.Collectors;
  22. import javax.annotation.Generated;
  23. import org.sonarqube.ws.MediaTypes;
  24. import org.sonarqube.ws.client.BaseService;
  25. import org.sonarqube.ws.client.GetRequest;
  26. import org.sonarqube.ws.client.PostRequest;
  27. import org.sonarqube.ws.client.WsConnector;
  28. /**
  29. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views">Further information about this web service online</a>
  30. */
  31. @Generated("sonar-ws-generator")
  32. public class ViewsService extends BaseService {
  33. public ViewsService(WsConnector wsConnector) {
  34. super(wsConnector, "api/views");
  35. }
  36. /**
  37. *
  38. * This is part of the internal API.
  39. * This is a POST request.
  40. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_local_view">Further information about this action online (including a response example)</a>
  41. * @since 1.0
  42. */
  43. public void addLocalView(AddLocalViewRequest request) {
  44. call(
  45. new PostRequest(path("add_local_view"))
  46. .setParam("key", request.getKey())
  47. .setParam("ref_key", request.getRefKey())
  48. .setMediaType(MediaTypes.JSON)
  49. ).content();
  50. }
  51. /**
  52. *
  53. * This is part of the internal API.
  54. * This is a POST request.
  55. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_project">Further information about this action online (including a response example)</a>
  56. * @since 1.0
  57. */
  58. public void addProject(AddProjectRequest request) {
  59. call(
  60. new PostRequest(path("add_project"))
  61. .setParam("key", request.getKey())
  62. .setParam("project", request.getProject())
  63. .setMediaType(MediaTypes.JSON)
  64. ).content();
  65. }
  66. /**
  67. *
  68. * This is part of the internal API.
  69. * This is a POST request.
  70. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/add_sub_view">Further information about this action online (including a response example)</a>
  71. * @since 1.0
  72. */
  73. public void addSubView(AddSubViewRequest request) {
  74. call(
  75. new PostRequest(path("add_sub_view"))
  76. .setParam("description", request.getDescription())
  77. .setParam("key", request.getKey())
  78. .setParam("name", request.getName())
  79. .setParam("subKey", request.getSubKey())
  80. .setMediaType(MediaTypes.JSON)
  81. ).content();
  82. }
  83. /**
  84. *
  85. * This is part of the internal API.
  86. * This is a GET request.
  87. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/app">Further information about this action online (including a response example)</a>
  88. * @since 1.0
  89. */
  90. public String app() {
  91. return call(
  92. new GetRequest(path("app"))
  93. .setMediaType(MediaTypes.JSON)
  94. ).content();
  95. }
  96. /**
  97. *
  98. * This is part of the internal API.
  99. * This is a POST request.
  100. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/create">Further information about this action online (including a response example)</a>
  101. * @since 1.0
  102. */
  103. public void create(CreateRequest request) {
  104. call(
  105. new PostRequest(path("create"))
  106. .setParam("description", request.getDescription())
  107. .setParam("key", request.getKey())
  108. .setParam("name", request.getName())
  109. .setParam("visibility", request.getVisibility())
  110. .setMediaType(MediaTypes.JSON)
  111. ).content();
  112. }
  113. /**
  114. *
  115. * This is part of the internal API.
  116. * This is a POST request.
  117. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/define">Further information about this action online (including a response example)</a>
  118. * @since 1.0
  119. */
  120. public void define(DefineRequest request) {
  121. call(
  122. new PostRequest(path("define"))
  123. .setParam("def", request.getDef())
  124. .setMediaType(MediaTypes.JSON)
  125. ).content();
  126. }
  127. /**
  128. *
  129. * This is part of the internal API.
  130. * This is a GET request.
  131. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/definition">Further information about this action online (including a response example)</a>
  132. * @since 2.0
  133. */
  134. public String definition() {
  135. return call(
  136. new GetRequest(path("definition"))
  137. .setMediaType(MediaTypes.JSON)
  138. ).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/views/delete">Further information about this action online (including a response example)</a>
  145. * @since 1.0
  146. */
  147. public void delete(DeleteRequest request) {
  148. call(
  149. new PostRequest(path("delete"))
  150. .setParam("key", request.getKey())
  151. .setMediaType(MediaTypes.JSON)
  152. ).content();
  153. }
  154. /**
  155. *
  156. * This is part of the internal API.
  157. * This is a GET request.
  158. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/list">Further information about this action online (including a response example)</a>
  159. * @since 1.0
  160. */
  161. public String list() {
  162. return call(
  163. new GetRequest(path("list"))
  164. .setMediaType(MediaTypes.JSON)
  165. ).content();
  166. }
  167. /**
  168. *
  169. * This is part of the internal API.
  170. * This is a GET request.
  171. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/local_views">Further information about this action online (including a response example)</a>
  172. * @since 1.0
  173. */
  174. public String localViews(LocalViewsRequest request) {
  175. return call(
  176. new GetRequest(path("local_views"))
  177. .setParam("key", request.getKey())
  178. .setMediaType(MediaTypes.JSON)
  179. ).content();
  180. }
  181. /**
  182. *
  183. * This is part of the internal API.
  184. * This is a POST request.
  185. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/move">Further information about this action online (including a response example)</a>
  186. * @since 1.0
  187. */
  188. public void move(MoveRequest request) {
  189. call(
  190. new PostRequest(path("move"))
  191. .setParam("destination", request.getDestination())
  192. .setParam("key", request.getKey())
  193. .setMediaType(MediaTypes.JSON)
  194. ).content();
  195. }
  196. /**
  197. *
  198. * This is part of the internal API.
  199. * This is a GET request.
  200. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/move_options">Further information about this action online (including a response example)</a>
  201. * @since 1.0
  202. */
  203. public String moveOptions(MoveOptionsRequest request) {
  204. return call(
  205. new GetRequest(path("move_options"))
  206. .setParam("key", request.getKey())
  207. .setMediaType(MediaTypes.JSON)
  208. ).content();
  209. }
  210. /**
  211. *
  212. * This is part of the internal API.
  213. * This is a GET request.
  214. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/projects">Further information about this action online (including a response example)</a>
  215. * @since 1.0
  216. */
  217. public String projects(ProjectsRequest request) {
  218. return call(
  219. new GetRequest(path("projects"))
  220. .setParam("key", request.getKey())
  221. .setParam("p", request.getP())
  222. .setParam("ps", request.getPs())
  223. .setParam("query", request.getQuery())
  224. .setParam("selected", request.getSelected())
  225. .setMediaType(MediaTypes.JSON)
  226. ).content();
  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/views/refresh">Further information about this action online (including a response example)</a>
  233. * @since 7.1
  234. */
  235. public void refresh(RefreshRequest request) {
  236. call(
  237. new PostRequest(path("refresh"))
  238. .setParam("key", request.getKey())
  239. .setMediaType(MediaTypes.JSON)
  240. ).content();
  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/views/remove_project">Further information about this action online (including a response example)</a>
  247. * @since 1.0
  248. */
  249. public void removeProject(RemoveProjectRequest request) {
  250. call(
  251. new PostRequest(path("remove_project"))
  252. .setParam("key", request.getKey())
  253. .setParam("project", request.getProject())
  254. .setMediaType(MediaTypes.JSON)
  255. ).content();
  256. }
  257. /**
  258. *
  259. * This is part of the internal API.
  260. * This is a POST request.
  261. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/run">Further information about this action online (including a response example)</a>
  262. * @since 1.0
  263. * @deprecated since 7.1
  264. */
  265. @Deprecated
  266. public String run() {
  267. return call(
  268. new PostRequest(path("run"))
  269. .setMediaType(MediaTypes.JSON)
  270. ).content();
  271. }
  272. /**
  273. *
  274. * This is part of the internal API.
  275. * This is a GET request.
  276. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/search">Further information about this action online (including a response example)</a>
  277. * @since 2.0
  278. */
  279. public String search(SearchRequest request) {
  280. return call(
  281. new GetRequest(path("search"))
  282. .setParam("onlyFavorites", request.getOnlyFavorites())
  283. .setParam("p", request.getP())
  284. .setParam("ps", request.getPs())
  285. .setParam("q", request.getQ())
  286. .setParam("qualifiers", request.getQualifiers())
  287. .setMediaType(MediaTypes.JSON)
  288. ).content();
  289. }
  290. /**
  291. *
  292. * This is part of the internal API.
  293. * This is a POST request.
  294. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_manual_mode">Further information about this action online (including a response example)</a>
  295. * @since 7.4
  296. */
  297. public void setManualMode(SetManualModeRequest request) {
  298. call(
  299. new PostRequest(path("set_manual_mode"))
  300. .setParam("portfolio", request.getPortfolio())
  301. .setMediaType(MediaTypes.JSON)
  302. ).content();
  303. }
  304. /**
  305. *
  306. * This is part of the internal API.
  307. * This is a POST request.
  308. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_none_mode">Further information about this action online (including a response example)</a>
  309. * @since 9.1
  310. */
  311. public void setNoneMode(SetNoneModeRequest request) {
  312. call(
  313. new PostRequest(path("set_none_mode"))
  314. .setParam("portfolio", request.getPortfolio())
  315. .setMediaType(MediaTypes.JSON)
  316. ).content();
  317. }
  318. /**
  319. *
  320. * This is part of the internal API.
  321. * This is a POST request.
  322. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_remaining_projects_mode">Further information about this action online (including a response example)</a>
  323. * @since 7.4
  324. */
  325. public void setRegexpMode(SetRegexpModeRequest request) {
  326. call(
  327. new PostRequest(path("set_regexp_mode"))
  328. .setParam("portfolio", request.getPortfolio())
  329. .setParam("regexp", request.getRegexp())
  330. .setMediaType(MediaTypes.JSON)
  331. ).content();
  332. }
  333. /**
  334. *
  335. * This is part of the internal API.
  336. * This is a POST request.
  337. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_remaining_projects_mode">Further information about this action online (including a response example)</a>
  338. * @since 7.4
  339. */
  340. public void setRemainingProjectsMode(SetRemainingProjectsModeRequest request) {
  341. call(
  342. new PostRequest(path("set_remaining_projects_mode"))
  343. .setParam("portfolio", request.getPortfolio())
  344. .setMediaType(MediaTypes.JSON)
  345. ).content();
  346. }
  347. /**
  348. *
  349. * This is part of the internal API.
  350. * This is a POST request.
  351. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/set_tags_mode">Further information about this action online (including a response example)</a>
  352. * @since 7.4
  353. */
  354. public void setTagsMode(SetTagsModeRequest request) {
  355. call(
  356. new PostRequest(path("set_tags_mode"))
  357. .setParam("portfolio", request.getPortfolio())
  358. .setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(",")))
  359. .setMediaType(MediaTypes.JSON)
  360. ).content();
  361. }
  362. /**
  363. *
  364. * This is part of the internal API.
  365. * This is a GET request.
  366. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/show">Further information about this action online (including a response example)</a>
  367. * @since 1.0
  368. */
  369. public String show(ShowRequest request) {
  370. return call(
  371. new GetRequest(path("show"))
  372. .setParam("key", request.getKey())
  373. .setMediaType(MediaTypes.JSON)
  374. ).content();
  375. }
  376. /**
  377. *
  378. * This is part of the internal API.
  379. * This is a POST request.
  380. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/views/update">Further information about this action online (including a response example)</a>
  381. * @since 1.0
  382. */
  383. public void update(UpdateRequest request) {
  384. call(
  385. new PostRequest(path("update"))
  386. .setParam("description", request.getDescription())
  387. .setParam("key", request.getKey())
  388. .setParam("name", request.getName())
  389. .setMediaType(MediaTypes.JSON)
  390. ).content();
  391. }
  392. }