Skip to content

Commit 963ebaf

Browse files
committed
Added endpoint to work with restricted token and modified user del
1 parent c258e57 commit 963ebaf

4 files changed

Lines changed: 30 additions & 7 deletions

File tree

bugout/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
__email__ = "engineering@bugout.dev"
99
__license__ = "MIT"
10-
__version__ = "0.1.5"
10+
__version__ = "0.1.6"
1111

1212
__all__ = (
1313
"__author__",

bugout/app.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ def delete_user(
121121
self,
122122
token: Union[str, uuid.UUID],
123123
user_id: Union[str, uuid.UUID],
124-
password: str,
124+
password: Optional[str] = None,
125125
timeout: float = REQUESTS_TIMEOUT,
126+
**kwargs: Dict[str, Any],
126127
) -> data.BugoutUser:
127128
self.user.timeout = timeout
128-
return self.user.delete_user(token=token, user_id=user_id, password=password)
129+
return self.user.delete_user(
130+
token=token, user_id=user_id, password=password, **kwargs
131+
)
129132

130133
# Token handlers
131134
def create_token(
@@ -134,6 +137,14 @@ def create_token(
134137
self.user.timeout = timeout
135138
return self.user.create_token(username=username, password=password)
136139

140+
def create_token_restricted(
141+
self,
142+
token: Union[str, uuid.UUID],
143+
timeout: float = REQUESTS_TIMEOUT,
144+
) -> data.BugoutToken:
145+
self.user.timeout = timeout
146+
return self.user.create_token_restricted(token=token)
147+
137148
def revoke_token(
138149
self, token: Union[str, uuid.UUID], timeout: float = REQUESTS_TIMEOUT
139150
) -> uuid.UUID:

bugout/data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class BugoutToken(BaseModel):
5757
active: bool
5858
token_type: Optional[str]
5959
note: Optional[str]
60+
restricted: Optional[bool]
6061
created_at: datetime
6162
updated_at: datetime
6263

bugout/user.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,18 @@ def delete_user(
142142
self,
143143
token: Union[str, uuid.UUID],
144144
user_id: Union[str, uuid.UUID],
145-
password: str,
145+
password: Optional[str] = None,
146+
**kwargs: Dict[str, Any],
146147
) -> BugoutUser:
147148
delete_user_path = f"user/{user_id}"
148-
data = {
149-
"password": password,
150-
}
149+
data = {}
150+
if password is not None:
151+
data.update({"password": password})
151152
headers = {
152153
"Authorization": f"Bearer {token}",
153154
}
155+
if "headers" in kwargs.keys():
156+
headers.update(kwargs["headers"])
154157
result = self._call(
155158
method=Method.delete, path=delete_user_path, headers=headers, data=data
156159
)
@@ -166,6 +169,14 @@ def create_token(self, username: str, password: str) -> BugoutToken:
166169
result = self._call(method=Method.post, path=create_token_path, data=data)
167170
return BugoutToken(**result)
168171

172+
def create_token_restricted(self, token: Union[str, uuid.UUID]) -> BugoutToken:
173+
create_token_path = "token/restricted"
174+
headers = {
175+
"Authorization": f"Bearer {token}",
176+
}
177+
result = self._call(method=Method.post, path=create_token_path, headers=headers)
178+
return BugoutToken(**result)
179+
169180
def revoke_token(self, token: Union[str, uuid.UUID]) -> uuid.UUID:
170181
revoke_token_path = "token"
171182
headers = {

0 commit comments

Comments
 (0)