百度智能云

All Product Document

          CDN

          Acceleration Domain Name Management

          Create an Accelerated Domain Name

          The following code creates an accelerated domain name:

          public void testCreateDomain(CdnClient client) { 
              String domainName = “my.test.com”; 
              ArrayList<OriginPeer> origin = new ArrayList<OriginPeer>(); 
              origin.add(new OriginPeer().withPeer("1.2.3.4"));  //Add an origin server 1.2.3.4 
              origin.add(new OriginPeer().withPeer("2.3.4.5"));  //Add an origin server 2.3.4.5 
              CreateDomainRequest request = new CreateDomainRequest() 
                          .withDomain(domainName) 
                          .withOrigin(origin); 
              CreateDomainResponse response = client.createDomain(request); 
              System.out.println(response.getCname());  //Create successfully, and access corresponding CNAME 
          } 

          Note: Since the accelerated domain name is unique in all the domains, the domain should be ensured to be different from the accelerated domain names in the other domains

          Query all Domain Names under the Username

           public void listUserDomains() throws Exception { 
                  ListUserDomainsRequest request=new ListUserDomainsRequest(); 
                  request.setStatus("RUNNING"); 
                  request.setRule(""); 
                  List<Domain> domains = cdnClient.listUserDomains(request).getDomains(); 
                  System.out.println(domains); 
              } 

          View the List of Accelerated Domain Name

          The following code can list all the domain names of the user:

          public void listDomains (CdnClient client) { 
              //Get the accelerated domain name list of the user 
              List<Domain> domains = client.listDomains().getDomains(); 
              //Traverse the acceleration domain name 
              for (Domain domain : domains) { 
                  System.out.println(domain.getName()); 
              } 
          } 

          Delete the Accelerated Domain Name

          The following code deletes an accelerated domain name:

          public void deleteDomain (CdnClient client, String domainName) { 
              client.deleteDomain(domainName); 
          } 

          Query Whether the Domain Name Can be Added

              public void checkDomainValid(){ 
                  String domain="www.baidu.com"; 
                  DomainCanBeAddedResponse response = cdnClient.checkDomainCanBeAdded(domain); 
                  System.out.println(response); 
              } 

          Create an Accelerated Domain Name Interface

          public void testCreateDomain() { 
                  ArrayList<OriginPeer> origin = new ArrayList<OriginPeer>(); 
                  origin.add(new OriginPeer().withPeer("1.2.3.4")); 
                  origin.add(new OriginPeer().withPeer("2.3.4.5")); 
                  
                  CreateDomainRequest request = new CreateDomainRequest() 
                          .withDomain(DOMAIN) 
                          .withOrigin(origin); 
                  CreateDomainResponse response = cdnClient.createDomain(request); 
                  System.out.println(response.getCname()); 
              } 

          Interface to Enable the Accelerated Domain Name

              public void enableDomain(){ 
                  String domain="vd3.bdstatic.com"; 
                  EnableDomainResponse response = cdnClient.enableDomain(domain); 
                  System.out.println(response); 
              } 

          Interface to Disable the Accelerated Domain Name

           public void disableDomain(){ 
                  String domain="vd3.bdstatic.com"; 
                  DisableDomainResponse disableDomainResponse = cdnClient.disableDomain(domain); 
                  System.out.println(disableDomainResponse); 
              } 

          Query Whether the Domain Name is Filed

          public void getIcpStatus() { 
                  String domain="vd1.bdstatic.com"; 
                  IcpStatusRequest request=new IcpStatusRequest().withDoamin(domain); 
                  IcpStatusResponse response = cdnClient.getIcpStatus(request); 
                  System.out.println(response); 
              } 

          Single Domain Name Copy Interface

           public void copyDomainConfig() throws Exception { 
                  String domain="vd1.bdstatic.com"; 
                  CopyDomainConfigResponse copyDomainConfigResponse = cdnClient.copyDomainConfig(domain); 
                  System.out.println(copyDomainConfigResponse); 
              } 
          Previous
          CdnClient
          Next
          Domain Name Configuration