Search in sources :

Example 6 with NewAction

use of org.sonar.api.server.ws.WebService.NewAction in project sonarqube by SonarSource.

the class SearchAction method define.

@Override
public void define(WebService.NewController controller) {
    NewAction action = controller.createAction(ACTION_SEARCH).setSince("5.2").setDescription("List quality profiles.").setHandler(this).setResponseExample(getClass().getResource("search-example.json"));
    action.createParam(PARAM_LANGUAGE).setDescription(format("Language key. If provided, only profiles for the given language are returned. " + "It should not be used with '%s', '%s or '%s' at the same time.", PARAM_DEFAULTS, PARAM_PROJECT_KEY, PARAM_PROFILE_NAME)).setPossibleValues(LanguageParamUtils.getLanguageKeys(languages)).setDeprecatedSince("6.4");
    action.createParam(PARAM_PROJECT_KEY).setDescription(format("Project or module key. If provided, '%s' and '%s' parameters should not be provided.", PARAM_LANGUAGE, PARAM_DEFAULTS)).setExampleValue("my-project-key");
    action.createParam(PARAM_DEFAULTS).setDescription(format("Return the quality profile marked as default for each language. " + "If provided, then the parameters '%s', '%s' must not be set.", PARAM_LANGUAGE, PARAM_PROJECT_KEY)).setDefaultValue(false).setBooleanPossibleValues();
    action.createParam(PARAM_PROFILE_NAME).setDescription(format("Profile name. It should be always used with the '%s' or '%s' parameter.", PARAM_PROJECT_KEY, PARAM_DEFAULTS)).setExampleValue("SonarQube Way").setDeprecatedSince("6.4");
}
Also used : NewAction(org.sonar.api.server.ws.WebService.NewAction)

Example 7 with NewAction

use of org.sonar.api.server.ws.WebService.NewAction in project sonarqube by SonarSource.

the class SetDefaultAction method define.

@Override
public void define(WebService.NewController controller) {
    NewAction setDefault = controller.createAction("set_default").setSince("5.2").setDescription("Select the default profile for a given language. Require Administer Quality Profiles permission.").setPost(true).setHandler(this);
    setDefault.createParam(PARAM_LANGUAGE).setDescription("The key of a language supported by the platform. If specified, profileName must be set to select the default profile for the selected language.").setExampleValue("js").setPossibleValues(LanguageParamUtils.getLanguageKeys(languages));
    setDefault.createParam(PARAM_PROFILE_NAME).setDescription("The name of a quality profile. If specified, language must be set. The matching profile will be used as default for the selected language.").setExampleValue("Sonar way");
    setDefault.createParam(PARAM_PROFILE_KEY).setDescription("The key of a quality profile. If specified, language and profileName must not be set. The matching profile will be used as default for its language.").setExampleValue("sonar-way-js-12345");
}
Also used : NewAction(org.sonar.api.server.ws.WebService.NewAction)

Example 8 with NewAction

use of org.sonar.api.server.ws.WebService.NewAction in project sonarqube by SonarSource.

the class CopyAction method define.

@Override
public void define(WebService.NewController controller) {
    NewAction setDefault = controller.createAction("copy").setSince("5.2").setDescription("Copy a quality profile. Require Administer Quality Profiles permission.").setPost(true).setHandler(this);
    setDefault.createParam(PARAM_PROFILE_NAME).setDescription("The name for the new quality profile.").setExampleValue("My Sonar way").setRequired(true);
    setDefault.createParam(PARAM_PROFILE_KEY).setDescription("The key of a quality profile.").setExampleValue("sonar-way-js-12345").setRequired(true);
}
Also used : NewAction(org.sonar.api.server.ws.WebService.NewAction)

Example 9 with NewAction

use of org.sonar.api.server.ws.WebService.NewAction in project sonarqube by SonarSource.

the class CreateAction method define.

@Override
public void define(WebService.NewController controller) {
    NewAction create = controller.createAction(ACTION_CREATE).setSince("5.2").setDescription("Create a quality profile.<br/>" + "Require Administer Quality Profiles permission.").setPost(true).setResponseExample(getClass().getResource("example-create.json")).setHandler(this);
    create.createParam(PARAM_PROFILE_NAME).setDescription("The name for the new quality profile. Since 6.1, this parameter has been renamed from '%s' to '%s'", DEPRECATED_PARAM_PROFILE_NAME, PARAM_PROFILE_NAME).setExampleValue("My Sonar way").setDeprecatedKey(DEPRECATED_PARAM_PROFILE_NAME, "6.3").setRequired(true);
    create.createParam(PARAM_LANGUAGE).setDescription("The language for the quality profile.").setExampleValue("js").setPossibleValues(LanguageParamUtils.getLanguageKeys(languages)).setRequired(true);
    for (ProfileImporter importer : importers) {
        create.createParam(getBackupParamName(importer.getKey())).setDescription(String.format("A configuration file for %s.", importer.getName()));
    }
}
Also used : ProfileImporter(org.sonar.api.profiles.ProfileImporter) NewAction(org.sonar.api.server.ws.WebService.NewAction)

Example 10 with NewAction

use of org.sonar.api.server.ws.WebService.NewAction in project sonarqube by SonarSource.

the class ExportAction method define.

@Override
public void define(WebService.NewController controller) {
    NewAction action = controller.createAction("export").setSince("5.2").setDescription("Export a quality profile.").setResponseExample(getClass().getResource("export-example.xml")).setHandler(this);
    action.createParam(PARAM_PROFILE_NAME).setDescription("The name of the quality profile to export. If left empty, will export the default profile for the language.").setExampleValue("My Sonar way");
    action.createParam(PARAM_LANGUAGE).setDescription("The language for the quality profile.").setExampleValue(LanguageParamUtils.getExampleValue(languages)).setPossibleValues(LanguageParamUtils.getLanguageKeys(languages)).setRequired(true);
    Set<String> exporterKeys = Arrays.stream(languages.all()).map(language -> exporters.exportersForLanguage(language.getKey())).flatMap(Collection::stream).map(ProfileExporter::getKey).collect(Collectors.toSet());
    if (!exporterKeys.isEmpty()) {
        action.createParam(PARAM_FORMAT).setDescription("Output format. If left empty, the same format as api/qualityprofiles/backup is used. " + "Possible values are described by api/qualityprofiles/exporters.").setPossibleValues(exporterKeys).setDeprecatedKey("format", "6.3");
    }
}
Also used : Arrays(java.util.Arrays) QProfileExporters(org.sonar.server.qualityprofile.QProfileExporters) DbSession(org.sonar.db.DbSession) Request(org.sonar.api.server.ws.Request) Languages(org.sonar.api.resources.Languages) WebService(org.sonar.api.server.ws.WebService) WsUtils.checkFound(org.sonar.server.ws.WsUtils.checkFound) Response(org.sonar.api.server.ws.Response) OutputStreamWriter(java.io.OutputStreamWriter) ProfileExporter(org.sonar.api.profiles.ProfileExporter) MediaTypes(org.sonarqube.ws.MediaTypes) Nullable(javax.annotation.Nullable) OutputStream(java.io.OutputStream) Collection(java.util.Collection) Stream(org.sonar.api.server.ws.Response.Stream) LanguageParamUtils(org.sonar.server.util.LanguageParamUtils) Set(java.util.Set) Collectors(org.sonar.core.util.stream.Collectors) IOException(java.io.IOException) NewAction(org.sonar.api.server.ws.WebService.NewAction) StandardCharsets(java.nio.charset.StandardCharsets) DbClient(org.sonar.db.DbClient) Writer(java.io.Writer) QProfileBackuper(org.sonar.server.qualityprofile.QProfileBackuper) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto) Collection(java.util.Collection) NewAction(org.sonar.api.server.ws.WebService.NewAction)

Aggregations

NewAction (org.sonar.api.server.ws.WebService.NewAction)37 Test (org.junit.Test)6 NewController (org.sonar.api.server.ws.WebService.NewController)6 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Set (java.util.Set)1 Nullable (javax.annotation.Nullable)1 ProfileExporter (org.sonar.api.profiles.ProfileExporter)1 ProfileImporter (org.sonar.api.profiles.ProfileImporter)1 Languages (org.sonar.api.resources.Languages)1 Request (org.sonar.api.server.ws.Request)1 Response (org.sonar.api.server.ws.Response)1 Stream (org.sonar.api.server.ws.Response.Stream)1 WebService (org.sonar.api.server.ws.WebService)1 Collectors (org.sonar.core.util.stream.Collectors)1