Kazoo API的包装器
项目描述
安装
从pip安装
pip install kazoo-sdk
认证
可以使用用户名/密码对进行认证
>>>import kazoo >>>client = kazoo.Client(username='myusername', password='mypassword', account_name='my account name', base_url='http://api.example.com:8000/v1') >>>client.authenticate()
或使用API密钥
>>>import kazoo >>>client = kazoo.Client(api_key="sdfasdfas") >>>client.authenticate()
默认API URL为:‘http://api.2600hz.com:8000/v1’。您可以通过向kazoo.Client()提供一个额外的参数“base_url”来覆盖此设置。
覆盖‘base_url’的示例
>>>client = kazoo.Client(base_url='http://api.example.com:8000/v1', api_key="sdfasdfas")
需要数据的API调用以名为‘data’的必需参数形式接收它,它是方法中的最后一个参数。例如
>>>client.update_account(acct_id, {"name": "somename", "realm":"superfunrealm"})
字典和列表将自动转换为适当的表示形式,因此您可以进行类似的操作
>>>client.update_callflow(acct_id, callflow_id, {"flow":{"module":"somemodule"}})
无效数据将导致异常,解释问题
服务器响应作为每个方法的Python字典返回,例如
>>>client.get_account(acct_id) {'auth_token': 'abc437daf8517d0454cc984f6f09daf3', 'data': {'billing_mode': 'normal', 'caller_id': {}, 'caller_id_options': {}, 'id': 'c4f64412ad0057222c12559a3e7da011', 'media': {'bypass_media': 'auto'}, 'music_on_hold': {}, 'name': 'test3', 'notifications': {}, 'realm': '4c8b50.sip.2600hz.com', 'superduper_admin': False, 'timezone': 'America/Los_Angeles', 'wnm_allow_additions': False}, 'request_id': 'ea6441422fb85f67ad21db4f1e2326c1', 'revision': '3-c16dd0a629fe1da254fe1e7b3e5fb35a', 'status': 'success'}
对于kazoo API公开的每个资源,客户端上都有相应的功能。例如,对于‘callflows’资源,对应关系如下。
GET /accounts/{account_id}/callflows -> client.get_callflows(acct_id) GET /accounts/{account_id}/callflows/{callflow_id} -> client.get_callflow(acct_id, callflow_id) PUT /accounts/{account_id}/callflows/ -> client.create_callflow(acct_id, data) POST /account/{account_id}/callflows/{callflow_id} -> client.update_callflow(acct_id, data) DELETE /account/{account_id}/callflows/{callflow_id} -> client.delete_callflow(acct_id, callflow_id)
一些资源没有所有方法都可用,在这种情况下,它们不在客户端上。
还有一些资源不完全符合这个范例,它们是
GET /accounts/{account_id}/media -> client.get_all_media(acct_id) GET /accounts/{account_id}/children -> client.get_account_children(acct_id) GET /accounts/{account_id}/descendants -> client.get_account_descendants(acct_id) GET /accounts/{account_id}/devices/status -> client.get_all_devices_status(acct_id) GET /accounts/{account_id}/servers/{server_id}/deployment -> client.get_deployment(acct_id, server_id) GET /accounts/{account_id}/users/hotdesk -> client.get_hotdesk(acct_id)
卡兹乌 Rest API 文档可在以下网址查看:https://2600hz.atlassian.net/wiki/display/APIs/Configuration+APIs
您可以在以下网址查看可用客户端方法列表:https://kazoo-api.readthedocs.org/en/latest/
项目详情
关闭
kazoo-sdk-0.2.4.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 34db426d1adc1ebe5ea7b4159b3e02043a7ee22bfe128913d0aad28e39a72da9 |
|
MD5 | bc9e1253f0eaa64644bca8f72122ac38 |
|
BLAKE2b-256 | 9baca07916be9a61ebba93c1f8dc5b01cdc317b4514515a86dbd710a28dab24e |