图管理API

所有URI均相对于{INTERACTIVE_ADMIN_ENDPOINT}

方法

HTTP请求

描述

ListGraphs

GET /v1/graph

列出所有图的元数据

CreateGraph

POST /v1/graph

创建一个新图

GetGraphMeta

GET /v1/graph/{graph_id}

获取指定graphId标识的图的元数据

GetGraphSchema

GET /v1/graph/{graph_id}/schema

获取由指定graphId标识的图的模式

DeleteGraph

DELETE /v1/graph/{graph_id}

删除由指定graphId标识的图

GetGraphStatistics

GET /v1/graph/{graph_id}/statistics

获取指定graphId标识的图统计信息

BulkLoading

POST /v1/graph/{graph_id}/dataloading

为指定graphId标识的图创建批量加载任务

创建图

结果[CreateGraphResponse] create_graph(create_graph_request)

创建新图

示例

from gs_interactive.client.driver import Driver
from gs_interactive.client.session import Session
from gs_interactive.models import *

test_graph_def = {
    "name": "test_graph",
    "description": "This is a test graph",
    "schema": {
        "vertex_types": [
            {
                "type_name": "person",
                "properties": [
                    {
                        "property_name": "id",
                        "property_type": {"primitive_type": "DT_SIGNED_INT64"},
                    },
                    {
                        "property_name": "name",
                        "property_type": {"string": {"long_text": ""}},
                    },
                    {
                        "property_name": "age",
                        "property_type": {"primitive_type": "DT_SIGNED_INT32"},
                    },
                ],
                "primary_keys": ["id"],
            }
        ],
        "edge_types": [
            {
                "type_name": "knows",
                "vertex_type_pair_relations": [
                    {
                        "source_vertex": "person",
                        "destination_vertex": "person",
                        "relation": "MANY_TO_MANY",
                    }
                ],
                "properties": [
                    {
                        "property_name": "weight",
                        "property_type": {"primitive_type": "DT_DOUBLE"},
                    }
                ],
                "primary_keys": [],
            }
        ],
    },
}
driver = Driver()
sess = driver.session()
create_graph_request = CreateGraphRequest.from_dict(test_graph_def)
resp = sess.create_graph(create_graph_request)
assert resp.is_ok()
graph_id = resp.get_value().graph_id
print("Graph id: ", graph_id)

参数

名称

类型

描述

备注

create_graph_request

CreateGraphRequest

返回类型

结果[CreateGraphResponse]

授权

无需授权

HTTP请求头

  • 内容类型: application/json

  • Accept: application/json

HTTP响应详情

状态码

描述

响应头

200

操作成功

-

400

错误请求

-

500

内部错误

-

[返回顶部] [返回API列表] [返回模型列表] [返回python_sdk]

删除图

结果[str] delete_graph(graph_id)

根据ID删除图。

示例

resp = sess.delete_graph(graph_id)
assert resp.is_ok()
print("graph deleted: ", resp)

参数

名称

类型

描述

备注

graph_id

str

要删除的图名称

返回类型

结果[str]

授权

无需授权

HTTP请求头

  • Content-Type: 未定义

  • Accept: application/json

HTTP响应详情

状态码

描述

响应头

200

操作成功

-

404

未找到

-

500

内部错误

-

[返回顶部] [返回API列表] [返回模型列表] [返回python_sdk]

获取图元数据

获取图响应 get_graph(图标识)

获取图的元数据。

示例

resp = sess.get_graph_meta(graph_id)
assert resp.is_ok()
print("Got metadata for graph {} is {}", graph_id, resp)

参数

名称

类型

描述

备注

graph_id

str

图的ID

返回类型

结果[GetGraphResponse]

授权

无需授权

HTTP请求头

  • Content-Type: 未定义

  • Accept: application/json

HTTP响应详情

状态码

描述

响应头

200

操作成功

-

404

未找到

-

[返回顶部] [返回API列表] [返回模型列表] [返回python_sdk]

获取图统计信息

获取图统计信息响应 get_graph_statistic(图标识符)

获取图的统计信息,包括每个标签的顶点数量和每个标签的边数量。

示例

resp = sess.get_graph_statistics(graph_id)
assert resp.is_ok()
print("Got statistics for graph {} is {}", graph_id, resp)

参数

名称

类型

描述

备注

graph_id

str

要获取统计信息的图的ID

返回类型

结果[GetGraphStatisticsResponse]

授权

无需授权

HTTP请求头

  • Content-Type: 未定义

  • Accept: application/json

HTTP响应详情

状态码

描述

响应头

200

操作成功

-

500

服务器内部错误

-

404

未找到

-

503

服务不可用

-

[返回顶部] [返回API列表] [返回模型列表] [返回python_sdk]

获取图模式

结果[GetGraphSchemaResponse] get_graph_schema(graph_id)

通过graph_id获取图的模式结构。

示例

resp = sess.get_graph_schema(graph_id)
assert resp.is_ok()
print("Got schema for graph {} is {}", graph_id, resp)

参数

名称

类型

描述

备注

graph_id

str

要删除的图名称

返回类型

结果[GetGraphSchemaResponse]

授权

无需授权

HTTP请求头

  • Content-Type: 未定义

  • Accept: application/json

HTTP响应详情

状态码

描述

响应头

200

操作成功

-

[返回顶部] [返回API列表] [返回模型列表] [返回python_sdk]

图列表

结果[List[GetGraphResponse]] list_graphs()

列出所有图

示例

resp = sess.list_graphs()
assert resp.is_ok()
print("List all graphs", resp)

参数

此端点不需要任何参数。

返回类型

结果[List[GetGraphResponse]]

授权

无需授权

HTTP请求头

  • Content-Type: 未定义

  • Accept: application/json

HTTP响应详情

状态码

描述

响应头

200

操作成功

-

[返回顶部] [返回API列表] [返回模型列表] [返回python_sdk]

批量加载

结果[JobResponse] bulk_loading(graph_id, schema_mapping)

创建一个数据加载任务

示例

test_graph_datasource = {
    "vertex_mappings": [
        {
            "type_name": "person",
            "inputs": ["@/path/to/person.csv"],
            "column_mappings": [
                {"column": {"index": 0, "name": "id"}, "property": "id"},
                {"column": {"index": 1, "name": "name"}, "property": "name"},
                {"column": {"index": 2, "name": "age"}, "property": "age"},
            ],
        }
    ],
    "edge_mappings": [
        {
            "type_triplet": {
                "edge": "knows",
                "source_vertex": "person",
                "destination_vertex": "person",
            },
            "inputs": [
                "@/path/to/person_knows_person.csv"
            ],
            "source_vertex_mappings": [
                {"column": {"index": 0, "name": "person.id"}, "property": "id"}
            ],
            "destination_vertex_mappings": [
                {"column": {"index": 1, "name": "person.id"}, "property": "id"}
            ],
            "column_mappings": [
                {"column": {"index": 2, "name": "weight"}, "property": "weight"}
            ],
        }
    ],
}
bulk_load_request = SchemaMapping.from_dict(test_graph_datasource)
resp = sess.bulk_loading(graph_id, bulk_load_request)
assert resp.is_ok()
job_id = resp.get_value().job_id
print("job id ", job_id)

参数

名称

类型

描述

备注

graph_id

str

要进行批量加载的图名称。

schema_mapping

SchemaMapping

返回类型

结果[JobResponse]

授权

无需授权

HTTP请求头

  • 内容类型: application/json

  • Accept: application/json

HTTP响应详情

状态码

描述

响应头

200

操作成功

-

[返回顶部] [返回API列表] [返回模型列表] [返回python_sdk]