• 华为云 缓存过期 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)
  • 相关阅读:
    vue 相对其他热门 框架 优点 --- 待续
    vue router 只需要这么几步
    正则表达式
    MySQL数据库优化的八种方式
    Django REST Framework 最佳实践
    Node.js ZLIB
    Node.js 虚拟机
    Node.js 实用工具
    Node.js URL
    Node.js UDP/Datagram
  • 原文地址:https://www.cnblogs.com/fengjian2016/p/13489587.html
Copyright © 2020-2023  润新知