Esempio n. 1
0
 def lookupStreams(self, collection, isCollectionPrefix, tags, annotations):
     tagkvlist = []
     for k, v in tags.items():
         if v is None:
             ov = None
         else:
             if isinstance(v, str):
                 v = v.encode("utf-8")
             ov = btrdb_pb2.OptValue(value=v)
         kv = btrdb_pb2.KeyOptValue(key=k, val=ov)
         tagkvlist.append(kv)
     annkvlist = []
     for k, v in annotations.items():
         if v is None:
             ov = None
         else:
             if isinstance(v, str):
                 v = v.encode("utf-8")
             ov = btrdb_pb2.OptValue(value=v)
         kv = btrdb_pb2.KeyOptValue(key=k, val=ov)
         annkvlist.append(kv)
     params = btrdb_pb2.LookupStreamsParams(
         collection=collection,
         isCollectionPrefix=isCollectionPrefix,
         tags=tagkvlist,
         annotations=annkvlist)
     for result in self.stub.LookupStreams(params):
         BTrDBError.checkProtoStat(result.stat)
         yield result.results
Esempio n. 2
0
 def create(self, uu, collection, tags, annotations):
     tagkvlist = []
     for k, v in tags.items():
         kv = btrdb_pb2.KeyOptValue(key=k, val=btrdb_pb2.OptValue(value=v))
         tagkvlist.append(kv)
     annkvlist = []
     for k, v in annotations.items():
         kv = btrdb_pb2.KeyOptValue(key=k, val=btrdb_pb2.OptValue(value=v))
         annkvlist.append(kv)
     params = btrdb_pb2.CreateParams(uuid=uu.bytes,
                                     collection=collection,
                                     tags=tagkvlist,
                                     annotations=annkvlist)
     result = self.stub.Create(params)
     BTrDBError.checkProtoStat(result.stat)
Esempio n. 3
0
 def setStreamAnnotations(self, uu, expected, changes):
     annkvlist = []
     for k, v in changes.items():
         if v is None:
             ov = None
         else:
             if isinstance(v, str):
                 v = v.encode("utf-8")
             ov = btrdb_pb2.OptValue(value=v)
         kv = btrdb_pb2.KeyOptValue(key=k, val=ov)
         annkvlist.append(kv)
     params = btrdb_pb2.SetStreamAnnotationsParams(
         uuid=uu.bytes, expectedPropertyVersion=expected, changes=annkvlist)
     result = self.stub.SetStreamAnnotations(params)
     BTrDBError.checkProtoStat(result.stat)
Esempio n. 4
0
 def setStreamTags(self, uu, expected, tags, collection):
     tag_data = []
     for k, v in tags.items():
         if v is None:
             ov = None
         else:
             if isinstance(v, str):
                 v = v.encode("utf-8")
             ov = btrdb_pb2.OptValue(value=v)
         kv = btrdb_pb2.KeyOptValue(key=k, val=ov)
         tag_data.append(kv)
     params = btrdb_pb2.SetStreamTagsParams(
         uuid=uu.bytes,
         expectedPropertyVersion=expected,
         tags=tag_data,
         collection=collection)
     result = self.stub.SetStreamTags(params)
     BTrDBError.checkProtoStat(result.stat)