华为云 缓存过期 python 脚本
[root@jenkins tools]# cat refreshTask.py # -*- coding:utf-8 -*- import os from openstack import connection os.environ.setdefault('OS_CDN_ENDPOINT_OVERRIDE', 'https://cdn.myhuaweicloud.com/v1.0/') # CDN API url,example:https://cdn.myhuaweicloud.com/v1.0/ # AKSK Auth projectId = "0539e8c1e700260a2fbec0160d871c9c" # Project ID of cn-north-1 cloud = "myhuaweicloud" # cdn use: cloud = "myhuaweicloud.com" region = "cn-north-1" # example: region = "cn-north-1" AK = "xxxxxxx" SK = "xxxxx" conn = connection.Connection( project_id=projectId, cloud=cloud, region=region, ak=AK, sk=SK) # token Auth # username = "xxxxxxxxxxx" # IAM User Name # password = "xxxxxxxxxxx" # IAM User Password # projectId = "xxxxxxxxxxx" # Project ID of cn-north-1 # userDomainId = "xxxxxxxxxxx" # Account ID # auth_url = "xxxxxxxxxxx" # IAM auth url,example: https://iam.myhuaweicloud.com/v3 # # conn = connection.Connection( # auth_url=auth_url, # user_domain_id=userDomainId, # project_id=projectId, # username=username, # password=password # ) # new version API # part 3: Refreshing and Preheating # Creating a Cache Refreshing Task def refresh_create(_refresh_task): print("refresh files or dirs:") task = conn.cdn.create_refresh_task(**_refresh_task) print(task) if __name__ == "__main__": # new version API # part 3: Refreshing and Preheating # Creating a Cache Refreshing Task # refresh_file_task = { # "type": "file", # "urls": ["xxxxxxxxxxx", # "xxxxxxxxxxx"] # } refresh_dir_task = { "type": "directory", "urls": ["https://static.xxxxx.com/home/", "https://static.xxxxx.com/learn/"] } # refresh_create(refresh_file_task) refresh_create(refresh_dir_task)