mirror of
https://github.com/remnawave/python-sdk.git
synced 2026-05-13 12:16:42 +00:00
fix: Добавить поддержку генерации алиасов в моделях CreateUserRequestDto и ConfigData; установить заголовки для HTTPS в RemnawaveSDK
This commit is contained in:
parent
2986cd3b69
commit
591ff5d120
4 changed files with 13 additions and 0 deletions
|
|
@ -137,6 +137,10 @@ class RemnawaveSDK:
|
|||
if self.custom_headers:
|
||||
headers.update(self.custom_headers)
|
||||
|
||||
if "http://" in self.base_url:
|
||||
headers["x-forwarded-proto"] = "https"
|
||||
headers["x-forwarded-for"] = "127.0.0.1"
|
||||
|
||||
return headers
|
||||
|
||||
def _prepare_url(self) -> str:
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from pydantic import (
|
|||
RootModel,
|
||||
StringConstraints,
|
||||
)
|
||||
from pydantic.alias_generators import to_camel
|
||||
|
||||
from remnawave.enums import TrafficLimitStrategy, UserStatus
|
||||
|
||||
|
|
@ -133,6 +134,8 @@ class UserResponseDto(BaseModel):
|
|||
external_squad_uuid: UUID | None = Field(None, alias="externalSquadUuid")
|
||||
created_at: datetime = Field(alias="createdAt")
|
||||
updated_at: datetime = Field(alias="updatedAt")
|
||||
|
||||
model_config = {"alias_generator": to_camel, "populate_by_name": True}
|
||||
|
||||
|
||||
class EmailUserResponseDto(RootModel[list[UserResponseDto]]):
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from typing import List
|
|||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.alias_generators import to_camel
|
||||
|
||||
|
||||
class UserUsageByRange(BaseModel):
|
||||
|
|
@ -11,6 +12,8 @@ class UserUsageByRange(BaseModel):
|
|||
node_name: str = Field(alias="nodeName")
|
||||
total: int
|
||||
date: datetime.date
|
||||
|
||||
model_config = {"alias_generator": to_camel, "populate_by_name": True}
|
||||
|
||||
|
||||
class UserUsageByRangeResponseDto(List[UserUsageByRange]):
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
from typing import Any, Dict
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic.alias_generators import to_camel
|
||||
|
||||
|
||||
class ConfigData(BaseModel):
|
||||
config: Any
|
||||
|
||||
model_config = {"alias_generator": to_camel, "populate_by_name": True}
|
||||
|
||||
|
||||
class GetConfigResponseDto(ConfigData):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue