# -*- coding: utf-8 -*- import json import sys from tencentcloud.common import credential from tencentcloud.common.profile.client_profile import ClientProfile from tencentcloud.common.profile.http_profile import HttpProfile from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException from tencentcloud.cdn.v20180606 import cdn_client, models if sys.argv.__len__() == 2: try: path = sys.argv[1] cred = credential.Credential("AKID5IPM91qVwNfjqu01uv5F7oHQcgZP4ncY", "lvtjOuLYWKzVt66yd3IJ5cr9Qju43nR0") httpProfile = HttpProfile() httpProfile.endpoint = "cdn.tencentcloudapi.com" clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile client = cdn_client.CdnClient(cred, "", clientProfile) req = models.PurgePathCacheRequest() params = { "Paths": [ path ], "FlushType": "flush" } req.from_json_string(json.dumps(params)) resp = client.PurgePathCache(req) print(resp.to_json_string()) except TencentCloudSDKException as err: print(err) else: print("params error!")