百度智能云

All Product Document

          CDN

          Forward-to-origin Setting

          Set Origin Address

          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'}, #The forward-to-origin address is 1.2.3.4 and the forward-to-origin Host is www.origin_host.com. The acceleration domain name is used by default if it is not configured. 
                              {'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——Set the customized origin server port

          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) 

          Set Range Origin

          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) 

          Query Range Origin

          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) 

          Set Mobile Access Control

          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) 

          Query Mobile Access Control

          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) 
          Previous
          Access Control
          Next
          Cache Management