File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -926,6 +926,29 @@ def create_dnssec_record(
926926 response_json .get ("message" , "Unknown message" ),
927927 )
928928
929+ def delete_dnssec_record (self , domain : str , key_tag : int ) -> bool :
930+ """
931+ API DNSSEC delete method: delete an existing DNSSEC record for the given domain.
932+ See https://porkbun.com/api/json/v3/documentation#DNSSEC%20Delete%20Record for more info.
933+
934+ :param domain: the domain for which the DNSSEC record should be deleted
935+ :param key_tag: the key tag of the DNSSEC record
936+ :return: True if everything went well
937+ """
938+
939+ url = urljoin (self .api_endpoint , f"dns/deleteDnssecRecord/{ domain } /{ key_tag } " )
940+ req_json = self ._get_auth_request_json ()
941+ r = requests .post (url = url , json = req_json )
942+
943+ if r .status_code == 200 :
944+ return True
945+ else :
946+ response_json = json .loads (r .text )
947+ raise PKBClientException (
948+ response_json .get ("status" , "Unknown status" ),
949+ response_json .get ("message" , "Unknown message" ),
950+ )
951+
929952 @staticmethod
930953 def __handle_error_backup__ (dns_records ):
931954 # merge the single DNS records into one single dict with the record id as key
Original file line number Diff line number Diff line change @@ -1158,6 +1158,23 @@ def test_create_dnssec_record(self):
11581158 )
11591159 self .assertTrue (success )
11601160
1161+ @responses .activate
1162+ def delete_dnssec_record (self ):
1163+ pkb_client = PKBClient ("key" , "secret" )
1164+
1165+ responses .post (
1166+ url = urljoin (API_ENDPOINT , "dns/deleteDnssecRecord/example.com/123456" ),
1167+ json = {"status" : "SUCCESS" },
1168+ match = [
1169+ matchers .json_params_matcher (
1170+ {"apikey" : "key" , "secretapikey" : "secret" }
1171+ )
1172+ ],
1173+ )
1174+
1175+ success = pkb_client .delete_dnssec_record ("example.com" , 123456 )
1176+ self .assertTrue (success )
1177+
11611178
11621179if __name__ == "__main__" :
11631180 unittest .main ()
You can’t perform that action at this time.
0 commit comments