添加筛选条件
This commit is contained in:
parent
5075039809
commit
62b5be0b0c
@ -62,7 +62,7 @@ class PorkbunAPI:
|
||||
|
||||
return response.status_code
|
||||
|
||||
def find_record(self, _type: "str" = None, name: "str" = None, content: "str" = None, verbose: "bool" = True):
|
||||
def find_record(self, _type: "str" = None, name: "str" = None, content: "str" = None, ttl: "int" = None, verbose: "bool" = True):
|
||||
records = {}
|
||||
|
||||
def filter_fun(x):
|
||||
@ -72,6 +72,8 @@ class PorkbunAPI:
|
||||
return False
|
||||
if content is not None and self.__records[x]["content"] != content:
|
||||
return False
|
||||
if ttl is not None and int(self.__records[x]["ttl"]) != ttl:
|
||||
return False
|
||||
return True
|
||||
|
||||
for i in filter(filter_fun, self.__records):
|
||||
@ -174,9 +176,9 @@ class PorkbunAPI:
|
||||
print("response code is ", response.status_code)
|
||||
print(response.json())
|
||||
|
||||
def edit_A_with_name(self, name: "str", content: "str" = "1.1.1.1"):
|
||||
def edit_A_with_name(self, name: "str", content: "str" = "1.1.1.1", ttl: "int" = None):
|
||||
self.retrieve(verbose=False)
|
||||
result = self.find_record(_type="A", name=name, verbose=False)
|
||||
result = self.find_record(_type="A", name=name, ttl=ttl, verbose=False)
|
||||
if len(result) != 1:
|
||||
print("Multiple records are selected")
|
||||
self.find_record(_type="A", name=name)
|
||||
|
Loading…
Reference in New Issue
Block a user