tencent cloud tccli
2024-08-16tccli是一个命令帮助你调用tencent api.
1、
pip install tencentcloud-sdk-python
pip install tccli
pip install certifi
2、
tccli billing DescribeBillDetail --cli-unfold-argument
tccli billing DescribeAccountBalance
tccli cdb DescribeDBInstances --cli-unfold-argument --region ap-beijing
3、cat << EOF > tx-GetAccout.py
#!/usr/bin/env python
#coding=utf-8
#author:suzhuchang
import json
import yaml
import urllib2
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.billing.v20180709 import billing_client, models
def GetAk(f_obj):
with open(f_obj) as f:
ak = yaml.load(f)
return ak
def GetAccout(ak,aks):
try:
cred = credential.Credential(ak, aks)
httpProfile = HttpProfile()
httpProfile.endpoint = "billing.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = billing_client.BillingClient(cred, "", clientProfile)
req = models.DescribeAccountBalanceRequest()
params = {
}
req.from_json_string(json.dumps(params))
resp = client.DescribeAccountBalance(req)
return resp.__dict__
except TencentCloudSDKException as err:
print(err)
if __name__ == "__main__":
AK = GetAk('tencentAk.yaml')
Mon =('%.2f' %(float(GetAccout(AK['SecretId'],AK['SecretKey'])['Balance'])/float(100)))
print('腾讯云账户余额: '+str(Mon))