- private Service toService(ServiceRegistrationInfo s) {
- return new Service(s.name(), Duration.ofSeconds(s.keepAliveInterval()));
- }
-
- @GetMapping("/services")
- public ResponseEntity<?> getServices() {
- Collection<Service> allServices = this.services.getAll();
- Collection<ServiceStatus> result = new Vector<>(allServices.size());
- for (Service s : allServices) {
- result.add(toServiceStatus(s));
+ @ApiOperation(value = "Delete a service")
+ @ApiResponses(
+ value = { //
+ @ApiResponse(code = 204, message = "OK"),
+ @ApiResponse(code = 404, message = "Service not found", response = String.class)})
+ @DeleteMapping("/services")
+ public ResponseEntity<String> deleteService(//
+ @RequestParam(name = "name", required = true) String serviceName) {
+ try {
+ Service service = removeService(serviceName);
+ // Remove the policies from the repo and let the consistency monitoring
+ // do the rest.
+ removePolicies(service);
+ return new ResponseEntity<>("OK", HttpStatus.NO_CONTENT);
+ } catch (Exception e) {
+ return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);