图管理API¶
所有URI均相对于{INTERACTIVE_ADMIN_ENDPOINT}
方法 |
HTTP请求 |
描述 |
|---|---|---|
GET /v1/graph |
列出所有图的元数据 |
|
POST /v1/graph |
创建一个新图 |
|
GET /v1/graph/{graph_id} |
获取指定graphId标识的图的元数据 |
|
GET /v1/graph/{graph_id}/schema |
获取由指定graphId标识的图的模式 |
|
DELETE /v1/graph/{graph_id} |
删除由指定graphId标识的图 |
|
GET /v1/graph/{graph_id}/statistics |
获取指定graphId标识的图统计信息 |
|
POST /v1/graph/{graph_id}/dataloading |
为指定graphId标识的图创建批量加载任务 |
图列表¶
结果
> getAllGraphs()
列出所有图
示例¶
// Import classes:
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
import com.alibaba.graphscope.interactive.client.common.Result;
import com.alibaba.graphscope.interactive.models.GetGraphResponse;
public class Example {
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();
Result<List<GetGraphResponse>> getRes = session.getAllGraphs();
if (!getRes.isOk()) {
System.out.println("Failed to get graph: " + getRes.getStatusMessage());
return;
}
else {
System.out.println("Got graphs: " + getRes.getValue());
}
}
}
参数¶
无。
返回类型¶
结果<列表<GetGraphResponse>>
HTTP请求头¶
Content-Type: 未定义
Accept: application/json
HTTP响应详情¶
状态码 |
描述 |
响应头 |
|---|---|---|
200 |
操作成功 |
- |
创建图¶
结果
createGraph(createGraphRequest)
创建新图
示例¶
// Import classes:
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
import com.alibaba.graphscope.interactive.client.common.Result;
import com.alibaba.graphscope.interactive.models.*;
public class Example {
private static final String MODERN_GRAPH_SCHEMA_JSON = "{\n" +
" \"name\": \"modern_graph\",\n" +
" \"description\": \"This is a test graph\",\n" +
" \"schema\": {\n" +
" \"vertex_types\": [\n" +
" {\n" +
" \"type_name\": \"person\",\n" +
" \"properties\": [\n" +
" {\n" +
" \"property_name\": \"id\",\n" +
" \"property_type\": {\"primitive_type\": \"DT_SIGNED_INT64\"},\n" +
" },\n" +
" {\n" +
" \"property_name\": \"name\",\n" +
" \"property_type\": {\"string\": {\"long_text\": \"\"}},\n" +
" },\n" +
" {\n" +
" \"property_name\": \"age\",\n" +
" \"property_type\": {\"primitive_type\": \"DT_SIGNED_INT32\"},\n" +
" },\n" +
" ],\n" +
" \"primary_keys\": [\"id\"],\n" +
" }\n" +
" ],\n" +
" \"edge_types\": [\n" +
" {\n" +
" \"type_name\": \"knows\",\n" +
" \"vertex_type_pair_relations\": [\n" +
" {\n" +
" \"source_vertex\": \"person\",\n" +
" \"destination_vertex\": \"person\",\n" +
" \"relation\": \"MANY_TO_MANY\",\n" +
" }\n" +
" ],\n" +
" \"properties\": [\n" +
" {\n" +
" \"property_name\": \"weight\",\n" +
" \"property_type\": {\"primitive_type\": \"DT_DOUBLE\"},\n" +
" }\n" +
" ],\n" +
" \"primary_keys\": [],\n" +
" }\n" +
" ],\n" +
" },\n" +
"}";
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();
// First create graph
CreateGraphRequest graph = CreateGraphRequest.fromJson(MODERN_GRAPH_SCHEMA_JSON);
Result<CreateGraphResponse> rep = session.createGraph(graph);
if (!rep.isOk()) {
System.out.println("Failed to create graph: " + rep.getStatusMessage());
return;
}
else {
System.out.println("Created graph: " + rep.getValue().getGraphId());
}
String graphId = rep.getValue().getGraphId();
System.out.println("GraphId: " + graphId);
}
}
参数¶
名称 |
类型 |
描述 |
备注 |
|---|---|---|---|
createGraphRequest |
返回类型¶
授权¶
无需授权
HTTP请求头¶
内容类型: application/json
Accept: application/json
HTTP响应详情¶
状态码 |
描述 |
响应头 |
|---|---|---|
200 |
操作成功 |
- |
400 |
错误请求 |
- |
500 |
内部错误 |
- |
批量加载¶
结果
bulkLoading(graphId, schemaMapping)
创建一个数据加载任务
示例¶
// Import classes:
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
import com.alibaba.graphscope.interactive.client.common.Result;
import com.alibaba.graphscope.interactive.models.*;
public class Example {
private static final String MODERN_GRAPH_SCHEMA_JSON = "{\n" +
" \"name\": \"modern_graph\",\n" +
" \"description\": \"This is a test graph\",\n" +
" \"schema\": {\n" +
" \"vertex_types\": [\n" +
" {\n" +
" \"type_name\": \"person\",\n" +
" \"properties\": [\n" +
" {\n" +
" \"property_name\": \"id\",\n" +
" \"property_type\": {\"primitive_type\": \"DT_SIGNED_INT64\"},\n" +
" },\n" +
" {\n" +
" \"property_name\": \"name\",\n" +
" \"property_type\": {\"string\": {\"long_text\": \"\"}},\n" +
" },\n" +
" {\n" +
" \"property_name\": \"age\",\n" +
" \"property_type\": {\"primitive_type\": \"DT_SIGNED_INT32\"},\n" +
" },\n" +
" ],\n" +
" \"primary_keys\": [\"id\"],\n" +
" }\n" +
" ],\n" +
" \"edge_types\": [\n" +
" {\n" +
" \"type_name\": \"knows\",\n" +
" \"vertex_type_pair_relations\": [\n" +
" {\n" +
" \"source_vertex\": \"person\",\n" +
" \"destination_vertex\": \"person\",\n" +
" \"relation\": \"MANY_TO_MANY\",\n" +
" }\n" +
" ],\n" +
" \"properties\": [\n" +
" {\n" +
" \"property_name\": \"weight\",\n" +
" \"property_type\": {\"primitive_type\": \"DT_DOUBLE\"},\n" +
" }\n" +
" ],\n" +
" \"primary_keys\": [],\n" +
" }\n" +
" ],\n" +
" },\n" +
"}";
private static final String MODERN_GRAPH_BULK_LOADING_JSON = "{\n" +
" \"vertex_mappings\": [\n" +
" {\n" +
" \"type_name\": \"person\",\n" +
" \"inputs\": [\"@/tmp/person.csv\"],\n" +
" \"column_mappings\": [\n" +
" {\"column\": {\"index\": 0, \"name\": \"id\"}, \"property\": \"id\"},\n" +
" {\"column\": {\"index\": 1, \"name\": \"name\"}, \"property\": \"name\"},\n" +
" {\"column\": {\"index\": 2, \"name\": \"age\"}, \"property\": \"age\"},\n" +
" ],\n" +
" }\n" +
" ],\n" +
" \"edge_mappings\": [\n" +
" {\n" +
" \"type_triplet\": {\n" +
" \"edge\": \"knows\",\n" +
" \"source_vertex\": \"person\",\n" +
" \"destination_vertex\": \"person\",\n" +
" },\n" +
" \"inputs\": [\n" +
" \"@/tmp/person_knows_person.csv\"\n" +
" ],\n" +
" \"source_vertex_mappings\": [\n" +
" {\"column\": {\"index\": 0, \"name\": \"person.id\"}, \"property\": \"id\"}\n" +
" ],\n" +
" \"destination_vertex_mappings\": [\n" +
" {\"column\": {\"index\": 1, \"name\": \"person.id\"}, \"property\": \"id\"}\n" +
" ],\n" +
" \"column_mappings\": [\n" +
" {\"column\": {\"index\": 2, \"name\": \"weight\"}, \"property\": \"weight\"}\n" +
" ],\n" +
" }\n" +
" ],\n" +
"}";
public static void main(String[] args) throws IOException {
Driver driver = Driver.connect();
Session session = driver.session();
// First create graph
CreateGraphRequest graph = CreateGraphRequest.fromJson(MODERN_GRAPH_SCHEMA_JSON);
Result<CreateGraphResponse> rep = session.createGraph(graph);
if (!rep.isOk()) {
System.out.println("Failed to create graph: " + rep.getStatusMessage());
return;
}
else {
System.out.println("Created graph: " + rep.getValue().getGraphId());
}
String graphId = rep.getValue().getGraphId();
SchemaMapping schema = SchemaMapping.fromJson(MODERN_GRAPH_BULK_LOADING_JSON);
Result<JobResponse> getRes = session.bulkLoading(graphId, schema);
if (!getRes.isOk()) {
System.out.println("Failed to bulk loading: " + getRes.getStatusMessage());
return;
}
else {
System.out.println("Bulk loading job id: " + getRes.getValue().getJobId());
}
}
}
参数¶
名称 |
类型 |
描述 |
备注 |
|---|---|---|---|
graphId |
String |
用于批量加载的图ID。 |
|
schemaMapping |
返回类型¶
授权¶
无需授权
HTTP请求头¶
内容类型: application/json
Accept: application/json
HTTP响应详情¶
状态码 |
描述 |
响应头 |
|---|---|---|
200 |
操作成功 |
- |
删除图¶
结果
deleteGraph(graphId)
根据图ID删除图。
示例¶
// Import classes:
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
import com.alibaba.graphscope.interactive.client.common.Result;
public class Example {
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();
String graphId = "2"; // Replace with the graph id you want to delete
Result<String> deleteRes = session.deleteGraph(graphId);
if (!deleteRes.isOk()) {
System.out.println("Failed to delete graph: " + deleteRes.getStatusMessage());
return;
}
else {
System.out.println("Deleted graph: " + deleteRes.getValue());
}
}
}
参数¶
名称 |
类型 |
描述 |
备注 |
|---|---|---|---|
graphId |
String |
要删除的图的ID |
返回类型¶
授权¶
无需授权
HTTP请求头¶
Content-Type: 未定义
Accept: application/json
HTTP响应详情¶
状态码 |
描述 |
响应头 |
|---|---|---|
200 |
操作成功 |
- |
404 |
未找到 |
- |
500 |
内部错误 |
- |
获取图元数据¶
结果
getGraphMeta(graphId)
通过ID获取图
示例¶
// Import classes:
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
import com.alibaba.graphscope.interactive.client.common.Result;
public class Example {
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();
Result<GetGraphResponse> getGraphResponseResult = session.getGraphMeta("1");
if (!getGraphResponseResult.isOk()) {
System.out.println("Failed to get graph: " + getGraphResponseResult.getStatusMessage());
return;
}
else {
System.out.println("Got graph: " + getGraphResponseResult.getValue());
}
}
}
参数¶
名称 |
类型 |
描述 |
备注 |
|---|---|---|---|
graphId |
String |
要获取的图的ID |
返回类型¶
授权¶
无需授权
HTTP请求头¶
Content-Type: 未定义
Accept: application/json
HTTP响应详情¶
状态码 |
描述 |
响应头 |
|---|---|---|
200 |
操作成功 |
- |
404 |
未找到 |
- |
获取图统计信息¶
获取图统计信息响应 getGraphStatistic(graphId)
获取图的统计信息,包括每个标签的顶点数量和每个标签的边数量。
示例¶
// Import classes:
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
import com.alibaba.graphscope.interactive.client.common.Result;
import com.alibaba.graphscope.interactive.models.GetGraphStatisticsResponse;
public class Example {
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();
Result<GetGraphStatisticsResponse> getRes = session.getGraphStatistics("2");
if (!getRes.isOk()) {
System.out.println("Failed to get graph statistics: " + getRes.getStatusMessage());
} else {
System.out.println("Got graph statistics: " + getRes.getValue());
}
}
}
参数¶
名称 |
类型 |
描述 |
备注 |
|---|---|---|---|
graphId |
String |
用于获取统计信息的图ID |
返回类型¶
授权¶
无需授权
HTTP请求头¶
Content-Type: 未定义
Accept: application/json
HTTP响应详情¶
状态码 |
描述 |
响应头 |
|---|---|---|
200 |
操作成功 |
- |
500 |
服务器内部错误 |
- |
404 |
未找到 |
- |
503 |
服务不可用 |
- |
获取图模式¶
获取图模式响应 getSchema(图ID)
通过图ID获取模式
示例¶
// Import classes:
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
import com.alibaba.graphscope.interactive.client.common.Result;
import com.alibaba.graphscope.interactive.models.GetGraphSchemaResponse;
public class Example {
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();
Result<GetGraphSchemaResponse> getRes = session.getGraphSchema("2");
if (!getRes.isOk()) {
System.out.println("Failed to get graph schema: " + getRes.getStatusMessage());
} else {
System.out.println("Got graph schema: " + getRes.getValue());
}
}
}
参数¶
名称 |
类型 |
描述 |
备注 |
|---|---|---|---|
graphId |
String |
用于获取模式的图ID |
返回类型¶
授权¶
无需授权
HTTP请求头¶
Content-Type: 未定义
Accept: application/json
HTTP响应详情¶
状态码 |
描述 |
响应头 |
|---|---|---|
200 |
操作成功 |
- |