A chinac api operator
Project description
ChinacApi 星界链API
星界链OpenApi Python SDK
支持
- 获取云手机列表
- 获取云手机详情
- 重启云手机
- 开启/关闭云手机
- 获取云手机ADB白名单IP列表
- 设置云手机ADB白名单IP
- 获取本机在星界链的公网IP
安装
pip install chinacapi -i https://pypi.tuna.tsinghua.edu.cn/simple
使用
你需要先在星界链控制台申请访问密钥。
from chinacapi.cloud_phone_region import CloudPhoneRegion
from chinacapi.entity.cloud_phone import CloudPhone
from chinacapi.chinac_api import ChinacApi
# 创建 ChinacApi 实例
ca = ChinacApi('your_access_key', 'your_access_secret')
cpa = ca.cloud_phone_api # 云手机API
# 列出所有云手机
cpl = cpa.list_cloud_phone()
for cp in cpl:
print(cp)
# 通过ID构造云手机对象
cp = CloudPhone({
'id': 'cp-xxxxxxxxxxxxxx',
'region': CloudPhoneRegion.SZ,
})
# 获取云手机详情
print(cpa.describe_cloud_phone(cp.region, cp.id))
# 列出云手机ADB白名单
ips = cpa.list_cloud_phone_adb_white_ip(CloudPhoneRegion.SZ)
print(ips)
# 获取本机在星界链的公网IP
my_ip = ChinacApi.get_request_ip()
print(my_ip)
# 设置云手机ADB白名单
print(cpa.set_cloud_phone_adb_white_ip(CloudPhoneRegion.SZ, list(set(ips + my_ip))))
ips = cpa.list_cloud_phone_adb_white_ip(CloudPhoneRegion.SZ)
print(ips)
print(cpa.reboot_cloud_phone(cp)) # 重启云手机
print(cpa.start_cloud_phone(cp)) # 开启云手机
print(cpa.stop_cloud_phone(cp)) # 关闭云手机
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chinacapi-0.1.3.tar.gz
(6.7 kB
view details)
Built Distribution
File details
Details for the file chinacapi-0.1.3.tar.gz
.
File metadata
- Download URL: chinacapi-0.1.3.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f54451b1a5515930eaa753b9ab69e5b5cda8d103b462517a0a5be0ae5d11363d |
|
MD5 | 51e6875d23e155b77392d592a145a5a0 |
|
BLAKE2b-256 | 3ac08cc8cdcb2b7696d1eefa52b44160c955f3645473dd502889c64be883af70 |
File details
Details for the file chinacapi-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: chinacapi-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db84c2caa97ff41f3add3f02988424e4521cc06cd89c7c839b9ea781516e2b5b |
|
MD5 | 35667a6dfedca9da937fe8c6b4a6d19b |
|
BLAKE2b-256 | 306034eaeef15ae42ce55a774a87216725c9ebc32200b5f94ed14e78de4001f5 |