connectordb/_user.py 1 location
                
                
                    
                                                
                                                    
                                |  | @@ 43-54 (lines=12) @@ | 
                                                            
                                    | 40 |  |             self.path, kwargs).json() | 
                                                            
                                    | 41 |  |  | 
                                                            
                                    | 42 |  |     def set_password(self, new_password): | 
                                                            
                                    | 43 |  |         """Sets a new password for the user""" | 
                                                            
                                    | 44 |  |         self.set({"password": new_password}) | 
                                                            
                                    | 45 |  |  | 
                                                            
                                    | 46 |  |     def devices(self): | 
                                                            
                                    | 47 |  |         """Returns the list of devices that belong to the user""" | 
                                                            
                                    | 48 |  |         result = self.db.read(self.path, {"q": "ls"}) | 
                                                            
                                    | 49 |  |  | 
                                                            
                                    | 50 |  |         if result is None or result.json() is None: | 
                                                            
                                    | 51 |  |             return [] | 
                                                            
                                    | 52 |  |         devices = [] | 
                                                            
                                    | 53 |  |         for d in result.json(): | 
                                                            
                                    | 54 |  |             dev = self[d["name"]] | 
                                                            
                                    | 55 |  |             dev.metadata = d | 
                                                            
                                    | 56 |  |             devices.append(dev) | 
                                                            
                                    | 57 |  |         return devices | 
                                                                        
                 
                                                            
                    
connectordb/_device.py 1 location
                
                
                    
                                                
                                                    
                                |  | @@ 28-39 (lines=12) @@ | 
                                                            
                                    | 25 |  |             }) | 
                                                            
                                    | 26 |  |  | 
                                                            
                                    | 27 |  |         Note that the schema must be encoded as a string when creating in this format. | 
                                                            
                                    | 28 |  |         """ | 
                                                            
                                    | 29 |  |         kwargs["public"] = public | 
                                                            
                                    | 30 |  |         self.metadata = self.db.create(self.path, kwargs).json() | 
                                                            
                                    | 31 |  |  | 
                                                            
                                    | 32 |  |     def streams(self): | 
                                                            
                                    | 33 |  |         """Returns the list of streams that belong to the device""" | 
                                                            
                                    | 34 |  |         result = self.db.read(self.path, {"q": "ls"}) | 
                                                            
                                    | 35 |  |  | 
                                                            
                                    | 36 |  |         if result is None or result.json() is None: | 
                                                            
                                    | 37 |  |             return [] | 
                                                            
                                    | 38 |  |         streams = [] | 
                                                            
                                    | 39 |  |         for s in result.json(): | 
                                                            
                                    | 40 |  |             strm = self[s["name"]] | 
                                                            
                                    | 41 |  |             strm.metadata = s | 
                                                            
                                    | 42 |  |             streams.append(strm) | 
                                                                        
                 
                                                            
                    
connectordb/_connectordb.py 1 location
                
                
                    
                                                
                                                    
                                |  | @@ 117-128 (lines=12) @@ | 
                                                            
                                    | 114 |  |     def __repr__(self): | 
                                                            
                                    | 115 |  |         return "[ConnectorDB:%s]" % (self.path, ) | 
                                                            
                                    | 116 |  |  | 
                                                            
                                    | 117 |  |     def users(self): | 
                                                            
                                    | 118 |  |         """Returns the list of users in the database""" | 
                                                            
                                    | 119 |  |         result = self.db.read("", {"q": "ls"}) | 
                                                            
                                    | 120 |  |  | 
                                                            
                                    | 121 |  |         if result is None or result.json() is None: | 
                                                            
                                    | 122 |  |             return [] | 
                                                            
                                    | 123 |  |         users = [] | 
                                                            
                                    | 124 |  |         for u in result.json(): | 
                                                            
                                    | 125 |  |             usr = self(u["name"]) | 
                                                            
                                    | 126 |  |             usr.metadata = u | 
                                                            
                                    | 127 |  |             users.append(usr) | 
                                                            
                                    | 128 |  |         return users | 
                                                            
                                    | 129 |  |  | 
                                                            
                                    | 130 |  |     def ping(self): | 
                                                            
                                    | 131 |  |         """Pings the ConnectorDB server. Useful for checking if the connection is valid""" |