Registering to Use CS

Sample Code

You can use the API to register with the public cloud to use CS. Sample code is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
// Import classes:
import com.huaweicloud.cs.java.v1.client.ApiException;
import com.huaweicloud.cs.java.v1.UserApi;

UserApi apiInstance = new UserApi(apiClient);//apiClient is created when initializing a CS API client.
String xProjectId = "xProjectId_example"; // String | Project ID used for obtaining the token for the project.
try {
    GlobalResponse result = apiInstance.userRegister(xProjectId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling UserApi#userRegister");
    System.err.println(e.getResponseBody());
    e.printStackTrace();
}

Parameters

Table 1 Parameters

Parameter

Mandatory

Type

Description

xProjectId

Yes

String

Project ID. This parameter is used to obtain the token for the project.

Table 2 Parameters involved in GlobalResponse

Parameter

Mandatory

Type

Description

messageId

No

String

Message type ID.

message

No

String

Message content.

currentTime

No

Long

Current time, expressed by milliseconds.