# coding=utf-8 import os import requests import time from apig_sdk import signer from cf_dns import manage_dns_records from dns import resolve_dns from parse_json import filter_cname_records zone_id = "ff8080828ac2ecdd018be79a284a1495" if __name__ == '__main__': sig = signer.Signer() # Set the AK/SK to sign and authenticate the request. sig.Key = "4IGDYQM6O1N1NYFZRY4F" #os.getenv('HUAWEICLOUD_SDK_AK') sig.Secret = "0Gw1kkJsMUHaL0pcJXPhgMfbti7VDNM3eqpIhwOT" #os.getenv('HUAWEICLOUD_SDK_SK') while (True): # The following example shows how to set the request URL and parameters to query a VPC list. # Set request Endpoint. # Specify a request method, such as GET, PUT, POST, DELETE, HEAD, and PATCH. # Set request URI. # Set parameters for the request URL. r = signer.HttpRequest("GET", "https://dns.ap-southeast-1.myhuaweicloud.com/v2/zones/" + zone_id + "/recordsets?type=CNAME") r.headers = {"content-type": "application/json"} # Add a body if you have specified the PUT or POST method. Special characters, such as the double quotation mark ("), contained in the body must be escaped. r.body = "" sig.Sign(r) resp = requests.request(r.method, r.scheme + "://" + r.host + r.uri, headers=r.headers) domains = filter_cname_records(resp.content) resolved = resolve_dns(domains) manage_dns_records(resolved, "1fd21a56b6b4bb97d2401e79b2cfb3b4") time.sleep(120) # end while