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.

SettingsService.java 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 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.settings;
  21. import java.util.stream.Collectors;
  22. import javax.annotation.Generated;
  23. import org.sonarqube.ws.MediaTypes;
  24. import org.sonarqube.ws.Settings.CheckSecretKeyWsResponse;
  25. import org.sonarqube.ws.Settings.EncryptWsResponse;
  26. import org.sonarqube.ws.Settings.GenerateSecretKeyWsResponse;
  27. import org.sonarqube.ws.Settings.ListDefinitionsWsResponse;
  28. import org.sonarqube.ws.Settings.ValuesWsResponse;
  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/settings">Further information about this web service online</a>
  35. */
  36. @Generated("sonar-ws-generator")
  37. public class SettingsService extends BaseService {
  38. public SettingsService(WsConnector wsConnector) {
  39. super(wsConnector, "api/settings");
  40. }
  41. /**
  42. * This is part of the internal API.
  43. * This is a GET request.
  44. *
  45. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/check_secret_key">Further information about this action online (including a response example)</a>
  46. * @since 6.1
  47. */
  48. public CheckSecretKeyWsResponse checkSecretKey() {
  49. return call(
  50. new GetRequest(path("check_secret_key")),
  51. CheckSecretKeyWsResponse.parser());
  52. }
  53. /**
  54. * This is part of the internal API.
  55. * This is a GET request.
  56. *
  57. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/encrypt">Further information about this action online (including a response example)</a>
  58. * @since 6.1
  59. */
  60. public EncryptWsResponse encrypt(EncryptRequest request) {
  61. return call(
  62. new PostRequest(path("encrypt"))
  63. .setParam("value", request.getValue()),
  64. EncryptWsResponse.parser());
  65. }
  66. /**
  67. * This is part of the internal API.
  68. * This is a GET request.
  69. *
  70. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/generate_secret_key">Further information about this action online (including a response example)</a>
  71. * @since 6.1
  72. */
  73. public GenerateSecretKeyWsResponse generateSecretKey() {
  74. return call(
  75. new GetRequest(path("generate_secret_key")),
  76. GenerateSecretKeyWsResponse.parser());
  77. }
  78. /**
  79. * This is part of the internal API.
  80. * This is a GET request.
  81. *
  82. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/list_definitions">Further information about this action online (including a response example)</a>
  83. * @since 6.3
  84. */
  85. public ListDefinitionsWsResponse listDefinitions(ListDefinitionsRequest request) {
  86. return call(
  87. new GetRequest(path("list_definitions"))
  88. .setParam("branch", request.getBranch())
  89. .setParam("component", request.getComponent())
  90. .setParam("pullRequest", request.getPullRequest()),
  91. ListDefinitionsWsResponse.parser());
  92. }
  93. /**
  94. * This is part of the internal API.
  95. * This is a POST request.
  96. *
  97. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/reset">Further information about this action online (including a response example)</a>
  98. * @since 6.1
  99. */
  100. public void reset(ResetRequest request) {
  101. call(
  102. new PostRequest(path("reset"))
  103. .setParam("branch", request.getBranch())
  104. .setParam("component", request.getComponent())
  105. .setParam("keys", request.getKeys() == null ? null : request.getKeys().stream().collect(Collectors.joining(",")))
  106. .setParam("pullRequest", request.getPullRequest())
  107. .setMediaType(MediaTypes.JSON)
  108. ).content();
  109. }
  110. /**
  111. * This is part of the internal API.
  112. * This is a POST request.
  113. *
  114. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/set">Further information about this action online (including a response example)</a>
  115. * @since 6.1
  116. */
  117. public void set(SetRequest request) {
  118. call(
  119. new PostRequest(path("set"))
  120. .setParam("branch", request.getBranch())
  121. .setParam("component", request.getComponent())
  122. .setParam("fieldValues", request.getFieldValues() == null ? null : request.getFieldValues())
  123. .setParam("key", request.getKey())
  124. .setParam("pullRequest", request.getPullRequest())
  125. .setParam("value", request.getValue())
  126. .setParam("values", request.getValues() == null ? null : request.getValues())
  127. .setMediaType(MediaTypes.JSON)
  128. ).content();
  129. }
  130. /**
  131. * This is part of the internal API.
  132. * This is a GET request.
  133. *
  134. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/settings/values">Further information about this action online (including a response example)</a>
  135. * @since 6.3
  136. */
  137. public ValuesWsResponse values(ValuesRequest request) {
  138. return call(
  139. new GetRequest(path("values"))
  140. .setParam("branch", request.getBranch())
  141. .setParam("component", request.getComponent())
  142. .setParam("keys", request.getKeys() == null ? null : request.getKeys().stream().collect(Collectors.joining(",")))
  143. .setParam("pullRequest", request.getPullRequest()),
  144. ValuesWsResponse.parser());
  145. }
  146. }