@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_SEARCH_PROJECTS) .setSince("6.2") .setDescription("Search for projects") .addPagingParams(DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE) .setInternal(true) .setResponseExample(getClass().getResource("search_projects-example.json")) .setChangelog( new Change("6.4", format("The '%s' parameter accepts '%s' to filter by language", FILTER_LANGUAGES, PARAM_FILTER)), new Change("6.4", "The 'visibility' field is added"), new Change("6.5", "Added the option 'analysisDate' for the 'sort' parameter"), new Change("6.5", format("Value '%s' is added to parameter '%s'", LEAK_PERIOD_DATE, FIELDS))) .setHandler(this); action.createFieldsParam(POSSIBLE_FIELDS) .setDescription("Comma-separated list of the fields to be returned in response") .setSince("6.4"); action.createParam(PARAM_ORGANIZATION) .setDescription("the organization to search projects in") .setRequired(false) .setInternal(true) .setSince("6.3"); action.createParam(FACETS) .setDescription("Comma-separated list of the facets to be computed. No facet is computed by default.") .setPossibleValues(SUPPORTED_FACETS.stream().sorted().collect(MoreCollectors.toList(SUPPORTED_FACETS.size()))); action .createParam(PARAM_FILTER) .setMinimumLength(2)
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("activity") .setDescription(format("Search for tasks.<br> " + "Requires the system administration permission, " + "or project administration permission if %s is set.", PARAM_COMPONENT_ID)) .setResponseExample(getClass().getResource("activity-example.json")) .setHandler(this) .setChangelog( new Change("5.5", "it's no more possible to specify the page parameter."), new Change("6.1", "field \"logs\" is deprecated and its value is always false"), new Change("7.1", "field \"pullRequest\" added"), new Change("7.6", String.format("The use of module keys in parameters '%s' and '%s' is deprecated", TEXT_QUERY, PARAM_COMPONENT_QUERY))) .setSince("5.2"); action.createParam(PARAM_COMPONENT_ID) .setDescription("Id of the component (project) to filter on") .setExampleValue(Uuids.UUID_EXAMPLE_03); action.createParam(PARAM_COMPONENT_QUERY) .setDescription(format("Limit search to: <ul>" + "<li>component names that contain the supplied string</li>" + .setExampleValue("Apache") .setDeprecatedSince("5.5"); action.createParam(TEXT_QUERY) .setDescription(format("Limit search to: <ul>" + "<li>component names that contain the supplied string</li>" + .setExampleValue("Apache")
@Override public void define(WebService.NewController controller) { NewAction action = controller .createAction("tags") .setDescription("List rule tags") .setSince("4.4") .setHandler(this) .setResponseExample(Resources.getResource(getClass(), "tags-example.json")); action.createSearchQuery("misra", "tags"); action.createPageSize(10, 100); action.createParam(PARAM_ORGANIZATION) .setDescription("Organization key") .setRequired(false) .setInternal(true) .setExampleValue("my-org") .setSince("6.4"); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_SEARCH_PROJECTS) .setSince("6.2") .setDescription("Search for projects") .addPagingParams(DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE) .setInternal(true) .setResponseExample(getClass().getResource("search_projects-example.json")) .setChangelog( new Change("6.4", format("The '%s' parameter accepts '%s' to filter by language", FILTER_LANGUAGES, PARAM_FILTER)), new Change("6.4", "The 'visibility' field is added"), new Change("6.5", "Added the option 'analysisDate' for the 'sort' parameter"), new Change("6.5", format("Value '%s' is added to parameter '%s'", LEAK_PERIOD_DATE, FIELDS))) .setHandler(this); action.createFieldsParam(POSSIBLE_FIELDS) .setDescription("Comma-separated list of the fields to be returned in response") .setSince("6.4"); action.createParam(PARAM_ORGANIZATION) .setDescription("the organization to search projects in") .setRequired(false) .setInternal(true) .setSince("6.3"); action.createParam(FACETS) .setDescription("Comma-separated list of the facets to be computed. No facet is computed by default.") .setPossibleValues(SUPPORTED_FACETS.stream().sorted().collect(MoreCollectors.toList(SUPPORTED_FACETS.size()))); action .createParam(PARAM_FILTER) .setMinimumLength(2)
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_COMPONENT_TREE) .setDescription(format("Navigate through components based on the chosen strategy with specified measures. The %s or the %s parameter must be provided.<br>" + "Requires the following permission: 'Browse' on the specified project.<br>" + "When limiting search with the %s parameter, directories are not returned.", DEPRECATED_PARAM_BASE_COMPONENT_ID, PARAM_COMPONENT, Param.TEXT_QUERY)) .setResponseExample(getClass().getResource("component_tree-example.json")) .setSince("5.4") .setHandler(this) .addPagingParams(100, MAX_SIZE) .setChangelog( new Change("7.2", "field 'bestValue' is added to the response"), new Change("6.3", format("Number of metric keys is limited to %s", MAX_METRIC_KEYS)), action.createSortParams(SORTS, NAME_SORT, true) .setDescription("Comma-separated list of sort fields") .setExampleValue(NAME_SORT + "," + PATH_SORT); action.createParam(Param.TEXT_QUERY) .setDescription(format("Limit search to: <ul>" + "<li>component names that contain the supplied string</li>" + action.createParam(DEPRECATED_PARAM_BASE_COMPONENT_ID) .setDescription("Base component id. The search is based on this component.") .setExampleValue(UUID_EXAMPLE_02) .setDeprecatedSince("6.6"); action.createParam(PARAM_COMPONENT) .setDescription("Component key. The search is based on this component.")
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("activity") .setDescription(format("Search for tasks.<br> " + "Requires the system administration permission, " + "or project administration permission if %s is set.", PARAM_COMPONENT_ID)) .setResponseExample(getClass().getResource("activity-example.json")) .setHandler(this) .setChangelog( new Change("5.5", "it's no more possible to specify the page parameter."), 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.1", "field \"pullRequest\" added")) .setSince("5.2"); action.createParam(PARAM_COMPONENT_ID) .setDescription("Id of the component (project) to filter on") .setExampleValue(Uuids.UUID_EXAMPLE_03); action.createParam(PARAM_COMPONENT_QUERY) .setDescription(format("Limit search to: <ul>" + "<li>component names that contain the supplied string</li>" + .setExampleValue("Apache") .setDeprecatedSince("5.5"); action.createParam(Param.TEXT_QUERY) .setDescription(format("Limit search to: <ul>" + "<li>component names that contain the supplied string</li>" + .setExampleValue("Apache") .setSince("5.5");
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_TREE) .setDescription(format("Navigate through components based on the chosen strategy. The %s or the %s parameter must be provided.<br>" + "Requires the following permission: 'Browse' on the specified project.<br>" + "When limiting search with the %s parameter, directories are not returned.", PARAM_COMPONENT_ID, PARAM_COMPONENT, Param.TEXT_QUERY)) .setSince("5.4") .setResponseExample(getClass().getResource("tree-example.json")) .setChangelog( new Change("6.4", "The field 'id' is deprecated in the response")) .setHandler(this) .addPagingParams(100, MAX_SIZE); action.createParam(PARAM_COMPONENT_ID) .setDescription("Base component id. The search is based on this component.") .setDeprecatedKey("baseComponentId", "6.4") action.createParam(PARAM_COMPONENT) .setDescription("Base component key. The search is based on this component.") .setDeprecatedKey("baseComponentKey", "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("groups") .setSince("5.2") .setInternal(true) .setDescription("Lists the groups with their permissions.<br>" + "This service defaults to global permissions, but can be limited to project permissions by providing project id or project key.<br> " + "This service defaults to all groups, but can be limited to groups with a specific permission by providing the desired permission.<br>" + "Requires one of the following permissions:" + "<ul>" + "<li>'Administer System'</li>" + "<li>'Administer' rights on the specified project</li>" + "</ul>") .addPagingParams(DEFAULT_PAGE_SIZE, RESULTS_MAX_SIZE) .setResponseExample(Resources.getResource(getClass(), "groups-example.json")) .setHandler(this); action.createSearchQuery("sonar", "names") .setDescription("Limit search to group names that contain the supplied string. When this parameter is not set, only groups having at least one permission are returned.") .setMinimumLength(SEARCH_QUERY_MIN_LENGTH); createOrganizationParameter(action).setSince("6.2"); createPermissionParameter(action).setRequired(false); createProjectParameters(action); }
@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); }
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("installed") .setDescription("Get the list of all the plugins installed on the SonarQube instance, sorted by plugin name.") .setSince("5.2") .setChangelog( new Change("6.6", "The 'filename' field is added"), new Change("6.6", "The 'fileHash' field is added"), new Change("6.6", "The 'sonarLintSupported' field is added"), new Change("6.6", "The 'updatedAt' field is added"), new Change("7.0", "The fields 'compressedHash' and 'compressedFilename' are added")) .setHandler(this) .setResponseExample(Resources.getResource(this.getClass(), "example-installed_plugins.json")); action.createFieldsParam(singleton("category")) .setDescription(format("Comma-separated list of the additional fields to be returned in response. No additional field is returned by default. Possible values are:" + "<ul>" + "<li>%s - category as defined in the Update Center. A connection to the Update Center is needed</li>" + "</lu>", FIELD_CATEGORY)) .setSince("5.6"); }
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("search") .setDescription("Get a list of active users. <br/>" + "Administer System permission is required to show the 'groups' field.<br/>" + "When accessed anonymously, only logins and names are returned.") .setSince("3.6") .setChangelog( new Change("6.4", "Paging response fields moved to a Paging object"), new Change("6.4", "Avatar has been added to the response"), new Change("6.4", "Email is only returned when user has Administer System permission")) .setHandler(this) .setResponseExample(getClass().getResource("search-example.json")); action.createFieldsParam(UserJsonWriter.FIELDS) .setDeprecatedSince("5.4"); action.addPagingParams(50, MAX_LIMIT); action.createParam(TEXT_QUERY) .setMinimumLength(2) .setDescription("Filter on login, name and email"); }
@Override public void define(WebService.NewController controller) { NewAction action = controller .createAction("tags") .setDescription("List rule tags") .setSince("4.4") .setHandler(this) .setResponseExample(Resources.getResource(getClass(), "example-tags.json")); action.createSearchQuery("misra", "tags"); action.createPageSize(10, 100); action.createParam(PARAM_ORGANIZATION) .setDescription("Organization key") .setRequired(false) .setInternal(true) .setExampleValue("my-org") .setSince("6.4"); }
@Override public void define(WebService.NewController controller) { NewAction action = controller.createAction("tags") .setHandler(this) .setSince("5.1") .setDescription("List tags matching a given query") .setResponseExample(Resources.getResource(getClass(), "tags-example.json")); action.createSearchQuery("misra", "tags"); action.createPageSize(10, 100); action.createParam(PARAM_ORGANIZATION) .setDescription("Organization key") .setRequired(false) .setInternal(true) .setExampleValue("my-org") .setSince("6.4"); }
/** * Creates the parameter {@link org.sonar.api.server.ws.WebService.Param#FIELDS}, which is * used to restrict the number of fields returned in JSON response. */ public NewAction addFieldsParam(Collection<?> possibleValues) { createFieldsParam(possibleValues); return this; }
/** * Add predefined parameters related to sorting of results. */ public <V> NewAction addSortParams(Collection<V> possibleValues, @Nullable V defaultValue, boolean defaultAscending) { createSortParams(possibleValues, defaultValue, defaultAscending); return this; }
/** * Creates the parameter {@link org.sonar.api.server.ws.WebService.Param#TEXT_QUERY}, which is * used to search for a subset of fields containing the supplied string. * <p> * The fields must be in the <strong>plural</strong> form (ex: "names", "keys"). * </p> */ public NewAction addSearchQuery(String exampleValue, String... pluralFields) { createSearchQuery(exampleValue, pluralFields); return this; }
/** * Add predefined parameters related to pagination of results with a maximum page size. * Note the maximum is a documentation only feature. It does not check anything. */ public NewAction addPagingParams(int defaultPageSize, int maxPageSize) { createPageParam(); createPageSize(defaultPageSize, maxPageSize); return this; }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction("search") .setDescription("Search tags") .setSince("6.4") .setResponseExample(getClass().getResource("search-example.json")) .setHandler(this); action.addSearchQuery("off", "tags"); action.createPageSize(10, 100); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_COMPONENT_TREE) .setDescription(format("Navigate through components based on the chosen strategy with specified measures. The %s or the %s parameter must be provided.<br>" + "Requires the following permission: 'Browse' on the specified project.<br>" + "When limiting search with the %s parameter, directories are not returned.", DEPRECATED_PARAM_BASE_COMPONENT_ID, PARAM_COMPONENT, Param.TEXT_QUERY)) .setResponseExample(getClass().getResource("component_tree-example.json")) .setSince("5.4") .setHandler(this) .addPagingParams(100, MAX_SIZE) .setChangelog( new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)), new Change("7.2", "field 'bestValue' is added to the response"), action.createSortParams(SORTS, NAME_SORT, true) .setDescription("Comma-separated list of sort fields") .setExampleValue(NAME_SORT + "," + PATH_SORT); action.createParam(Param.TEXT_QUERY) .setDescription(format("Limit search to: <ul>" + "<li>component names that contain the supplied string</li>" + action.createParam(DEPRECATED_PARAM_BASE_COMPONENT_ID) .setDescription("Base component id. The search is based on this component.") .setExampleValue(UUID_EXAMPLE_02) .setDeprecatedSince("6.6"); action.createParam(PARAM_COMPONENT) .setDescription("Component key. The search is based on this component.")
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_TREE) .setDescription(format("Navigate through components based on the chosen strategy. The %s or the %s parameter must be provided.<br>" + "Requires the following permission: 'Browse' on the specified project.<br>" + "When limiting search with the %s parameter, directories are not returned.", PARAM_COMPONENT_ID, PARAM_COMPONENT, Param.TEXT_QUERY)) .setSince("5.4") .setResponseExample(getClass().getResource("tree-example.json")) .setChangelog( new Change("7.6", String.format("The use of 'BRC' as value for parameter '%s' is deprecated", PARAM_QUALIFIERS)), new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)), new Change("6.4", "The field 'id' is deprecated in the response")) .setHandler(this) .addPagingParams(100, MAX_SIZE); action.createParam(PARAM_COMPONENT_ID) .setDescription("Base component id. The search is based on this component.") .setDeprecatedKey("baseComponentId", "6.4") action.createParam(PARAM_COMPONENT) .setDescription("Base component key. The search is based on this component.") .setDeprecatedKey("baseComponentKey", "6.4") .setExampleValue(KEY_PROJECT_EXAMPLE_001); action.createParam(PARAM_BRANCH) .setDescription("Branch key") .setExampleValue(KEY_BRANCH_EXAMPLE_001) action.createParam(PARAM_PULL_REQUEST)