Compare commits
No commits in common. "d1d486c4c7e041c3b81e3cc16dc81f22f93850e5" and "7867b8cf60d640a3d43e9b30931a23147e69d1a8" have entirely different histories.
d1d486c4c7
...
7867b8cf60
3 changed files with 1 additions and 53 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "asteriskapimanager"
|
||||
version = "0.1.1"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = [
|
||||
{name = "Evgeny (Krymmy) Momotov",email = "evgeny.momotov@gmail.com"}
|
||||
|
|
|
|||
|
|
@ -57,10 +57,6 @@ class AsteriskManagerClient:
|
|||
response = await self._request('GET', f'/sip/{account_id}')
|
||||
return SIPAccount(**response)
|
||||
|
||||
async def update_sip_account(self, account_id: int, data: SIPAccountIn):
|
||||
response = await self._request('PATCH', f'/sip/{account_id}', json=data.model_dump(exclude_unset=True, exclude_none=True))
|
||||
return SIPAccount(**response)
|
||||
|
||||
async def set_sip_register_status(self, account_id: int, is_registered: bool):
|
||||
data = {"is_registered": is_registered}
|
||||
response = await self._request('PATCH', f'/sip/{account_id}', json=data)
|
||||
|
|
|
|||
|
|
@ -79,54 +79,6 @@ class SIPAccount(BaseModel):
|
|||
extra = "ignore"
|
||||
from_attributes = True
|
||||
|
||||
class SIPAccountIn(BaseModel):
|
||||
"""
|
||||
SIP-аккаунт.
|
||||
"""
|
||||
owner_id: Optional[int]
|
||||
name: Optional[str]
|
||||
is_registered: Optional[bool]
|
||||
username: Optional[str]
|
||||
password: Optional[str]
|
||||
|
||||
server_url: Optional[str]
|
||||
port: Optional[int]
|
||||
internal_number: Optional[str]
|
||||
endpoint_name: Optional[str]
|
||||
|
||||
@validator("username")
|
||||
def validate_username(cls, v):
|
||||
if v and len(v) > 40:
|
||||
raise ValueError("Username too long (max 40 characters)")
|
||||
return v
|
||||
|
||||
@validator("name")
|
||||
def validate_name(cls, v):
|
||||
if v and len(v) > 255:
|
||||
raise ValueError("Name too long (max 255 characters)")
|
||||
return v
|
||||
|
||||
@validator("internal_number")
|
||||
def validate_internal_number(cls, v):
|
||||
if v and len(v) > 255:
|
||||
raise ValueError("Internal number too long (max 255 characters)")
|
||||
return v
|
||||
|
||||
@validator("endpoint_name")
|
||||
def validate_endpoint_name(cls, v):
|
||||
if v and len(v) > 255:
|
||||
raise ValueError("Endpoint name too long (max 255 characters)")
|
||||
return v
|
||||
|
||||
@validator("port")
|
||||
def validate_port(cls, v):
|
||||
if v is not None and not (0 <= v <= 65535):
|
||||
raise ValueError("Port must be between 0 and 65535")
|
||||
return v
|
||||
|
||||
class Config:
|
||||
extra = "ignore"
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class AccessResponse(BaseModel):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue