use of org.sonar.api.server.ws.WebService in project sonarqube by SonarSource.
the class GetByProjectAction method define.
@Override
public void define(WebService.NewController context) {
WebService.NewAction action = context.createAction(ACTION_GET_BY_PROJECT).setInternal(false).setSince("6.1").setDescription("Get the quality gate of a project.<br />" + "Requires one of the following permissions:" + "<ul>" + "<li>'Administer System'</li>" + "<li>'Administer' rights on the specified project</li>" + "<li>'Browse' on the specified project</li>" + "</ul>").setResponseExample(getClass().getResource("get_by_project-example.json")).setHandler(this).setChangelog(new Change("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."), new Change("6.6", "The parameter 'projectId' has been removed"), new Change("6.6", "The parameter 'projectKey' has been renamed to 'project'"), new Change("6.6", "This webservice is now part of the public API"));
action.createParam(PARAM_PROJECT).setDescription("Project key").setExampleValue(KEY_PROJECT_EXAMPLE_001).setRequired(true);
}
use of org.sonar.api.server.ws.WebService in project sonarqube by SonarSource.
the class WebServiceEngineTest method fail_when_start_in_not_called.
@Test
public void fail_when_start_in_not_called() {
Request request = new TestRequest().setPath("/api/ping");
DumbResponse response = new DumbResponse();
WebServiceEngine underTest = new WebServiceEngine(new WebService[] { newPingWs(a -> {
}) });
underTest.execute(request, response);
assertThat(logTester.logs(LoggerLevel.ERROR)).contains("Fail to process request /api/ping");
}
use of org.sonar.api.server.ws.WebService in project sonarqube by SonarSource.
the class ResponseExampleAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
checkState(context != null, "Webservice global context must be loaded before calling the action");
String controllerKey = request.mandatoryParam("controller");
WebService.Controller controller = context.controller(controllerKey);
checkArgument(controller != null, "Controller does not exist: %s", controllerKey);
String actionKey = request.mandatoryParam("action");
WebService.Action action = controller.action(actionKey);
checkArgument(action != null, "Action does not exist: %s", actionKey);
if (action.responseExample() == null) {
response.noContent();
return;
}
try (JsonWriter json = response.newJsonWriter()) {
json.beginObject().prop("format", action.responseExampleFormat()).prop("example", action.responseExampleAsString()).endObject();
}
}
Aggregations