class HostResource implements HostApi {

    @Override
    public PatchHostResponse patch(String hostNameString, PatchHostRequest request) {
        HostName hostName = new HostName(hostNameString);

        if (request.state != null) {
            HostStatus state;
            try {
                state = HostStatus.valueOf(request.state);
            } catch (IllegalArgumentException dummy) {
                throw new BadRequestException("Bad state in request: '" + request.state + "'");
            }

            try {
                orchestrator.setNodeStatus(hostName, state);
            } catch (HostNameNotFoundException e) {
                log.log(Level.FINE, "Host not found: " + hostName);
                throw new NotFoundException(e);
            } catch (UncheckedTimeoutException e) {
                log.log(Level.FINE, "Failed to patch " + hostName + ": " + e.getMessage());
                throw webExceptionFromTimeout("patch", hostName, e);
            } catch (OrchestrationException e) {
                String message = "Failed to set " + hostName + " to " + state + ": " + e.getMessage();
                log.log(Level.FINE, message, e);
                throw new InternalServerErrorException(message);
            }
        }

        PatchHostResponse response = new PatchHostResponse();
        response.description = "ok";
        return response;
    }

    @Inject public  HostResource(@Component Orchestrator orchestrator, @Context UriInfo uriInfo);

}