内容分发网络CDN

    回源配置

    设置回源地址

    example 1

    def test_set_domain_origin(self):
        """
        test_set_domain_origin
        """
        error = None
        try:
            origin = [
                        {'peer': '1.2.3.4', 'host': 'www.origin_host.com'}, #回源地址1.2.3.4,回源Host www.origin_host.com,不配置则默认使用加速域名
                        {'peer': '1.2.3.5', 'host': 'www.origin_host.com'}
                     ]
            response = self.cdn_client.set_domain_origin('opencdn3.sys-qa.com', origin)
            print response
        except BceServerError as e:
            error = e
        finally:
            self.assertIsNone(error)

    example 2——设置自定义源站端口

    def test_set_domain_origin_with_port(self):
        """
        test_set_domain_origin_with_port
        """
        error = None
        try:
            origin = [
                {'peer': '1.2.3.4', 'host': 'www.originhost.com'},
                {'peer': '1.2.3.5', 'host': 'www.originhost.com'},
                {'peer': 'http://1.2.3.8:80', 'host': 'www.originhost.com'}, # set origin with http port
                {'peer': 'https://1.2.3.8:443', 'host': 'www.originhost.com'}, # set origin with https port
                {'peer': '1.2.3.9:8080', 'host': 'www.originhost.com'} # set origin with http port
             ]
            response = self.cdn_client.set_domain_origin('test-sdk.sys-qa.com', origin)
            print(response)
        except BceServerError as e:
            error = e
        finally:
            self.assertIsNone(error)

    设置 Range 回源

    def test_set_domain_range_switch(c):
        """
        test set domain range switch
        """
        range_switch = True
        domain = 'test-sdk.sys-qa.com'
        response = c.set_domain_range_switch(domain, range_switch);
        print(response)

    查询 Range 回源

    def test_get_domain_range_switch(c):
        """
        test get domain range switch
        """
        response = c.get_domain_range_switch('test-sdk.sys-qa.com')
        print(response)

    设置移动访问控制

    def test_set_domain_mobile_access(c):
        """
        test set domain mobile access 
        """
        mobile_access = {
            "distinguishClient": True
        }
        domain = 'test-sdk.sys-qa.com'
        response = c.set_domain_mobile_access(domain, mobile_access);
        print(response)

    查询移动访问控制

    def test_get_domain_mobile_access(c):
        """
        test get domain mobile access
        """
        response = c.get_domain_mobile_access('test-sdk.sys-qa.com')
        print(response)
    上一篇
    缓存配置
    下一篇
    访问控制