Browse Source

Replace var name by more descriptive name

master
juga 2 years ago
parent
commit
969b3ac8d3
1 changed files with 26 additions and 24 deletions
  1. +26
    -24
      pygnunetrest/gnunetrest.py

+ 26
- 24
pygnunetrest/gnunetrest.py View File

@ -35,9 +35,9 @@ class GNUnetRest:
r = requests.get(self.identity)
return r.json() if r.ok else (False, r.reason)
def fetch_identity_keyhash(self, name):
def fetch_identity_keyhash(self, identity_name):
"""Returns the public key of an identity specified by name."""
r = requests.get(self.identity_hash + name)
r = requests.get(self.identity_hash + identity_name)
return r.json()['name'] if r.ok else (False, r.reason)
def fetch_identity_name(self, key_hash):
@ -50,37 +50,39 @@ class GNUnetRest:
r = requests.get(self.identity_namestore)
return r.json()['name'] if r.ok else (False, r.reason)
def create_identity(self, name):
def create_identity(self, identity_name):
"""Creates Identy, returns True if successful, False if not."""
r = requests.post(self.identity, {"name": name})
r = requests.post(self.identity, {"name": identity_name})
return r.ok if r.ok else (False, r.reason)
def change_identity_name(self, name, new_name):
def change_identity_name(self, identity_name, new_identity_name):
"""Changes name of identity.
Returns True if successful, False if not.
"""
r = requests.put(
self.identity_name + name,
{"new_name": new_name}
self.identity_name + identity_name,
{"newname": new_identity_name}
)
return True if r.ok else (False, r.reason)
def delete_identity(self, name):
def delete_identity(self, identity_name):
"""Deletes Identity, returns True if successful, false if not."""
r = requests.delete(self.identity_name + name)
r = requests.delete(self.identity_name + identity_name)
return True if r.ok else (False, r.reason)
# Namestore Section
def set_namestore_identity(self, name):
def set_namestore_identity(self, identity_name):
"""Sets the default Identity for subsystem 'namestore'.
Returns True if successful False if not.
"""
r = requests.put(self.identity_subsystem, {"subsystem": "namestore"})
r = requests.put(
self.identity_subsystem + identity_name,
{"subsystem": "namestore"})
return True if r.ok else (False, r.reason)
def list_namestore_entries(self, zone):
@ -88,13 +90,13 @@ class GNUnetRest:
r = requests.get(self.namestore + zone)
return r.json() if r.ok else (False, r.reason)
def add_namestore_entry(self, zone, name, value, record_type):
def add_namestore_entry(self, zone, record_name, value, record_type):
"""Adds a namestore entry, returns true if successful, false if not."""
data = {
'value': value,
'record_type': record_type,
'record_name': name,
'record_name': record_name,
"expiration_time": "1d",
"private": False,
"relative_expiration": False,
@ -104,34 +106,34 @@ class GNUnetRest:
r = requests.post(self.namestore + zone, data)
return True if r.ok else (False, r.reason)
def change_namestore_entry(self, zone, name, value, record_type):
def change_namestore_entry(self, zone, record_name, value, record_type):
# changes a namestore entry, returns true if successful, false if not
data = {
'value': value,
'record_type': record_type,
'record_name': name,
'record_name': record_name,
}
r = requests.put(self.namestore + zone, data)
return True if r.ok else (False, r.reason)
def delete_namestore_entry(self, zone, name):
"""Deletes a namestore entry.
def delete_namestore_entry(self, zone, record_name):
"""Deletes a record_namestore entry.
Returns true if successful, false if not.
"""
r = requests.delete(self.namestore + zone + "/" + name)
r = requests.delete(self.namestore + zone + "/" + record_name)
return True if r.ok else (False, r.reason)
# GNS section
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 + name + "." + zone)
def list_gns_record(self, zone, record_name):
"""Returns a list of values and record types with the same record record_name."""
r = requests.get(self.gns + record_name + "." + zone)
return r.json() if r.ok else (False, r.reason)
def list_gns_record_type(self, zone, name, record_type):
"""Returns a list of values of a certain name and record type."""
def list_gns_record_type(self, zone, record_name, record_type):
"""Returns a list of values of a certain record_name and record type."""
r = requests.get(
self.gns + name + "." + zone + "?record_type=" + record_type
self.gns + record_name + "." + zone + "?record_type=" + record_type
)
return r.json() if r.ok else (False, r.reason)

Loading…
Cancel
Save