优化get_west_domain_price
This commit is contained in:
parent
586a4effcf
commit
7c95d02097
@ -10,7 +10,7 @@ from urllib.parse import urlencode
|
||||
from typing import Dict, Any, Optional, List
|
||||
|
||||
|
||||
class WestDomainAPI:
|
||||
class WestDomain:
|
||||
"""西部数码域名API客户端"""
|
||||
|
||||
def __init__(self, username: str, password: str):
|
||||
@ -292,7 +292,7 @@ class WestDomainAPI:
|
||||
return self._make_request(action, 'POST', body_params=body_params)
|
||||
|
||||
|
||||
def get_west_domain_client() -> WestDomainAPI:
|
||||
def get_west_client() -> WestDomain:
|
||||
"""获取西部数码域名API客户端实例"""
|
||||
try:
|
||||
# 从Jcloud Settings获取配置
|
||||
@ -302,7 +302,7 @@ def get_west_domain_client() -> WestDomainAPI:
|
||||
password = settings.get_password("west_api_password") if settings.get("west_api_password") else None
|
||||
|
||||
if username and password:
|
||||
return WestDomainAPI(username, password)
|
||||
return WestDomain(username, password)
|
||||
else:
|
||||
jingrow.log_error("西部数码域名API: 缺少用户名或密码配置")
|
||||
return None
|
||||
@ -318,7 +318,7 @@ def get_west_domain_client() -> WestDomainAPI:
|
||||
@jingrow.whitelist()
|
||||
def check_west_balance():
|
||||
"""检查西部数码账户余额"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -326,15 +326,12 @@ def check_west_balance():
|
||||
|
||||
|
||||
@jingrow.whitelist()
|
||||
def check_domain(**data):
|
||||
def check_domain(domain: str, suffix: str = '.com'):
|
||||
"""查询域名是否可注册"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
domain = data.get('domain')
|
||||
suffix = data.get('suffix', '.com')
|
||||
|
||||
if not domain:
|
||||
return {"status": "error", "message": "缺少域名参数"}
|
||||
|
||||
@ -342,15 +339,12 @@ def check_domain(**data):
|
||||
|
||||
|
||||
@jingrow.whitelist()
|
||||
def west_domain_get_price(**data):
|
||||
def get_west_domain_price(domain: str, year: int = 1):
|
||||
"""获取域名价格"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
domain = data.get('domain')
|
||||
year = data.get('year', 1)
|
||||
|
||||
if not domain:
|
||||
return {"status": "error", "message": "缺少域名参数"}
|
||||
|
||||
@ -360,7 +354,7 @@ def west_domain_get_price(**data):
|
||||
@jingrow.whitelist()
|
||||
def west_domain_register(**data):
|
||||
"""注册域名"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -377,7 +371,7 @@ def west_domain_register(**data):
|
||||
@jingrow.whitelist()
|
||||
def west_domain_renew(**data):
|
||||
"""域名续费"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -395,7 +389,7 @@ def west_domain_renew(**data):
|
||||
@jingrow.whitelist()
|
||||
def west_domain_get_list(**data):
|
||||
"""获取域名列表"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -408,7 +402,7 @@ def west_domain_get_list(**data):
|
||||
@jingrow.whitelist()
|
||||
def west_domain_get_info(**data):
|
||||
"""获取域名信息"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -422,7 +416,7 @@ def west_domain_get_info(**data):
|
||||
@jingrow.whitelist()
|
||||
def west_domain_get_dns(**data):
|
||||
"""获取域名DNS记录"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -436,7 +430,7 @@ def west_domain_get_dns(**data):
|
||||
@jingrow.whitelist()
|
||||
def west_domain_modify_dns(**data):
|
||||
"""修改域名DNS记录"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -454,7 +448,7 @@ def west_domain_modify_dns(**data):
|
||||
@jingrow.whitelist()
|
||||
def west_domain_add_dns_record(**data):
|
||||
"""添加DNS记录"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -473,7 +467,7 @@ def west_domain_add_dns_record(**data):
|
||||
@jingrow.whitelist()
|
||||
def west_domain_delete_dns_record(**data):
|
||||
"""删除DNS记录"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -491,7 +485,7 @@ def west_domain_delete_dns_record(**data):
|
||||
@jingrow.whitelist()
|
||||
def west_domain_transfer(**data):
|
||||
"""域名转入"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -509,7 +503,7 @@ def west_domain_transfer(**data):
|
||||
@jingrow.whitelist()
|
||||
def west_domain_lock(**data):
|
||||
"""锁定域名"""
|
||||
client = get_west_domain_client()
|
||||
client = get_west_client()
|
||||
if not client:
|
||||
return {"status": "error", "message": "API客户端初始化失败"}
|
||||
|
||||
@ -537,7 +531,7 @@ def call_west_domain_api(api_name: str, **kwargs) -> Dict[str, Any]:
|
||||
api_functions = {
|
||||
'check_balance': check_west_balance,
|
||||
'query': check_domain,
|
||||
'get_price': west_domain_get_price,
|
||||
'get_price': get_west_domain_price,
|
||||
'register': west_domain_register,
|
||||
'renew': west_domain_renew,
|
||||
'get_list': west_domain_get_list,
|
||||
|
||||
@ -1601,7 +1601,7 @@
|
||||
],
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2025-07-31 17:02:23.928563",
|
||||
"modified": "2025-07-31 17:10:00.443783",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Jcloud",
|
||||
"name": "Jcloud Settings",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user