内容分发网络CDN

    访问配置接口

    设置访问Referer控制

    public void testSetDomainRefererACL() {
            RefererACL acl = new RefererACL()
                    .addBlackList("http://a.com")
                    .addBlackList("http://b.com");
            SetDomainRefererACLRequest request = new SetDomainRefererACLRequest()
                   .withDomain("vd1.bdstatic.com")
                   .withRefererACL(acl);
            cdnClient.setDomainRefererACL(request);
        }

    查询访问Referer控制

    public void getDomainRefererACL(){
            GetDomainRefererACLResponse response=cdnClient.getDomainRefererACL(DOMAIN);
            System.out.println(response);
        }

    设置访问IP控制

    public void testSetDomainIpACL() {
            IpACL acl = new IpACL()
                    .addBlackList("1.2.3.4")
                    .addBlackList("5.6.7.0/24");
            SetDomainIpACLRequest request = new SetDomainIpACLRequest()
                   .withDomain(DOMAIN)
                   .withIpACL(acl);
            cdnClient.setDomainIpACL(request);
        }

    查询访问IP控制

     public void getDomainIpACL(){
            GetDomainIpACLResponse response = cdnClient.getDomainIpACL(DOMAIN);
            System.out.println(response);
        }

    设置访问鉴权

    public void testSetRequestAuth() {
            RequestAuth requestAuth = new RequestAuth()
                    .withType("a")
                    .withKey1("secretkey1");
            cdnClient.setRequestAuth(DOMAIN,requestAuth);
        }

    设置域名限速

     public void setTrafficLimit() {
            TrafficLimit trafficLimit=new TrafficLimit();
            trafficLimit.withEnable(true).withLimitRate(10485760).withLimitStartHour(10).withLimitEndHour(19)
                    .withLimitRateAfter(0).withTrafficLimitArg("rate").withTrafficLimitUnit("m");
            SetTrafficLimitResponse response = cdnClient.setTrafficLimit(DOMAIN, trafficLimit);
            System.out.println(response);
        }

    设置Cors跨域

     public void setCorsConfig(){
            String domain="vd3.bdstatic.com";
            CorsConfig cors=new CorsConfig()
                    .withAllow("on")
                    .addOrigin("http://www.baidu.com")
                    .addOrigin("http://*.bce.com");
            SetCorsConfigResponse response = cdnClient.setCorsConfig(domain, cors);
            System.out.println(response);
        }

    查询Cors跨域

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

    设置IP访问限频

     public void setAccessLimit(){
            String domain="vd3.bdstatic.com";
            AccessLimit accessLimit=new AccessLimit().withEnabled(true).withLimit(200);
            SetAccessLimitResponse response = cdnClient.setAccessLimit(domain, accessLimit);
            System.out.println(response);
        }

    查询IP访问限频

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

    设置获取真实用户IP

    public void setObtainClientIp(){
            String domain="vd3.bdstatic.com";
            ClientIp clientIp = new ClientIp(true,"X-Real-IP");
            SetObtainClientIpResponse response = cdnClient.setObtainClientIp(domain, clientIp);
            System.out.println(response);
        }

    查询获取真实用户IP

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

    查询域名限速

     public void getTrafficLimit() {
            String domain="imagete11.changxin.com";
            GetTrafficLimitResponse resp = cdnClient.getTrafficLimit(domain);
            System.out.println(resp);
        }

    设置访问ua控制

     public void setUaAcl(){
            String domain="vd3.bdstatic.com";
            List<String> whiteList=new ArrayList<String>();
            whiteList.add("MQQBrowser/5.3/Mozilla/5.0");
            whiteList.add("Mozilla/5.0 (Linux; Android 7.0");
            UaAcl uaAcl=new UaAcl().withWhiteList(whiteList);
            SetUaAclResponse response = cdnClient.setUaAcl(domain, uaAcl);
            System.out.println(response);
        }

    查询访问ua控制

    public void getUaAcl(){
            String domain="vd3.bdstatic.com";
            GetUaAclResponse response = cdnClient.getUaAcl(domain);
            System.out.println(response);
        }
    上一篇
    缓存配置接口
    下一篇
    回源配置接口