tencent-sdk

Crates.iotencent-sdk
lib.rstencent-sdk
version0.1.5
created_at2025-02-15 06:26:00.999391+00
updated_at2026-01-03 12:44:41.180875+00
description📦 Tencent Cloud API SDK written in Rust
homepagehttps://github.com/lvillis/tencent-sdk-rust
repositoryhttps://github.com/lvillis/tencent-sdk-rust
max_upload_size
id1556459
size302,227
(lvillis)

documentation

https://github.com/lvillis/tencent-sdk-rust/blob/main/README.md

README

🇺🇸 English · 🇨🇳 中文      |      Table of Contents ↗️

📦 Tencent Cloud API SDK written in Rust

crates.io version crates.io version crates.io version build status say thanks

Tencent Cloud API SDK for Rust. Async-first with an optional blocking client, sharing the same service layer, types and error model. Requests are authenticated using TC3-HMAC-SHA256.

Usage

Add the crate

[dependencies]
tencent-sdk = "0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Blocking-only (no Tokio):

[dependencies]
tencent-sdk = { version = "0.1", default-features = false, features = ["blocking-rustls"] }

Configure credentials and create clients

use std::time::Duration;
use tencent_sdk::types::{cvm::DescribeInstancesRequest, Filter};
use tencent_sdk::{Auth, Client};

#[tokio::main(flavor = "multi_thread")]
async fn main() -> Result<(), tencent_sdk::Error> {
    let secret_id = std::env::var("TENCENT_SECRET_ID").expect("missing TENCENT_SECRET_ID");
    let secret_key = std::env::var("TENCENT_SECRET_KEY").expect("missing TENCENT_SECRET_KEY");

    let client = Client::builder_tencent_cloud()?
        .auth(Auth::tc3(secret_id, secret_key))
        .default_region("ap-guangzhou")
        .no_system_proxy(true)
        .retry(3, Duration::from_millis(200))
        .build()?;

    let request = DescribeInstancesRequest::new()
        .limit(20)
        .push_filter(Filter::new("instance-name", ["example"]));

    let response = client.cvm().describe_instances(&request).await?;
    println!("instances: {:?}", response.response.total_count);
    Ok(())
}

The blocking client mirrors the async API (does not require Tokio):

use tencent_sdk::{Auth, BlockingClient};

fn main() -> Result<(), tencent_sdk::Error> {
    let secret_id = std::env::var("TENCENT_SECRET_ID").expect("missing TENCENT_SECRET_ID");
    let secret_key = std::env::var("TENCENT_SECRET_KEY").expect("missing TENCENT_SECRET_KEY");

    let client = BlockingClient::builder_tencent_cloud()?
        .auth(Auth::tc3(secret_id, secret_key))
        .no_system_proxy(true)
        .build()?;

    let result = client.billing().describe_account_balance()?;
    println!("balance: {:?}", result.response.real_balance);
    Ok(())
}

Features

  • Feature flags
    • async (default) with TLS backend: rustls (default) or native-tls
    • blocking via blocking-rustls or blocking-native-tls
    • Optional integrations: tracing, metrics
  • Async-first, optional blocking: Client (async) + BlockingClient (feature gated), sharing the same services and types.
  • No HTTP types in public API: the SDK does not expose reqwest/ureq types in public signatures.
  • TC3 signing: built-in TC3-HMAC-SHA256 signing with credential redaction in Debug output.
  • Actionable errors: structured Error with status / request_id / body snippet and service classification.

Implemented Interfaces

  • CVM

    • DescribeInstances
    • ResetInstancesPassword
    • DescribeInstanceVncUrl
    • StartInstances
    • RebootInstances
    • StopInstances
    • ModifyInstancesProject
    • RunInstances
    • TerminateInstances
    • DescribeImages
  • Tag

    • DescribeProjects
  • Billing

    • DescribeAccountBalance
  • CDN

    • UpdateDomainConfig (HTTPS certificate switch)
  • DNSPod

    • CreateRecord (TXT)
    • ModifyRecord (TXT)
    • DeleteRecord
  • SSL

    • ApplyCertificate
    • DescribeCertificate
    • DownloadCertificate
    • UploadCertificate
Commit count: 33

cargo fmt