or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication.mdclient-infrastructure.mdconfiguration.mddata-models.mderror-handling.mdindex.mdservice-clients.md
tile.json

tessl/pypi-tencentcloud-sdk-python

Comprehensive Python SDK for integrating with Tencent Cloud services, supporting 240+ cloud services with authentication, error handling, and retry mechanisms.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/tencentcloud-sdk-python@3.0.x

To install, run

npx @tessl/cli install tessl/pypi-tencentcloud-sdk-python@3.0.0

index.mddocs/

TencentCloud SDK for Python

A comprehensive Software Development Kit (SDK) for integrating with Tencent Cloud services, enabling Python developers to programmatically access and manage over 240 cloud services including CVM (Cloud Virtual Machine), CBS (Cloud Block Storage), and numerous other Tencent Cloud products. The SDK offers a unified API interface with automatic request signing, authentication handling, and error management.

Package Information

  • Package Name: tencentcloud-sdk-python
  • Language: Python
  • Installation: pip install tencentcloud-sdk-python
  • Supported Python Versions: 2.7, 3.7-3.12
  • Dependencies: requests>=2.16.0

Core Imports

# Core authentication and client infrastructure
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile

# Service-specific imports (example with CVM)
from tencentcloud.cvm.v20170312 import cvm_client, models

# Generic client for any service
from tencentcloud.common.common_client import CommonClient

Basic Usage

import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cvm.v20170312 import cvm_client, models

try:
    # Initialize credentials (recommended: use environment variables)
    cred = credential.Credential(
        os.environ.get("TENCENTCLOUD_SECRET_ID"),
        os.environ.get("TENCENTCLOUD_SECRET_KEY")
    )
    
    # Create service client
    client = cvm_client.CvmClient(cred, "ap-shanghai")
    
    # Create request object
    req = models.DescribeInstancesRequest()
    
    # Call API
    resp = client.DescribeInstances(req)
    
    # Handle response
    print(resp.to_json_string())
    
except TencentCloudSDKException as err:
    print(f"Error: {err.get_code()} - {err.get_message()}")

Architecture

The TencentCloud SDK follows a consistent, hierarchical structure across all 242 cloud services:

  • Common Module: Core authentication, client infrastructure, and utilities shared across all services
  • Service Modules: Individual service packages (cvm, cbs, vpc, etc.) with versioned APIs
  • Abstract Classes: Base classes (AbstractClient, AbstractModel) providing common functionality
  • Credential Providers: Multiple authentication methods for different deployment scenarios
  • Configuration Profiles: Customizable HTTP, retry, and circuit breaker settings

Each service follows the pattern: tencentcloud.{service}.{version}.{service}_client and tencentcloud.{service}.{version}.models.

Capabilities

Authentication and Credentials

Multiple authentication methods supporting various deployment scenarios including development, production, container environments, and cross-account access.

class Credential:
    def __init__(self, secret_id: str, secret_key: str, token: str = None): ...

class CVMRoleCredential:
    def __init__(self, role_name: str = None): ...

class STSAssumeRoleCredential:
    def __init__(self, secret_id: str, secret_key: str, role_arn: str, role_session_name: str, duration_seconds: int = 7200): ...

class EnvironmentVariableCredential:
    def __init__(self): ...

class ProfileCredential:
    def __init__(self, profile_name: str = None, profile_path: str = None): ...

class DefaultCredentialProvider:
    def __init__(self): ...

Authentication and Credentials

Client Infrastructure

Core client classes providing HTTP communication, request signing, error handling, and logging capabilities for all Tencent Cloud services.

class AbstractClient:
    def __init__(self, credential, region: str, profile = None): ...
    def set_stream_logger(self, stream, level): ...
    def set_file_logger(self, file_path: str, level): ...

class CommonClient(AbstractClient):
    def __init__(self, service: str, version: str, credential, region: str, profile = None): ...
    def call_json(self, action: str, params: dict, headers: dict = None): ...

Client Infrastructure

Configuration and Profiles

Comprehensive configuration system for HTTP settings, retry behavior, circuit breakers, and request customization.

class ClientProfile:
    def __init__(self, signMethod: str = "TC3-HMAC-SHA256", httpProfile = None, language: str = "zh-CN", debug: bool = False): ...

class HttpProfile:
    def __init__(self, protocol: str = "https", endpoint: str = None, reqMethod: str = "POST", reqTimeout: int = 60): ...

class RegionBreakerProfile:
    def __init__(self, backup_endpoint: str, max_fail_num: int = 5, max_fail_percent: float = 0.75): ...

Configuration and Profiles

Error Handling and Retry

Unified exception handling and configurable retry mechanisms with exponential backoff for robust cloud service integration.

class TencentCloudSDKException(Exception):
    def __init__(self, code: str = None, message: str = None, requestId: str = None): ...
    def get_code(self) -> str: ...
    def get_message(self) -> str: ...
    def get_request_id(self) -> str: ...

class StandardRetryer:
    def __init__(self, max_attempts: int = 3, backoff_fn = None, logger = None): ...

class NoopRetryer:
    def __init__(self): ...

Error Handling and Retry

Service Clients

Service-specific client classes for accessing Tencent Cloud APIs. All service clients follow a consistent pattern and inherit from AbstractClient.

Core Compute Services:

  • CVM (Cloud Virtual Machine): EC2-equivalent compute instances, images, snapshots
  • SCF (Serverless Cloud Function): Function-as-a-service execution environment
  • THPC (Tencent High Performance Computing): High-performance computing clusters

Storage Services:

  • CBS (Cloud Block Storage): Block storage volumes for CVM instances
  • CFS (Cloud File Storage): Managed NFS file systems
  • COS (Cloud Object Storage): S3-compatible object storage

Networking Services:

  • VPC (Virtual Private Cloud): Software-defined networking, subnets, routing
  • CLB (Cloud Load Balancer): Application and network load balancing
  • CDN (Content Delivery Network): Global content caching and acceleration
# Example service client signatures (CVM, CBS, VPC)
class CvmClient(AbstractClient):
    def __init__(self, credential, region: str, profile = None): ...
    def DescribeInstances(self, request) -> models.DescribeInstancesResponse: ...
    def RunInstances(self, request) -> models.RunInstancesResponse: ...
    def TerminateInstances(self, request) -> models.TerminateInstancesResponse: ...

class CbsClient(AbstractClient):
    def __init__(self, credential, region: str, profile = None): ...
    def CreateDisks(self, request) -> models.CreateDisksResponse: ...
    def AttachDisks(self, request) -> models.AttachDisksResponse: ...
    def DetachDisks(self, request) -> models.DetachDisksResponse: ...

class VpcClient(AbstractClient):
    def __init__(self, credential, region: str, profile = None): ...
    def CreateVpc(self, request) -> models.CreateVpcResponse: ...
    def CreateSubnet(self, request) -> models.CreateSubnetResponse: ...
    def DescribeVpcs(self, request) -> models.DescribeVpcsResponse: ...

Service Clients

Data Models

Base model class and service-specific request/response models providing JSON serialization and data validation for all API interactions.

class AbstractModel:
    def __init__(self): ...
    def to_json_string(self, indent: int = None) -> str: ...
    def from_json_string(self, json_string: str): ...

# Example model classes (all models inherit from AbstractModel)
class DescribeInstancesRequest(AbstractModel):
    def __init__(self): ...

class DescribeInstancesResponse(AbstractModel):
    def __init__(self): ...

class Instance(AbstractModel):
    def __init__(self): ...

Data Models

Types

# Core credential interface
class CredentialInterface:
    def get_credential(self): ...

# Request/response base
class AbstractModel:
    def to_json_string(self, indent: int = None) -> str: ...
    def from_json_string(self, json_string: str): ...
    def _serialize(self) -> dict: ...

# Filter for query operations
class Filter:
    def __init__(self):
        self.Name: str = None
        self.Values: list = None

# Basic pagination
class Paging:
    def __init__(self):
        self.Offset: int = None
        self.Limit: int = None

# Common placement information
class Placement:
    def __init__(self):
        self.Zone: str = None
        self.ProjectId: int = None
        self.HostIds: list = None