Search in sources :

Example 16 with Status

use of com.baidu.hugegraph.api.filter.StatusFilter.Status in project incubator-hugegraph by apache.

the class TaskAPI method update.

@PUT
@Timed
@Path("{id}")
@Status(Status.ACCEPTED)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public Map<String, Object> update(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("id") long id, @QueryParam("action") String action) {
    LOG.debug("Graph [{}] cancel task: {}", graph, id);
    if (!ACTION_CANCEL.equals(action)) {
        throw new NotSupportedException(String.format("Not support action '%s'", action));
    }
    TaskScheduler scheduler = graph(manager, graph).taskScheduler();
    HugeTask<?> task = scheduler.task(IdGenerator.of(id));
    if (!task.completed() && !task.cancelling()) {
        scheduler.cancel(task);
        if (task.cancelling() || task.cancelled()) {
            return task.asMap();
        }
    }
    assert task.completed() || task.cancelling();
    throw new BadRequestException(String.format("Can't cancel task '%s' which is completed or cancelling", id));
}
Also used : BadRequestException(jakarta.ws.rs.BadRequestException) NotSupportedException(jakarta.ws.rs.NotSupportedException) TaskScheduler(com.baidu.hugegraph.task.TaskScheduler) Path(jakarta.ws.rs.Path) TaskStatus(com.baidu.hugegraph.task.TaskStatus) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) PUT(jakarta.ws.rs.PUT)

Example 17 with Status

use of com.baidu.hugegraph.api.filter.StatusFilter.Status in project incubator-hugegraph by apache.

the class BelongAPI method create.

@POST
@Timed
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String create(@Context GraphManager manager, @PathParam("graph") String graph, JsonBelong jsonBelong) {
    LOG.debug("Graph [{}] create belong: {}", graph, jsonBelong);
    checkCreatingBody(jsonBelong);
    HugeGraph g = graph(manager, graph);
    HugeBelong belong = jsonBelong.build();
    belong.id(manager.authManager().createBelong(belong));
    return manager.serializer(g).writeAuthElement(belong);
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) HugeBelong(com.baidu.hugegraph.auth.HugeBelong) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) POST(jakarta.ws.rs.POST) Consumes(jakarta.ws.rs.Consumes) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed)

Example 18 with Status

use of com.baidu.hugegraph.api.filter.StatusFilter.Status in project incubator-hugegraph by apache.

the class AccessAPI method create.

@POST
@Timed
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String create(@Context GraphManager manager, @PathParam("graph") String graph, JsonAccess jsonAccess) {
    LOG.debug("Graph [{}] create access: {}", graph, jsonAccess);
    checkCreatingBody(jsonAccess);
    HugeGraph g = graph(manager, graph);
    HugeAccess access = jsonAccess.build();
    access.id(manager.authManager().createAccess(access));
    return manager.serializer(g).writeAuthElement(access);
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) HugeAccess(com.baidu.hugegraph.auth.HugeAccess) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) POST(jakarta.ws.rs.POST) Consumes(jakarta.ws.rs.Consumes) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed)

Example 19 with Status

use of com.baidu.hugegraph.api.filter.StatusFilter.Status in project incubator-hugegraph by apache.

the class VertexAPI method create.

@POST
@Timed(name = "single-create")
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin", "$owner=$graph $action=vertex_write" })
public String create(@Context GraphManager manager, @PathParam("graph") String graph, JsonVertex jsonVertex) {
    LOG.debug("Graph [{}] create vertex: {}", graph, jsonVertex);
    checkCreatingBody(jsonVertex);
    HugeGraph g = graph(manager, graph);
    Vertex vertex = commit(g, () -> g.addVertex(jsonVertex.properties()));
    return manager.serializer(g).writeVertex(vertex);
}
Also used : HugeVertex(com.baidu.hugegraph.structure.HugeVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) HugeGraph(com.baidu.hugegraph.HugeGraph) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) RolesAllowed(jakarta.annotation.security.RolesAllowed) POST(jakarta.ws.rs.POST) Consumes(jakarta.ws.rs.Consumes) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed)

Example 20 with Status

use of com.baidu.hugegraph.api.filter.StatusFilter.Status in project incubator-hugegraph by apache.

the class GroupAPI method create.

@POST
@Timed
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String create(@Context GraphManager manager, @PathParam("graph") String graph, JsonGroup jsonGroup) {
    LOG.debug("Graph [{}] create group: {}", graph, jsonGroup);
    checkCreatingBody(jsonGroup);
    HugeGraph g = graph(manager, graph);
    HugeGroup group = jsonGroup.build();
    group.id(manager.authManager().createGroup(group));
    return manager.serializer(g).writeAuthElement(group);
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) HugeGroup(com.baidu.hugegraph.auth.HugeGroup) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) POST(jakarta.ws.rs.POST) Consumes(jakarta.ws.rs.Consumes) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Status (com.baidu.hugegraph.api.filter.StatusFilter.Status)30 Timed (com.codahale.metrics.annotation.Timed)30 Produces (jakarta.ws.rs.Produces)30 HugeGraph (com.baidu.hugegraph.HugeGraph)29 Consumes (jakarta.ws.rs.Consumes)26 RolesAllowed (jakarta.annotation.security.RolesAllowed)21 POST (jakarta.ws.rs.POST)20 Path (jakarta.ws.rs.Path)18 PUT (jakarta.ws.rs.PUT)5 RaftGroupManager (com.baidu.hugegraph.backend.store.raft.RaftGroupManager)4 DELETE (jakarta.ws.rs.DELETE)4 Id (com.baidu.hugegraph.backend.id.Id)3 SchemaElement (com.baidu.hugegraph.schema.SchemaElement)3 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)3 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)3 Decompress (com.baidu.hugegraph.api.filter.DecompressInterceptor.Decompress)2 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)2 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)2 BadRequestException (jakarta.ws.rs.BadRequestException)2 ArrayList (java.util.ArrayList)2