Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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,
     ), )
Ejemplo n.º 4
0
 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,
     ), )
Ejemplo n.º 5
0
 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,
     ), )
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
0
    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,
        ), )
Ejemplo n.º 9
0
 def index_property(self, name):
     req = proto.IndexPropertyRequest(name=proto.Identifier(value=name))
     return self.stub.IndexProperty(req)
Ejemplo n.º 10
0
 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),
     )
Ejemplo n.º 11
0
 def to_message(self):
     return proto.EdgePropertyQuery(
         inner=self._inner.to_message(),
         name=proto.Identifier(value=self._name),
     )
Ejemplo n.º 12
0
 def to_message(self):
     return proto.VertexQuery(range=proto.PipePropertyPresenceVertexQuery(
         inner=self._inner.to_message(),
         name=proto.Identifier(value=self._name),
         exists=self._exists,
     ), )
Ejemplo n.º 13
0
 def to_message(self):
     return proto.VertexQuery(range=proto.PropertyValueVertexQuery(
         name=proto.Identifier(value=self._name),
         value=json.dumps(self._value),
     ), )
Ejemplo n.º 14
0
 def to_message(self):
     return proto.VertexQuery(range=proto.PropertyPresenceVertexQuery(
         name=proto.Identifier(value=self._name), ), )
Ejemplo n.º 15
0
 def to_message(self):
     return proto.Vertex(
         id=proto.Uuid(value=self.id.bytes),
         t=proto.Identifier(value=self.t),
     )