Skip to content

Commit db3895f

Browse files
author
Joshua Yin
committed
* api-刷新缓存
1 parent 36e4af3 commit db3895f

4 files changed

Lines changed: 136 additions & 0 deletions

File tree

ucloud-sdk-java-ucdn/src/main/java/cn/ucloud/ucdn/client/DefaultUcdnClient.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,19 @@ public void prefetchNewUcdnDomainCache(PrefetchNewUcdnDomainCacheParam param, Uc
258258
} catch (Exception e) {
259259
}
260260
}
261+
262+
@Override
263+
public RefreshNewUcdnDomainCacheResult refreshNewUcdnDomainCache(RefreshNewUcdnDomainCacheParam param) throws Exception {
264+
UcloudHttp http = new UcloudHttpImpl(RefreshNewUcdnDomainCacheResult.class);
265+
return (RefreshNewUcdnDomainCacheResult) http.doGet(param, config, null);
266+
}
267+
268+
@Override
269+
public void refreshNewUcdnDomainCache(RefreshNewUcdnDomainCacheParam param, UcloudHandler<RefreshNewUcdnDomainCacheResult> handler, Boolean... asyncFlag) {
270+
UcloudHttp http = new UcloudHttpImpl(RefreshNewUcdnDomainCacheResult.class);
271+
try {
272+
http.doGet(param, config, handler, asyncFlag);
273+
} catch (Exception e) {
274+
}
275+
}
261276
}

ucloud-sdk-java-ucdn/src/main/java/cn/ucloud/ucdn/client/UcdnClient.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,22 @@ public interface UcdnClient extends UcloudClient {
301301
* @param asyncFlag 异步标记,默认异步true
302302
*/
303303
void prefetchNewUcdnDomainCache(PrefetchNewUcdnDomainCacheParam param, UcloudHandler<PrefetchNewUcdnDomainCacheResult> handler, Boolean... asyncFlag);
304+
305+
/**
306+
* 刷新缓存
307+
*
308+
* @param param 参数对象
309+
* @return 结果对象
310+
* @throws Exception 出错则抛出异常
311+
*/
312+
RefreshNewUcdnDomainCacheResult refreshNewUcdnDomainCache(RefreshNewUcdnDomainCacheParam param) throws Exception;
313+
314+
/**
315+
* 刷新缓存
316+
*
317+
* @param param 参数对象
318+
* @param handler 回调处理器
319+
* @param asyncFlag 异步标记,默认异步true
320+
*/
321+
void refreshNewUcdnDomainCache(RefreshNewUcdnDomainCacheParam param, UcloudHandler<RefreshNewUcdnDomainCacheResult> handler, Boolean... asyncFlag);
304322
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package cn.ucloud.ucdn.model;
2+
3+
import cn.ucloud.common.annotation.UcloudParam;
4+
import cn.ucloud.common.pojo.BaseRequestParam;
5+
import cn.ucloud.common.pojo.Param;
6+
7+
import javax.validation.ValidationException;
8+
import javax.validation.constraints.NotEmpty;
9+
import javax.validation.constraints.NotNull;
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
13+
14+
/**
15+
* @description: 刷新缓存 param
16+
* @author: joshua
17+
* @E-mail: joshua.yin@ucloud.cn
18+
* @date: 2020/8/6 15:59
19+
*/
20+
public class RefreshNewUcdnDomainCacheParam extends BaseRequestParam {
21+
22+
/**
23+
* 刷新类型,file代表文件刷新,dir 代表路径刷新
24+
*/
25+
@UcloudParam("Type")
26+
@NotEmpty(message = "Type can not be empty")
27+
private String type;
28+
29+
/**
30+
* 预热URL列表,n从自然数0开始。UrlList.n字段必须以“http://域名/”开始。目录要以“/”结尾,
31+
* 如刷新目录a下所有文件,格式为:http://abc.ucloud.cn/a/;如刷新文件目录a下面img.png文件,格式为http://abc.ucloud.cn/a/img.png。
32+
* 请正确提交需要刷新的域名
33+
*/
34+
@NotNull(message = "UrlList can not be null")
35+
private List<String> urlList;
36+
37+
@UcloudParam("UrlList")
38+
public List<Param> checkUrlList() throws ValidationException {
39+
List<Param> list = new ArrayList<>();
40+
if (urlList == null || urlList.isEmpty()) {
41+
throw new ValidationException("urlList can not be empty");
42+
} else {
43+
for (int i = 0, len = urlList.size(); i < len; i++) {
44+
if (urlList.get(i) == null || urlList.get(i).length() < 1) {
45+
throw new ValidationException(String.format("urlList[%d] can not be empty", i));
46+
} else {
47+
Param param = new Param(String.format("UrlList.%d", i), urlList.get(i));
48+
list.add(param);
49+
}
50+
}
51+
}
52+
return list;
53+
}
54+
55+
public RefreshNewUcdnDomainCacheParam(@NotEmpty(message = "Type can not be empty") String type,
56+
@NotNull(message = "UrlList can not be null") List<String> urlList) {
57+
super("RefreshNewUcdnDomainCache");
58+
this.type = type;
59+
this.urlList = urlList;
60+
}
61+
62+
public String getType() {
63+
return type;
64+
}
65+
66+
public void setType(String type) {
67+
this.type = type;
68+
}
69+
70+
public List<String> getUrlList() {
71+
return urlList;
72+
}
73+
74+
public void setUrlList(List<String> urlList) {
75+
this.urlList = urlList;
76+
}
77+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cn.ucloud.ucdn.model;
2+
3+
import cn.ucloud.common.pojo.BaseResponseResult;
4+
import com.google.gson.annotations.SerializedName;
5+
6+
/**
7+
* @description: 刷新缓存 result
8+
* @author: joshua
9+
* @E-mail: joshua.yin@ucloud.cn
10+
* @date: 2020/8/12 12:58
11+
*/
12+
public class RefreshNewUcdnDomainCacheResult extends BaseResponseResult {
13+
/**
14+
* 本次提交url对应的任务id
15+
*/
16+
@SerializedName("TaskId")
17+
private String taskId;
18+
19+
public String getTaskId() {
20+
return taskId;
21+
}
22+
23+
public void setTaskId(String taskId) {
24+
this.taskId = taskId;
25+
}
26+
}

0 commit comments

Comments
 (0)