Search in sources :

Example 21 with RestResult

use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.

the class EdgeAPI method create.

public List<String> create(List<Edge> edges, boolean checkVertex) {
    MultivaluedHashMap<String, Object> headers = new MultivaluedHashMap<>();
    headers.putSingle("Content-Encoding", BATCH_ENCODING);
    Map<String, Object> params = ImmutableMap.of("check_vertex", checkVertex);
    RestResult result = this.client.post(this.batchPath(), edges, headers, params);
    List<String> ids = result.readList(String.class);
    if (edges.size() != ids.size()) {
        throw new NotAllCreatedException("Not all edges are successfully created, " + "expect '%s', the actual is '%s'", ids, edges.size(), ids.size());
    }
    return ids;
}
Also used : MultivaluedHashMap(jakarta.ws.rs.core.MultivaluedHashMap) RestResult(com.baidu.hugegraph.rest.RestResult) NotAllCreatedException(com.baidu.hugegraph.exception.NotAllCreatedException)

Example 22 with RestResult

use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.

the class VertexAPI method get.

public Vertex get(Object id) {
    String vertexId = GraphAPI.formatVertexId(id);
    RestResult result = this.client.get(this.path(), vertexId);
    return result.readObject(Vertex.class);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult)

Example 23 with RestResult

use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.

the class EdgeLabelAPI method append.

public EdgeLabel append(EdgeLabel edgeLabel) {
    String id = edgeLabel.name();
    Map<String, Object> params = ImmutableMap.of("action", "append");
    Object el = this.checkCreateOrUpdate(edgeLabel);
    RestResult result = this.client.put(this.path(), id, el, params);
    return result.readObject(EdgeLabel.class);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult)

Example 24 with RestResult

use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.

the class EdgeLabelAPI method delete.

public long delete(String name) {
    RestResult result = this.client.delete(this.path(), name);
    @SuppressWarnings("unchecked") Map<String, Object> task = result.readObject(Map.class);
    return TaskAPI.parseTaskId(task);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult)

Example 25 with RestResult

use of com.baidu.hugegraph.rest.RestResult in project incubator-hugegraph-toolchain by apache.

the class EdgeLabelAPI method list.

public List<EdgeLabel> list(List<String> names) {
    this.client.checkApiVersion("0.48", "getting schema by names");
    E.checkArgument(names != null && !names.isEmpty(), "The edge label names can't be null or empty");
    Map<String, Object> params = ImmutableMap.of("names", names);
    RestResult result = this.client.get(this.path(), params);
    return result.readList(this.type(), EdgeLabel.class);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult)

Aggregations

RestResult (com.baidu.hugegraph.rest.RestResult)132 Test (org.junit.Test)44 LinkedHashMap (java.util.LinkedHashMap)23 AbstractRestClient (com.baidu.hugegraph.rest.AbstractRestClient)19 RestClient (com.baidu.hugegraph.rest.RestClient)19 MultivaluedHashMap (jakarta.ws.rs.core.MultivaluedHashMap)12 Response (com.baidu.hugegraph.structure.gremlin.Response)6 Result (com.baidu.hugegraph.structure.gremlin.Result)6 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)6 Edge (com.baidu.hugegraph.structure.graph.Edge)5 Vertex (com.baidu.hugegraph.structure.graph.Vertex)5 Map (java.util.Map)5 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)4 InvalidResponseException (com.baidu.hugegraph.exception.InvalidResponseException)3 NotSupportException (com.baidu.hugegraph.exception.NotSupportException)3 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)3 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)3 ArrayList (java.util.ArrayList)3 NotAllCreatedException (com.baidu.hugegraph.exception.NotAllCreatedException)2 Project (com.baidu.hugegraph.structure.auth.Project)2