Created
March 11, 2019 10:55
-
-
Save lqqyt2423/00a7fbc5d8f675588bc7359c4afc575e to your computer and use it in GitHub Desktop.
python 调用阿里云 sdk 示例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf8 -*- | |
# 调试模式 | |
# DEBUG=sdk python3 main.py | |
import json | |
from aliyunsdkcore.client import AcsClient | |
from aliyunsdkcore.acs_exception.exceptions import ClientException | |
from aliyunsdkcore.acs_exception.exceptions import ServerException | |
from aliyunsdkcdn.request.v20180510 import DescribeCdnServiceRequest | |
from aliyunsdkcdn.request.v20180510 import RefreshObjectCachesRequest | |
from aliyunsdkcdn.request.v20180510 import DescribeRefreshTasksRequest | |
client = AcsClient( | |
'key', | |
'secret', | |
'cn-hangzhou' | |
) | |
# 查询CDN服务状态 | |
# req = DescribeCdnServiceRequest.DescribeCdnServiceRequest() | |
# res = client.do_action_with_exception(req) | |
# res = json.loads(res) | |
# res = json.dumps(res, indent=2) | |
# print(res) | |
# 刷新节点上的文件内容 | |
# req = RefreshObjectCachesRequest.RefreshObjectCachesRequest() | |
# req.set_ObjectPath('path') | |
# req.set_ObjectType('Directory') | |
# res = client.do_action_with_exception(req) | |
# # { | |
# # "RefreshTaskId": "", | |
# # "RequestId": "" | |
# # } | |
# res = json.loads(res) | |
# print(json.dumps(res, indent=2)) | |
# 查询刷新、预热状态是否在全网生效 | |
req = DescribeRefreshTasksRequest.DescribeRefreshTasksRequest() | |
req.set_TaskId('task_id') | |
res = client.do_action_with_exception(req) | |
res = json.loads(res) | |
print(json.dumps(res, indent=2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment