예제 #1
0
  @Override
  public void define(WebService.NewController controller) {
    NewAction create =
        controller
            .createAction("create")
            .setSince("5.2")
            .setDescription(
                "Create a quality profile. 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.")
        .setExampleValue("My Sonar way")
        .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()));
    }
  }
예제 #2
0
  @Override
  public void define(WebService.NewController controller) {
    WebService.NewAction action =
        controller
            .createAction("index")
            .setDescription(
                "Get source code as line number / text pairs. Require See Source Code permission on file")
            .setSince("5.0")
            .setResponseExample(Resources.getResource(getClass(), "example-index.json"))
            .setInternal(true)
            .setHandler(this);

    action
        .createParam("resource")
        .setRequired(true)
        .setDescription("File key")
        .setExampleValue("my_project:/src/foo/Bar.php");

    action.createParam("from").setDefaultValue(1).setDescription("First line");

    action
        .createParam("to")
        .setDescription(
            "Last line (excluded). If not specified, all lines are returned until end of file");
  }
예제 #3
0
  @Override
  public void define(WebService.NewController context) {
    WebService.NewAction action =
        context
            .createAction(ACTION)
            .setPost(true)
            .setDescription(
                "Update a custom metric.<br /> Requires 'Administer System' permission.")
            .setSince("5.2")
            .setHandler(this);

    action
        .createParam(PARAM_ID)
        .setRequired(true)
        .setDescription("Id of the custom metric to update")
        .setExampleValue("42");

    action.createParam(PARAM_NAME).setDescription("Name").setExampleValue("Team Size");

    action.createParam(PARAM_KEY).setDescription("Key").setExampleValue("team_size");

    action
        .createParam(PARAM_TYPE)
        .setDescription("Type")
        .setPossibleValues(Metric.ValueType.names());

    action
        .createParam(PARAM_DESCRIPTION)
        .setDescription("Description")
        .setExampleValue("Size of the team");

    action.createParam(PARAM_DOMAIN).setDescription("Domain").setExampleValue("Tests");
  }
예제 #4
0
  @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).")
            .setResponseExample(getClass().getResource("example-create.json"))
            .setInternal(true)
            .setSince("6.2")
            .setHandler(this);

    action
        .createParam(PARAM_KEY)
        .setRequired(false)
        .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 />"
                + "Otherwise, it must be between 2 and 32 chars long. All chars must be lower-case letters (a to z), digits or dash (but dash can neither be trailing nor heading)")
        .setExampleValue("foo-company");

    wsSupport.addOrganizationDetailsParams(action, true);
  }
예제 #5
0
  @Test
  public void action_pending_is_defined() {
    WsTester wsTester = new WsTester();
    WebService.NewController newController =
        wsTester.context().createController(DUMMY_CONTROLLER_KEY);

    underTest.define(newController);
    newController.done();

    WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY);
    assertThat(controller.actions()).extracting("key").containsExactly("pending");

    WebService.Action action = controller.actions().iterator().next();
    assertThat(action.isPost()).isFalse();
    assertThat(action.description()).isNotEmpty();
    assertThat(action.responseExample()).isNotNull();
  }
예제 #6
0
  @Test
  public void action_update_is_defined() {
    WsTester wsTester = new WsTester();
    WebService.NewController newController =
        wsTester.context().createController(DUMMY_CONTROLLER_KEY);

    underTest.define(newController);
    newController.done();

    WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY);
    assertThat(controller.actions()).extracting("key").containsExactly(ACTION_KEY);

    WebService.Action action = controller.actions().iterator().next();
    assertThat(action.isPost()).isTrue();
    assertThat(action.description()).isNotEmpty();
    assertThat(action.responseExample()).isNull();

    assertThat(action.params()).hasSize(1);
    WebService.Param key = action.param(KEY_PARAM);
    assertThat(key).isNotNull();
    assertThat(key.isRequired()).isTrue();
    assertThat(key.description()).isNotNull();
  }
  @Override
  public void define(WebService.NewController context) {
    WebService.NewAction action =
        context
            .createAction("remove_project_creator_from_template")
            .setDescription(
                "Remove a project creator from a permission template.<br>"
                    + "Requires the 'Administer' permission.")
            .setSince("6.0")
            .setPost(true)
            .setHandler(this);

    createTemplateParameters(action);
    createProjectPermissionParameter(action);
  }
예제 #8
0
  @Override
  public void define(WebService.NewController context) {
    WebService.NewAction action =
        context
            .createAction("upload")
            .setDescription("Upload a plugin.<br /> Requires 'Administer System' permission.")
            .setSince("6.0")
            .setPost(true)
            .setInternal(true)
            .setHandler(this);

    action
        .createParam(PARAM_FILE)
        .setDescription("The jar file of the plugin to install")
        .setRequired(true);
  }
예제 #9
0
 @Override
 public void define(WebService.NewController newController) {
   WebService.NewAction action =
       newController
           .createAction("show")
           .setDescription("Detail of a dashboard (name, description, layout and widgets)")
           .setInternal(true)
           .setSince("5.0")
           .setResponseExample(getClass().getResource("show-example.json"))
           .setHandler(this);
   action
       .createParam(PARAM_KEY)
       .setDescription("Dashboard key")
       .setExampleValue("12345")
       .setRequired(true);
 }
예제 #10
0
  @Override
  public void define(WebService.NewController controller) {
    WebService.NewAction action =
        controller
            .createAction("users")
            .setDescription("Return user details.")
            .setSince("5.2")
            .setResponseExample(getClass().getResource("users-example.proto"))
            .setInternal(true)
            .setHandler(this);

    action
        .createParam(PARAM_LOGINS)
        .setRequired(true)
        .setDescription("A comma separated list of user logins")
        .setExampleValue("ada.lovelace,grace.hopper");
  }
예제 #11
0
  @Override
  public void define(WebService.NewController controller) {
    WebService.NewAction action =
        controller
            .createAction("issues")
            .setDescription("Return open issues")
            .setResponseExample(getClass().getResource("issues-example.proto"))
            .setSince("5.1")
            .setInternal(true)
            .setHandler(this);

    action
        .createParam(PARAM_KEY)
        .setRequired(true)
        .setDescription("Project, module or file key")
        .setExampleValue(KEY_PROJECT_EXAMPLE_001);
  }
  @Override
  public void define(WebService.NewController context) {
    WebService.NewAction action =
        context
            .createAction("search_project_permissions")
            .setDescription(
                "List project permissions. A project can be a technical project, a view or a developer.<br />"
                    + "Requires 'Administer System' permission or 'Administer' rights on the specified project.")
            .setResponseExample(getClass().getResource("search_project_permissions-example.json"))
            .setSince("5.2")
            .addPagingParams(25)
            .addSearchQuery("sonarq", "project names", "project keys")
            .setHandler(this);

    createProjectUuidParameter(action);
    createProjectKeyParameter(action);
  }
예제 #13
0
 @Override
 public void define(WebService.NewController controller) {
   controller
       .createAction("updates")
       .setDescription(
           "Lists plugins installed on the SonarQube instance for which at least one newer version is available, sorted by plugin name."
               + "<br/>"
               + "Each newer version is listed, ordered from the oldest to the newest, with its own update/compatibility status."
               + "<br/>"
               + "Plugin information is retrieved from Update Center. Date and time at which Update Center was last refreshed is provided in the response."
               + "<br/>"
               + "Update status values are: [COMPATIBLE, INCOMPATIBLE, REQUIRES_UPGRADE, DEPS_REQUIRE_UPGRADE].<br/>"
               + "Require 'Administer System' permission.")
       .setSince("5.2")
       .setHandler(this)
       .setResponseExample(Resources.getResource(this.getClass(), "example-updates_plugins.json"));
 }
예제 #14
0
  @Override
  public void define(WebService.NewController context) {
    WebService.NewAction action =
        context
            .createAction(ACTION)
            .setPost(true)
            .setDescription(
                "Delete an organization.<br/>" + "Require 'Administer System' permission.")
            .setInternal(true)
            .setSince("6.2")
            .setHandler(this);

    action
        .createParam(PARAM_KEY)
        .setRequired(true)
        .setDescription("Organization key")
        .setExampleValue("foo-company");
  }
예제 #15
0
  @Override
  public void define(WebService.NewController controller) {
    WebService.NewAction action =
        controller
            .createAction(ACTION)
            .setDescription(
                "Give Compute Engine task details such as type, status, duration and associated component.<br />"
                    + "Requires 'Administer System' or 'Execute Analysis' permission.")
            .setResponseExample(getClass().getResource("task-example.json"))
            .setSince("5.2")
            .setHandler(this);

    action
        .createParam(PARAM_TASK_UUID)
        .setRequired(true)
        .setDescription("Id of task")
        .setExampleValue(Uuids.UUID_EXAMPLE_01);
  }
  @Override
  public void define(WebService.NewController context) {
    WebService.NewAction action =
        context
            .createAction(ACTION)
            .setDescription(
                "Remove a permission from a group.<br /> "
                    + "This service defaults to global permissions, but can be limited to project permissions by providing project id or project key.<br /> "
                    + "The group id or group name must be provided, not both.<br />"
                    + "It requires administration permissions to access.")
            .setSince("5.2")
            .setPost(true)
            .setHandler(this);

    createPermissionParameter(action);
    createGroupNameParameter(action);
    createGroupIdParameter(action);
    createProjectParameter(action);
  }
예제 #17
0
  void define(WebService.NewController controller) {
    WebService.NewAction action =
        controller
            .createAction("app")
            .setDescription("Coverage data required for rendering the component viewer")
            .setResponseExample(getClass().getResource("app-example.json"))
            .setSince("4.4")
            .setInternal(true)
            .setHandler(this);

    action
        .createParam(PARAM_UUID)
        .setRequired(true)
        .setDescription("Component ID")
        .setExampleValue(UUID_EXAMPLE_01);

    action
        .createParam(PARAM_PERIOD)
        .setDescription("Period index in order to get differential measures")
        .setPossibleValues(1, 2, 3, 4, 5);
  }
예제 #18
0
  @Override
  public void define(WebService.NewController context) {
    WebService.NewAction action =
        context
            .createAction("create_template")
            .setDescription(
                "Create a permission template.<br />"
                    + "It requires administration permissions to access.")
            .setResponseExample(getClass().getResource("create_template-example.json"))
            .setSince("5.2")
            .setPost(true)
            .setHandler(this);

    action
        .createParam(PARAM_TEMPLATE_NAME)
        .setRequired(true)
        .setDescription("Name")
        .setExampleValue("Financial Service Permissions");

    createTemplateProjectKeyPatternParameter(action);
    createTemplateDescriptionParameter(action);
  }
예제 #19
0
  @Override
  public void define(WebService.NewController controller) {
    WebService.NewAction action =
        controller
            .createAction(ACTION)
            .setDescription(
                "Do workflow transition on an issue. Requires authentication and Browse permission on project")
            .setSince("3.6")
            .setHandler(this)
            .setPost(true);

    action
        .createParam("issue")
        .setDescription("Key of the issue")
        .setRequired(true)
        .setExampleValue("5bccd6e8-f525-43a2-8d76-fcb13dde79ef");
    action
        .createParam("transition")
        .setDescription("Transition")
        .setRequired(true)
        .setPossibleValues(DefaultTransitions.ALL);
  }
예제 #20
0
  @Override
  public void define(WebService.NewController context) {
    WebService.NewAction action =
        context
            .createAction(ACTION)
            .setPost(true)
            .setDescription(
                "Delete one or several projects.<br /> Requires 'Administer System' permission.")
            .setSince("5.2")
            .setHandler(this);

    action
        .createParam(PARAM_IDS)
        .setDescription("List of project ids to delete")
        .setExampleValue(
            "ce4c03d6-430f-40a9-b777-ad877c00aa4d,c526ef20-131b-4486-9357-063fa64b5079");

    action
        .createParam(PARAM_KEYS)
        .setDescription("List of project keys to delete")
        .setExampleValue("org.apache.hbas:hbase,com.microsoft.roslyn:roslyn");
  }
예제 #21
0
  void define(WebService.NewController controller) {
    WebService.NewAction action =
        controller
            .createAction("copy")
            .setDescription(
                "Copy a Quality Gate. Require Administer Quality Profiles and Gates permission")
            .setPost(true)
            .setSince("4.3")
            .setHandler(this);

    action
        .createParam(QGatesWs.PARAM_ID)
        .setDescription("The ID of the source quality gate")
        .setRequired(true)
        .setExampleValue("1");

    action
        .createParam(QGatesWs.PARAM_NAME)
        .setDescription("The name of the quality gate to create")
        .setRequired(true)
        .setExampleValue("My Quality Gate");
  }
예제 #22
0
  @Override
  public void define(WebService.NewController context) {
    WebService.NewAction action =
        context
            .createAction(ACTION)
            .setDescription(
                "Remove permission from a user.<br /> Requires 'Administer System' permission.")
            .setSince("5.2")
            .setPost(true)
            .setHandler(this);

    action
        .createParam(PARAM_PERMISSION)
        .setDescription("Permission")
        .setRequired(true)
        .setPossibleValues(GlobalPermissions.ALL);

    action
        .createParam(PARAM_USER_LOGIN)
        .setRequired(true)
        .setDescription("User login")
        .setExampleValue("g.hopper");
  }
  @Override
  public void define(WebService.NewController context) {
    WebService.NewAction action =
        context
            .createAction("bulk_apply_template")
            .setDescription(
                "Apply a permission template to several projects.<br />"
                    + "The template id or name must be provided.<br />"
                    + "It requires administration permissions to access.")
            .setPost(true)
            .setSince("5.5")
            .setHandler(this);

    action
        .createParam(Param.TEXT_QUERY)
        .setDescription(
            "Limit search to: <ul>"
                + "<li>project names that contain the supplied string</li>"
                + "<li>project keys that are exactly the same as the supplied string</li>"
                + "</ul>")
        .setExampleValue("apac");
    createRootQualifierParameter(action, newQualifierParameterContext(i18n, resourceTypes));
    createTemplateParameters(action);
  }
  void define(WebService.NewController controller) {
    WebService.NewAction action =
        controller
            .createAction("search_view_components")
            .setDescription(
                "Search for components. Currently limited to projects in a view or a sub-view")
            .setSince("5.1")
            .setInternal(true)
            .setHandler(this);

    action
        .createParam(PARAM_COMPONENT_UUID)
        .setRequired(true)
        .setDescription("View or sub view UUID")
        .setExampleValue(Uuids.UUID_EXAMPLE_01);

    action
        .createParam(Param.TEXT_QUERY)
        .setRequired(true)
        .setDescription("UTF-8 search query")
        .setExampleValue("sonar");

    action.addPagingParams(10);
  }
예제 #25
0
  @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.<br/>"
                        + "Since 5.5, it's no more possible to specify the page parameter",
                    PARAM_COMPONENT_ID))
            .setResponseExample(getClass().getResource("activity-example.json"))
            .setHandler(this)
            .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>"
                    + "<li>component keys that are exactly the same as the supplied string</li>"
                    + "</ul>"
                    + "Must not be set together with %s.<br />"
                    + "Deprecated and replaced by '%s'",
                PARAM_COMPONENT_ID, Param.TEXT_QUERY))
        .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>"
                    + "<li>component keys that are exactly the same as the supplied string</li>"
                    + "<li>task ids that are exactly the same as the supplied string</li>"
                    + "</ul>"
                    + "Must not be set together with %s",
                PARAM_COMPONENT_ID))
        .setExampleValue("Apache")
        .setSince("5.5");
    action
        .createParam(PARAM_STATUS)
        .setDescription("Comma separated list of task statuses")
        .setPossibleValues(
            ImmutableList.builder()
                .add(CeActivityDto.Status.values())
                .add(CeQueueDto.Status.values())
                .build())
        .setExampleValue(
            Joiner.on(",").join(CeQueueDto.Status.IN_PROGRESS, CeActivityDto.Status.SUCCESS))
        // activity statuses by default to be backward compatible
        // queued tasks have been added in 5.5
        .setDefaultValue(Joiner.on(",").join(CeActivityDto.Status.values()));
    action
        .createParam(PARAM_ONLY_CURRENTS)
        .setDescription("Filter on the last tasks (only the most recent finished task by project)")
        .setBooleanPossibleValues()
        .setDefaultValue("false");
    action
        .createParam(PARAM_TYPE)
        .setDescription("Task type")
        .setExampleValue(CeTaskTypes.REPORT)
        .setPossibleValues(taskTypes);
    action
        .createParam(PARAM_MIN_SUBMITTED_AT)
        .setDescription("Minimum date of task submission (inclusive)")
        .setExampleValue(DateUtils.formatDateTime(new Date()));
    action
        .createParam(PARAM_MAX_EXECUTED_AT)
        .setDescription("Maximum date of end of task processing (inclusive)")
        .setExampleValue(DateUtils.formatDateTime(new Date()));
    action
        .createParam(Param.PAGE)
        .setDescription("Deprecated parameter")
        .setDeprecatedSince("5.5")
        .setDeprecatedKey("pageIndex");
    action.addPageSize(100, MAX_PAGE_SIZE);
  }