Skip to content

Commit 0d0225e

Browse files
committed
release 0.0.5-beta source code for java
1 parent a9c4a7d commit 0d0225e

File tree

181 files changed

+19609
-2665
lines changed

Some content is hidden

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

181 files changed

+19609
-2665
lines changed

CHANGELOG.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
1-
# 0.0.4-beta # 0.0.4-beta 2023-02-20
1+
# 0.0.5-beta 2023-04-14
2+
3+
### G42Cloud SDK Core
4+
5+
- _Features_
6+
- None
7+
- _Bug Fix_
8+
- None
9+
- _Change_
10+
- Optimize the code structure.
11+
12+
### G42Cloud SDK BMS
13+
14+
- _Features_
15+
- None
16+
- _Bug Fix_
17+
- None
18+
- _Change_
19+
- **ShowJobInfos**
20+
- changes of response param
21+
- `* begin_time: date-time -> string`
22+
- `* end_time: date-time -> string`
23+
- `* entities.sub_jobs.begin_time: date-time -> string`
24+
- `* entities.sub_jobs.end_time: date-time -> string`
25+
- **ListBareMetalServers**
26+
- changes of response param
27+
- `+ servers.status: enum value [HARD_REBOOT,DELETED]`
28+
- `- servers.OS-EXT-STS:vm_state: enum value [suspended]`
29+
- **ListBareMetalServerDetails**
30+
- changes of response param
31+
- `+ server.status: enum value [HARD_REBOOT,DELETED]`
32+
- `- server.OS-EXT-STS:vm_state: enum value [suspended]`
33+
- **ChangeBaremetalServerName**
34+
- changes of response param
35+
- `- server.OS-EXT-STS:vm_state: enum value [SUSPENDED]`
36+
37+
# 0.0.4-beta 2023-02-20
238

339
### G42Cloud SDK CBR
440

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ At first, you need to [download](https://maven.apache.org/download.cgi)
2727
and [install](https://maven.apache.org/install.html) Maven, and then declare dependencies in the `pom.xml` file in your
2828
Java project.
2929

30+
Please choose a specific version number when specifying dependencies, otherwise it may cause unforeseen issues at build time.
31+
3032
### Individual Services
3133

3234
You can add depenencies for the specific services only. Take using ECS and VPC SDK for example, you need to
@@ -36,12 +38,12 @@ import `g42cloud-sdk-ecs` and `g42cloud-sdk-vpc` libraries:
3638
<dependency>
3739
<groupId>io.github.g42cloud-sdk</groupId>
3840
<artifactId>g42cloud-sdk-ecs</artifactId>
39-
<version>0.0.1</version>
41+
<version>[0.0.1-beta, 1.0.0)</version>
4042
</dependency>
4143
<dependency>
4244
<groupId>io.github.g42cloud-sdk</groupId>
4345
<artifactId>g42cloud-sdk-vpc</artifactId>
44-
<version>0.0.1</version>
46+
<version>[0.0.1-beta, 1.0.0)</version>
4547
</dependency>
4648
```
4749

core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
<parent>
77
<groupId>io.github.g42cloud-sdk</groupId>
8-
<version>0.0.4-beta</version>
8+
<version>0.0.5-beta</version>
99
<artifactId>g42cloud-sdk</artifactId>
1010
</parent>
1111

1212
<modelVersion>4.0.0</modelVersion>
1313
<packaging>jar</packaging>
1414
<artifactId>g42cloud-sdk-core</artifactId>
15-
<version>0.0.4-beta</version>
15+
<version>0.0.5-beta</version>
1616
<name>G42 Cloud SDK for Java Core</name>
1717
<description>Core library for G42 Cloud Java SDK</description>
1818
<url>https://github.com/g42cloud-sdk/g42cloud-sdk-java</url>

core/src/main/java/com/g42cloud/sdk/core/ClientBuilder.java

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343
* @author G42Cloud_SDK
4444
*/
4545
public class ClientBuilder<T> {
46-
private Function<HcClient, T> creator;
46+
private final Function<HcClient, T> creator;
4747

4848
private ICredential credential;
4949

5050
private HttpConfig httpConfig;
5151

5252
private Region region;
5353

54-
private String endpoint;
54+
private List<String> endpoints;
5555

5656
private List<String> credentialType = new ArrayList<>(
5757
Collections.singletonList(BasicCredentials.class.getSimpleName()));
@@ -87,8 +87,17 @@ public ClientBuilder<T> withRegion(Region region) {
8787
return this;
8888
}
8989

90+
/**
91+
* @deprecated As of 3.1.27, because of the support of the multi-endpoint feature,
92+
* use {@link #withEndpoints(List<String> endpoints)} instead
93+
*/
94+
@Deprecated
9095
public ClientBuilder<T> withEndpoint(String endpoint) {
91-
this.endpoint = endpoint;
96+
return withEndpoints(Arrays.asList(endpoint));
97+
}
98+
99+
public ClientBuilder<T> withEndpoints(List<String> endpoints) {
100+
this.endpoints = endpoints;
92101
return this;
93102
}
94103

@@ -102,7 +111,7 @@ public T build() {
102111

103112
if (Objects.isNull(credential)) {
104113
CredentialProviderChain providerChain = CredentialProviderChain.getDefaultCredentialProviderChain(
105-
credentialType.get(0));
114+
credentialType.get(0));
106115
credential = providerChain.getCredentials();
107116
}
108117

@@ -116,7 +125,10 @@ public T build() {
116125
}
117126

118127
if (Objects.nonNull(region)) {
119-
endpoint = region.getEndpoint();
128+
if (region.getEndpoints() != null) {
129+
endpoints = region.getEndpoints();
130+
}
131+
120132
try {
121133
hcClient.withCredential(credential);
122134
credential = credential.processAuthParams(hcClient, region.getId()).get();
@@ -129,11 +141,13 @@ public T build() {
129141
}
130142
}
131143

132-
if (!endpoint.startsWith(Constants.HTTP_SCHEME)) {
133-
endpoint = Constants.HTTPS_SCHEME + "://" + endpoint;
144+
if (endpoints.isEmpty()) {
145+
throw new SdkException("Could not find any endpoints, at least one endpoint is required");
134146
}
147+
endpoints.replaceAll(endpoint -> endpoint.startsWith(Constants.HTTP_SCHEME)
148+
? endpoint : Constants.HTTPS_SCHEME + "://" + endpoint);
135149

136-
hcClient.withEndpoint(endpoint).withCredential(credential);
150+
hcClient.withEndpoints(endpoints).withCredential(credential);
137151

138152
T t = creator.apply(hcClient);
139153
ClientCustomization clientCustomization = loadClientCustomization(t);
@@ -168,8 +182,16 @@ public HttpConfig getHttpConfig() {
168182
return httpConfig;
169183
}
170184

185+
/**
186+
* @deprecated As of 3.1.27, because of the support of the multi-endpoint feature,
187+
* use {@link #getEndpoints()} instead
188+
*/
189+
@Deprecated
171190
public String getEndpoint() {
172-
return endpoint;
191+
return endpoints.isEmpty() ? null : endpoints.get(0);
173192
}
174193

194+
public List<String> getEndpoints() {
195+
return endpoints;
196+
}
175197
}

core/src/main/java/com/g42cloud/sdk/core/Constants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ public static class MEDIATYPE {
8181

8282
public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
8383

84+
public static final String BINARY_OCTET_STREAM = "binary/octet-stream";
85+
8486
public static final String APPLICATION_BSON = "application/bson";
8587

88+
public static final String APPLICATION_XML = "application/xml";
89+
8690
public static final String MULTIPART_FORM_DATA = "multipart/form-data";
8791

8892
public static final String TEXT = "text";
@@ -100,6 +104,8 @@ public static class MEDIATYPE {
100104

101105
public static final String X_REQUEST_ID = "X-Request-Id";
102106

107+
public static final String ENCODED_AUTHORIZATION_MESSAGE = "encoded_authorization_message";
108+
103109
public static final String CODE = "code";
104110

105111
public static final String MESSAGE = "message";

0 commit comments

Comments
 (0)