All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.instaclustr.cassandra.sidecar.resource.StatusResource Maven / Gradle / Ivy

There is a newer version: 2.0.0-alpha8
Show newest version
package com.instaclustr.cassandra.sidecar.resource;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

import com.instaclustr.cassandra.sidecar.service.CassandraStatusService;
import com.instaclustr.cassandra.sidecar.service.CassandraStatusService.Status;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;

@Path("/status")
@Produces(APPLICATION_JSON)
public class StatusResource {

    private final CassandraStatusService statusService;

    @Inject
    public StatusResource(final CassandraStatusService statusService) {
        this.statusService = statusService;
    }

    @GET
    public Response getStatus() {

        final Status status = statusService.getStatus();

        if (status.getException() != null) {
            return Response.serverError().entity(status).build();
        }

        return Response.ok(status).build();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy