Skip to content

Commit 9665e1a

Browse files
author
Jeroen van der Heijden
committed
Fix build-in
2 parents 2150ea3 + 7decf00 commit 9665e1a

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

thingsdb/client/buildin.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
from typing import Union as U
3-
3+
from typing import Optional as O
44

55
class Buildin:
66

@@ -42,6 +42,9 @@ async def grant(self, target: U[int, str], user: str, mask: int):
4242
async def has_collection(self, name: str):
4343
return await self.query(f'has_collection(name)', name=name, scope='@t')
4444

45+
async def has_token(self, token: str):
46+
return await self.query(f'has_token(token)', token=token, scope='@t')
47+
4548
async def has_user(self, name: str):
4649
return await self.query(f'has_user(name)', name=name, scope='@t')
4750

@@ -51,12 +54,10 @@ async def new_collection(self, name: str):
5154
async def new_token(
5255
self,
5356
user: str,
54-
expiration_time: datetime.datetime = None,
57+
expiration_time: O[datetime.datetime] = None,
5558
description: str = ''):
5659

57-
if expiration_time is None:
58-
expiration_time = 'nil'
59-
else:
60+
if expiration_time is not None:
6061
expiration_time = int(datetime.datetime.timestamp(expiration_time))
6162

6263
return await self.query(
@@ -66,12 +67,32 @@ async def new_token(
6667
description=description,
6768
scope='@t')
6869

70+
async def new_user(self, name: str):
71+
return await self.query(f'new_user(name)', name=name, scope='@t')
72+
6973
async def node_info(self, scope='@n'):
7074
return await self.query('node_info()', scope=scope)
7175

7276
async def nodes_info(self, scope='@n') -> list:
7377
return await self.query('nodes_info()', scope=scope)
7478

79+
async def rename_collection(
80+
self,
81+
collection: U[int, str],
82+
new_name: str) -> None:
83+
return await self.query(
84+
f'rename_collection(collection, new_name)',
85+
collection=collection,
86+
new_name=new_name,
87+
scope='@t')
88+
89+
async def rename_user(self, user: str, new_name: str) -> None:
90+
return await self.query(
91+
f'rename_user(user, new_name)',
92+
user=user,
93+
new_name=new_name,
94+
scope='@t')
95+
7596
async def reset_counters(self, scope='@n') -> None:
7697
return await self.query('reset_counters()', scope=scope)
7798

@@ -88,6 +109,13 @@ async def set_log_level(self, log_level: str, scope='@n') -> None:
88109
return await self.query(
89110
f'set_log_level(log_level)', log_level=log_level, scope=scope)
90111

112+
async def set_password(self, user: str, new_password: str = None) -> None:
113+
return await self.query(
114+
f'set_password(user, new_password)',
115+
user=user,
116+
new_password=new_password,
117+
scope='@t')
118+
91119
async def shutdown(self, scope='@n') -> None:
92120
return await self.query('shutdown()', scope=scope)
93121

0 commit comments

Comments
 (0)