@POST
@Path("/{policy}/destroy")
@ApiOperation(value = "Destroy a policy", notes="Removes a policy from being associated with the entity and destroys it (stopping first if running)")
@ApiErrors(value = {
@ApiError(code = 404, reason = "Could not find application, entity or policy")
})
public Response destroy(
@ApiParam(name = "application", value = "Application ID or name", required = true)
@PathParam("application") String application,
@ApiParam(name = "entity", value = "Entity ID or name", required = true)
@PathParam("entity") String entityToken,
@ApiParam(name = "policy", value = "Policy ID or name", required = true)
@PathParam("policy") String policyToken
) {
EntityLocal entity = brooklyn().getEntity(application, entityToken);
Policy policy = brooklyn().getPolicy(entity, policyToken);
policy.suspend();
entity.removePolicy(policy);
return Response.status(Response.Status.OK).build();
}
}