mirror of
https://github.com/remnawave/python-sdk.git
synced 2026-08-03 22:25:14 +00:00
Новые эндпоинты: - GET /tokens/scopes (api_tokens_management.get_scopes) - GET /users/stream — keyset-пагинация (users.get_users_stream) - PATCH /hosts/bulk/update (hosts_bulk_actions.update_hosts) - POST /bandwidth-stats/nodes/users (bandwidthstats.get_stats_nodes_users_usage) Удалённые эндпоинты (вслед за API): - POST /hosts/bulk/set-inbound, /hosts/bulk/set-port (заменены update_hosts) - POST /system/tools/happ/encrypt Изменения моделей: - Hosts: tags (вместо tag), mihomoIpVersion, pinnedPeerCertSha256, verifyPeerCertByName, finalMask, xhttpExtraParams; fingerprint -> str; удалены tag/allowInsecure (с обратной совместимостью через свойства) - API-токены: name/expiresInDays/scopes, tokens/enabled; новый enum Scope (полный каталог scope-ов v2.8.0) - Nodes: nodeConsumptionMultiplier, note, proxyUrl; тело RestartNodeRequestBodyDto - trafficLimitBytes int -> float (users, nodes, bulk-actions) - Infra billing: name, nullable nodeUuid, обязательное nextBillingAt - HWID: requestIp; webhook-события (user/service) обновлены - Новый enum MihomoIpVersion Исправления: - Bulk-ответы хостов переведены на RootModel (раньше падали с ValueError) - revoke_user_subscription: исправлен порядок Annotated/Optional (тело терялось) - Restart*RequestBodyDto: populate_by_name (force_restart игнорировался) Зависимости: - Убраны избыточные пины pydantic и pydantic-core (покрыты pydantic[email]) - requires-python <3.14 -> <3.15, добавлен классификатор Python 3.14 Версия пакета 2.7.1 -> 2.8.0.
46 lines
1.3 KiB
Python
46 lines
1.3 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,
|
|
GetApiTokenScopesResponseDto,
|
|
)
|
|
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"""
|
|
...
|
|
|
|
@get("/tokens/scopes", response_class=GetApiTokenScopesResponseDto)
|
|
async def get_scopes(
|
|
self,
|
|
) -> GetApiTokenScopesResponseDto:
|
|
"""Get available API token scopes"""
|
|
...
|