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.

webService.vm 3.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2022 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 $helper.packageName($webService.path.asString);
  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. #foreach($action in $webService.actions)
  29. #if ($helper.responseTypeImport($webService.path.asString, $action.key.asString))
  30. $helper.responseTypeImport($webService.path.asString, $action.key.asString)
  31. #end
  32. #end
  33. /**
  34. * @see <a href="$helper.apiDocUrl($webService.path.asString)">Further information about this web service online</a>
  35. */
  36. @Generated("sonar-ws-generator")
  37. public class $helper.className($webService.path.asString) extends BaseService {
  38. public $helper.className($webService.path.asString)(WsConnector wsConnector) {
  39. super(wsConnector, "$webService.path.asString");
  40. }
  41. #foreach($action in $webService.actions)
  42. /**
  43. *
  44. #if ($action.internal)
  45. * This is part of the internal API.
  46. #end
  47. #if ($action.post.asBoolean)
  48. * This is a POST request.
  49. #else
  50. * This is a GET request.
  51. #end
  52. #if ($action.hasResponseExample)
  53. * @see <a href="$helper.apiDocUrl($webService.path.asString, $action.key.asString)">Further information about this action online (including a response example)</a>
  54. #else
  55. * @see <a href="$helper.apiDocUrl($webService.path.asString, $action.key.asString)">Further information about this action online</a>
  56. #end
  57. #if ($action.since.asString)
  58. * @since $action.since.asString
  59. #end
  60. #if ($action.deprecatedSince)
  61. * @deprecated since $action.deprecatedSince.asString
  62. #end
  63. */
  64. #if ($action.deprecatedSince)
  65. @Deprecated
  66. #end
  67. public#if ($action.hasResponseExample.asBoolean) $helper.responseType($webService.path.asString, $action.key.asString)#else void#end $helper.methodName($webService.path.asString, $action.key.asString)(#if ($action.params && $action.params.size() > 0)$helper.requestType($webService.path.asString, $action.key.asString) request#end) {
  68. #if ($action.hasResponseExample.asBoolean) return#end call(
  69. #if ($action.post.asBoolean)
  70. new PostRequest(path("$action.key.asString"))#else
  71. new GetRequest(path("$action.key.asString"))#end
  72. #foreach($param in $action.params)
  73. #if ($helper.setterParameterType($param.key.asString, $param.description) == "List<String>")
  74. .setParam("$param.key.asString", request.${helper.parameterGetter($param.key.asString)}() == null ? null : request.${helper.parameterGetter($param.key.asString)}().stream().collect(Collectors.joining(",")))#else
  75. .setParam("$param.key.asString", request.${helper.parameterGetter($param.key.asString)}())#end
  76. #end
  77. #if ($helper.responseType($webService.path.asString, $action.key.asString) == "String")
  78. .setMediaType(MediaTypes.JSON)
  79. ).content();
  80. #else,
  81. ${helper.responseType($webService.path.asString, $action.key.asString)}.parser());
  82. #end
  83. }
  84. #end
  85. }