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

35 lines
1.2 KiB
Plaintext

async def eip_batch_bind_and_reserve_ip(ns={}):
import aiohttp
NETWORK_URL = 'http://cdsapi.capitalonline.net/vpc'
action = 'ReserveIPAndBindEIP'
method = "POST"
param = {}
url = get_signature(action, method, NETWORK_URL, param=param)
body = {
"AvailableZoneCode": ns.get('AvailableZoneCode'),
"Ips": [
{
"NetId": ns.get('NetId'),
"AddressList": json.loads(ns.get('AddressList')),
"EIPList": json.loads(ns.get('EIPList')),
"Description": ns.get('Description')
}
]
}
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')
result['msg'] = result.pop('Message')
else:
result['status'] = False
result['msg'] = result.pop('Message')
return result
ret = await eip_batch_bind_and_reserve_ip(params_kw)
return ret