defineIndexAction(controller);
defineBackupAction(controller);
defineRestoreAction(controller);
- defineDestroyAction(controller);
controller.done();
}
.setDescription("Path to the file containing the backup (HTML format)");
RailsHandler.addJsonOnlyFormatParam(action);
}
-
- private static void defineDestroyAction(NewController controller) {
- WebService.NewAction action = controller.createAction("destroy")
- .setDescription("Delete a quality profile. Requires Administer Quality Profiles permission")
- .setSince("3.3")
- .setPost(true)
- .setHandler(RailsHandler.INSTANCE);
-
- action.createParam("language")
- .setDescription("Profile language")
- .setRequired(true)
- .setExampleValue("java");
- action.createParam("name")
- .setDescription("Profile name")
- .setRequired(true)
- .setExampleValue("Sonar way");
- }
}
assertThat(controller).isNotNull();
assertThat(controller.path()).isEqualTo("api/profiles");
assertThat(controller.description()).isNotEmpty();
- assertThat(controller.actions()).hasSize(4);
+ assertThat(controller.actions()).hasSize(3);
}
@Test
assertThat(restoreProfiles.handler()).isInstanceOf(RailsHandler.class);
assertThat(restoreProfiles.params()).hasSize(2);
}
-
- @Test
- public void define_destroy_action() {
- WebService.Controller controller = tester.controller("api/profiles");
-
- WebService.Action restoreProfiles = controller.action("destroy");
- assertThat(restoreProfiles).isNotNull();
- assertThat(restoreProfiles.handler()).isInstanceOf(RailsHandler.class);
- assertThat(restoreProfiles.params()).hasSize(2);
- }
}
class Api::ProfilesController < Api::ApiController
- # POST /api/profiles/destroy?language=<language>&name=<name>
- def destroy
- verify_post_request
- access_denied unless has_role?(:profileadmin)
- require_parameters :language, :name
-
- call_backend do
- profile = Internal.quality_profiles.profile(params[:name], params[:language])
- not_found('Profile not found') unless profile
- Internal.component(Java::OrgSonarServerQualityprofile::QProfileService.java_class).delete(profile.key)
- end
- render_success('Profile destroyed')
- end
-
# GET /api/profiles?language=<language>[&name=<name>]
def index
require_parameters :language