Common utilities and core components for Tencent Cloud SDK for Python, providing credential management, HTTP clients, authentication, error handling, and foundational classes required by all Tencent Cloud service SDKs
npx @tessl/cli install tessl/pypi-tencentcloud-sdk-python-common@3.0.0Common utilities and core components for Tencent Cloud SDK for Python, providing credential management, HTTP clients, authentication, error handling, and foundational classes required by all Tencent Cloud service SDKs. This package serves as the foundational layer for the entire Tencent Cloud SDK ecosystem, enabling developers to build applications that integrate with Tencent Cloud services through a consistent, well-architected foundation.
pip install tencentcloud-sdk-python-common# Import specific credential classes
from tencentcloud.common.credential import Credential, CVMRoleCredential, STSAssumeRoleCredential
# Import client base classes
from tencentcloud.common.abstract_client import AbstractClient
from tencentcloud.common.common_client import CommonClient
# Import profile configuration
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
# Import exception handling
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKExceptionfrom tencentcloud.common.credential import Credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.common_client import CommonClient
# Create credentials
cred = Credential("your-secret-id", "your-secret-key")
# Configure HTTP profile
http_profile = HttpProfile()
http_profile.endpoint = "cvm.tencentcloudapi.com"
# Configure client profile
client_profile = ClientProfile()
client_profile.httpProfile = http_profile
# Create common client
client = CommonClient("cvm", "2017-03-12", cred, "ap-guangzhou", client_profile)
# Make API call
response = client.call_json("DescribeInstances", {})
print(response)The package follows a layered architecture with clear separation of concerns:
This design enables consistent behavior across all Tencent Cloud service SDKs while providing flexibility for different deployment scenarios and authentication methods.
Multiple credential providers supporting environment variables, configuration files, instance roles, STS temporary credentials, and OIDC tokens. Includes automatic credential chain resolution for flexible deployment scenarios.
class Credential:
def __init__(self, secret_id: str, secret_key: str, token: str = None): ...
def get_credential_info(self) -> tuple[str, str, str]: ...
class DefaultCredentialProvider:
def __init__(self): ...
def get_credentials(self): ...Comprehensive HTTP client implementation with connection pooling, proxy support, pre-connected pools for performance, and custom certificate handling. Supports both HTTP and HTTPS with configurable timeouts and keep-alive.
class ApiRequest:
def __init__(self, host: str, req_timeout: int = 60, debug: bool = False,
proxy: str = None, is_http: bool = False, certification = None,
pre_conn_pool_size: int = 0): ...
def send_request(self, req_inter: RequestInternal): ...Abstract base classes providing the foundation for all Tencent Cloud service clients. Handles request building, signature generation, response processing, and error handling with support for multiple signature methods.
class AbstractClient:
def __init__(self, credential, region: str, profile: ClientProfile = None): ...
def call_json(self, action: str, params: dict, headers: dict = None,
options: dict = None) -> dict: ...
def call_sse(self, action: str, params: dict, headers: dict = None,
options: dict = None): ...Flexible configuration system for HTTP settings, signature methods, language preferences, and regional failover. Supports customization of endpoints, timeouts, retry policies, and circuit breaker settings.
class ClientProfile:
def __init__(self, signMethod: str = None, httpProfile: HttpProfile = None,
language: str = "zh-CN", disable_region_breaker: bool = True,
region_breaker_profile = None, request_client: str = None,
retryer = None): ...
class HttpProfile:
def __init__(self, protocol: str = None, endpoint: str = None,
reqMethod: str = "POST", reqTimeout: int = 60,
keepAlive: bool = False, proxy: str = None,
rootDomain: str = None, certification = None): ...Circuit breaker implementation for regional failover and retry mechanisms with configurable backoff strategies. Provides automatic failure detection and recovery for improved reliability.
class CircuitBreaker:
def __init__(self, breaker_setting): ...
def before_requests(self) -> tuple[int, bool]: ...
def after_requests(self, before: int, success: bool): ...
class StandardRetryer:
def __init__(self, max_attempts: int = 3, backoff_fn = None, logger = None): ...
def send_request(self, fn): ...Digital signature utilities supporting multiple signature methods (HmacSHA1, HmacSHA256, TC3-HMAC-SHA256) and comprehensive exception handling for authentication and API errors.
class Sign:
@staticmethod
def sign(secret_key: str, sign_str: str, sign_method: str) -> str: ...
@staticmethod
def sign_tc3(secret_key: str, date: str, service: str, str2sign: str) -> str: ...
class TencentCloudSDKException(Exception):
def __init__(self, code: str = None, message: str = None,
requestId: str = None): ...All operations may raise TencentCloudSDKException with specific error codes: