def _find_domain_record_id(self, domain, rr='', typ='', value=''): request = DescribeDomainRecordsRequest() request.set_accept_format("json") request.set_DomainName(domain) request.set_TypeKeyWord(typ) request.set_RRKeyWord(rr) request.set_ValueKeyWord(value) records = json.loads(self._client.do_action_with_exception(request)) for record in records['DomainRecords']['Record']: if record['RR'] == rr: return record['RecordId'] raise errors.PluginError( 'Unexpected error determining record identifier for {0}: {1}'. format(rr, 'record not found'))
def get_domain_records(self, domain_name: str, host_record_keyword: str = None, type_keyword: str = 'A', value_keyword: str = None) -> dict: if not self._data_valid(domain_name): raise RuntimeError('缺少域名名称') request = DescribeDomainRecordsRequest() request.set_accept_format('json') request.set_DomainName(domain_name) # request.set_PageSize('100') if self._data_valid(host_record_keyword): request.set_RRKeyWord(host_record_keyword) request.set_TypeKeyWord(type_keyword) if self._data_valid(value_keyword): request.set_ValueKeyWord(value_keyword) response = self.client.do_action_with_exception(request) # type: bytes response_data = json.loads(response.decode('utf-8')) return response_data