Search in sources :

Example 21 with Status

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

the class EdgeLabelAPI method delete.

@DELETE
@Timed
@Path("{name}")
@Status(Status.ACCEPTED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin", "$owner=$graph $action=edge_label_delete" })
public Map<String, Id> delete(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("name") String name) {
    LOG.debug("Graph [{}] remove edge label by name '{}'", graph, name);
    HugeGraph g = graph(manager, graph);
    // Throw 404 if not exists
    g.schema().getEdgeLabel(name);
    return ImmutableMap.of("task_id", g.schema().edgeLabel(name).remove());
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) Path(jakarta.ws.rs.Path) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) DELETE(jakarta.ws.rs.DELETE) RolesAllowed(jakarta.annotation.security.RolesAllowed) Consumes(jakarta.ws.rs.Consumes) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed)

Example 22 with Status

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

the class EdgeLabelAPI method create.

@POST
@Timed
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin", "$owner=$graph $action=edge_label_write" })
public String create(@Context GraphManager manager, @PathParam("graph") String graph, JsonEdgeLabel jsonEdgeLabel) {
    LOG.debug("Graph [{}] create edge label: {}", graph, jsonEdgeLabel);
    checkCreatingBody(jsonEdgeLabel);
    HugeGraph g = graph(manager, graph);
    EdgeLabel.Builder builder = jsonEdgeLabel.convert2Builder(g);
    EdgeLabel edgeLabel = builder.create();
    return manager.serializer(g).writeEdgeLabel(edgeLabel);
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) EdgeLabel(com.baidu.hugegraph.schema.EdgeLabel) 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 23 with Status

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

the class RaftAPI method transferLeader.

@POST
@Timed
@Status(Status.OK)
@Path("transfer_leader")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin" })
public Map<String, String> transferLeader(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("group") @DefaultValue("default") String group, @QueryParam("endpoint") String endpoint) {
    LOG.debug("Graph [{}] prepare to transfer leader to: {}", graph, endpoint);
    HugeGraph g = graph(manager, graph);
    RaftGroupManager raftManager = raftGroupManager(g, group, "transfer_leader");
    String leaderId = raftManager.transferLeaderTo(endpoint);
    return ImmutableMap.of(raftManager.group(), leaderId);
}
Also used : RaftGroupManager(com.baidu.hugegraph.backend.store.raft.RaftGroupManager) HugeGraph(com.baidu.hugegraph.HugeGraph) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) Path(jakarta.ws.rs.Path) 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 24 with Status

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

the class RaftAPI method removePeer.

@POST
@Timed
@Status(Status.OK)
@Path("remove_peer")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin" })
public Map<String, String> removePeer(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("group") @DefaultValue("default") String group, @QueryParam("endpoint") String endpoint) {
    LOG.debug("Graph [{}] prepare to remove peer: {}", graph, endpoint);
    HugeGraph g = graph(manager, graph);
    RaftGroupManager raftManager = raftGroupManager(g, group, "remove_peer");
    String peerId = raftManager.removePeer(endpoint);
    return ImmutableMap.of(raftManager.group(), peerId);
}
Also used : RaftGroupManager(com.baidu.hugegraph.backend.store.raft.RaftGroupManager) HugeGraph(com.baidu.hugegraph.HugeGraph) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) Path(jakarta.ws.rs.Path) 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 25 with Status

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

the class RaftAPI method setLeader.

@POST
@Timed
@Status(Status.OK)
@Path("set_leader")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin" })
public Map<String, String> setLeader(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("group") @DefaultValue("default") String group, @QueryParam("endpoint") String endpoint) {
    LOG.debug("Graph [{}] prepare to set leader to: {}", graph, endpoint);
    HugeGraph g = graph(manager, graph);
    RaftGroupManager raftManager = raftGroupManager(g, group, "set_leader");
    String leaderId = raftManager.setLeader(endpoint);
    return ImmutableMap.of(raftManager.group(), leaderId);
}
Also used : RaftGroupManager(com.baidu.hugegraph.backend.store.raft.RaftGroupManager) HugeGraph(com.baidu.hugegraph.HugeGraph) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) Path(jakarta.ws.rs.Path) 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)

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