|
9 | 9 | download as _download,
|
10 | 10 | get_file_info as getFileInfo,
|
11 | 11 | get_balance as getBalance,
|
12 |
| - get_api_key as getApiKey |
| 12 | + get_api_key as getApiKey, |
| 13 | + ipns_generate_key as ipnsGenerateKey, |
| 14 | + ipns_publish_record as ipnsPublishRecord, |
| 15 | + get_ipns_record as getIpnsRecord, |
| 16 | + remove_ipns_record as removeIpnsRecord, |
13 | 17 | )
|
14 | 18 |
|
15 | 19 |
|
@@ -57,6 +61,51 @@ def getBalance(self):
|
57 | 61 | return getBalance.get_balance(self.token)
|
58 | 62 | except Exception as e:
|
59 | 63 | raise e
|
| 64 | + |
| 65 | + def generateKey(self): |
| 66 | + """ |
| 67 | + Generate a new IPNS key for the authenticated user. |
| 68 | + :return: dict, The generated IPNS key information. |
| 69 | + """ |
| 70 | + try: |
| 71 | + return ipnsGenerateKey.ipns_generate_key(self.token) |
| 72 | + except Exception as e: |
| 73 | + raise e |
| 74 | + |
| 75 | + def publishRecord(self, cid: str, keyName: str): |
| 76 | + """ |
| 77 | + Publish an IPNS record for a given CID and key name. |
| 78 | + :param cid: str, Content Identifier to publish |
| 79 | + :param keyName: str, Name of the IPNS key to use |
| 80 | + :return: dict, The published IPNS record information |
| 81 | + """ |
| 82 | + try: |
| 83 | + return ipnsPublishRecord.ipns_publish_record(self.token, cid, keyName) |
| 84 | + except Exception as e: |
| 85 | + raise e |
| 86 | + |
| 87 | + def getAllKeys(self): |
| 88 | + """ |
| 89 | + Retrieves all IPNS records associated with the current token. |
| 90 | + return: list A list of IPNS records retrieved using the provided token. |
| 91 | + """ |
| 92 | + |
| 93 | + try: |
| 94 | + return getIpnsRecord.get_ipns_records(self.token) |
| 95 | + except Exception as e: |
| 96 | + raise e |
| 97 | + |
| 98 | + def removeKey(self, keyName: str): |
| 99 | + """ |
| 100 | + Remove IPNS record of the given keyName |
| 101 | + :param keyName: str, Name of the IPNS key to use |
| 102 | + :return: dict, A dict of removed IPNS record. |
| 103 | + """ |
| 104 | + |
| 105 | + try: |
| 106 | + return removeIpnsRecord.remove_ipns_record(self.token, keyName) |
| 107 | + except Exception as e: |
| 108 | + raise e |
60 | 109 |
|
61 | 110 | @staticmethod
|
62 | 111 | def downloadBlob(dist: io.BufferedWriter, cid: str, chunk_size=1024*1024*10):
|
|
0 commit comments