コード例 #1
0
 def delete(self):
     alld = self.init_data_Text.get(1.0, END).strip()
     par = self.key.get(1.0, END).strip()
     for domain in alld.split():
         try:
             domain = domain.strip()
             requ = DeleteDomainRecordRequest()
             requ.set_RecordId(par)
             self.client.do_action_with_exception(requ).decode()
             self.name_data_Text.insert(END, f'{par}     删除成功\n', "tag2")
         except Exception as err:
               if "DNS record does not exist in your account" in str(err):
                   self.name_data_Text.insert(END, f'没有 {par}  dns记录\n', "tag1")
               elif "The parameter value RecordId is invalid"   in str(err):
                   self.name_data_Text.insert(END, f'{par}  键值错误\n', "tag1")
               else:
                   self.name_data_Text.insert(END, "========================================\n", "tag1")
                   self.name_data_Text.insert(END, f"{par}    {err}\n", "tag1")
                   self.name_data_Text.insert(END, "========================================\n", "tag1")
コード例 #2
0
    def del_record(self, *args, **kwargs):
        request = DeleteDomainRecordRequest()
        request.set_accept_format('json')
        request.set_RecordId(kwargs.get('record_id'))

        response = self.__client.do_action_with_exception(request)
        return str(response, encoding='utf-8')
コード例 #3
0
    def del_txt_record(self, domain, record_name, record_content):
        """
        Delete a TXT record using the supplied information.

        Note that both the record's name and content are used to ensure that similar records
        created concurrently (e.g., due to concurrent invocations of this plugin) are not deleted.

        Failures are logged, but not raised.

        :param str domain: The domain to use to look up the Aliyun zone.
        :param str record_name: The record name (typically beginning with '_acme-challenge.').
        :param str record_content: The record content (typically the challenge validation).
        """

        record_id = self._find_txt_record_id(domain, record_name,
                                             record_content)
        if record_id is None:
            logger.debug('TXT record not found; no cleanup needed.')
            return

        request = DeleteDomainRecordRequest()
        request.set_accept_format('json')
        request.set_RecordId(record_id)

        try:
            self.ac.do_action_with_exception(request)
            logger.debug('Successfully deleted TXT record.')
        except ClientException as e:
            logger.warning(
                'Encountered Aliyun ClientException deleting TXT record: %s',
                e)
コード例 #4
0
    def delete_record(accessKeyId, accessSecret, recordid):
        client = AcsClient(accessKeyId, accessSecret, 'cn-hangzhou')

        request = DeleteDomainRecordRequest()
        request.set_accept_format('json')

        request.set_RecordId(recordid)

        response = client.do_action_with_exception(request)
コード例 #5
0
    def _delete_domain_record(self, record_id: str):
        request = DeleteDomainRecordRequest()
        request.set_accept_format('json')

        request.set_RecordId(record_id)

        response = self.client.do_action_with_exception(request)
        response = response.decode('utf-8')
        return json.loads(response)
コード例 #6
0
def DeleteDomainRecordHelper(Client, RecordId):
    Request = DeleteDomainRecordRequest()
    Request.set_accept_format(RecordId)

    #设置待删除记录的RecordId
    Request.set_RecordId(RecordId)

    result = ExecuteGetResults(Client,Request)
    print(result)
    return result
コード例 #7
0
    def del_txt_record(self, domain, record_name, value):
        rr = record_name[:record_name.rindex('.' + domain)]
        record_id = self._find_domain_record_id(domain, rr=rr, typ='TXT')

        request = DeleteDomainRecordRequest()
        request.set_accept_format("json")

        request.set_RecordId(record_id)

        self._client.do_action_with_exception(request)
コード例 #8
0
ファイル: aliyun.py プロジェクト: aixan/aixan
def Ali_Del_Parsing(key, secret, region, RecordId):
    try:
        client = AcsClient(key, secret, region)
        request = DeleteDomainRecordRequest()
        request.set_accept_format('json')
        request.set_RecordId(RecordId)
        response = client.do_action_with_exception(request)
        data = {"code": 0, "data": response.decode(encoding='utf-8')}
        return data
    except Exception:
        return {"code": 1}
コード例 #9
0
ファイル: aliyun.py プロジェクト: ypoison/jumpserver
    def del_record(self, obj):
        self.client = AcsClient(obj.domain_name.account.access_id,
                                obj.domain_name.account.access_key,
                                'cn-hangzhou')
        request = DeleteDomainRecordRequest()
        request.set_accept_format('json')

        request.set_RecordId(obj.record_id)

        try:
            response = self.client.do_action_with_exception(request)
            ret = json.loads(str(response, encoding='utf-8'))
            return {'code': 1, 'message': ret}
        except Exception as e:
            return {'code': 0, 'message': e}
コード例 #10
0
ファイル: aliyundns.py プロジェクト: scsven/dns-restful
    def delete(self, rr):
        """
        Delete specify domain record if exists.

        :param rr: subdomain
        """
        record_id = None
        records = self.list()
        for record in records:
            if record['RR'] == rr:
                record_id = record['RecordId']
                break
        if record_id is None:
            logging.debug(
                f'AliyunDNS::delete: record for {rr + "." + self.domain} does not exist, ignore'
            )
            return
        request = DeleteDomainRecordRequest()
        request.set_accept_format('json')
        request.set_RecordId(f'{record_id}')
        response = str(self.client.do_action_with_exception(request),
                       encoding='utf-8')
        logging.debug(json.loads(response))
コード例 #11
0
ファイル: deleteTXT.py プロジェクト: selko0521/CertUpdate
from aliyunsdkalidns.request.v20150109.DeleteDomainRecordRequest import DeleteDomainRecordRequest
from aliyunsdkalidns.request.v20150109.DescribeDomainRecordsRequest import DescribeDomainRecordsRequest

domain = idna.decode(os.getenv("DOMAIN"))
accessKeyID = os.getenv("ACCESSKEYID")
accessSecret = os.getenv("ACCESSSECRET")
apinode = "cn-shanghai"

client = AcsClient(accessKeyID, accessSecret, apinode)

request = DescribeDomainRecordsRequest()
request.set_accept_format('json')

request.set_DomainName(domain)

response = client.do_action_with_exception(request)
records = json.loads(str(response, encoding='utf-8'))
records = records["DomainRecords"]["Record"]

for r in records:
    if r["Type"] == "TXT" and r["RR"] == "_acme-challenge":
        RecordId = r["RecordId"]

        request = DeleteDomainRecordRequest()
        request.set_accept_format('json')

        request.set_RecordId(RecordId)

        response = client.do_action_with_exception(request)
        print(str(response, encoding='utf-8'))
コード例 #12
0
ファイル: alidns.py プロジェクト: chenwb-m/ddns
 def __remove_record(self, record_id):
     '''Remove record'''
     req = DeleteDomainRecordRequest()
     req.set_RecordId(record_id)
     js = json.loads(self.__client.do_action_with_exception(req).decode())