@@ 43-54 (lines=12) @@ | ||
40 | """Sets a new password for the user""" |
|
41 | self.set({"password": new_password}) |
|
42 | ||
43 | def devices(self): |
|
44 | """Returns the list of devices that belong to the user""" |
|
45 | result = self.db.read(self.path, {"q": "ls"}) |
|
46 | ||
47 | if result is None or result.json() is None: |
|
48 | return [] |
|
49 | devices = [] |
|
50 | for d in result.json(): |
|
51 | dev = self[d["name"]] |
|
52 | dev.metadata = d |
|
53 | devices.append(dev) |
|
54 | return devices |
|
55 | ||
56 | def __getitem__(self, device_name): |
|
57 | """Gets the child device by name""" |
@@ 28-39 (lines=12) @@ | ||
25 | kwargs["public"] = public |
|
26 | self.metadata = self.db.create(self.path,kwargs).json() |
|
27 | ||
28 | def streams(self): |
|
29 | """Returns the list of streams that belong to the device""" |
|
30 | result = self.db.read(self.path, {"q": "ls"}) |
|
31 | ||
32 | if result is None or result.json() is None: |
|
33 | return [] |
|
34 | streams = [] |
|
35 | for s in result.json(): |
|
36 | strm = self[s["name"]] |
|
37 | strm.metadata = s |
|
38 | streams.append(strm) |
|
39 | return streams |
|
40 | ||
41 | def __getitem__(self, stream_name): |
|
42 | """Gets the child stream by name""" |