class Consul {

    public ConsulSession createSession(final String name, final int ttlMs, final int lockDelay) {
        // TODO: move http stuff into the session class.
        final ConsulSession newSession
                = new ConsulSession(this.endpoint, "id", name, ttlMs, lockDelay);
        final String sessionString = newSession.toJson();
        final Entity<String> entity = Entity.entity(sessionString, MediaType.APPLICATION_JSON);
        final Response response = httpClient
                .target(endpoint)
                .path("/v1/session/create")
                .request()
                .accept(MediaType.APPLICATION_JSON)
                .put(entity);
        if (response.getStatus() != Response.Status.OK.getStatusCode()) {
            LOG.log(Level.WARNING, "Expected 200 when creating session "
                    + sessionString + " but got " + response.getStatus() + ". Consul Agent"
                    + " responded with " + response.readEntity(String.class));
            return null;
        }

        final ConsulSession session
                = ConsulSession.fromJsonResponse(newSession, response.readEntity(String.class));
        if (session != null) {
            session.startKeepAlive();
        }
        return session;

    }

    public  Consul(final String endpoint);

}