pub struct TencentCloudClient {
pub secret_id: String,
pub secret_key: String,
pub token: Option<String>,
}
Expand description
Tencent Cloud SDK Client
This client is used to send authenticated requests to Tencent Cloud APIs.
It constructs the canonical request string, computes the TC3-HMAC-SHA256 signature,
builds the necessary headers, and sends an HTTPS POST request.
This version returns the response as a serde_json::Value
, preserving Chinese characters.
Fieldsยง
ยงsecret_id: String
Your Tencent Cloud SecretId.
secret_key: String
Your Tencent Cloud SecretKey.
token: Option<String>
Optional token.
Implementationsยง
Sourceยงimpl TencentCloudClient
impl TencentCloudClient
Sourcepub fn new(secret_id: &str, secret_key: &str, token: Option<&str>) -> Self
pub fn new(secret_id: &str, secret_key: &str, token: Option<&str>) -> Self
Creates a new TencentCloudClient.
ยงArguments
secret_id
- Your Tencent Cloud SecretId.secret_key
- Your Tencent Cloud SecretKey.token
- An optional token.
Sourcepub async fn request(
&self,
service: &str,
host: &str,
region: Option<&str>,
version: &str,
action: &str,
payload: &str,
) -> Result<Value, Box<dyn Error>>
pub async fn request( &self, service: &str, host: &str, region: Option<&str>, version: &str, action: &str, payload: &str, ) -> Result<Value, Box<dyn Error>>
Asynchronous general request function.
This method constructs the canonical request, computes the TC3-HMAC-SHA256 signature, builds the Authorization header, and sends an HTTPS POST request.
Instead of returning plain text, this version parses the response as JSON
and returns a serde_json::Value
, which preserves Chinese characters.
ยงArguments
service
- The service name (e.g., โcvmโ).host
- The request host (e.g., โcvm.tencentcloudapi.comโ).region
- Optional region string.version
- API version (e.g., โ2017-03-12โ).action
- API action name (e.g., โDescribeInstancesโ).payload
- The request body as a JSON string.
ยงReturns
A Result
containing the response parsed as serde_json::Value
on success,
or a boxed error on failure.