• 华为云 缓存过期 python 脚本


    华为云 缓存过期 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)
  • 相关阅读:
    javascript运动系列第二篇——变速运动
    深入学习jQuery动画控制
    深入学习jQuery动画队列
    深入学习jQuery自定义动画
    深入学习jQuery的三种常见动画效果
    深入学习jQuery鼠标事件
    深入学习jQuery事件对象
    深入学习jQuery事件绑定
    只想显示日期不想显示时间
    The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
  • 原文地址:https://www.cnblogs.com/fengjian2016/p/13489587.html
Copyright © 2020-2023  润新知