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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations