action .createParam(PARAM_FILTER) .setMinimumLength(2) .setDescription("Filter of projects on name, key, measure value, quality gate, language, tag or whether a project is a favorite or not.<br>" + "The filter must be encoded to form a valid URL (for example '=' must be replaced by '%3D').<br>" +
.setMinimumLength(2) .setDescription("Search query: can contain several search tokens separated by spaces.") .setExampleValue("sonar");
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction("template_groups") .setSince("5.2") .setInternal(true) .setDescription("Lists the groups with their permission as individual groups rather than through user affiliation on the chosen template.<br />" + "This service defaults to all groups, but can be limited to groups with a specific permission by providing the desired permission.<br>" + "Requires the following permission: 'Administer System'.") .addPagingParams(DEFAULT_PAGE_SIZE, RESULTS_MAX_SIZE) .setResponseExample(getClass().getResource("template_groups-example.json")) .setHandler(this); action.createParam(TEXT_QUERY) .setMinimumLength(SEARCH_QUERY_MIN_LENGTH) .setDescription("Limit search to group names that contain the supplied string. <br/>" + "When this parameter is not set, only group having at least one permission are returned.") .setExampleValue("eri"); wsParameters.createProjectPermissionParameter(action, false); createTemplateParameters(action); }
@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 context) { WebService.NewAction action = context .createAction("template_users") .setSince("5.2") .setDescription("Lists the users with their permission as individual users rather than through group affiliation on the chosen template. <br />" + "This service defaults to all users, but can be limited to users with a specific permission by providing the desired permission.<br>" + "Requires the following permission: 'Administer System'.") .addPagingParams(DEFAULT_PAGE_SIZE, RESULTS_MAX_SIZE) .setInternal(true) .setResponseExample(getClass().getResource("template_users-example.json")) .setHandler(this); action.createParam(Param.TEXT_QUERY) .setMinimumLength(SEARCH_QUERY_MIN_LENGTH) .setDescription("Limit search to user names that contain the supplied string. <br/>" + "When this parameter is not set, only users having at least one permission are returned.") .setExampleValue("eri"); createProjectPermissionParameter(action).setRequired(false); createTemplateParameters(action); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction("template_groups") .setSince("5.2") .setInternal(true) .setDescription("Lists the groups with their permission as individual groups rather than through user affiliation on the chosen template.<br />" + "This service defaults to all groups, but can be limited to groups with a specific permission by providing the desired permission.<br>" + "Requires the following permission: 'Administer System'.") .addPagingParams(DEFAULT_PAGE_SIZE, RESULTS_MAX_SIZE) .setResponseExample(getClass().getResource("template_groups-example.json")) .setHandler(this); action.createParam(TEXT_QUERY) .setMinimumLength(SEARCH_QUERY_MIN_LENGTH) .setDescription("Limit search to group names that contain the supplied string. <br/>" + "When this parameter is not set, only group having at least one permission are returned.") .setExampleValue("eri"); createProjectPermissionParameter(action, false); createTemplateParameters(action); }
public static void defineGenericRuleSearchParameters(WebService.NewAction action) { action .createParam(TEXT_QUERY) .setMinimumLength(2) .setDescription("UTF-8 search query") .setExampleValue("xpath");
"<li>component keys that are exactly the same as the supplied string</li>" + "</ul>")) .setMinimumLength(QUERY_MINIMUM_LENGTH) .setExampleValue("FILE_NAM");
.createParam("constrained_string_param") .setMaximumLength(64) .setMinimumLength(3);
"<li>component keys that are exactly the same as the supplied string</li>" + "</ul>") .setMinimumLength(QUERY_MINIMUM_LENGTH) .setExampleValue("FILE_NAM");
.setMinimumLength(LOGIN_MIN_LENGTH) .setMaximumLength(LOGIN_MAX_LENGTH) .setDescription("User login")
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION) .setPost(true) .setDescription("Create an organization.<br />" + "Requires 'Administer System' permission unless any logged in user is allowed to create an organization (see appropriate setting). Organization support must be enabled.") .setResponseExample(getClass().getResource("create-example.json")) .setInternal(true) .setSince("6.2") .setChangelog( new Change("7.4", "Maximal number of character of name and key is 300 characters"), new Change("7.2", "Minimal number of character of name and key is one character")) .setHandler(this); action.createParam(PARAM_KEY) .setRequired(false) .setMinimumLength(KEY_MIN_LENGTH) .setMaximumLength(KEY_MAX_LENGTH) .setDescription("Key of the organization. <br />" + "The key is unique to the whole SonarQube. <br/>" + "When not specified, the key is computed from the name. <br />" + "All chars must be lower-case letters (a to z), digits or dash (but dash can neither be trailing nor heading)") .setExampleValue("foo-company"); action.createParam(PARAM_INSTALLATION_ID) .setRequired(false) .setInternal(true) .setDescription("Installation ID of the GitHub/Bitbucket application") .setExampleValue("387133"); wsSupport.addOrganizationDetailsParams(action, true); }
@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) .setChangelog( new Change("7.4", "The response list is returning all groups even those without permissions, the groups with permission are at the top of the list.")) .setResponseExample(Resources.getResource(getClass(), "groups-example.json")) .setHandler(this); action.createSearchQuery("sonar", "names") .setDescription("Limit search to group names that contain the supplied string.") .setMinimumLength(SEARCH_QUERY_MIN_LENGTH); createOrganizationParameter(action).setSince("6.2"); wsParameters.createPermissionParameter(action).setRequired(false); createProjectParameters(action); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction("users") .setSince("5.2") .setDescription("Lists the users with their permissions as individual users rather than through group affiliation.<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 users, but can be limited to users 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) .setChangelog( new Change("7.4", "The response list is returning all users even those without permissions, the users with permission are at the top of the list.")) .setInternal(true) .setResponseExample(getClass().getResource("users-example.json")) .setHandler(this); action.createParam(Param.TEXT_QUERY) .setMinimumLength(SEARCH_QUERY_MIN_LENGTH) .setDescription("Limit search to user names that contain the supplied string. <br/>") .setExampleValue("eri"); createOrganizationParameter(action).setSince("6.2"); wsParameters.createPermissionParameter(action).setRequired(false); createProjectParameters(action); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction("search_members") .setDescription("Search members of an organization.<br/>" + "Require organization membership.") .setResponseExample(getClass().getResource("search_members-example.json")) .setSince("6.4") .setInternal(true) .setChangelog(new Change("7.3", "This action now requires organization membership")) .setHandler(this); action.createSearchQuery("orwe", "names", "logins") .setMinimumLength(2); action.addPagingParams(50, MAX_LIMIT); action.createParam(Param.SELECTED) .setDescription("Depending on the value, show only selected items (selected=selected) or deselected items (selected=deselected).") .setInternal(true) .setDefaultValue(SELECTED.value()) .setPossibleValues(SELECTED.value(), SelectionMode.DESELECTED.value()); action.createParam(PARAM_ORGANIZATION) .setDescription("Organization key") .setInternal(true) .setRequired(false); }
void addOrganizationDetailsParams(WebService.NewAction action, boolean isNameRequired) { action.createParam(PARAM_NAME) .setRequired(isNameRequired) .setMinimumLength(NAME_MIN_LENGTH) .setMaximumLength(NAME_MAX_LENGTH) .setDescription("Name of the organization") .setExampleValue("Foo Company"); action.createParam(PARAM_DESCRIPTION) .setRequired(false) .setMaximumLength(DESCRIPTION_MAX_LENGTH) .setDescription("Description of the organization.<br/> It must be less than 256 chars long.") .setExampleValue("The Foo company produces quality software for Bar."); action.createParam(PARAM_URL) .setRequired(false) .setMaximumLength(URL_MAX_LENGTH) .setDescription("URL of the organization.<br/> It must be less than 256 chars long.") .setExampleValue("https://www.foo.com"); action.createParam(PARAM_AVATAR_URL) .setRequired(false) .setMaximumLength(URL_MAX_LENGTH) .setDescription("URL of the organization avatar.<br/> It must be less than 256 chars long.") .setExampleValue("https://www.foo.com/foo.png"); }
@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/>" + "Field 'tokensCount' is only accessible to System Administrator and logged in user.<br/>" + "When accessed anonymously, only logins and names are returned.") .setSince("3.6") .setChangelog( new Change("7.4", "External identity is only returned to system administrators"), 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) { WebService.NewAction action = controller.createAction("update_login") .setDescription("Update a user login. A login can be updated many times,<br/>" + "Updating the login of a user will invalidate his browser session, he will be required to login again.<br/>" + "Requires Administer System permission") .setSince("7.6") .setPost(true) .setHandler(this); action.createParam(PARAM_LOGIN) .setRequired(true) .setDescription("The current login (case-sensitive)") .setExampleValue("mylogin"); action.createParam(PARAM_NEW_LOGIN) .setRequired(true) .setMaximumLength(LOGIN_MAX_LENGTH) .setMinimumLength(LOGIN_MIN_LENGTH) .setDescription("The new login. It must not already exist.") .setExampleValue("mynewlogin"); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context .createAction("template_users") .setSince("5.2") .setDescription("Lists the users with their permission as individual users rather than through group affiliation on the chosen template. <br />" + "This service defaults to all users, but can be limited to users with a specific permission by providing the desired permission.<br>" + "Requires the following permission: 'Administer System'.") .addPagingParams(DEFAULT_PAGE_SIZE, RESULTS_MAX_SIZE) .setInternal(true) .setResponseExample(getClass().getResource("template_users-example.json")) .setHandler(this); action.createParam(Param.TEXT_QUERY) .setMinimumLength(SEARCH_QUERY_MIN_LENGTH) .setDescription("Limit search to user names that contain the supplied string. <br/>" + "When this parameter is not set, only users having at least one permission are returned.") .setExampleValue("eri"); wsParameters.createProjectPermissionParameter(action).setRequired(false); createTemplateParameters(action); }
@Test public void param_with_minimum_length() { ((WebService) context -> { NewController newController = context.createController("api/custom_measures"); NewAction create = newDefaultAction(newController, "create"); create.createParam("string_value") .setMinimumLength(3); newController.done(); }).define(context); WebService.Action action = context.controller("api/custom_measures").action("create"); assertThat(action.param("string_value").minimumLength()).isEqualTo(3); }