当前位置:   article > 正文

Python 华为云CDN更新_python 华为云cdn 更新

python 华为云cdn 更新
import os
from openstack import connection
import sys
os.environ.setdefault('OS_CDN_ENDPOINT_OVERRIDE',
                      'https://cdn.myhuaweicloud.com/v1.0/')  # CDN API url,example:https://cdn.myhuaweicloud.com/v1.0/

class REFRESH_TASK(object):

    def __init__(self):
        # AKSK Auth
        self.projectId = ""  # Project ID of cn-north-1
        self.cloud = "myhuaweicloud.com"  # cdn use: cloud = "myhuaweicloud.com"
        self.region = ""  # example: region = "cn-north-1"
        self.AK = ""
        self.SK = ""
        self.conn = connection.Connection(
                    project_id=self.projectId,
                    cloud=self.cloud,
                    region=self.region,
                    ak=self.AK,
                    sk=self.SK)

    def refresh_create(self, _refresh_task):
        # print("refresh files or dirs:")
        task = self.conn.cdn.create_refresh_task(**_refresh_task)
        print(task)

if __name__ == "__main__":
    # urls 更新的链接
    urls = sys.argv[1]
    refresh_dir_task = {
        "type": "directory",
        "urls": [urls]
    }
    # refresh_create(refresh_file_task)
    refresh_task = REFRESH_TASK()
    refresh_task.refresh_create(refresh_dir_task)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/579762
推荐阅读
相关标签
  

闽ICP备14008679号