ListGraph()
方法及相关类:
ListGraph(config *configuration.RequestConfig) (*http.ResponseGraphs, error)
示例:获取图集列表
func TestMisc(t *testing.T) {
// 创建名为conn的连接,此部分代码省略
responseGraphs, _ := conn.ListGraph(nil)
for i := 0; i < len(responseGraphs.Graphs); i++ {
fmt.Println(*responseGraphs.Graphs[i])
}
}
CreateGraph()
方法及相关类:
CreateGraph(graph *structs.GraphInfo, config *configuration.RequestConfig) (*http.UQLResponse, error)
GraphInfo struct {
ID types.ID
Name string
Description string
TotalNodes uint64
TotalEdges uint64
Status string
}
示例:创建名为testGraph的图集,设置描述为graphset for test
func TestMisc(t *testing.T) {
// 创建名为conn的连接,此部分代码省略
graph := &structs.GraphInfo{
Name: "testGraph",
Description: "graphset for test",
}
uqlResponse, err := conn.CreateGraph(graph, nil)
log.Println(uqlResponse.Status.Code, err)
}
DropGraph()
方法及相关类:
DropGraph(graphName string, config *configuration.RequestConfig) (*http.UQLResponse, error)
示例:删除图集testGraph
func TestMisc(t *testing.T) {
// 创建名为conn的连接,此部分代码省略
uqlResponse, err := conn.DropGraph("testGraph", nil)
log.Println(uqlResponse.Status.Code, err)
}
HasGraph()
方法及相关类:
HasGraph(graphName string, config *configuration.RequestConfig) (bool, error)
示例:查找图集testGraph是否存在
func TestMisc(t *testing.T) {
// 创建名为conn的连接,此部分代码省略
isExist, err := conn.HasGraph("testGraph", nil)
log.Println(isExist, err)
}