-- 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("请求错误,请查看用户认证信息是否正确")