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:
Prerequisites
- You have configured the Java SDK environment by following the instructions provided Instructions.
- You have initialized the DLI Client by following the instructions provided in Initializing the DLI Client.
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:
- Log in to the management console.
- Hover the cursor on the username in the upper right corner and select My Credentials from the drop-down list.
- In the navigation pane on the left, choose Access Keys and click Create Access Key. Confirm that you want to proceed with the operation and click OK.
- On the displayed page, click Download. Open the credential file to obtain the AK/SK information.
- In the navigation pane on the left, choose API Credentials. In the Projects pane, locate project_id and obtain the region information.
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).
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.