Initializing the Client
The client AIDatalake_Catalog_Client is the core entry of the SDK. During initialization, you need to pass in authentication credentials (AK/SK), endpoints for LakeFormation and OBS, and other relevant information. Once initialized, you can use this client to create, query, and delete functions.
Prerequisites
- A LakeFormation instance has been created, with a catalog and a database available in the instance.
- An OBS parallel file system has been created.
Sample Code for AK/SK Authentication
- Sample code
from aidatalake_catalog.client import AIDatalake_Catalog_Client client = AIDatalake_Catalog_Client( ak="your-ak", sk="your-sk", security_token=None, # Used for temporary credentials obs_endpoint="obs.cn-north-4.myhuaweicloud.com", lakeformation_endpoint="https://lakeformation.cn-north-4.myhuaweicloud.com", lakeformation_instanceid="your-instance-id", catalog_name="your-catalog-name", default_database="your_default_db", obs_path="your-bucket/udf/", # bucket_name/dir/subdir project_id="your-project-id", ignore_ssl_verification=False, ) - Parameter description
Parameter
Mandatory (Yes/No)
Type
Description
ak
Yes
str
Access keys (AK/SK). For details about how to obtain the AK/SK, see AK/SK Obtaining.
sk
Yes
str
security_token
No
str | None
Security token of the temporary credentials. If the long-term AK/SK credential is used, set this parameter to None.
obs_endpoint
Yes
str
OBS endpoint, for example, obs.cn-north-4.myhuaweicloud.com.
lakeformation_endpoint
Yes
str
URL of the LakeFormation API endpoint.
lakeformation_instanceid
Yes
str
LakeFormation instance ID (used for IAM authentication).
catalog_name
Yes
str
LakeFormation catalog name (three-layer structure: instance/catalog/database).
default_database
Yes
str
Default database name for function operations.
obs_path
Yes
str
OBS path, in the format of bucket_name/dir/subdir.
project_id
Yes
str
Project ID (used for LakeFormation API authentication).
ignore_ssl_verification
No
bool
Whether to disable SSL certificate verification. The default value is False. This parameter can be set to True in the self-signed certificate scenario.
- Hard coding AKs and SKs or storing them in code in plaintext poses significant security risks. You are advised to store them in encrypted form in configuration files or environment variables and decrypt them when needed to ensure security.
- This example stores AK and SK in environment variables. Before running this example, set the environment variables xxx_SDK_AK and xxx_SDK_SK in the local environment.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot