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

io.split.qos.server.resources.BehaviourResource Maven / Gradle / Ivy

There is a newer version: 22.4.3
Show newest version
package io.split.qos.server.resources;

import com.google.common.base.Preconditions;
import com.google.inject.Singleton;
import io.split.qos.server.QOSServerBehaviour;

import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("/behaviour")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Singleton
public class BehaviourResource {

    private final QOSServerBehaviour behaviour;

    @Inject
    public BehaviourResource(QOSServerBehaviour behaviour) {
        this.behaviour = Preconditions.checkNotNull(behaviour);
    }

    @POST
    @Path("pause/{who}")
    public Response pause(@PathParam("who") String who) {
        Preconditions.checkNotNull(who);
        behaviour.pause(who);
        return Response.ok().build();
    }

    @POST
    @Path("runall")
    public Response runAll() {
        behaviour.runAllNow();
        return Response.ok().build();
    }

    @POST
    @Path("resume/{who}")
    public Response resume(@PathParam("who") String who) {
        Preconditions.checkNotNull(who);
        behaviour.resume(who);
        return Response.ok().build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy