Remnawave_python-sdk/remnawave/controllers/api_tokens_management.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

38 lines
1.1 KiB
Python

from typing import Annotated
from httpx import Response
from rapid_api_client import Path
from rapid_api_client.annotations import PydanticBody
from remnawave.models import (
CreateApiTokenRequestDto,
CreateApiTokenResponseDto,
DeleteApiTokenResponseDto,
FindAllApiTokensResponseDto,
)
from remnawave.rapid import BaseController, delete, get, post
class APITokensManagementController(BaseController):
@post("/tokens", response_class=CreateApiTokenResponseDto)
async def create(
self,
body: Annotated[CreateApiTokenRequestDto, PydanticBody()],
) -> CreateApiTokenResponseDto:
"""Create new API token"""
...
@delete("/tokens/{uuid}", response_class=DeleteApiTokenResponseDto)
async def delete(
self,
uuid: Annotated[str, Path(description="UUID of the API token")],
) -> DeleteApiTokenResponseDto:
"""Delete API token"""
...
@get("/tokens", response_class=FindAllApiTokensResponseDto)
async def find_all(
self,
) -> FindAllApiTokensResponseDto:
"""Get all API tokens"""
...