Update token (支持修改project_id和project_name) 当用户编辑保存token时,如果token未过期,自动清空429禁用状态
(
self,
token_id: int,
st: Optional[str] = None,
at: Optional[str] = None,
at_expires: Optional[datetime] = None,
project_id: Optional[str] = None,
project_name: Optional[str] = None,
remark: Optional[str] = None,
image_enabled: Optional[bool] = None,
video_enabled: Optional[bool] = None,
image_concurrency: Optional[int] = None,
video_concurrency: Optional[int] = None,
captcha_proxy_url: Optional[str] = None,
extension_route_key: Optional[str] = None,
protocol_mode: Optional[str] = None,
google_cookies: Optional[str] = None,
login_account: Optional[str] = None,
login_password: Optional[str] = None,
proxy_url: Optional[str] = None,
auto_refresh_enabled: Optional[bool] = None,
refresh_interval_minutes: Optional[int] = None,
)
| 387 | ) |
| 388 | return token |
| 389 | async def update_token( |
| 390 | self, |
| 391 | token_id: int, |
| 392 | st: Optional[str] = None, |
| 393 | at: Optional[str] = None, |
| 394 | at_expires: Optional[datetime] = None, |
| 395 | project_id: Optional[str] = None, |
| 396 | project_name: Optional[str] = None, |
| 397 | remark: Optional[str] = None, |
| 398 | image_enabled: Optional[bool] = None, |
| 399 | video_enabled: Optional[bool] = None, |
| 400 | image_concurrency: Optional[int] = None, |
| 401 | video_concurrency: Optional[int] = None, |
| 402 | captcha_proxy_url: Optional[str] = None, |
| 403 | extension_route_key: Optional[str] = None, |
| 404 | protocol_mode: Optional[str] = None, |
| 405 | google_cookies: Optional[str] = None, |
| 406 | login_account: Optional[str] = None, |
| 407 | login_password: Optional[str] = None, |
| 408 | proxy_url: Optional[str] = None, |
| 409 | auto_refresh_enabled: Optional[bool] = None, |
| 410 | refresh_interval_minutes: Optional[int] = None, |
| 411 | ): |
| 412 | """Update token (支持修改project_id和project_name) |
| 413 | |
| 414 | 当用户编辑保存token时,如果token未过期,自动清空429禁用状态 |
| 415 | """ |
| 416 | update_fields = {} |
| 417 | credential_updated = any(value is not None for value in (st, at, at_expires)) |
| 418 | |
| 419 | if st is not None: |
| 420 | update_fields["st"] = st |
| 421 | if at is not None: |
| 422 | update_fields["at"] = at |
| 423 | if at_expires is not None: |
| 424 | update_fields["at_expires"] = at_expires |
| 425 | if project_id is not None: |
| 426 | update_fields["current_project_id"] = project_id |
| 427 | if project_name is not None: |
| 428 | update_fields["current_project_name"] = project_name |
| 429 | if remark is not None: |
| 430 | update_fields["remark"] = remark |
| 431 | if image_enabled is not None: |
| 432 | update_fields["image_enabled"] = image_enabled |
| 433 | if video_enabled is not None: |
| 434 | update_fields["video_enabled"] = video_enabled |
| 435 | if image_concurrency is not None: |
| 436 | update_fields["image_concurrency"] = image_concurrency |
| 437 | if video_concurrency is not None: |
| 438 | update_fields["video_concurrency"] = video_concurrency |
| 439 | if captcha_proxy_url is not None: |
| 440 | update_fields["captcha_proxy_url"] = captcha_proxy_url |
| 441 | if extension_route_key is not None: |
| 442 | update_fields["extension_route_key"] = extension_route_key |
| 443 | if protocol_mode is not None: |
| 444 | update_fields["protocol_mode"] = self._normalize_protocol_mode(protocol_mode) |
| 445 | if google_cookies is not None: |
| 446 | update_fields["google_cookies"] = google_cookies.strip() |
no test coverage detected