Alibaba Cloud CDN SDK (2018-05-10)

raw JSON →
9.0.0 verified Fri May 01 auth: no python

Alibaba Cloud CDN (Content Delivery Network) SDK for Python. Current version 9.0.0. Allows management of CDN domains, configurations, and monitoring. Released under the Alibaba Cloud SDK for Python umbrella. Active development with frequent minor releases.

pip install alibabacloud-cdn20180510
error ModuleNotFoundError: No module named 'alibabacloud_cdn20180510'
cause Library not installed or installed with incorrect name.
fix
Run 'pip install alibabacloud-cdn20180510' (note hyphens, not underscores).
error AttributeError: module 'alibabacloud_cdn20180510' has no attribute 'Client'
cause Wrong import path; Client is not in the top-level module.
fix
Use 'from alibabacloud_cdn20180510.client import Client'.
error tealink.UnknownHostException: Failed to connect to cdn.aliyuncs.com port 443
cause Missing or incorrect region_id, or network connectivity issue.
fix
Ensure region_id is set correctly in Config (e.g., 'cn-hangzhou') and that your machine can reach the Alibaba Cloud endpoint.
breaking Version 9.0.0 changed the import paths: Client is now in alibabacloud_cdn20180510.client instead of alibabacloud_cdn20180510. Also, models are in a separate subpackage. Code from v8.x will break.
fix Update imports to use the .client and .models subpackages. See quickstart for correct pattern.
deprecated The old authentication method using 'access_key_id' and 'access_key_secret' directly in Config is being phased out. Consider using credential providers like 'AlibabacloudCredentials'.
fix Use alibabacloud_credentials to create a credential object and pass it to Config.
gotcha All API methods are generated and may have inconsistent naming (e.g., describe_* vs. list_*). Always check the model files for the exact method name.
fix Refer to the official API documentation or inspect the client methods via dir(Client).

Initializes the client and calls a simple API to describe a CDN domain detail.

import os
from alibabacloud_cdn20180510.client import Client
from alibabacloud_cdn20180510.models import DescribeCdnDomainDetailRequest
from alibabacloud_tea_openapi.models import Config

config = Config(
    access_key_id=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', ''),
    access_key_secret=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', ''),
    region_id='cn-hangzhou'
)
client = Client(config)
request = DescribeCdnDomainDetailRequest(
    domain_name='example.com'
)
response = client.describe_cdn_domain_detail(request)
print(response.body)