G42 Cloud SDK RDS

raw JSON →
0.0.10b0 verified Sat May 09 auth: no python

Official Huawei G42 Cloud Python SDK for Relational Database Service (RDS). Version 0.0.10b0, beta release cadence.

pip install g42cloudsdkrds
error from g42cloudsdkrds import RdsClient ImportError: cannot import name 'RdsClient' from 'g42cloudsdkrds'
cause RdsClient is not exposed at top-level; it's in the v3 submodule.
fix
Use: from g42cloudsdkrds.v3 import RdsClient
error ModuleNotFoundError: No module named 'g42cloudsdkcore'
cause Required core SDK is not installed.
fix
Install both: pip install g42cloudsdkcore g42cloudsdkrds
error ApiException: APIGW.0301: Incorrect IAM authentication information: decrypt token fail
cause Invalid or missing AK/SK credentials, or wrong region.
fix
Ensure G42_AK and G42_SK environment variables are set and valid, and use correct region ID.
error TypeError: object of type 'ShowInstanceRequest' has no len()
cause Attempting to pass request object directly to client method without using the proper model instance.
fix
Create request object properly and call appropriate client method (e.g., client.show_instance(request)).
gotcha All model classes must be imported from the v3.model submodule, not directly from g42cloudsdkrds.
fix Use from g42cloudsdkrds.v3.model import ...
gotcha Region must be obtained via RdsRegion.value_of() with a valid region ID (e.g., 'ae-ad-1'). Using incorrect region ID causes authentication errors.
fix Check available regions in G42 Cloud documentation.
deprecated The SDK is in beta; API contract may break without notice.
fix Pin exact version and test upgrades.

Lists RDS instances. Requires G42_AK and G42_SK env vars.

from g42cloudsdkcore.auth.credentials import BasicCredentials
from g42cloudsdkrds.v3 import RdsClient
from g42cloudsdkrds.v3.region import RdsRegion
from g42cloudsdkrds.v3.model import ListInstancesRequest

ak = os.environ.get('G42_AK', '')
sk = os.environ.get('G42_SK', '')
credentials = BasicCredentials(ak, sk)
client = RdsClient.new_builder() \
    .with_credentials(credentials) \
    .with_region(RdsRegion.value_of("ae-ad-1")) \
    .build()
request = ListInstancesRequest()
response = client.list_instances(request)
print(response)