加速域名管理
所有文档

          内容分发网络 CDN

          加速域名管理

          下列代码中对函数入参c即是CdnClient对象,详情参见CdnClient

          查询域名是否可添加

          def test_valid_domain(c):
              """
              test valid domain
              """
              response = c.valid_domain('test.example.com')
              print(response)

          新建加速域名

          case1:支持自定义源站端口,指定业务类型(form),默认回源host(defaultHost)

          def test_create_domain(c):
              """
              test_create_domain
              """
              origin = [
                          {'peer': 'http://1.2.3.2'}, # no port
                          {'peer': 'http://1.2.3.7:80'}, # set origin with http port
                          {'peer': 'https://1.2.3.9:443'}, # set origin with https port
                          {'peer': '1.2.3.1:8080'} # set origin with http port
                       ]
          
              other_config = {
                          "form":"image",
                          "defaultHost":"1.2.3.4"
                      }
          
              response = c.create_domain('test-sdk.sys-qa.com', origin, other_config)
              print(response)

          case2:创建域名时设置302跟随回源(follow302)

          def test_create_domain_with_follow302(c):
              """
              create_domain with origin follow302 config
              """
          
              origin = [
                  {'peer': '1.2.3.5'}
              ]
              other_config = {
                  "follow302": True
              }
          
              response = c.create_domain('example.test.com', origin, other_config)
              print(response)

          注意:由于加速域名在所有区域中是唯一的,所以需要保证domain不与其他所有区域上的加速域名名称相同。

          查看加速域名列表

          def test_list_domains(c):
              """
              test_list_domains
              """
              response = c.list_domains()
              print(response)

          查看用户名下所有域名及其状态

          def test_list_user_domains(c):
              """
              test list user domains with status,rule
              """
              status = 'ALL'
              rule = None
          
              response = c.list_user_domains(status, rule)
              print(response)

          查看域名全量配置

          def test_get_domain_config(c):
              """
              test_get_domain_config
              """
              response = c.get_domain_config('test.example.com')
              print(response)

          删除加速域名

          def test_delete_domain(c):
              """
              test_delete_domain
              """
              response = c.delete_domain('example.test.com')
              print(response)
          上一篇
          CdnClient
          下一篇
          缓存管理