Help Center/ Data Lake Insight/ SDK Reference/ Python SDK/ Initializing the DLI Client

Initializing the DLI Client

Updated on 2023-07-19 GMT+08:00

To use DLI Python SDK to access DLI, you need to initialize the DLI client. During DLI client initialization, you can use the AK/SK or token for authentication. For details about the dependencies and complete sample code, see Instructions.

Example Code for AK/SK Authentication

1
2
3
4
5
6
7
8
def init_aksk_dli_client():
    auth_mode = 'aksk'
    region = 'xxx'
    project_id = 'xxxx'
    ak = 'xxxx'
    sk = 'xxxx'
    dli_client = DliClient(auth_mode=auth_mode, region=region, project_id=project_id,ak=ak, sk=sk)
    return dli_client
NOTE:

You can perform the following operations to obtain the Access Keys, project ID, and Region:

  1. Log in to the management console.
  2. Hover the cursor on the username in the upper right corner and select My Credentials from the drop-down list.
  3. 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.
  4. On the displayed page, click Download. Open the credential file to obtain the AK/SK information.
  5. In the navigation pane on the left, choose API Credentials. In the Projects pane, locate project_id and obtain the region information.

Example Code for Token-based Authentication

1
2
3
4
5
6
7
8
9
def init_token_dli_client():
   auth_mode = 'token'
    region = 'xxx'
    project_id = 'xxxx'
    account = 'xxx account'
    user = 'xxxx'
    password = 'xxxx'
    dli_client = DliClient(auth_mode=auth_mode, region=region, project_id=project_id,account=account, user=user, password=password)
    return dli_client
NOTE:

You can change the endpoint in set mode. Run the following statement: dliInfo.setServerEndpoint(endpoint).

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback