add auth check
This commit is contained in:
@@ -84,13 +84,10 @@ def validate_volume_config(config) -> dict:
|
||||
|
||||
|
||||
def _post_volume_request(payload, timeout=10):
|
||||
import requests
|
||||
from api import data_record_url
|
||||
from api import device_post
|
||||
|
||||
try:
|
||||
response = requests.post(data_record_url, json=payload, timeout=timeout)
|
||||
response.raise_for_status()
|
||||
result = response.json()
|
||||
result = device_post(payload, timeout=timeout)
|
||||
except Exception as exc:
|
||||
raise ValueError(f"连接云端容积参数服务失败: {exc}") from exc
|
||||
|
||||
@@ -101,11 +98,8 @@ def _post_volume_request(payload, timeout=10):
|
||||
|
||||
def create_volume_config_request(timeout=10) -> dict:
|
||||
"""Create exactly one cloud request after the customer clicks Test."""
|
||||
from api import the_folder
|
||||
|
||||
result = _post_volume_request({
|
||||
"type": "createVolumeConfigRequest",
|
||||
"deviceId": the_folder,
|
||||
}, timeout=timeout)
|
||||
if not result.get("requestId") or not result.get("expiresAtMs"):
|
||||
raise ValueError("云端未返回有效的容积参数请求编号")
|
||||
@@ -118,11 +112,9 @@ def create_volume_config_request(timeout=10) -> dict:
|
||||
def poll_volume_config_request(request_id: str, timeout=10) -> dict:
|
||||
"""Poll one request; download and validate JSON only when it is ready."""
|
||||
import requests
|
||||
from api import the_folder
|
||||
|
||||
result = _post_volume_request({
|
||||
"type": "getVolumeConfigRequest",
|
||||
"deviceId": the_folder,
|
||||
"requestId": request_id,
|
||||
}, timeout=timeout)
|
||||
if result.get("expired"):
|
||||
@@ -145,10 +137,7 @@ def poll_volume_config_request(request_id: str, timeout=10) -> dict:
|
||||
|
||||
def acknowledge_volume_config_request(request_id: str, timeout=10) -> None:
|
||||
"""Delete the consumed/abandoned request and its temporary JSON file."""
|
||||
from api import the_folder
|
||||
|
||||
_post_volume_request({
|
||||
"type": "ackVolumeConfigRequest",
|
||||
"deviceId": the_folder,
|
||||
"requestId": request_id,
|
||||
}, timeout=timeout)
|
||||
|
||||
Reference in New Issue
Block a user