- 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 = 200, message = "OK")})
+ @DeleteMapping("/services")
+ public ResponseEntity<String> deleteService( //
+ @RequestParam(name = "name", required = true) String name) {
+ try {
+ Service service = removeService(name);
+ // Remove the policies from the repo and let the consistency monitoring
+ // do the rest.
+ removePolicies(service);
+ return new ResponseEntity<String>("OK", HttpStatus.NO_CONTENT);
+ } catch (Exception e) {
+ return new ResponseEntity<String>(e.getMessage(), HttpStatus.NO_CONTENT);