- private Service toService(ServiceRegistrationInfo s) {
- return new Service(s.name(), Duration.ofSeconds(s.keepAliveInterval()), s.callbackUrl());
+ @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);
+ }