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

33 lines
1.2 KiB
Plaintext

async def create_bandwidth(ns={}):
import aiohttp
NETWORK_URL = 'http://cdsapi.capitalonline.net/vpc'
action = 'CreateBandwidth'
method = "POST"
param = {}
url = get_signature(action, method, NETWORK_URL, param=param)
body = {
"RegionCode": ns.get("RegionCode"),
"Name": ns.get("Name"),
"AvailableZoneCode": ns.get("AvailableZoneCode"),
"BandwidthType": ns.get("BandwidthType"),
"BillScheme": ns.get("BillScheme"),
"Qos": ns.get("Qos"),
"NETID": ns.get("NETID"),
}
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 create_bandwidth(params_kw)
return ret