Skip to content

Commit d9bb87d

Browse files
release 3.0.10-beta source code for nodejs
1 parent 1512256 commit d9bb87d

File tree

118 files changed

+3472
-7400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+3472
-7400
lines changed

CHANGELOG.md

+59
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,62 @@
1+
# 3.0.10-beta 2021-07-09
2+
3+
### HuaweiCloud SDK Core
4+
- _feature_
5+
- None
6+
- _Bug Fix_
7+
- The response level is incorrect.
8+
- _Change_
9+
- Optimize exception information.
10+
11+
### HuaweiCloud SDK CCE
12+
13+
- _Features_
14+
- Support the interfaces `RemoveNode`,`MigrateNode`.
15+
- _Bug Fix_
16+
- None
17+
- _Change_
18+
- Add the request parameter `tobedeleted` to the interface `DeleteCluster`.
19+
20+
### HuaweiCloud SDK EIP
21+
22+
- _Features_
23+
- None
24+
- _Bug Fix_
25+
- None
26+
- _Change_
27+
- Add the response parameter `publicip_border_group` to the interfaces `CreateSharedBandwidth`,`ListBandwidths`.
28+
29+
### HuaweiCloud SDK IMS
30+
31+
- _Features_
32+
- None
33+
- _Bug Fix_
34+
- None
35+
- _Change_
36+
- Add the response parameters `__root_origin`,`checksum`,`size` to the interfaces `GlanceCreateImageMetadata`.
37+
- Remove the request parameters `deleted`, `deleted_at` of the interface `GlanceAddImageMember`, and add the following request parameters:
38+
- `__lazyloading`
39+
- `__os_feature_list`
40+
- `__root_origin`
41+
- `__sequence_num`
42+
- `__support_agent_list`
43+
- `__system__cmkid`
44+
- `active_at`
45+
- `hw_vif_multiqueue_enabled`
46+
- `max_ram`
47+
- `__image_location`
48+
- `__is_config_init`
49+
- `__account_code`
50+
51+
### HuaweiCloud SDK IoTDA
52+
53+
- _Features_
54+
- None
55+
- _Bug Fix_
56+
- None
57+
- _Change_
58+
- Add the response parameters `edge_node_ids`, `last_update_time` to the interface `ListRules`.
59+
160
# 3.0.9-beta 2021-06-29
261

362
### HuaweiCloud SDK Core

CHANGELOG_CN.md

+60
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
# 3.0.10-beta 2021-07-09
2+
3+
### HuaweiCloud SDK Core
4+
- _新增特性_
5+
-
6+
- _解决问题_
7+
- 修复 Response 返回层级错误
8+
- _特性变更_
9+
- 优化异常信息
10+
11+
12+
### HuaweiCloud SDK CCE
13+
14+
- _新增特性_
15+
- 支持接口`RemoveNode``MigrateNode`
16+
- _解决问题_
17+
-
18+
- _特性变更_
19+
- 接口`DeleteCluster`新增请求参数`tobedeleted`
20+
21+
### HuaweiCloud SDK EIP
22+
23+
- _新增特性_
24+
-
25+
- _解决问题_
26+
-
27+
- _特性变更_
28+
- 接口`CreateSharedBandwidth``ListBandwidths`新增响应参数`publicip_border_group`
29+
30+
### HuaweiCloud SDK IMS
31+
32+
- _新增特性_
33+
-
34+
- _解决问题_
35+
-
36+
- _特性变更_
37+
- 接口`GlanceCreateImageMetadata`新增响应参数`__root_origin``checksum``size`
38+
- 接口`GlanceAddImageMember`移除请求参数`deleted``deleted_at`,新增以下请求参数:
39+
- `__lazyloading`
40+
- `__os_feature_list`
41+
- `__root_origin`
42+
- `__sequence_num`
43+
- `__support_agent_list`
44+
- `__system__cmkid`
45+
- `active_at`
46+
- `hw_vif_multiqueue_enabled`
47+
- `max_ram`
48+
- `__image_location`
49+
- `__is_config_init`
50+
- `__account_code`
51+
52+
### HuaweiCloud SDK IoTDA
53+
54+
- _新增特性_
55+
-
56+
- _解决问题_
57+
-
58+
- _特性变更_
59+
- 接口`ListRules`新增响应参数`edge_node_ids``last_update_time`
60+
161
# 3.0.9-beta 2021-06-29
262

363
### HuaweiCloud SDK Core

core/HcClient.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { HttpRequestBuilder } from "./http/IHttpRequestBuilder";
2626
import { SdkResponse } from "./SdkResponse";
2727
import { ExceptionUtil } from "./exception/ExceptionUtil";
2828
import { getLogger, Logger, LogLevel } from './logger';
29+
import { DefaultHttpResponse } from "./http/DefaultHttpResponse";
2930

3031
export class HcClient {
3132
private httpClient: HttpClient;
@@ -58,17 +59,15 @@ export class HcClient {
5859
return this;
5960
}
6061

61-
public sendRequest<T>(options: any): Promise<T> {
62+
public sendRequest<T extends SdkResponse>(options: any): Promise<T> | Promise<any> {
6263
this.logger.debug('send request');
6364

6465
const request = this.buildRequest(options);
6566
// @ts-ignore
66-
return this.httpClient.sendRequest(request).then(res => {
67-
return this.extractResponse(res);
67+
return this.httpClient.sendRequest<T>(request).then(res => {
68+
return this.extractResponse<T>(res);
6869
}, err => {
69-
let error = err;
70-
let statusCode = error.status;
71-
return ExceptionUtil.generalException(statusCode, error.body);
70+
return ExceptionUtil.generalException(err);
7271
});
7372
}
7473

@@ -94,19 +93,21 @@ export class HcClient {
9493
if (options['responseHeaders']) {
9594
httpRequest['responseHeaders'] = options['responseHeaders'];
9695
}
96+
httpRequest.proxy = this.proxyAgent;
9797
return httpRequest;
9898
}
9999

100-
private extractResponse(result?: any) {
100+
private extractResponse<T extends SdkResponse>(result: DefaultHttpResponse<T>): T {
101101
const headers = result.headers;
102102
let contentType = headers['content-type'];
103103
contentType = contentType.toLowerCase();
104104
if (contentType && contentType == 'application/octet-stream') {
105-
return result.result;
105+
return result.data as T;
106106
} else {
107-
let response = new SdkResponse();
108-
response.setStatusCode(result.status);
109-
response.setResult(result.result);
107+
let response = result.data instanceof Object ? result.data : {} as T;
108+
let sdkRespone = response as SdkResponse;
109+
sdkRespone.httpStatusCode = result.statusCode;
110+
110111
return response;
111112
}
112113
}

core/SdkResponse.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,5 @@
2020
*/
2121

2222
export class SdkResponse {
23-
private httpStatusCode: number | undefined;
24-
public result?: any;
25-
public constructor(statusCode?: number) {
26-
this.httpStatusCode = statusCode;
27-
}
28-
29-
public getStatusCode(): number {
30-
return <number>this.httpStatusCode;
31-
}
32-
public setStatusCode(code: number) {
33-
this.httpStatusCode = code;
34-
}
35-
public setResult(result: any) {
36-
this.result = result;
37-
}
38-
public getResult() {
39-
return this.result;
40-
}
23+
httpStatusCode?: number;
4124
}

core/exception/ExceptionResponse.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2020 Huawei Technologies Co.,Ltd.
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
export interface ExceptionResponse {
23+
data?: any;
24+
status?: number;
25+
headers?: any;
26+
request?: any;
27+
message?: string;
28+
config?: any;
29+
originalError?: any;
30+
requestId?: string;
31+
}

core/exception/ExceptionUtil.ts

+8-16
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,18 @@
2020
*/
2121

2222
import { ClientRequestException } from "./ClientRequestException";
23+
import { ExceptionResponse } from "./ExceptionResponse";
2324
import { ServerResponseException } from "./ServerResponseException";
2425
import { ServiceResponseException } from "./ServiceResponseException";
2526

2627
export class ExceptionUtil {
27-
static generalException(httpStatusCode: string | number, errorData: { error_code: any; error_msg: any; request_id: any; code: any; message: any; } | null | undefined) {
28-
let errorCode;
29-
let errorMsg;
30-
let requestId;
31-
if (errorData !== null && errorData !== undefined) {
32-
errorCode = errorData.error_code;
33-
errorMsg = errorData.error_msg;
34-
requestId = errorData.request_id;
35-
if (errorCode === null || errorCode === undefined) {
36-
errorCode = errorData.code;
37-
errorMsg = errorData.message;
38-
if (errorCode === null || errorCode === undefined) {
39-
errorMsg = errorData;
40-
}
41-
}
42-
}
28+
static generalException(exception: ExceptionResponse) {
29+
const data = exception.data || {};
30+
let errorCode = data.error ? data.error.code : exception.status;
31+
let errorMsg = data.error ? data.error.message : exception.message;
32+
let requestId = exception.requestId;
33+
34+
const httpStatusCode = exception.status;
4335
if (httpStatusCode) {
4436
if (httpStatusCode >= 400 && httpStatusCode < 500) {
4537
return new ClientRequestException(httpStatusCode, errorMsg, errorCode, requestId);

0 commit comments

Comments
 (0)