Tencent Cloud WAF SDK for Python
raw JSON → 3.1.91 verified Sat May 09 auth: no python
Official Tencent Cloud SDK for the Web Application Firewall (WAF) service. Current version 3.1.91. Released frequently as part of the tencentcloud-sdk-python monorepo.
pip install tencentcloud-sdk-python-waf Common errors
error ModuleNotFoundError: No module named 'tencentcloud.waf' ↓
cause The per-service package tencentcloud-sdk-python-waf was not installed, or common module is missing.
fix
Install both: pip install tencentcloud-sdk-python-waf tencentcloud-sdk-python-common
error AttributeError: module 'tencentcloud.waf' has no attribute 'WafClient' ↓
cause Direct import from tencentcloud.waf does not expose WafClient; versioned subpackage is required.
fix
Use from tencentcloud.waf.v20180125 import waf_client
error tencentcloud.common.exception.TencentCloudSDKException: UnsupportedRegion ↓
cause Region string is invalid or not supported by WAF service.
fix
Use a valid region like 'ap-guangzhou', 'ap-shanghai', etc. Check Tencent Cloud docs.
Warnings
breaking Version 3.x changes all imports to date-based subpackages (e.g., v20180125). Direct imports like 'from tencentcloud.waf import WafClient' will fail. ↓
fix Use versioned import: from tencentcloud.waf.v20180125 import waf_client, models
gotcha The SDK does not install its common dependency automatically when using the per-service package. Must install tencentcloud-sdk-python-common separately. ↓
fix Run: pip install tencentcloud-sdk-python-common
deprecated The older v20180419 API version is deprecated. New projects should use v20180125. ↓
fix Use v20180125 for all new development.
Imports
- WafClient wrong
from tencentcloud.waf import WafClientcorrectfrom tencentcloud.waf.v20180125 import waf_client, models
Quickstart
import os
from tencentcloud.common import credential
from tencentcloud.waf.v20180125 import waf_client, models
cred = credential.Credential(
os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
)
client = waf_client.WafClient(cred, "ap-guangzhou")
req = models.DescribeWafInfoRequest()
resp = client.DescribeWafInfo(req)
print(resp.to_json_string())