goblin.relationships package

Submodules

goblin.relationships.base module

class goblin.relationships.base.Relationship(edge_class, vertex_class, direction='both', strict=True, gremlin_path=None, vertex_callback=None, edge_callback=None, query_callback=None, create_callback=None)[source]

Bases: object

Define incoming and outgoing relationships that exist. Also enforce schema IN, OUT and BOTH directions

Warn if queries return schema violations.

allowed(edge_type, vertex_type)[source]

Check whether or not the allowed Edge and Vertex type are compatible with the schema defined

Parameters:
  • edge_type – Edge Class
  • vertex_type – Vertex Class
Type:

goblin.models.Edge

Type:

goblin.models.Vertex

Return type:

bool

create(edge_params={}, vertex_params={}, edge_type=None, vertex_type=None, callback=None, **kwargs)[source]

Creates a Relationship defined by the schema

Parameters:
  • edge_params (dict) – (Optional) Parameters passed to the instantiation method of the Edge
  • vertex_params (dict) – (Optional) Parameters passed to the instantiation method
  • edge_type (goblin.models.Vertex | None) – (Optional) Edge class type, otherwise it defaults to the first Edge type known
  • edge_type – (Optional) Vertex class type, otherwise it defaults to the first Vertex type known
  • callback (method) – (Optional) Callback function to handle results
Return type:

tuple(goblin.models.Edge, goblin.models.Vertex) | Object

edges(limit=None, offset=None, callback=None, **kwargs)[source]

Query and return all Edges attached to the current Vertex

TODO: fix this, the instance method isn’t properly setup :param limit: Limit the number of returned results :type limit: int | long :param offset: Query offset of the number of paginated results :type offset: int | long :param callback: (Optional) Callback function to handle results :type callback: method :rtype: List[goblin.models.Edge] | Object

query(edge_types=None, callback=None)[source]

Generic Query method for quick access

Parameters:
  • edge_types (List[goblin.models.Edge] | None) – List of Edge classes to query against
  • callback (method) – (Optional) Callback function to handle results
Return type:

goblin.models.query.Query | Object

vertices(limit=None, offset=None, callback=None, **kwargs)[source]

Query and return all Vertices attached to the current Vertex

TODO: fix this, the instance method isn’t properly setup :param limit: Limit the number of returned results :type limit: int | long :param offset: Query offset of the number of paginated results :type offset: int | long :param callback: (Optional) Callback function to handle results :type callback: method :rtype: List[goblin.models.Vertex] | Object

goblin.relationships.base.requires_vertex(method)[source]