public static void defineParams(WebService.NewAction action, Languages languages) { action.createParam(PARAM_KEY) .setDescription("Quality profile key") .setDeprecatedKey("profileKey", "6.5") .setDeprecatedSince("6.6") .setExampleValue(UUID_EXAMPLE_01); action.createParam(PARAM_QUALITY_PROFILE) .setDescription("Quality profile name") .setDeprecatedKey("profileName", "6.6") .setExampleValue("Sonar way"); action.createParam(PARAM_LANGUAGE) .setDescription("Quality profile language") .setPossibleValues(Arrays.stream(languages.all()).map(Language::getKey).collect(MoreCollectors.toSet())); } }
public NewParam createPageSize(int defaultPageSize, int maxPageSize) { return createParam(Param.PAGE_SIZE) .setDeprecatedKey("pageSize", "5.2") .setDefaultValue(String.valueOf(defaultPageSize)) .setMaximumValue(maxPageSize) .setDescription("Page size. Must be greater than 0 and less or equal than " + maxPageSize) .setExampleValue("20"); }
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("component") .setDescription("Get the pending tasks, in-progress tasks and the last executed task of a given component (usually a project).<br>" + "Requires the following permission: 'Browse' on the specified component.<br>" + "Either '%s' or '%s' must be provided.", PARAM_COMPONENT_ID, PARAM_COMPONENT) .setSince("5.2") .setResponseExample(getClass().getResource("component-example.json")) .setChangelog( new Change("6.1", "field \"logs\" is deprecated and its value is always false"), new Change("6.6", "fields \"branch\" and \"branchType\" added"), new Change("7.6", String.format("The use of module keys in parameter \"%s\" is deprecated", PARAM_COMPONENT))) .setHandler(this); action.createParam(PARAM_COMPONENT_ID) .setRequired(false) .setExampleValue(Uuids.UUID_EXAMPLE_01) .setDeprecatedSince("6.6"); action.createParam(PARAM_COMPONENT) .setRequired(false) .setExampleValue(KeyExamples.KEY_PROJECT_EXAMPLE_001) .setDeprecatedKey("componentKey", "6.6"); }
@Override public void define(WebService.NewController controller) { NewAction create = controller.createAction(ACTION_CREATE) .setPost(true) .setDescription("Create a quality profile.<br>" + "Requires to be logged in and the 'Administer Quality Profiles' permission.") .setResponseExample(getClass().getResource("create-example.json")) .setSince("5.2") .setHandler(this); createOrganizationParam(create) .setSince("6.4"); create.createParam(PARAM_NAME) .setRequired(true) .setMaximumLength(NAME_MAXIMUM_LENGTH) .setDescription("Quality profile name") .setExampleValue("My Sonar way") .setDeprecatedKey("profileName", "6.6"); create.createParam(PARAM_LANGUAGE) .setRequired(true) .setDescription("Quality profile language") .setExampleValue("js") .setPossibleValues(getOrderedLanguageKeys(languages)); for (ProfileImporter importer : importers) { create.createParam(getBackupParamName(importer.getKey())) .setDescription(String.format("A configuration file for %s.", importer.getName())); } }
@Override public void define(NewController context) { NewAction action = context.createAction("component") .setDescription("Get information concerning component navigation for the current user. " + "Requires the 'Browse' permission on the component's project.") .setHandler(this) .setInternal(true) .setResponseExample(getClass().getResource("component-example.json")) .setSince("5.2") .setChangelog( new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)), new Change("7.3", "The 'almRepoUrl' and 'almId' fields are added"), new Change("6.4", "The 'visibility' field is added")); action.createParam(PARAM_COMPONENT) .setDescription("A component key.") .setDeprecatedKey("componentKey", "6.4") .setExampleValue(KEY_PROJECT_EXAMPLE_001); action .createParam(PARAM_BRANCH) .setDescription("Branch key") .setExampleValue(KEY_BRANCH_EXAMPLE_001); action .createParam(PARAM_PULL_REQUEST) .setDescription("Pull request id") .setExampleValue(KEY_PULL_REQUEST_EXAMPLE_001); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_EDIT_COMMENT) .setDescription("Edit a comment.<br/>" + "Requires authentication and the following permission: 'Browse' on the project of the specified issue.") .setSince("3.6") .setChangelog( new Change("6.3", "the response returns the issue with all its details"), new Change("6.3", format("the 'key' parameter has been renamed %s", PARAM_COMMENT)), new Change("6.5", "the database ids of the components are removed from the response"), new Change("6.5", "the response field components.uuid is deprecated. Use components.key instead.")) .setHandler(this) .setResponseExample(Resources.getResource(this.getClass(), "edit_comment-example.json")) .setPost(true); action.createParam(PARAM_COMMENT) .setDescription("Comment key") .setDeprecatedKey("key", "6.3") .setSince("6.3") .setRequired(true) .setExampleValue(UUID_EXAMPLE_01); action.createParam(PARAM_TEXT) .setDescription("Comment text") .setRequired(true) .setExampleValue("Won't fix because it doesn't apply to the context"); }
@Override public void define(WebService.NewController controller) { NewAction action = controller.createAction(ACTION_ADD_PROJECT) .setSince("5.2") .setDescription("Associate a project with a quality profile.<br> " + "Requires one of the following permissions:" + "<ul>" + " <li>'Administer Quality Profiles'</li>" + " <li>Edit right on the specified quality profile</li>" + " <li>Administer right on the specified project</li>" + "</ul>") .setPost(true) .setHandler(this); QProfileReference.defineParams(action, languages); QProfileWsSupport.createOrganizationParam(action) .setSince("6.4"); action.createParam(PARAM_PROJECT) .setDescription("Project key") .setDeprecatedKey("projectKey", "6.5") .setExampleValue(KEY_PROJECT_EXAMPLE_001); action.createParam(PARAM_PROJECT_UUID) .setDescription("Project ID. Either this parameter or '%s' must be set.", PARAM_PROJECT) .setDeprecatedSince("6.5") .setExampleValue(UUID_EXAMPLE_08); }
@Override public void define(WebService.NewController controller) { NewAction action = controller.createAction(ACTION_REMOVE_PROJECT) .setSince("5.2") .setDescription("Remove a project's association with a quality profile.<br> " + "Requires one of the following permissions:" + "<ul>" + " <li>'Administer Quality Profiles'</li>" + " <li>Edit right on the specified quality profile</li>" + " <li>Administer right on the specified project</li>" + "</ul>") .setPost(true) .setHandler(this); QProfileReference.defineParams(action, languages); QProfileWsSupport.createOrganizationParam(action).setSince("6.4"); action.createParam(PARAM_PROJECT) .setDescription("Project key") .setDeprecatedKey("projectKey", "6.5") .setExampleValue(KEY_PROJECT_EXAMPLE_001); action.createParam(PARAM_PROJECT_UUID) .setDescription("Project ID. Either this parameter, or '%s' must be set.", PARAM_PROJECT) .setDeprecatedSince("6.5") .setExampleValue(UUID_EXAMPLE_09); }
@Override public void define(WebService.NewController controller) { NewAction action = controller.createAction(ACTION_SET_TAGS) .setPost(true) .setSince("5.1") .setDescription("Set tags on an issue. <br/>" + "Requires authentication and Browse permission on project") .setChangelog( new Change("6.5", "the database ids of the components are removed from the response"), new Change("6.5", "the response field components.uuid is deprecated. Use components.key instead."), new Change("6.4", "response contains issue information instead of list of tags")) .setResponseExample(Resources.getResource(this.getClass(), "set_tags-example.json")) .setHandler(this); action.createParam(PARAM_ISSUE) .setDescription("Issue key") .setSince("6.3") .setDeprecatedKey("key", "6.3") .setExampleValue(Uuids.UUID_EXAMPLE_01) .setRequired(true); action.createParam(PARAM_TAGS) .setDescription("Comma-separated list of tags. All tags are removed if parameter is empty or not set.") .setExampleValue("security,cwe,misra-c"); }
public void define(WebService.NewController controller) { WebService.NewAction activate = controller .createAction(ACTION_ACTIVATE_RULES) .setDescription("Bulk-activate rules on one quality profile.<br> " + "Requires one of the following permissions:" + "<ul>" + " <li>'Administer Quality Profiles'</li>" + " <li>Edit right on the specified quality profile</li>" + "</ul>") .setPost(true) .setSince("4.4") .setHandler(this); defineGenericRuleSearchParameters(activate); activate.createParam(PARAM_TARGET_KEY) .setDescription("Quality Profile key on which the rule activation is done. To retrieve a quality profile key please see <code>api/qualityprofiles/search</code>") .setDeprecatedKey("profile_key", "6.5") .setRequired(true) .setExampleValue(UUID_EXAMPLE_03); activate.createParam(PARAM_TARGET_SEVERITY) .setDescription("Severity to set on the activated rules") .setDeprecatedKey("activation_severity", "6.5") .setPossibleValues(Severity.ALL); }
@Override public void define(NewController controller) { NewAction action = controller.createAction("projects") .setSince("5.2") .setHandler(this) .setDescription("List projects with their association status regarding a quality profile") .setResponseExample(getClass().getResource("projects-example.json")); action.setChangelog( new Change("7.2", "'more' response field is deprecated"), new Change("6.5", "'id' response field is deprecated"), new Change("6.0", "'uuid' response field is deprecated and replaced by 'id'"), new Change("6.0", "'key' response field has been added to return the project key")); action.createParam(PARAM_KEY) .setDescription("Quality profile key") .setRequired(true) .setExampleValue(UUID_EXAMPLE_01); action.addSelectionModeParam(); action.createSearchQuery("sonar", "projects") .setDeprecatedKey("query", "6.5"); action.createPageParam() .setDeprecatedKey("page", "6.5"); action.createPageSize(100, MAX_PAGE_SIZE); }
public void define(WebService.NewController controller) { WebService.NewAction deactivate = controller .createAction(ACTION_DEACTIVATE_RULE) .setDescription("Deactivate a rule on a quality profile.<br> " + "Requires one of the following permissions:" + "<ul>" + " <li>'Administer Quality Profiles'</li>" + " <li>Edit right on the specified quality profile</li>" + "</ul>") .setHandler(this) .setPost(true) .setSince("4.4"); deactivate.createParam(PARAM_KEY) .setDescription("Quality Profile key. Can be obtained through <code>api/qualityprofiles/search</code>") .setDeprecatedKey("profile_key", "6.5") .setRequired(true) .setExampleValue(UUID_EXAMPLE_01); deactivate.createParam(PARAM_RULE) .setDescription("Rule key") .setDeprecatedKey("rule_key", "6.5") .setRequired(true) .setExampleValue("squid:AvoidCycles"); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_DELETE_COMMENT) .setDescription("Delete a comment.<br/>" + "Requires authentication and the following permission: 'Browse' on the project of the specified issue.") .setSince("3.6") .setChangelog( new Change("6.5", "the response field components.uuid is deprecated. Use components.key instead."), new Change("6.5", "the database ids of the components are removed from the response"), new Change("6.3", "the response returns the issue with all its details"), new Change("6.3", "the 'key' parameter is renamed 'comment'")) .setHandler(this) .setResponseExample(Resources.getResource(this.getClass(), "delete_comment-example.json")) .setPost(true); action.createParam(PARAM_COMMENT) .setDescription("Comment key") .setDeprecatedKey("key", "6.3") .setSince("6.3") .setRequired(true) .setExampleValue(UUID_EXAMPLE_01); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context .createAction(ACTION) .setPost(true) .setDescription("Delete a project.<br> " + "Requires 'Administer System' permission or 'Administer' permission on the project.") .setSince("5.2") .setHandler(this); action .createParam(PARAM_PROJECT_ID) .setDescription("Project ID") .setDeprecatedKey("id", "6.4") .setDeprecatedSince("6.4") .setExampleValue("ce4c03d6-430f-40a9-b777-ad877c00aa4d"); action .createParam(PARAM_PROJECT) .setDescription("Project key") .setDeprecatedKey("key", "6.4") .setExampleValue(KEY_PROJECT_EXAMPLE_001); }
public void define(WebService.NewController controller) { WebService.NewAction deactivate = controller .createAction(ACTION_DEACTIVATE_RULES) .setDescription("Bulk deactivate rules on Quality profiles.<br>" + "Requires one of the following permissions:" + "<ul>" + " <li>'Administer Quality Profiles'</li>" + " <li>Edit right on the specified quality profile</li>" + "</ul>") .setPost(true) .setSince("4.4") .setHandler(this); defineGenericRuleSearchParameters(deactivate); deactivate.createParam(PARAM_TARGET_KEY) .setDescription("Quality Profile key on which the rule deactivation is done. To retrieve a profile key please see <code>api/qualityprofiles/search</code>") .setDeprecatedKey("profile_key", "6.5") .setRequired(true) .setExampleValue(UUID_EXAMPLE_04); }
@Override public void define(WebService.NewController controller) { NewAction show = controller.createAction(ACTION_SHOW) .setDescription("Show a quality profile") .setSince("6.5") .setResponseExample(getClass().getResource("show-example.json")) .setInternal(true) .setHandler(this); show.createParam(PARAM_KEY) .setDescription("Quality profile key") .setExampleValue(UUID_EXAMPLE_01) .setDeprecatedKey("profile", "6.6") .setRequired(true); show.createParam(PARAM_COMPARE_TO_SONAR_WAY) .setDescription("Add the number of missing rules from the related Sonar way profile in the response") .setInternal(true) .setDefaultValue("false") .setBooleanPossibleValues(); }
/** * Add predefined parameters related to pagination of results. */ public NewAction addPagingParams(int defaultPageSize) { createParam(Param.PAGE) .setDescription(PAGE_PARAM_DESCRIPTION) .setExampleValue("42") .setDeprecatedKey("pageIndex", "5.2") .setDefaultValue("1"); createParam(Param.PAGE_SIZE) .setDescription("Page size. Must be greater than 0.") .setExampleValue("20") .setDeprecatedKey("pageSize", "5.2") .setDefaultValue(String.valueOf(defaultPageSize)); return this; }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION) .setPost(true) .setDescription("Delete an organization.<br/>" + "Require 'Administer System' permission on the specified organization. Organization support must be enabled.") .setInternal(true) .setSince("6.2") .setHandler(this); action.createParam(PARAM_ORGANIZATION) .setRequired(true) .setDescription("Organization key") .setDeprecatedKey(PARAM_KEY, "6.4") .setExampleValue(KEY_ORG_EXAMPLE_002); }
/** * Add predefined parameters related to sorting of results. */ public <V> NewParam createSortParams(Collection<V> possibleValues, @Nullable V defaultValue, boolean defaultAscending) { createParam(Param.ASCENDING) .setDescription("Ascending sort") .setBooleanPossibleValues() .setDefaultValue(defaultAscending); return createParam(Param.SORT) .setDescription("Sort field") .setDeprecatedKey("sort", "5.4") .setDefaultValue(defaultValue) .setPossibleValues(possibleValues); }
public NewParam createPageParam() { return createParam(Param.PAGE) .setDescription(PAGE_PARAM_DESCRIPTION) .setExampleValue("42") .setDeprecatedKey("pageIndex", "5.2") .setDefaultValue("1"); }