mirror of
https://github.com/remnawave/python-sdk.git
synced 2026-05-13 12:16:42 +00:00
feat: добавить модель TagUserResponseDto и обновить контроллер пользователей для использования новой модели
This commit is contained in:
parent
8a84503191
commit
8e34b50c6c
3 changed files with 31 additions and 10 deletions
|
|
@ -13,7 +13,8 @@ from remnawave.models import (
|
|||
UserResponseDto,
|
||||
UsersResponseDto,
|
||||
TagsResponseDto,
|
||||
RevokeUserRequestDto
|
||||
TagUserResponseDto,
|
||||
RevokeUserRequestDto,
|
||||
)
|
||||
from remnawave.rapid import BaseController, delete, get, patch, post
|
||||
|
||||
|
|
@ -38,8 +39,12 @@ class UsersController(BaseController):
|
|||
@get("/users", response_class=UsersResponseDto)
|
||||
async def get_all_users_v2(
|
||||
self,
|
||||
start: Annotated[int, Query(default=0, ge=0, description="Index to start pagination from")],
|
||||
size: Annotated[int, Query(default=25, ge=1, description="Number of users per page")],
|
||||
start: Annotated[
|
||||
int, Query(default=0, ge=0, description="Index to start pagination from")
|
||||
],
|
||||
size: Annotated[
|
||||
int, Query(default=25, ge=1, description="Number of users per page")
|
||||
],
|
||||
) -> UsersResponseDto:
|
||||
"""
|
||||
Get users page from the end.
|
||||
|
|
@ -52,7 +57,7 @@ class UsersController(BaseController):
|
|||
UsersResponseDto
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
@delete("/users/{uuid}", response_class=DeleteUserResponseDto)
|
||||
async def delete_user(
|
||||
self,
|
||||
|
|
@ -102,7 +107,10 @@ class UsersController(BaseController):
|
|||
"""Get User By Short UUID"""
|
||||
...
|
||||
|
||||
@get("/users/by-subscription-uuid/{subscription_uuid}", response_class=UserResponseDto)
|
||||
@get(
|
||||
"/users/by-subscription-uuid/{subscription_uuid}",
|
||||
response_class=UserResponseDto,
|
||||
)
|
||||
async def get_user_by_subscription_uuid(
|
||||
self,
|
||||
subscription_uuid: Annotated[str, Path(description="UUID of the subscription")],
|
||||
|
|
@ -145,14 +153,14 @@ class UsersController(BaseController):
|
|||
"""Get Users By Email"""
|
||||
...
|
||||
|
||||
@get("/users/by-tag/{tag}", response_class=UsersResponseDto)
|
||||
@get("/users/by-tag/{tag}", response_class=TagUserResponseDto)
|
||||
async def get_users_by_tag(
|
||||
self,
|
||||
tag: Annotated[str, Path(description="Tag of the user")],
|
||||
) -> UsersResponseDto:
|
||||
) -> TagUserResponseDto:
|
||||
"""Get Users By Tag"""
|
||||
...
|
||||
|
||||
|
||||
@get("/users/tags", response_class=TagsResponseDto)
|
||||
async def get_all_tags(
|
||||
self,
|
||||
|
|
@ -160,10 +168,13 @@ class UsersController(BaseController):
|
|||
"""Get All Tags"""
|
||||
...
|
||||
|
||||
@get("/users/{uuid}/accessible-nodes", response_class=GetUserAccessibleNodesResponseDto)
|
||||
@get(
|
||||
"/users/{uuid}/accessible-nodes",
|
||||
response_class=GetUserAccessibleNodesResponseDto,
|
||||
)
|
||||
async def get_user_accessible_nodes(
|
||||
self,
|
||||
uuid: Annotated[str, Path(description="UUID of the user")],
|
||||
) -> GetUserAccessibleNodesResponseDto:
|
||||
"""Get User Accessible Nodes"""
|
||||
...
|
||||
...
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ from .users import (
|
|||
UserResponseDto,
|
||||
UsersResponseDto,
|
||||
TagsResponseDto,
|
||||
TagUserResponseDto,
|
||||
RevokeUserRequestDto,
|
||||
)
|
||||
from .users_bulk_actions import (
|
||||
|
|
@ -379,6 +380,7 @@ __all__ = [
|
|||
"UserLastConnectedNodeDto",
|
||||
"UserResponseDto",
|
||||
"UsersResponseDto",
|
||||
"TagUserResponseDto",
|
||||
# Users bulk actions models
|
||||
"BulkAllResetTrafficUsersResponseDto",
|
||||
"BulkAllUpdateUsersRequestDto",
|
||||
|
|
|
|||
|
|
@ -154,6 +154,14 @@ class EmailUserResponseDto(RootModel[List[UserResponseDto]]):
|
|||
return self.root[item]
|
||||
|
||||
|
||||
class TagUserResponseDto(RootModel[List[UserResponseDto]]):
|
||||
def __iter__(self):
|
||||
return iter(self.root)
|
||||
|
||||
def __getitem__(self, item):
|
||||
return self.root[item]
|
||||
|
||||
|
||||
class TelegramUserResponseDto(RootModel[List[UserResponseDto]]):
|
||||
def __iter__(self):
|
||||
return iter(self.root)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue