def vertex_property(self, id, name, value): self._add_req(vertex_property=proto.VertexPropertyBulkInsertItem( id=proto.Uuid(value=id.bytes), name=proto.Identifier(value=name), value=proto.Json(value=json.dumps(value)), )) return self
def edge_property(self, key, name, value): self._add_req(edge_property=proto.EdgePropertyBulkInsertItem( key=key.to_message(), name=proto.Identifier(value=name), value=proto.Json(value=json.dumps(value)), )) return self
def to_message(self): return proto.VertexQuery(range=proto.RangeVertexQuery( limit=self._limit, t=proto.Identifier(value=self._t) if self._t is not None else None, start_id=proto.Uuid(value=self._start_id.bytes) if self._start_id is not None else None, ), )
def to_message(self): return proto.VertexQuery(pipe=proto.PipeVertexQuery( inner=self._inner.to_message(), direction=self._direction.value, limit=self._limit, t=proto.Identifier(value=self._t) if self._t is not None else None, ), )
def to_message(self): return proto.VertexQuery(range=proto.PropertyValueVertexQuery( inner=self._inner.to_message(), name=proto.Identifier(value=self._name), value=json.dumps(self._value), equal=self._equal, ), )
def create_vertex_from_type(self, t): """ Creates a new vertex from a type. `t` specifies the new vertex's type. """ req = proto.Identifier(value=t) res = self.stub.CreateVertexFromType(req) return uuid.UUID(bytes=res.value)
def get_edge_count(self, id, t, direction): """ Gets the number of edges related to a vertex. `id` specifies the ID of the vertex. `t` specifies which type of edges to count - set this to `None` if all edges should be counted. `direction` specifies the direction of edges to count. """ req = proto.GetEdgeCountRequest( id=proto.Uuid(value=id.bytes), t=proto.Identifier(value=t) if t is not None else None, direction=direction.value, ) return self.stub.GetEdgeCount(req).count
def to_message(self): high = None if self._high is not None: high = proto.google_dot_protobuf_dot_timestamp__pb2.Timestamp() high.FromDatetime(self._high) low = None if self._low is not None: low = proto.google_dot_protobuf_dot_timestamp__pb2.Timestamp() low.FromDatetime(self._low) return proto.EdgeQuery(pipe=proto.PipeEdgeQuery( inner=self._inner.to_message(), direction=self._direction.value, t=proto.Identifier(value=self._t) if self._t is not None else None, high=high, low=low, limit=self._limit, ), )
def index_property(self, name): req = proto.IndexPropertyRequest(name=proto.Identifier(value=name)) return self.stub.IndexProperty(req)
def to_message(self): return proto.EdgeKey( outbound_id=proto.Uuid(value=self.outbound_id.bytes), t=proto.Identifier(value=self.t), inbound_id=proto.Uuid(value=self.inbound_id.bytes), )
def to_message(self): return proto.EdgePropertyQuery( inner=self._inner.to_message(), name=proto.Identifier(value=self._name), )
def to_message(self): return proto.VertexQuery(range=proto.PipePropertyPresenceVertexQuery( inner=self._inner.to_message(), name=proto.Identifier(value=self._name), exists=self._exists, ), )
def to_message(self): return proto.VertexQuery(range=proto.PropertyValueVertexQuery( name=proto.Identifier(value=self._name), value=json.dumps(self._value), ), )
def to_message(self): return proto.VertexQuery(range=proto.PropertyPresenceVertexQuery( name=proto.Identifier(value=self._name), ), )
def to_message(self): return proto.Vertex( id=proto.Uuid(value=self.id.bytes), t=proto.Identifier(value=self.t), )