package main
import (
"fmt"
"github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/errors"
"github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/common/profile"
cvm "github.com/tencentcloud/tencentcloud-sdk-go-intl-en/tencentcloud/cvm/v20170312"
)
func main() {
// Instantiate an authentication object. The Tencent Cloud account secretId and secretKey need to be passed in as the input parameters.
credential := common.NewCredential(
"your-secret-id",
"your-secret-key",
)
// Instantiate a client configuration object; you can specify the timeout and other configurations.
cpf := profile.NewClientProfile()
cpf.HttpProfile.ReqMethod = "GET"
cpf.HttpProfile.ReqTimeout = 5
cpf.SignMethod = "HmacSHA1"
// Instantiate the client object to request the product (with CVM as an example).
client, _ := cvm.NewClient(credential, "ap-beijing", cpf)
// Instantiate a request object; you can further set the request parameters according to the API called and actual conditions.
request := cvm.NewDescribeZonesRequest()
// Call the API you want to access through the client object; you need to pass in the request object.
response, err := client.DescribeZones(request)
// Handle the exception
if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err)
return
}
// unexpected errors
if err != nil {
panic(err)
}
// Print the returned json string
fmt.Printf("%s", response.ToJsonString())
}
本页内容是否解决了您的问题?