TigerGraphDriver

class TigerGraphDriver: IOverridenIdDriver, ISchemaSafeDriver, Any

The driver used to connect to a remote TigerGraph instance.

Fields

Name Description
var hostname: String

The TigerGraph REST++ server hostname.

var username: String

The TigerGraph GSQL server password.

var password: String

The TigerGraph GSQL server username.

var restPpPort: Int

The TigerGraph REST++ server port number.

var gsqlPort: Int

The TigerGraph GSQL server port number.

var secure: Boolean

The TigerGraph REST++ server security status. Used for determining the protocol used between HTTPS or HTTP.

var authKey: String

The authorization key used for TigerGraph servers with token authorization turned on. This is placed under the Authorization header when making requests.

Methods

hostname

fun hostname(value: String): TigerGraphDriver

Set the hostname for the TigerGraph REST++ server.

Parameters

Name Description
value: String

the hostname e.g. 127.0.0.1, www.tgserver.com, etc.

ReturnValue

Name Description
TigerGraphDriver

username

fun username(value: String): TigerGraphDriver

Set the hostname for the TigerGraph GSQL server.

Parameters

Name Description
value: String

the username e.g. "tigergraph".

ReturnValue

Name Description
TigerGraphDriver

password

fun password(value: String): TigerGraphDriver

Set the password for the TigerGraph GSQL server.

Parameters

Name Description
value: String

the password e.g. "tigergraph"

ReturnValue

Name Description
TigerGraphDriver

restPpPort

fun restPpPort(value: Int): TigerGraphDriver

Set the port for the TigerGraph REST++ server.

Parameters

Name Description
value: Int

the port number e.g. 9000

ReturnValue

Name Description
TigerGraphDriver

gsqlPort

fun gsqlPort(value: Int): TigerGraphDriver

Set the port for the TigerGraph GSQL server.

Parameters

Name Description
value: Int

the port number e.g. 14240

ReturnValue

Name Description
TigerGraphDriver

secure

fun secure(value: Boolean): TigerGraphDriver

Sets the secure flag when building the API path.

Parameters

Name Description
value: Boolean

set to true if using HTTPS and false if using HTTP.

ReturnValue

Name Description
TigerGraphDriver

authKey

fun authKey(value: String): TigerGraphDriver

Sets the authorization token used in requests.

An example of where this is used is in TigerGraph Cloud.

Parameters

Name Description
value: String

ReturnValue

Name Description
TigerGraphDriver

addVertex

fun addVertex(v: NewNodeBuilder)

Inserts a vertex in the graph database.

Parameters

Name Description
v: NewNodeBuilder

the NewNodeBuilder to insert.

ReturnValue

Name Description
Unit

exists

fun exists(v: NewNodeBuilder): Boolean

Checks if the given NewNodeBuilder exists in the database.

Parameters

Name Description
v: NewNodeBuilder

the NewNodeBuilder to check existence of.

ReturnValue

Name Description
Boolean

true if the vertex exists, false if otherwise.

exists

fun exists(src: NewNodeBuilder, tgt: NewNodeBuilder, edge: String): Boolean

Checks if there exists a directed edge of the given label between two NewNodeBuilder vertices.

Parameters

Name Description
src: NewNodeBuilder

the source NewNodeBuilder.

tgt: NewNodeBuilder

the target NewNodeBuilder.

edge: String

the edge label.

ReturnValue

Name Description
Boolean

true if the edge exists, false if otherwise.

addEdge

fun addEdge(src: NewNodeBuilder, tgt: NewNodeBuilder, edge: String)

Creates an edge with the given label between two NewNodeBuilder vertices in the graph database. If the given vertices are not already present in the database, they are created. If the edge already exists it wil not be recreated.

Parameters

Name Description
src: NewNodeBuilder

the source NewNodeBuilder.

tgt: NewNodeBuilder

the target NewNodeBuilder.

edge: String

the edge label.

ReturnValue

Name Description
Unit

getWholeGraph

fun getWholeGraph(): Graph

Returns the whole CPG as a Graph object. Depending on the size of the CPG, this may be very memory intensive and usually a bad idea to call.

ReturnValue

Name Description
Graph

The whole CPG in the graph database.

getMethod

fun getMethod(fullName: String, includeBody: Boolean): Graph

Given the full signature of a method, returns the subgraph of the method body.

Parameters

Name Description
fullName: String

The fully qualified name with signature e.g. interprocedural.basic.Basic4.f:int(int,int)

includeBody: Boolean

True if the body should be included, false if only method head should be included.

ReturnValue

Name Description
Graph

The Graph containing the method graph.

getMethodNames

fun getMethodNames(): List<String>

Obtains all method full names in the CPG. These can be used in IDriver.getMethod.

ReturnValue

Name Description
List<String>

A list of all method full names.

getProgramStructure

fun getProgramStructure(): Graph

Obtains all program structure related vertices. These are NAMESPACE_BLOCK, FILE, and TYPE_DECL vertices.

ReturnValue

Name Description
Graph

The Graph containing the program structure related sub-graphs.

getProgramTypeData

fun getProgramTypeData(): Graph

Obtains all the type references, declarations, and arguments of a program to their children and referenced vertices.

ReturnValue

Name Description
Graph

The Graph containing the type data of the CPG.

getNeighbours

fun getNeighbours(v: NewNodeBuilder): Graph

Given a vertex, returns a Graph representation of neighbouring vertices.

Parameters

Name Description
v: NewNodeBuilder

The source vertex.

ReturnValue

Name Description
Graph

The Graph representation of the source vertex and its neighbouring vertices.

deleteVertex

fun deleteVertex(id: Long, label: String?)

Given a vertex, will remove it from the graph if present.

Parameters

Name Description
id: Long

The id to remove.

label: String?

The label, if known.

ReturnValue

Name Description
Unit

deleteEdge

fun deleteEdge(src: NewNodeBuilder, tgt: NewNodeBuilder, edge: String)

Given two vertices and an edge label.

Parameters

Name Description
src: NewNodeBuilder

Outgoing vertex.

tgt: NewNodeBuilder

Incoming vertex.

edge: String

The edge label of the edge to remove.

ReturnValue

Name Description
Unit

deleteMethod

fun deleteMethod(fullName: String)

Given the full signature of a method, removes the method and its body from the graph.

Parameters

Name Description
fullName: String

The fully qualified name with signature e.g. interprocedural.basic.Basic4.f:int(int,int)

ReturnValue

Name Description
Unit

updateVertexProperty

fun updateVertexProperty(id: Long, label: String?, key: String, value: Any)

Updates a vertex's property if the node exists.

Parameters

Name Description
id: Long

The ID of the vertex to update.

label: String?

The label of the node, if known.

key: String

The key of the property to update.

value: Any

The updated value.

ReturnValue

Name Description
Unit

getMetaData

fun getMetaData(): NewMetaDataBuilder?

Obtains the graph meta data information, if found.

ReturnValue

Name Description
NewMetaDataBuilder?

A NewMetaDataBuilder containing the meta data information, false if no information found.

getVerticesByProperty

fun getVerticesByProperty(propertyKey: String, propertyValue: Any, label: String?): List<NewNodeBuilder>

Attempts to get vertex by it's fullname property.

Parameters

Name Description
propertyKey: String

The key to match with.

propertyValue: Any

The value to match with.

label: String?

An optional vertex label if known to further filter results by.

ReturnValue

Name Description
List<NewNodeBuilder>

A list of all vertices which match the predicates.

getPropertyFromVertices

fun <T : Any> getPropertyFromVertices(propertyKey: String, label: String?): List<T>

Get a list of the results from a given property in vertices.

Parameters

Name Description
propertyKey: String

The property to retrieve.

label: String?

An optional vertex label if known to further filter results by.

ReturnValue

Name Description
List<T>

A list of the values from the given key using the specified type.

getVertexIds

fun getVertexIds(lowerBound: Long, upperBound: Long): Set<Long>

Given a lower bound and an upper bound, return all vertex IDs which fall between these ranges in the database.

Parameters

Name Description
lowerBound: Long

The lower bound for the result set.

upperBound: Long

The upper bound for the result set.

ReturnValue

Name Description
Set<Long>

close

fun close()

ReturnValue

Name Description
Unit

clearGraph

fun clearGraph(): ()

Clears the graph of all vertices and edges.

ReturnValue

Name Description
()

itself as so to be chained in method calls.

buildSchema

fun buildSchema()

Uses the generated schema from TigerGraphDriver.buildSchemaPayload and remotely executes it on the database. This is done via the GSQL server using the GSQL client.

See Also: Using a Remote GSQL Client

ReturnValue

Name Description
Unit

buildSchemaPayload

fun buildSchemaPayload(): String

Builds the schema from generated CPG code and returns it as a String to be executed on the database.

ReturnValue

Name Description
String