Remnawave_python-sdk/remnawave/controllers/internal_squads.py
Artem 950a7ffab3
Add Pydantic models for nodes usage history, subscriptions, and user management
- Implemented models for nodes usage history including NodeInfoDto, GetUserAccessibleNodesResponse, and usage statistics.
- Created subscription-related models such as UserSubscription, SubscriptionInfoData, and various response DTOs for subscription information.
- Developed models for subscription settings, templates, and system statistics, enhancing the API's capability to manage and retrieve subscription configurations.
- Introduced user management models including CreateUserRequestDto, UpdateUserRequestDto, and various response DTOs for user actions.
- Added bulk actions for user updates and statistics tracking, improving the efficiency of user management operations.
- Established a base controller for handling API requests and responses, along with decorators for HTTP methods to streamline API interactions.
- Included utility functions for serialization using orjson for better performance with Pydantic models.
2025-07-03 12:22:16 +02:00

74 lines
2.8 KiB
Python

from typing import Annotated
from rapid_api_client import Path
from rapid_api_client.annotations import PydanticBody
from remnawave.models import (
AddUsersToInternalSquadRequestDto,
AddUsersToInternalSquadResponseDto,
CreateInternalSquadRequestDto,
CreateInternalSquadResponseDto,
DeleteInternalSquadResponseDto,
DeleteUsersFromInternalSquadRequestDto,
DeleteUsersFromInternalSquadResponseDto,
GetAllInternalSquadsResponseDto,
GetInternalSquadByUuidResponseDto,
UpdateInternalSquadRequestDto,
UpdateInternalSquadResponseDto,
)
from remnawave.rapid import BaseController, delete, get, patch, post
class InternalSquadsController(BaseController):
@get("/internal-squads", response_class=GetAllInternalSquadsResponseDto)
async def get_internal_squads(self) -> GetAllInternalSquadsResponseDto:
"""Get all internal squads"""
...
@post("/internal-squads", response_class=CreateInternalSquadResponseDto)
async def create_internal_squad(
self,
body: Annotated[CreateInternalSquadRequestDto, PydanticBody()],
) -> CreateInternalSquadResponseDto:
"""Create internal squad"""
...
@patch("/internal-squads", response_class=UpdateInternalSquadResponseDto)
async def update_internal_squad(
self,
body: Annotated[UpdateInternalSquadRequestDto, PydanticBody()],
) -> UpdateInternalSquadResponseDto:
"""Update internal squad"""
...
@get("/internal-squads/{uuid}", response_class=GetInternalSquadByUuidResponseDto)
async def get_internal_squad_by_uuid(
self,
uuid: Annotated[str, Path(description="UUID of the internal squad")],
) -> GetInternalSquadByUuidResponseDto:
"""Get internal squad by uuid"""
...
@delete("/internal-squads/{uuid}", response_class=DeleteInternalSquadResponseDto)
async def delete_internal_squad(
self,
uuid: Annotated[str, Path(description="UUID of the internal squad")],
) -> DeleteInternalSquadResponseDto:
"""Delete internal squad"""
...
@post("/internal-squads/{uuid}/bulk-actions/add-users", response_class=AddUsersToInternalSquadResponseDto)
async def add_users_to_internal_squad(
self,
uuid: Annotated[str, Path(description="UUID of the internal squad")],
) -> AddUsersToInternalSquadResponseDto:
"""Add users to internal squad"""
...
@delete("/internal-squads/{uuid}/bulk-actions/remove-users", response_class=DeleteUsersFromInternalSquadResponseDto)
async def remove_users_from_internal_squad(
self,
uuid: Annotated[str, Path(description="UUID of the internal squad")],
) -> DeleteUsersFromInternalSquadResponseDto:
"""Delete users from internal squad"""
...