Search in sources :

Example 26 with RestResult

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

the class PropertyKeyAPI method create.

public PropertyKey.PropertyKeyWithTask create(PropertyKey propertyKey) {
    Object pkey = this.checkCreateOrUpdate(propertyKey);
    RestResult result = this.client.post(this.path(), pkey);
    if (this.client.apiVersionLt("0.65")) {
        return new PropertyKey.PropertyKeyWithTask(result.readObject(PropertyKey.class), 0L);
    }
    return result.readObject(PropertyKey.PropertyKeyWithTask.class);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey)

Example 27 with RestResult

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

the class PropertyKeyAPI method list.

public List<PropertyKey> list(List<String> names) {
    this.client.checkApiVersion("0.48", "getting schema by names");
    E.checkArgument(names != null && !names.isEmpty(), "The property key 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(), PropertyKey.class);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult)

Example 28 with RestResult

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

the class VertexLabelAPI method eliminate.

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

Example 29 with RestResult

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

the class VertexLabelAPI method list.

public List<VertexLabel> list(List<String> names) {
    this.client.checkApiVersion("0.48", "getting schema by names");
    E.checkArgument(names != null && !names.isEmpty(), "The vertex 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(), VertexLabel.class);
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult)

Example 30 with RestResult

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

the class VertexLabelAPI 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)

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