/** * 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 NewParam createSearchQuery(String exampleValue, String... pluralFields) { String actionDescription = format("Limit search to %s that contain the supplied string.", String.join(" or ", pluralFields)); return createParam(Param.TEXT_QUERY) .setDescription(actionDescription) .setExampleValue(exampleValue); }
WebService.NewParam addPullRequestParam(WebService.NewAction action) { return action.createParam(PARAM_PULL_REQUEST) .setDescription("Pull request. Only available on following settings : %s", SettingsWs.SETTING_ON_BRANCHES.stream().collect(COMMA_JOINER)) .setExampleValue(KEY_PULL_REQUEST_EXAMPLE_001) .setInternal(true) .setSince("7.1"); } }
WebService.NewParam addBranchParam(WebService.NewAction action) { return action.createParam(PARAM_BRANCH) .setDescription("Branch key. Only available on following settings : %s", SettingsWs.SETTING_ON_BRANCHES.stream().collect(COMMA_JOINER)) .setExampleValue(KEY_BRANCH_EXAMPLE_001) .setInternal(true) .setSince("6.6"); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION) .setPost(true) .setDescription("Update a custom measure. Value and/or description must be provided<br />" + "Requires 'Administer System' permission or 'Administer' permission on the project.") .setHandler(this) .setSince("5.2") .setDeprecatedSince("7.4"); action.createParam(PARAM_ID) .setRequired(true) .setDescription("id") .setExampleValue("42"); action.createParam(PARAM_VALUE) .setExampleValue("true") .setDescription(measureValueDescription()); action.createParam(PARAM_DESCRIPTION) .setExampleValue("Team size growing."); }
@Override public void define(WebService.NewController controller) { NewAction action = controller.createAction(ACTION_COPY) .setSince("5.2") .setDescription("Copy a quality profile.<br> " + "Requires to be logged in and the 'Administer Quality Profiles' permission.") .setResponseExample(getClass().getResource("copy-example.json")) .setPost(true) .setHandler(this); action.createParam(PARAM_TO_NAME) .setDescription("Name for the new quality profile.") .setExampleValue("My Sonar way") .setRequired(true); action.createParam(PARAM_FROM_KEY) .setDescription("Quality profile key") .setExampleValue(UUID_EXAMPLE_01) .setRequired(true); }
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("copy") .setDescription("Copy a Quality Gate.<br>" + "Requires the 'Administer Quality Gates' permission.") .setPost(true) .setSince("4.3") .setHandler(this); action.createParam(PARAM_ID) .setDescription("The ID of the source quality gate") .setRequired(true) .setExampleValue("1"); action.createParam(PARAM_NAME) .setDescription("The name of the quality gate to create") .setRequired(true) .setExampleValue("My Quality Gate"); wsSupport.createOrganizationParam(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"); wsParameters.createProjectPermissionParameter(action, false); createTemplateParameters(action); }
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("analysis_status") .setDescription("Get the analysis status of a given component: a project, branch or pull request.<br>" + "Requires the following permission: 'Browse' on the specified component.") .setSince("7.4") .setResponseExample(getClass().getResource("analysis_status-example.json")) .setInternal(true) .setHandler(this); action.createParam(PARAM_COMPONENT) .setRequired(true) .setExampleValue(KeyExamples.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 controller) { WebService.NewAction action = controller.createAction("show") .setDescription("Display the details of a quality gate") .setSince("4.3") .setResponseExample(Resources.getResource(this.getClass(), "show-example.json")) .setChangelog( new Change("7.6", "'period' and 'warning' fields of conditions are removed from the response"), new Change("7.0", "'isBuiltIn' field is added to the response"), new Change("7.0", "'actions' field is added in the response")) .setHandler(this); action.createParam(PARAM_ID) .setDescription("ID of the quality gate. Either id or name must be set") .setExampleValue("1"); action.createParam(PARAM_NAME) .setDescription("Name of the quality gate. Either id or name must be set") .setExampleValue("My Quality Gate"); wsSupport.createOrganizationParam(action); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction("index") .setDescription("This web service is deprecated, please use api/settings/values instead.") .setDeprecatedSince("6.3") .setResponseExample(getClass().getResource("index-example.json")) .setSince("2.6") .setHandler(this); action.createParam(PARAM_ID) .setDescription("Setting key") .setExampleValue("sonar.test.inclusions"); action.createParam(PARAM_COMPONENT) .setDescription("Component key or database id") .setExampleValue(KEY_PROJECT_EXAMPLE_001); action.createParam(PARAM_FORMAT) .setDescription("Only json response format is available") .setPossibleValues("json"); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION) .setDescription("List custom measures. The project id or project key must be provided.<br />" + "Requires 'Administer System' permission or 'Administer' permission on the project.") .setSince("5.2") .setDeprecatedSince("7.4") .addFieldsParam(CustomMeasureJsonWriter.OPTIONAL_FIELDS) .addPagingParams(100, MAX_LIMIT) .setResponseExample(getClass().getResource("example-search.json")) .setHandler(this); action.createParam(PARAM_PROJECT_ID) .setDescription("Project id") .setExampleValue("ce4c03d6-430f-40a9-b777-ad877c00aa4d"); action.createParam(PARAM_PROJECT_KEY) .setDescription("Project key") .setExampleValue(KEY_PROJECT_EXAMPLE_001); }
/** * Add predefined parameters related to pagination of results with a maximum page size. * @since 7.1 */ public NewAction addPagingParamsSince(int defaultPageSize, int maxPageSize, String version) { createParam(Param.PAGE) .setDescription(PAGE_PARAM_DESCRIPTION) .setExampleValue("42") .setDefaultValue("1") .setSince(version); createParam(Param.PAGE_SIZE) .setDescription("Page size. Must be greater than 0 and less than " + maxPageSize) .setDefaultValue(String.valueOf(defaultPageSize)) .setMaximumValue(maxPageSize) .setExampleValue("20") .setSince(version); return this; }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION) .setSince("5.2") .setDeprecatedSince("7.4") .setInternal(true) .setHandler(this) .setResponseExample(Resources.getResource(getClass(), "example-metrics.json")) .setDescription("List all custom metrics for which no custom measure already exists on a given project.<br /> " + "The project id or project key must be provided.<br />" + "Requires 'Administer System' permission or 'Administer' permission on the project."); action.createParam(PARAM_PROJECT_ID) .setDescription("Project id") .setExampleValue("ce4c03d6-430f-40a9-b777-ad877c00aa4d"); action.createParam(PARAM_PROJECT_KEY) .setDescription("Project key") .setExampleValue(KEY_PROJECT_EXAMPLE_001); }
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction(LIST_ACTION) .setDescription("Search for global webhooks or project webhooks. Webhooks are ordered by name.<br>" + "Requires 'Administer' permission on the specified project, or global 'Administer' permission.") .setSince("7.1") .setResponseExample(Resources.getResource(this.getClass(), "example-webhooks-search.json")) .setHandler(this); action.createParam(ORGANIZATION_KEY_PARAM) .setDescription("Organization key. If no organization is provided, the default organization is used.") .setInternal(true) .setRequired(false) .setExampleValue(KEY_ORG_EXAMPLE_001); action.createParam(PROJECT_KEY_PARAM) .setDescription("Project key") .setRequired(false) .setExampleValue(KEY_PROJECT_EXAMPLE_001); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION) .setSince("5.2") .setDescription("Search for metrics") .setResponseExample(getClass().getResource("example-search.json")) .addPagingParams(100, MAX_LIMIT) .addFieldsParam(MetricJsonWriter.OPTIONAL_FIELDS) .setHandler(this); action.createParam(PARAM_IS_CUSTOM) .setExampleValue("true") .setDescription("Choose custom metrics following 3 cases:" + "<ul>" + "<li>true: only custom metrics are returned</li>" + "<li>false: only non custom metrics are returned</li>" + "<li>not specified: all metrics are returned</li>" + "</ul>"); }
@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("create_template") .setDescription("Create a permission template.<br />" + "Requires the following permission: 'Administer System'.") .setResponseExample(getClass().getResource("create_template-example.json")) .setSince("5.2") .setPost(true) .setHandler(this); action.createParam(PARAM_NAME) .setRequired(true) .setDescription("Name") .setExampleValue("Financial Service Permissions"); WsParameters.createTemplateProjectKeyPatternParameter(action); WsParameters.createTemplateDescriptionParameter(action); WsParameters.createOrganizationParameter(action).setSince("6.2"); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction("search") .setInternal(true) .setDescription("Search for project measures ordered by project names.<br>" + "At most %d projects can be provided.<br>" + "Returns the projects with the 'Browse' permission.", MAX_NB_PROJECTS) .setSince("6.2") .setResponseExample(getClass().getResource("search-example.json")) .setHandler(this); createMetricKeysParameter(action); action.createParam(PARAM_PROJECT_KEYS) .setDescription("Comma-separated list of project, view or sub-view keys") .setExampleValue(String.join(",", KEY_PROJECT_EXAMPLE_001, KEY_PROJECT_EXAMPLE_002)) .setRequired(true); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction("set") .setDescription("Set tags on a project.<br>" + "Requires the following permission: 'Administer' rights on the specified project") .setSince("6.4") .setPost(true) .setHandler(this); action.createParam(PARAM_PROJECT) .setDescription("Project key") .setRequired(true) .setExampleValue(KEY_PROJECT_EXAMPLE_001); action.createParam(PARAM_TAGS) .setDescription("Comma-separated list of tags") .setRequired(true) .setExampleValue("finance, offshore"); }
@Override public void define(WebService.NewController context) { WebService.NewAction action = context.createAction("delete") .setDescription("Delete a project analysis.<br>" + "Requires one of the following permissions:" + "<ul>" + " <li>'Administer System'</li>" + " <li>'Administer' rights on the project of the specified analysis</li>" + "</ul>") .setSince("6.3") .setPost(true) .setHandler(this); action.createParam(PARAM_ANALYSIS) .setDescription("Analysis key") .setExampleValue(Uuids.UUID_EXAMPLE_04) .setRequired(true); }