from appPublic.dictObject import DictObject from appPublic.oauth_client import OAuthClient api_desc = { "data":{ "apikey":'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJHcm91cE5hbWUiOiJtb3FpbmcgeXUiLCJVc2VyTmFtZSI6Im1vcWluZyB5dSIsIkFjY291bnQiOiIiLCJTdWJqZWN0SUQiOiIxNzY4NTM3NjQ1ODMyNDg3NjAyIiwiUGhvbmUiOiIxMzgwMTAxNTI5MiIsIkdyb3VwSUQiOiIxNzY4NTM3NjQ1ODI4MjkyOTMwIiwiUGFnZU5hbWUiOiIiLCJNYWlsIjoiIiwiQ3JlYXRlVGltZSI6IjIwMjQtMDQtMTAgMTg6MDA6NTMiLCJpc3MiOiJtaW5pbWF4In0.VaRRHr9XMUSYhZOKVS2PRZv6Y9VCaW4JX2ks4QZX3aFr_emjnDbGv5HfNskf54piflEAeTMW4Qw1nG7bqhYea7N5LKHGf0YpesPGSoqxwyZUR4oaJNNVUsSe6eiLbdYSDO2wMb_hV5xyawh-lYe1reBKWaPVuOjfTrDhxzA0IBmzl-jAQhL8-kIZet2uX-p3NjxElpo_zjmVV_hA1BJEvTwuAk8ka-1SBZmXciMhBi1fJG4jcqoHCCN_JHJ7pgjKr5bk2Zw5qCqiU2Ecsc-kPIEK1SI5EYoLszT43UpJ8_wV4Pm07UBCn3vktAa0fjKDSUArPkBoYWSkgKDMWlmxig', "group_id":'1768537645828292930' }, "sub_account":{ "path":"/v1/sub_account", "method":"POST", "headers":[ { "name":"Content-Type", "value":"application/json" }, { "name":"Authorization", "value":"Bearer ${apikey}" } ], "params":[ { "name":"GroupId", "value":"${group_id}" } ], "data":[ { "name":"account_name", "value":"${account_name}" } ], "resp":[ { "name":"subject_id", "resp_keys":"subject_id" }, { "name":"account_name", "resp_keys":"account", }, { "name":"password", "resp_keys":"password" }, { "name":"group_id", "resp_keys":"group_id" }, { "name":"apikey", "resp_keys":"token" } ], "error_if":{ "error_keys":"base_resp.status_code", "op":"!=", "value":0, "code_keys":"base_resp.status_code", "msg_keys":"base_resp.status_msg" } }, "sub_delete":{ "path":"/v1/sub_account/${sub_account_id}", "method":"DELETE", "headers":[ { "name":"Content-Type", "value":"application/json" }, { "name":"Authorization", "value":"Bearer ${apikey}" } ], "params":[ { "name":"GroupId", "value":"${group_id}" } ], "error_if":{ "error_keys":"base_resp.status_code", "op":"!=", "value":0, "code_keys":"base_resp.status_code", "msg_keys":"base_resp.status_msg" } }, "change_sub_status":{ "path":"/v1/sub_account/${sub_account_id}/status", "method":"PUT", "headers":[ { "name":"Content-Type", "value":"application/json" }, { "name":"Authorization", "value":"Bearer ${apikey}" } ], "params":[ { "name":"GroupId", "value":"${group_id}" } ], "data":[ { "name":"status", "value":"${status}" } ], "error_if":{ "error_keys":"base_resp.status_code", "op":"!=", "value":0, "code_keys":"base_resp.status_code", "msg_keys":"base_resp.status_msg" } }, "change_sub_apikey":{ "path":"/v1/sub_account/${sub_account_id}/token", "method":"PUT", "headers":[ { "name":"Content-Type", "value":"application/json" }, { "name":"Authorization", "value":"Bearer ${apikey}" } ], "params":[ { "name":"GroupId", "value":"${group_id}" } ], "resp":[ { "name":"apikey", "resp_keys":"token" } ], "error_if":{ "error_keys":"base_resp.status_code", "op":"!=", "value":0, "code_keys":"base_resp.status_code", "msg_keys":"base_resp.status_msg" } }, "get_sub_bill":{ "path":"/v1/sub_account/${sub_account_id}/bill", "method":"GET", "headers":[ { "name":"Content-Type", "value":"application/json" }, { "name":"Authorization", "value":"Bearer ${apikey}" } ], "params":[ { "name":"GroupId", "value":"${group_id}" }, { "name":"method", "value":"${bill_type}" } ], "resp":[ { "name":"bills", "resp_keys":"bill_list" } ], "error_if":{ "error_keys":"base_resp.status_code", "op":"!=", "value":0, "code_keys":"base_resp.status_code", "msg_keys":"base_resp.status_msg" } }, "bill":{ "path":"/v1/batch_query_bill", "method":"GET", "headers":[ { "name":"Content-Type", "value":"application/json" }, { "name":"Authorization", "value":"Bearer ${apikey}" } ], "params":[ { "name":"GroupId", "value":"${group_id}" }, { "name":"start_date", "value":"${start_date}" }, { "name":"end_date", "value":"${end_date}" } ], "resp":[ { "name":"bills", "resp_keys":"bill_list" } ], "error_if":{ "error_keys":"base_resp.status_code", "op":"!=", "value":0, "code_keys":"base_resp.status_code", "msg_keys":"base_resp.status_msg" } } } if __name__ == '__main__': import asyncio async def main(): m = OAuthClient(DictObject(**api_desc)) # sub_account test ok # resp = await m('https://api.minimax.chat', 'sub_account', {'account_name':'test1'}) # sub_delete test ok # resp = await m('https://api.minimax.chat', 'sub_delete', {'sub_account_id':'1765984131482656836'}) # change_sub_status test ok # resp = await m('https://api.minimax.chat', 'change_sub_status', # {'sub_account_id':'1766027179931476048', 'status':0}) # change_sub_apikey test ok # resp = await m('https://api.minimax.chat', 'change_sub_apikey', # {'sub_account_id':'1766027179931476048'}) # get_sub_bill test, wait data to check # resp = await m('https://api.minimax.chat', 'get_sub_bill', # {'sub_account_id':'1766027179931476048', # bill test ok resp = await m('https://api.minimax.chat', 'bill', { 'start_date':'20240419', 'end_date':'20240419'}) print(resp) async def t(): for i in range(100): await main() with open('t.py', 'r') as f: print('-------------------',f.fileno()) asyncio.get_event_loop().run_until_complete(main())