Search in sources :

Example 16 with RestResult

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

the class WeightedShortestPathAPI method get.

public WeightedPath get(Object sourceId, Object targetId, Direction direction, String label, String weight, long degree, long skipDegree, long capacity, boolean withVertex) {
    this.client.checkApiVersion("0.51", "weighted shortest path");
    String source = GraphAPI.formatVertexId(sourceId, false);
    String target = GraphAPI.formatVertexId(targetId, false);
    E.checkNotNull(weight, "weight");
    checkDegree(degree);
    checkCapacity(capacity);
    checkSkipDegree(skipDegree, degree, capacity);
    Map<String, Object> params = new LinkedHashMap<>();
    params.put("source", source);
    params.put("target", target);
    params.put("direction", direction);
    params.put("label", label);
    params.put("weight", weight);
    params.put("max_degree", degree);
    params.put("skip_degree", skipDegree);
    params.put("capacity", capacity);
    params.put("with_vertex", withVertex);
    RestResult result = this.client.get(this.path(), params);
    return result.readObject(WeightedPath.class);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) LinkedHashMap(java.util.LinkedHashMap)

Example 17 with RestResult

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

the class GraphsAPI method create.

@SuppressWarnings("unchecked")
public Map<String, String> create(String name, String cloneGraphName, String configText) {
    this.client.checkApiVersion("0.67", "dynamic graph add");
    MultivaluedHashMap<String, Object> headers = new MultivaluedHashMap<>();
    headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
    Map<String, Object> params = null;
    if (StringUtils.isNotEmpty(cloneGraphName)) {
        params = ImmutableMap.of("clone_graph_name", cloneGraphName);
    }
    RestResult result = this.client.post(joinPath(this.path(), name), configText, headers, params);
    return result.readObject(Map.class);
}
Also used : MultivaluedHashMap(jakarta.ws.rs.core.MultivaluedHashMap) RestResult(com.baidu.hugegraph.rest.RestResult)

Example 18 with RestResult

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

the class EdgeAPI method eliminate.

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

Example 19 with RestResult

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

the class EdgeAPI method update.

public List<Edge> update(BatchEdgeRequest request) {
    this.client.checkApiVersion("0.45", "batch property update");
    MultivaluedHashMap<String, Object> headers = new MultivaluedHashMap<>();
    headers.putSingle("Content-Encoding", BATCH_ENCODING);
    RestResult result = this.client.put(this.batchPath(), null, request, headers);
    return result.readList(this.type(), Edge.class);
}
Also used : MultivaluedHashMap(jakarta.ws.rs.core.MultivaluedHashMap) RestResult(com.baidu.hugegraph.rest.RestResult)

Example 20 with RestResult

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

the class EdgeAPI method list.

public Edges list(Object vertexId, Direction direction, String label, Map<String, Object> properties, boolean keepP, int offset, String page, int limit) {
    checkOffset(offset);
    checkLimit(limit, "Limit");
    String vid = GraphAPI.formatVertexId(vertexId, true);
    String props = GraphAPI.formatProperties(properties);
    Map<String, Object> params = new LinkedHashMap<>();
    params.put("vertex_id", vid);
    params.put("direction", direction);
    params.put("label", label);
    params.put("properties", props);
    params.put("keep_start_p", keepP);
    params.put("offset", offset);
    params.put("limit", limit);
    params.put("page", page);
    RestResult result = this.client.get(this.path(), params);
    return result.readObject(Edges.class);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) LinkedHashMap(java.util.LinkedHashMap)

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