22
33import os
44import io
5- from .functions import (
5+ from .functions import (
66 upload as d ,
77 deal_status ,
88 get_uploads as getUploads ,
99 download as _download ,
10- create_wallet as createWallet
10+ get_file_info as getFileInfo ,
11+ get_balance as getBalance ,
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 ,
1117)
1218
1319
@@ -44,20 +50,63 @@ def uploadBlob(self, source: io.BufferedReader, filename: str, tag: str = ''):
4450 return d .uploadBlob (source , filename , self .token , tag )
4551 except Exception as e :
4652 raise e
53+
54+ def getBalance (self ):
55+ """
56+ Retrieve the balance information of a user from the Lighthouse.
57+ :param publicKey: str, The public key of the user.
58+ :return: dict[str, any], A dictionary containing the data usage and data limit details.
59+ """
60+ try :
61+ return getBalance .get_balance (self .token )
62+ except Exception as e :
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
4774
48- @staticmethod
49- def createWallet (password : str ):
75+ def publishRecord (self , cid : str , keyName : str ):
5076 """
51- Creates a new wallet using the provided password.
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
5286
53- :param password: str, The password to secure the wallet.
54- :return: dict, The wallet encrypted with the passowrd
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.
5591 """
92+
5693 try :
57- return createWallet . create_wallet ( password )
94+ return getIpnsRecord . get_ipns_records ( self . token )
5895 except Exception as e :
5996 raise e
60-
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
109+
61110 @staticmethod
62111 def downloadBlob (dist : io .BufferedWriter , cid : str , chunk_size = 1024 * 1024 * 10 ):
63112 """
@@ -87,18 +136,16 @@ def getDealStatus(cid: str):
87136 return deal_status .get_deal_status (cid )
88137 except Exception as e :
89138 raise e
90-
91- @staticmethod
92- def getUploads (publicKey : str , pageNo : int = 1 ):
139+
140+ def getUploads (self , lastKey : str = None ):
93141 """
94142 Get uploads from the Lighthouse.
95143
96- :param publicKey: str, public key
97- :param pageNo: int, page number (default: 1)
144+ :param lastKey: To navigate to different pages of results
98145 :return: List[t.DealData], list of deal data
99146 """
100147 try :
101- return getUploads .get_uploads (publicKey , pageNo )
148+ return getUploads .get_uploads (self . token , lastKey )
102149 except Exception as e :
103150 raise e
104151
@@ -115,6 +162,34 @@ def download(cid: str):
115162 return _download .get_file (cid )
116163 except Exception as e :
117164 raise e
165+
166+ @staticmethod
167+ def getFileInfo (cid : str ):
168+ """
169+ Retrieves information about a file using its CID (Content Identifier).
170+ :param cid: str, Content Identifier for the data to be downloaded
171+ returns: dict, A dictionary containing file information.
172+ """
173+
174+ try :
175+ return getFileInfo .get_file_info (cid )
176+ except Exception as e :
177+ raise e
178+
179+ @staticmethod
180+ def getApiKey (publicKey : str , signedMessage : str ):
181+ """
182+ Generates and returns an API key for the given public key and signed message.
183+ :param publicKey: str, The public key associated with the user.
184+ :param signedMessage: str, The message signed by the user's private key.
185+ :return: dict, A dict with generated API key.
186+ """
187+
188+
189+ try :
190+ return getApiKey .get_api_key (publicKey , signedMessage )
191+ except Exception as e :
192+ raise e
118193
119194 def getTagged (self , tag : str ):
120195 """
0 commit comments