Replace args names to make them clearer

- remove the article
- separate words by undersore
- add adjetive
master
juga 2 years ago
parent d9831d15af
commit 531b242ebd

@ -35,14 +35,14 @@ class GNUnetRest:
r = requests.get(self.identity)
return r.json() if r.ok else (False, r.reason)
def fetch_identity_name(self, thename):
def fetch_identity_name(self, name):
"""Returns the public key of an identity specified by name."""
r = requests.get(self.identity_hash + thename)
r = requests.get(self.identity_hash + name)
return r.json()['name'] if r.ok else (False, r.reason)
def fetch_identity_hash(self, thepubkey):
def fetch_identity_hash(self, key_hash):
"""Returns the name of an identity specified by public key."""
r = requests.get(self.identity_name + thepubkey)
r = requests.get(self.identity_name + key_hash)
return r.json()['pubkey'] if r.ok else (False, r.reason)
def fetch_identity_namestore(self):
@ -50,89 +50,88 @@ class GNUnetRest:
r = requests.get(self.identity_namestore)
return r.json()['name'] if r.ok else (False, r.reason)
def create_identity(self, thename):
def create_identity(self, name):
"""Creates Identy, returns True if successful, False if not."""
r = requests.post(self.identity, {"name": thename})
r = requests.post(self.identity, {"name": name})
return r.ok if r.ok else (False, r.reason)
def change_identity_name(self, thename, newname):
def change_identity_name(self, name, new_name):
"""Changes name of identity.
Returns True if successful, False if not.
"""
r = requests.put(
self.identity_name + thename,
{"newname": newname}
self.identity_name + name,
{"new_name": new_name}
)
return True if r.ok else (False, r.reason)
def delete_identity(self, thename):
def delete_identity(self, name):
"""Deletes Identity, returns True if successful, false if not."""
r = requests.delete(self.identity_name + thename)
r = requests.delete(self.identity_name + name)
return True if r.ok else (False, r.reason)
# Namestore Section
def set_namestore_identity(self, thename):
def set_namestore_identity(self, name):
"""Sets the default Identity for subsystem 'namestore'.
Returns True if successful False if not.
"""
r = requests.put(self.identity_subsystem, {"subsystem": "namestore"})
# r =
return True if r.ok else (False, r.reason)
def list_namestore_entries(self, thezone):
def list_namestore_entries(self, zone):
"""Returns a list of all namestore entries."""
r = requests.get(self.namestore + thezone)
r = requests.get(self.namestore + zone)
return r.json() if r.ok else (False, r.reason)
def add_namestore_entry(self, thezone, thename, thevalue, thetype):
def add_namestore_entry(self, zone, name, value, record_type):
"""Adds a namestore entry, returns true if successful, false if not."""
data = {
'value': thevalue,
'record_type': thetype,
'record_name': thename,
'value': value,
'record_type': record_type,
'record_name': name,
"expiration_time": "1d",
"private": False,
"relative_expiration": False,
"supplemental": False,
"shadow": False,
}
r = requests.post(self.namestore + thezone, data)
r = requests.post(self.namestore + zone, data)
return True if r.ok else (False, r.reason)
def change_namestore_entry(self, thezone, thename, thevalue, thetype):
def change_namestore_entry(self, zone, name, value, record_type):
# changes a namestore entry, returns true if successful, false if not
data = {
'value': thevalue,
'record_type': thetype,
'record_name': thename,
'value': value,
'record_type': record_type,
'record_name': name,
}
r = requests.put(self.namestore + thezone, data)
r = requests.put(self.namestore + zone, data)
return True if r.ok else (False, r.reason)
def delete_namestore_entry(self, thezone, thename):
def delete_namestore_entry(self, zone, name):
"""Deletes a namestore entry.
Returns true if successful, false if not.
"""
r = requests.delete(self.namestore + thezone + "/" + thename)
r = requests.delete(self.namestore + zone + "/" + name)
return True if r.ok else (False, r.reason)
# GNS section
def list_gns_record(self, thezone, thename):
def list_gns_record(self, zone, name):
"""Returns a list of values and record types with the same record name."""
r = requests.get(self.gns + thename + "." + thezone)
r = requests.get(self.gns + name + "." + zone)
return r.json() if r.ok else (False, r.reason)
def list_gns_record_type(self, thezone, thename, thetype):
def list_gns_record_type(self, zone, name, record_type):
"""Returns a list of values of a certain name and record type."""
r = requests.get(
self.gns + thename + "." + thezone + "?record_type=" + thetype
self.gns + name + "." + zone + "?record_type=" + record_type
)
return r.json() if r.ok else (False, r.reason)

Loading…
Cancel
Save