Skip to content

Commit 1f218fd

Browse files
author
fengyikai
committed
内容分发网络(cdn):GetBillingData提高qpm
1 parent ac2d788 commit 1f218fd

36 files changed

Lines changed: 3331 additions & 293 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.ksyun</groupId>
88
<artifactId>ksyun-java-sdk</artifactId>
9-
<version>1.8.6.34</version>
9+
<version>1.8.6.35</version>
1010
<packaging>jar</packaging>
1111

1212
<name>KSYUN SDK for Java</name>
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
package ksyun.client.cdn.deletehttpheadersconfig.v3;
2+
3+
import com.alibaba.fastjson.JSON;
4+
import com.alibaba.fastjson.JSONObject;
5+
import common.BaseClient;
6+
import common.Credential;
7+
import common.RpcRequestContentModel;
8+
import common.utils.RequestHelpUtils;
9+
import common.utils.RpcRequestClient;
10+
import lombok.extern.slf4j.Slf4j;
11+
12+
import java.util.*;
13+
14+
/**
15+
* @Classname DeleteHttpHeadersConfigClient
16+
* @Description 删除Http响应头
17+
*/
18+
@Slf4j
19+
public class DeleteHttpHeadersConfigClient extends BaseClient {
20+
private final static String service = "cdn";
21+
private final static String version = "V3";
22+
private final static String action = "DeleteHttpHeadersConfig";
23+
24+
25+
/**
26+
* 证书
27+
*/
28+
private Credential credential;
29+
30+
31+
public DeleteHttpHeadersConfigClient(Credential credential) {
32+
this.credential = credential;
33+
}
34+
35+
36+
/**
37+
* post请求
38+
*
39+
* @param path
40+
* @param requestObj
41+
* @return
42+
* @throws Exception
43+
*/
44+
public DeleteHttpHeadersConfigResponse doPost(String path, DeleteHttpHeadersConfigRequest requestObj) throws Exception {
45+
Map<String, String> head = new HashMap<>();
46+
head.put("Content-Type", "application/x-www-form-urlencoded");
47+
return doPost(path, requestObj, head);
48+
}
49+
50+
/**
51+
* post请求
52+
*
53+
* @param path
54+
* @param requestObj
55+
* @param head
56+
* @return
57+
* @throws Exception
58+
*/
59+
public DeleteHttpHeadersConfigResponse doPost(String path, DeleteHttpHeadersConfigRequest requestObj, Map<String, String> head) throws Exception {
60+
final Map<String, String> requestHeaders = head != null ? new HashMap<>(head) : new HashMap<>();
61+
requestHeaders.putIfAbsent("Content-Type", "application/x-www-form-urlencoded");
62+
String response = doRpc(path, requestObj, requestHeaders, "post");
63+
return JSON.parseObject(response, DeleteHttpHeadersConfigResponse.class);
64+
}
65+
66+
/**
67+
* post 请求
68+
* @param path
69+
* @param requestObj
70+
* @return
71+
* @throws Exception
72+
*/
73+
public DeleteHttpHeadersConfigResponse doPostRaw(String path, DeleteHttpHeadersConfigRequest requestObj) throws Exception {
74+
Map<String, String> head = new HashMap<>();
75+
head.put("Content-Type", "application/x-www-form-urlencoded");
76+
return doPostRaw(path, requestObj, head);
77+
}
78+
79+
/**
80+
* post 请求
81+
*
82+
* @param path
83+
* @param requestObj
84+
* @return
85+
* @throws Exception
86+
*/
87+
public DeleteHttpHeadersConfigResponse doPostRaw(String path, DeleteHttpHeadersConfigRequest requestObj, Map<String, String> head) throws Exception {
88+
final Map<String, String> requestHeaders = head != null ? new HashMap<>(head) : new HashMap<>();
89+
requestHeaders.putIfAbsent("Content-Type", "application/x-www-form-urlencoded");
90+
String response = doRpc(path, requestObj, requestHeaders, "post");
91+
return JSON.parseObject(response, DeleteHttpHeadersConfigResponse.class);
92+
}
93+
/**
94+
* get 请求
95+
*
96+
* @param path
97+
* @param requestObj
98+
* @return
99+
* @throws Exception
100+
*/
101+
public DeleteHttpHeadersConfigResponse doGet(String path, DeleteHttpHeadersConfigRequest requestObj) throws Exception {
102+
Map<String, String> head = new HashMap<>();
103+
head.putIfAbsent("Content-Type", "application/x-www-form-urlencoded");
104+
return doGet(path, requestObj, head);
105+
}
106+
107+
/**
108+
* get 请求
109+
*
110+
* @param path
111+
* @param requestObj
112+
* @param head
113+
* @return
114+
* @throws Exception
115+
*/
116+
public DeleteHttpHeadersConfigResponse doGet(String path, DeleteHttpHeadersConfigRequest requestObj, Map<String, String> head) throws Exception {
117+
final Map<String, String> requestHeaders = head != null ? new HashMap<>(head) : new HashMap<>();
118+
requestHeaders.putIfAbsent("Content-Type", "application/x-www-form-urlencoded");
119+
String response = doRpc(path, requestObj, requestHeaders, "get");
120+
return JSON.parseObject(response, DeleteHttpHeadersConfigResponse.class);
121+
}
122+
123+
/**
124+
* doDelete 请求
125+
*
126+
* @param path
127+
* @param requestObj
128+
* @return
129+
* @throws Exception
130+
*/
131+
public DeleteHttpHeadersConfigResponse doDelete(String path, DeleteHttpHeadersConfigRequest requestObj) throws Exception {
132+
Map<String, String> head = new HashMap<>();
133+
head.put("Content-Type", "application/x-www-form-urlencoded");
134+
return doDelete(path, requestObj, head);
135+
}
136+
137+
/**
138+
* doDelete 请求
139+
*
140+
* @param path
141+
* @param requestObj
142+
* @param head
143+
* @return
144+
* @throws Exception
145+
*/
146+
public DeleteHttpHeadersConfigResponse doDelete(String path, DeleteHttpHeadersConfigRequest requestObj, Map<String, String> head) throws Exception {
147+
final Map<String, String> requestHeaders = head != null ? new HashMap<>(head) : new HashMap<>();
148+
requestHeaders.putIfAbsent("Content-Type", "application/x-www-form-urlencoded");
149+
String response = doRpc(path, requestObj, requestHeaders, "delete");
150+
return JSON.parseObject(response, DeleteHttpHeadersConfigResponse.class);
151+
}
152+
153+
154+
/**
155+
* doPut 请求
156+
*
157+
* @param path
158+
* @param requestObj
159+
* @return
160+
* @throws Exception
161+
*/
162+
public DeleteHttpHeadersConfigResponse doPut(String path, DeleteHttpHeadersConfigRequest requestObj) throws Exception {
163+
Map<String, String> head = new HashMap<>();
164+
head.putIfAbsent("Content-Type", "application/x-www-form-urlencoded");
165+
return doPut(path, requestObj, head);
166+
}
167+
168+
/**
169+
* doPut 请求
170+
*
171+
* @param path
172+
* @param requestObj
173+
* @param head
174+
* @return
175+
* @throws Exception
176+
*/
177+
public DeleteHttpHeadersConfigResponse doPut(String path, DeleteHttpHeadersConfigRequest requestObj, Map<String, String> head) throws Exception {
178+
final Map<String, String> requestHeaders = head != null ? new HashMap<>(head) : new HashMap<>();
179+
requestHeaders.putIfAbsent("Content-Type", "application/x-www-form-urlencoded");
180+
String response = doRpc(path, requestObj, requestHeaders, "put");
181+
return JSON.parseObject(response, DeleteHttpHeadersConfigResponse.class);
182+
}
183+
184+
/**
185+
* rpc
186+
*
187+
* @param path
188+
* @param requestObj
189+
* @param head
190+
* @return
191+
* @throws Exception
192+
*/
193+
private String doRpc(String path, DeleteHttpHeadersConfigRequest requestObj, Map<String, String> head, String requestMethod) throws Exception {
194+
//断言
195+
Objects.requireNonNull(path, "path cannot be null");
196+
Objects.requireNonNull(requestObj, "requestObj cannot be null");
197+
Objects.requireNonNull(requestMethod, "requestMethod cannot be null");
198+
Objects.requireNonNull(head, "head cannot be null");
199+
200+
//请求上下文
201+
RpcRequestContentModel requestContentModel = RpcRequestContentModel.builder()
202+
.action(action)
203+
.version(version)
204+
.service(service)
205+
.region(credential.getRegion())
206+
.accessKeyId(credential.getSecretKey())
207+
.secretAccessKey(credential.getSignStr())
208+
.build();
209+
210+
// 根据内容类型设置请求体
211+
String contentType = head.getOrDefault("Content-Type", "application/x-www-form-urlencoded");
212+
JSONObject requestParam = getRequestParam(requestObj, contentType);
213+
214+
//uri
215+
path = path + "?Action=" + action + "&Version=" + version;
216+
217+
//发起请求
218+
String response = new RpcRequestClient(requestContentModel).beginRpcRequest(path, requestMethod, requestParam, head);
219+
log.info("doRpc end,path:{},params:{},head:{}", path, JSONObject.toJSON(requestParam), head);
220+
return response;
221+
222+
}
223+
224+
225+
private JSONObject getRequestParam(DeleteHttpHeadersConfigRequest requestObj, String contentType) throws Exception {
226+
//请求参数
227+
if (contentType.equalsIgnoreCase("application/json")) {
228+
return getPostRawRequestParams(requestObj);
229+
}
230+
return getSimpleRequestParams(requestObj);
231+
}
232+
233+
234+
private JSONObject getSimpleRequestParams(DeleteHttpHeadersConfigRequest requestObj) throws Exception {
235+
JSONObject requestParams = new JSONObject();
236+
237+
//设置请求体请求参数
238+
setRequestField(requestObj, requestParams);
239+
return requestParams;
240+
}
241+
242+
private JSONObject getPostRawRequestParams(DeleteHttpHeadersConfigRequest requestObj) throws Exception {
243+
JSONObject requestParams = new JSONObject();
244+
245+
//设置请求体请求参数
246+
setRequestFieldForPostRaw(requestObj, requestParams);
247+
return requestParams;
248+
}
249+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package ksyun.client.cdn.deletehttpheadersconfig.v3;
2+
3+
import common.annotation.KsYunField;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.ToString;
7+
8+
import java.util.List;
9+
import java.util.Arrays;
10+
11+
/**
12+
* @Classname DeleteHttpHeadersConfigRequest
13+
* @Description 请求参数
14+
*/
15+
@Data
16+
public class DeleteHttpHeadersConfigRequest{
17+
/**域名ID*/
18+
@KsYunField(name="DomainId")
19+
private String DomainId;
20+
21+
/**已经设置的Http头参数*/
22+
@KsYunField(name="HeaderKey")
23+
private String HeaderKey;
24+
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package ksyun.client.cdn.deletehttpheadersconfig.v3;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import common.BaseResponseModel;
5+
import lombok.Data;
6+
import lombok.ToString;
7+
8+
import java.util.Set;
9+
10+
/**
11+
* @Classname DeleteHttpHeadersConfigResponse
12+
* @Description DeleteHttpHeadersConfig 返回体
13+
*/
14+
@Data
15+
@ToString
16+
public class DeleteHttpHeadersConfigResponse extends BaseResponseModel {
17+
18+
/**
19+
* 请求id
20+
*/
21+
@JsonProperty("RequestId")
22+
private String requestId;
23+
24+
//返回结果,需要按需扩展
25+
26+
}

0 commit comments

Comments
 (0)