def check_money(): # try: for line in open("config.txt", 'r', encoding='utf-8'): line = line.strip().split(',') zhm = line[0] phone = line[1] accessKey = line[2] accessSecret = line[3] region = line[4] # print(line) # print(zhm,accessKey,accessSecret,region) cred = credential.Credential(accessKey, accessSecret) httpProfile = HttpProfile() httpProfile.endpoint = "billing.tencentcloudapi.com" clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile client = billing_client.BillingClient(cred, region, clientProfile) req = models.DescribeAccountBalanceRequest() params = '{}' req.from_json_string(params) resp = client.DescribeAccountBalance(req) # print(resp.to_json_string()) messg = resp.Balance # print(type(messg)) # print(messg) ye = messg / 100 # print(ye) mssg = ('{0}({1}): {2}(余额)'.format(zhm, phone, ye)) # print(mssg) mslist.append(mssg) a = print_mail(mslist) # print(a) send_mail(a)
def money(): 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) m_respon = float(json.loads(resp.to_json_string())['Balance']) / 100 print(m_respon)
def query_account_balance(self): # 账户余额 from tencentcloud.billing.v20180709 import billing_client, models self.httpProfile.endpoint = "billing.tencentcloudapi.com" try: client = billing_client.BillingClient(self.cred, self.regionid, self.clientProfile) req = models.DescribeAccountBalanceRequest() params = '{}' req.from_json_string(params) resp = client.DescribeAccountBalance(req) except TencentCloudSDKException as err: print(err) return False else: return resp.to_json_string()
def query_product_bill(self, start_time, end_time): # 产品级别的账单 from tencentcloud.billing.v20180709 import billing_client, models self.httpProfile.endpoint = "billing.tencentcloudapi.com" PayerUin = "100013454040" try: client = billing_client.BillingClient(self.cred, self.regionid, self.clientProfile) req = models.DescribeBillSummaryByProductRequest() params = '{\"PayerUin\":\"%s\",\"BeginTime\":\"%s\",\"EndTime\":\"%s\"}' % ( PayerUin, start_time, end_time) req.from_json_string(params) resp = client.DescribeBillSummaryByProduct(req) except TencentCloudSDKException as err: print(err) return False else: print(resp.to_json_string()) return resp.to_json_string()
def bill(): httpProfile = HttpProfile() httpProfile.endpoint = "billing.tencentcloudapi.com" clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile client = billing_client.BillingClient(cred, "", clientProfile) req = models.DescribeBillSummaryByProductRequest() params = {"BeginTime": args.time, "EndTime": args.time} req.from_json_string(json.dumps(params)) resp = client.DescribeBillSummaryByProduct(req) listnum = len(resp.SummaryOverview) for list_item in range(listnum): overview = json.loads(str(resp.SummaryOverview[list_item])) print("\n") for project, value in overview.items(): print(project, ":", value) total = json.loads(str(resp.SummaryTotal)) print("\n", "TOTAL COST:", sep="") for project, value in total.items(): print(project, ":", value)
def __init__(self, secretId, secretKey): super(AccountTencentClient, self).__init__(secretId, secretKey) self.client = billing_client.BillingClient(self.cred, None)
for line in open("config.txt", 'r', encoding='utf-8'): line = line.strip().split(',') zhm = line[0] phone = line[1] accessKey = line[2] accessSecret = line[3] region = line[4] # print(line) # print(zhm,accessKey,accessSecret,region) cred = credential.Credential(accessKey, accessSecret) httpProfile = HttpProfile() httpProfile.endpoint = "billing.tencentcloudapi.com" clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile client = billing_client.BillingClient(cred, region, clientProfile) req = models.DescribeAccountBalanceRequest() params = '{}' req.from_json_string(params) resp = client.DescribeAccountBalance(req) # print(resp.to_json_string()) messg = resp.Balance # print(type(messg)) # print(messg) ye = messg / 100 # print(ye) mssg = ('{0}({1}): {2}(余额)'.format(zhm, phone, ye)) print(mssg)