G42 Cloud SDK CBR

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

G42 Cloud SDK for Cloud Backup and Recovery (CBR) service. Version 0.0.10b0 (beta), supports Python >=2.7. Released irregularly.

pip install g42cloudsdkcbr
error AttributeError: module 'g42cloudsdkcbr' has no attribute 'CbrClient'
cause Incorrect import path; CbrClient is in v1 submodule.
fix
Use 'from g42cloudsdkcbr.v1 import CbrClient'.
error KeyError: 'region'
cause Using a non-G42 region string or incorrect region ID.
fix
Use CbrRegion.value_of('ap-southeast-1') or another valid G42 region.
deprecated Python 2.7 support is deprecated and will be removed in future versions.
fix Upgrade to Python 3.6+.
gotcha All endpoints and region codes differ from Huawei Cloud; use G42-specific values.
fix Use CbrRegion.value_of('ap-southeast-1') for G42 region.
gotcha The SDK is in beta; breaking changes may occur between minor versions without notice.
fix Pin exact version in requirements.

Basic setup with CbrClient.

from g42cloudsdkcore.auth.credentials import BasicCredentials
from g42cloudsdkcbr.v1 import CbrClient
from g42cloudsdkcbr.v1.region import CbrRegion

ak = os.environ.get('G42_AK', '')
sk = os.environ.get('G42_SK', '')
project_id = os.environ.get('G42_PROJECT_ID', '')

credentials = BasicCredentials(ak, sk, project_id)
client = CbrClient.new_builder()\
    .with_credentials(credentials)\
    .with_region(CbrRegion.value_of("ap-southeast-1"))\
    .build()

print(client.list_protectable([]))