|
@@ -1,13 +1,12 @@
|
|
|
# toolkit/vs_cloud_api.py
|
|
# toolkit/vs_cloud_api.py
|
|
|
import requests
|
|
import requests
|
|
|
-import json
|
|
|
|
|
import time
|
|
import time
|
|
|
from urllib.parse import quote
|
|
from urllib.parse import quote
|
|
|
-from datetime import datetime
|
|
|
|
|
|
|
+from datetime import datetime, timezone, timedelta
|
|
|
from typing import Dict, Any, List, Optional
|
|
from typing import Dict, Any, List, Optional
|
|
|
|
|
|
|
|
import configure
|
|
import configure
|
|
|
-from vs_types import NotFoundError, PermissionDeniedError, RateLimiteddError, SessionExpiredOrInvalidError, BizLogicError
|
|
|
|
|
|
|
+from vs_types import PermissionDeniedError, RateLimiteddError, SessionExpiredOrInvalidError, BizLogicError
|
|
|
from vs_log_macros import VSC_ERROR, VSC_INFO, VSC_WARN, VSC_DEBUG
|
|
from vs_log_macros import VSC_ERROR, VSC_INFO, VSC_WARN, VSC_DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
@@ -283,7 +282,22 @@ class VSCloudApi:
|
|
|
raise BizLogicError(message=f"Get next account biz error: {result.get('message')}")
|
|
raise BizLogicError(message=f"Get next account biz error: {result.get('message')}")
|
|
|
|
|
|
|
|
def lock_account(self, account_id: int, lock_duration: int = 3600):
|
|
def lock_account(self, account_id: int, lock_duration: int = 3600):
|
|
|
- pass
|
|
|
|
|
|
|
+ url = f"{self.base_url}/api/account/update"
|
|
|
|
|
+ params = {"account_id": account_id}
|
|
|
|
|
+ next_use_time = (
|
|
|
|
|
+ datetime.now(timezone.utc) +
|
|
|
|
|
+ timedelta(seconds=lock_duration)
|
|
|
|
|
+ ).isoformat(timespec="milliseconds").replace("+00:00", "Z")
|
|
|
|
|
+ payload = {
|
|
|
|
|
+ 'next_use_time': next_use_time
|
|
|
|
|
+ }
|
|
|
|
|
+ headers = self._get_headers()
|
|
|
|
|
+ resp = self._perform_request('PUT', url, params=params, json_data=payload, headers=headers, timeout=10)
|
|
|
|
|
+ result = resp.json()
|
|
|
|
|
+ if result.get("code") == 0:
|
|
|
|
|
+ return result.get("data", {})
|
|
|
|
|
+ else:
|
|
|
|
|
+ raise BizLogicError(message=f"Lock account biz error: {result.get('message')}")
|
|
|
|
|
|
|
|
def get_next_proxy(self, pools: List[str], proxy_cd: int = 60):
|
|
def get_next_proxy(self, pools: List[str], proxy_cd: int = 60):
|
|
|
if configure.TEST_PROXY:
|
|
if configure.TEST_PROXY:
|