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.

UsersService.java 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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.users;
  21. import java.util.stream.Collectors;
  22. import javax.annotation.Generated;
  23. import org.sonarqube.ws.MediaTypes;
  24. import org.sonarqube.ws.Users.CreateWsResponse;
  25. import org.sonarqube.ws.Users.CurrentWsResponse;
  26. import org.sonarqube.ws.Users.GroupsWsResponse;
  27. import org.sonarqube.ws.Users.IdentityProvidersWsResponse;
  28. import org.sonarqube.ws.Users.SearchWsResponse;
  29. import org.sonarqube.ws.client.BaseService;
  30. import org.sonarqube.ws.client.GetRequest;
  31. import org.sonarqube.ws.client.PostRequest;
  32. import org.sonarqube.ws.client.WsConnector;
  33. /**
  34. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users">Further information about this web service online</a>
  35. */
  36. @Generated("sonar-ws-generator")
  37. public class UsersService extends BaseService {
  38. public UsersService(WsConnector wsConnector) {
  39. super(wsConnector, "api/users");
  40. }
  41. /**
  42. *
  43. * This is part of the internal API.
  44. * This is a POST request.
  45. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/change_password">Further information about this action online (including a response example)</a>
  46. * @since 5.2
  47. */
  48. public void changePassword(ChangePasswordRequest request) {
  49. call(
  50. new PostRequest(path("change_password"))
  51. .setParam("login", request.getLogin())
  52. .setParam("password", request.getPassword())
  53. .setParam("previousPassword", request.getPreviousPassword())
  54. .setMediaType(MediaTypes.JSON)
  55. ).content();
  56. }
  57. /**
  58. *
  59. * This is part of the internal API.
  60. * This is a POST request.
  61. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/create">Further information about this action online (including a response example)</a>
  62. * @since 3.7
  63. */
  64. public CreateWsResponse create(CreateRequest request) {
  65. return call(
  66. new PostRequest(path("create"))
  67. .setParam("email", request.getEmail())
  68. .setParam("local", request.getLocal())
  69. .setParam("login", request.getLogin())
  70. .setParam("name", request.getName())
  71. .setParam("password", request.getPassword())
  72. .setParam("scmAccount", request.getScmAccount())
  73. .setParam("scmAccounts", request.getScmAccounts() == null ? null : request.getScmAccounts().stream().collect(Collectors.joining(","))),
  74. CreateWsResponse.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/users/current">Further information about this action online (including a response example)</a>
  81. * @since 5.2
  82. */
  83. public CurrentWsResponse current() {
  84. return call(
  85. new GetRequest(path("current")),
  86. CurrentWsResponse.parser());
  87. }
  88. /**
  89. *
  90. * This is part of the internal API.
  91. * This is a POST request.
  92. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/deactivate">Further information about this action online (including a response example)</a>
  93. * @since 3.7
  94. */
  95. public String deactivate(DeactivateRequest request) {
  96. return call(
  97. new PostRequest(path("deactivate"))
  98. .setParam("login", request.getLogin())
  99. .setMediaType(MediaTypes.JSON)
  100. ).content();
  101. }
  102. /**
  103. *
  104. * This is part of the internal API.
  105. * This is a GET request.
  106. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/groups">Further information about this action online (including a response example)</a>
  107. * @since 5.2
  108. */
  109. public GroupsWsResponse groups(GroupsRequest request) {
  110. return call(
  111. new GetRequest(path("groups"))
  112. .setParam("login", request.getLogin())
  113. .setParam("organization", request.getOrganization())
  114. .setParam("p", request.getP())
  115. .setParam("ps", request.getPs())
  116. .setParam("q", request.getQ())
  117. .setParam("selected", request.getSelected()),
  118. GroupsWsResponse.parser());
  119. }
  120. /**
  121. *
  122. * This is part of the internal API.
  123. * This is a GET request.
  124. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/identity_providers">Further information about this action online (including a response example)</a>
  125. * @since 5.5
  126. */
  127. public IdentityProvidersWsResponse identityProviders() {
  128. return call(
  129. new GetRequest(path("identity_providers")),
  130. IdentityProvidersWsResponse.parser());
  131. }
  132. /**
  133. *
  134. * This is part of the internal API.
  135. * This is a GET request.
  136. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/search">Further information about this action online (including a response example)</a>
  137. * @since 3.6
  138. */
  139. public SearchWsResponse search(SearchRequest request) {
  140. return call(
  141. new GetRequest(path("search"))
  142. .setParam("f", request.getF() == null ? null : request.getF().stream().collect(Collectors.joining(",")))
  143. .setParam("p", request.getP())
  144. .setParam("ps", request.getPs())
  145. .setParam("q", request.getQ()),
  146. SearchWsResponse.parser());
  147. }
  148. /**
  149. *
  150. * This is part of the internal API.
  151. * This is a POST request.
  152. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/set_homepage">Further information about this action online (including a response example)</a>
  153. * @since 7.0
  154. */
  155. public void setHomepage(SetHomepageRequest request) {
  156. call(
  157. new PostRequest(path("set_homepage"))
  158. .setParam("parameter", request.getParameter())
  159. .setParam("type", request.getType())
  160. .setMediaType(MediaTypes.JSON)
  161. ).content();
  162. }
  163. /**
  164. *
  165. * This is part of the internal API.
  166. * This is a POST request.
  167. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/set_setting">Further information about this action online (including a response example)</a>
  168. * @since 7.6
  169. */
  170. public void setSetting(SetSettingRequest request) {
  171. call(
  172. new PostRequest(path("set_setting"))
  173. .setParam("key", request.getKey())
  174. .setParam("value", request.getValue())
  175. .setMediaType(MediaTypes.JSON)
  176. ).content();
  177. }
  178. /**
  179. *
  180. * This is part of the internal API.
  181. * This is a POST request.
  182. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/skip_onboarding_tutorial">Further information about this action online (including a response example)</a>
  183. * @since 6.5
  184. */
  185. public void skipOnboardingTutorial() {
  186. call(
  187. new PostRequest(path("skip_onboarding_tutorial"))
  188. .setMediaType(MediaTypes.JSON)
  189. ).content();
  190. }
  191. /**
  192. *
  193. * This is part of the internal API.
  194. * This is a POST request.
  195. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/update">Further information about this action online (including a response example)</a>
  196. * @since 3.7
  197. */
  198. public String update(UpdateRequest request) {
  199. return call(
  200. new PostRequest(path("update"))
  201. .setParam("email", request.getEmail())
  202. .setParam("login", request.getLogin())
  203. .setParam("name", request.getName())
  204. .setParam("scmAccount", request.getScmAccount())
  205. .setParam("scmAccounts", request.getScmAccounts())
  206. .setMediaType(MediaTypes.JSON)
  207. ).content();
  208. }
  209. /**
  210. *
  211. * This is part of the internal API.
  212. * This is a POST request.
  213. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/update_login">Further information about this action online (including a response example)</a>
  214. * @since 7.6
  215. */
  216. public void updateLogin(UpdateLoginRequest request) {
  217. call(
  218. new PostRequest(path("update_login"))
  219. .setParam("login", request.getLogin())
  220. .setParam("newLogin", request.getNewLogin())
  221. .setMediaType(MediaTypes.JSON)
  222. ).content();
  223. }
  224. }