kboss/b/capital/describe_eip.dspy
2025-07-16 14:27:17 +08:00

34 lines
1.3 KiB
Plaintext

async def describe_eip(ns={}):
import aiohttp
NETWORK_URL = 'http://cdsapi.capitalonline.net/vpc'
action = 'DescribeEIP'
method = "POST"
param = {}
url = get_signature(action, method, NETWORK_URL, param=param)
body = {
"RegionCode": ns.get('RegionCode')
}
async with aiohttp.ClientSession() as session:
async with session.request(method, url, json=body) as response:
resp = await response.text()
result = json.loads(resp)
if result['Code'] == 'Success':
result['status'] = True
result.pop('Code')
result['data'] = result.pop('Data')
if result['data']['Total'] > 0:
new_eip_li = []
for eip in result['data']['EIPList']:
if ns.get('orgid') in eip['Description']:
eip['Description'] = eip['Description'].split('0_____0')[-1]
new_eip_li.append(eip)
result['data']['EIPList'] = new_eip_li
result['data']['Total'] = len(new_eip_li)
result['msg'] = result.pop('Message')
else:
result['status'] = False
result['msg'] = result.pop('Message')
return result
ret = await describe_eip(params_kw)
return ret