Initializing the DLI Client
To use DLI SDK to access DLI, you need to initialize the DLI client. During DLI client initialization, you can perform authentication using the Access Key ID/Secret Access Key (AK/SK) or token. The sample code is as follows:
Sample code for AK/SK authentication
1 2 3 4 5 6 | String ak = "ak";
String sk = "sk";
String regionName = "regionname";
String projectId = "project_id";
DLIInfo dliInfo = new DLIInfo(regionName, ak, sk, projectId);
DLIClient client = new DLIClient(AuthenticationMode.AKSK, dliInfo);
|
You can perform the following operations to obtain the Access Keys, project ID, and Region:
- Register with and log in to the management console.
- Click the username in the upper right corner and select My Credentials from the drop-down list.
- On the My Credentials page,
- Click Access Keys to view the created access key.
- Click Projects to view the project ID and Region.
Sample code for token-based authentication
1 2 3 4 5 6 7 | String domainName = "domainname";
String userName = "username";
String password = "password";
String regionName = "regionname";
String projectId = "project_id";
DLIInfo dliInfo = new DLIInfo(regionName, domainName, userName, password, projectId);
DLIClient client = new DLIClient(AuthenticationMode.TOKEN, dliInfo);
|
You can change the endpoint in set mode. Run the following statement: dliInfo.setServerEndpoint(endpoint).
Last Article: Java SDK
Next Article: OBS Authorization
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.