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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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.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)).content();
  55. }
  56. /**
  57. *
  58. * This is part of the internal API.
  59. * This is a POST request.
  60. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/create">Further information about this action online (including a response example)</a>
  61. * @since 3.7
  62. */
  63. public CreateWsResponse create(CreateRequest request) {
  64. return call(
  65. new PostRequest(path("create"))
  66. .setParam("email", request.getEmail())
  67. .setParam("local", request.getLocal())
  68. .setParam("login", request.getLogin())
  69. .setParam("name", request.getName())
  70. .setParam("password", request.getPassword())
  71. .setParam("scmAccount", request.getScmAccount())
  72. .setParam("scmAccounts", request.getScmAccounts() == null ? null : request.getScmAccounts().stream().collect(Collectors.joining(","))),
  73. CreateWsResponse.parser());
  74. }
  75. /**
  76. *
  77. * This is part of the internal API.
  78. * This is a GET request.
  79. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/current">Further information about this action online (including a response example)</a>
  80. * @since 5.2
  81. */
  82. public CurrentWsResponse current() {
  83. return call(
  84. new GetRequest(path("current")),
  85. CurrentWsResponse.parser());
  86. }
  87. /**
  88. *
  89. * This is part of the internal API.
  90. * This is a POST request.
  91. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/deactivate">Further information about this action online (including a response example)</a>
  92. * @since 3.7
  93. */
  94. public String deactivate(DeactivateRequest request) {
  95. return call(
  96. new PostRequest(path("deactivate"))
  97. .setParam("login", request.getLogin())
  98. .setMediaType(MediaTypes.JSON)).content();
  99. }
  100. /**
  101. *
  102. * This is part of the internal API.
  103. * This is a GET request.
  104. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/groups">Further information about this action online (including a response example)</a>
  105. * @since 5.2
  106. */
  107. public GroupsWsResponse groups(GroupsRequest request) {
  108. return call(
  109. new GetRequest(path("groups"))
  110. .setParam("login", request.getLogin())
  111. .setParam("p", request.getP())
  112. .setParam("ps", request.getPs())
  113. .setParam("q", request.getQ())
  114. .setParam("selected", request.getSelected()),
  115. GroupsWsResponse.parser());
  116. }
  117. /**
  118. *
  119. * This is part of the internal API.
  120. * This is a GET request.
  121. * @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>
  122. * @since 5.5
  123. */
  124. public IdentityProvidersWsResponse identityProviders() {
  125. return call(
  126. new GetRequest(path("identity_providers")),
  127. IdentityProvidersWsResponse.parser());
  128. }
  129. /**
  130. *
  131. * This is part of the internal API.
  132. * This is a GET request.
  133. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/search">Further information about this action online (including a response example)</a>
  134. * @since 3.6
  135. */
  136. public SearchWsResponse search(SearchRequest request) {
  137. return call(
  138. new GetRequest(path("search"))
  139. .setParam("p", request.getP())
  140. .setParam("ps", request.getPs())
  141. .setParam("q", request.getQ()),
  142. SearchWsResponse.parser());
  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/users/set_homepage">Further information about this action online (including a response example)</a>
  149. * @since 7.0
  150. */
  151. public void setHomepage(SetHomepageRequest request) {
  152. call(
  153. new PostRequest(path("set_homepage"))
  154. .setParam("parameter", request.getParameter())
  155. .setParam("type", request.getType())
  156. .setMediaType(MediaTypes.JSON)).content();
  157. }
  158. /**
  159. *
  160. * This is part of the internal API.
  161. * This is a POST request.
  162. * @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>
  163. * @since 7.6
  164. */
  165. public void setSetting(SetSettingRequest request) {
  166. call(
  167. new PostRequest(path("set_setting"))
  168. .setParam("key", request.getKey())
  169. .setParam("value", request.getValue())
  170. .setMediaType(MediaTypes.JSON)).content();
  171. }
  172. /**
  173. *
  174. * This is part of the internal API.
  175. * This is a POST request.
  176. * @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>
  177. * @since 6.5
  178. */
  179. public void skipOnboardingTutorial() {
  180. call(
  181. new PostRequest(path("skip_onboarding_tutorial"))
  182. .setMediaType(MediaTypes.JSON)).content();
  183. }
  184. /**
  185. *
  186. * This is part of the internal API.
  187. * This is a POST request.
  188. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/update">Further information about this action online (including a response example)</a>
  189. * @since 3.7
  190. */
  191. public String update(UpdateRequest request) {
  192. return call(
  193. new PostRequest(path("update"))
  194. .setParam("email", request.getEmail())
  195. .setParam("login", request.getLogin())
  196. .setParam("name", request.getName())
  197. .setParam("scmAccount", request.getScmAccount())
  198. .setParam("scmAccounts", request.getScmAccounts())
  199. .setMediaType(MediaTypes.JSON)).content();
  200. }
  201. /**
  202. *
  203. * This is part of the internal API.
  204. * This is a POST request.
  205. * @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>
  206. * @since 7.6
  207. */
  208. public void updateLogin(UpdateLoginRequest request) {
  209. call(
  210. new PostRequest(path("update_login"))
  211. .setParam("login", request.getLogin())
  212. .setParam("newLogin", request.getNewLogin())
  213. .setMediaType(MediaTypes.JSON)).content();
  214. }
  215. /**
  216. *
  217. * This is part of the internal API.
  218. * This is a POST request.
  219. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/update_identity_provider">Further information about this action online (including a response example)</a>
  220. * @since 8.7
  221. */
  222. public void updateIdentityProvider(UpdateIdentityProviderRequest request) {
  223. call(
  224. new PostRequest(path("update_identity_provider"))
  225. .setParam("login", request.getLogin())
  226. .setParam("newExternalIdentity", request.getNewExternalIdentity())
  227. .setParam("newExternalProvider", request.getNewExternalProvider())
  228. .setMediaType(MediaTypes.JSON)
  229. ).content();
  230. }
  231. }