阿里雲平臺,使用sdk刷新cdn(python3環境)

-- coding: utf-8 --
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkcdn.request.v20180510.RefreshObjectCachesRequest import RefreshObjectCachesRequest

class PushCdn(object):

def __init__(self,acessid,secert,domain):

    self.__acessid = acessid
    self.__secert = secert
    self.__domain = domain
    self.acessdir = "Directory"
    self.china = "cn-beijing"

def Flush_Dir(self):
    try:
        client = AcsClient(self.__acessid, self.__secert, self.china)
        request = RefreshObjectCachesRequest()
        request.set_accept_format("json")
        request.set_ObjectPath(self.__domain)
        request.set_ObjectType(self.acessdir)
        responce = client.do_action_with_exception(request)
        print(responce)
    except Exception:
        print("請求錯誤,請查看用戶認證信息是否正確")
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章