@@ -53,6 +53,7 @@ def __init__(self, config: traitlets.config.Config) -> None:
5353 self ._max_files_listed = 1025
5454 self ._drives = None
5555 self ._external_drives = {}
56+ self ._excluded_drives = set ()
5657
5758 # instate fsspec file system
5859 self ._file_system = fsspec .filesystem (self ._config .provider , asynchronous = True )
@@ -171,6 +172,65 @@ def set_listing_limit(self, new_limit):
171172
172173 return
173174
175+ def exclude_drive (self , exclude_drive_name ):
176+ """Exclude drive from listing.
177+
178+ Args:
179+ exclude_bucket_name: drive to exclude
180+ """
181+ try :
182+ self ._excluded_drives .add (exclude_drive_name );
183+ except Exception as e :
184+ raise tornado .web .HTTPError (
185+ status_code = httpx .codes .BAD_REQUEST ,
186+ reason = f"The following error occured when excluding the drive: { e } "
187+ )
188+
189+ return
190+
191+ def get_excluded_drives (self ):
192+ """Get list of excluded drives.
193+
194+ Returns:
195+ List of excluded drives and their properties.
196+ """
197+ data = []
198+ for drive in self ._excluded_drives :
199+ try :
200+ data .append ({
201+ "name" : drive ,
202+ "region" : self ._config .region_name if drive not in self ._content_managers else self ._content_managers [drive ]["location" ],
203+ "creationDate" : datetime .now ().isoformat (timespec = 'milliseconds' ).replace ('+00:00' , 'Z' ),
204+ "mounted" : False if drive not in self ._content_managers else True ,
205+ "provider" : self ._config .provider
206+ })
207+ except Exception as e :
208+ raise tornado .web .HTTPError (
209+ status_code = httpx .codes .BAD_REQUEST ,
210+ reason = f"The following error occurred when listing excluded drives: { e } " ,
211+ )
212+
213+ response = {
214+ "data" : data
215+ }
216+ return response
217+
218+ def include_drive (self , include_drive_name ):
219+ """Include drive in listing.
220+
221+ Args:
222+ include_bucket_name: drive to include in listing
223+ """
224+ try :
225+ self ._excluded_drives .remove (include_drive_name );
226+ except Exception as e :
227+ raise tornado .web .HTTPError (
228+ status_code = httpx .codes .BAD_REQUEST ,
229+ reason = f"The following error occurred when including the drive: { e } "
230+ )
231+
232+ return
233+
174234 async def list_drives (self ):
175235 """Get list of available drives.
176236
@@ -196,26 +256,28 @@ async def list_drives(self):
196256 )
197257
198258 for result in results :
199- data .append (
200- {
201- "name" : result .name ,
202- "region" : self ._config .region_name ,
203- "creationDate" : result .extra ["creation_date" ],
204- "mounted" : False if result .name not in self ._content_managers else True ,
205- "provider" : self ._config .provider
206- }
207- )
259+ if result .name not in self ._excluded_drives :
260+ data .append (
261+ {
262+ "name" : result .name ,
263+ "region" : self ._config .region_name if result .name not in self ._content_managers else self ._content_managers [result .name ]["location" ],
264+ "creationDate" : result .extra ["creation_date" ],
265+ "mounted" : False if result .name not in self ._content_managers else True ,
266+ "provider" : self ._config .provider
267+ }
268+ )
208269
209270 if len (self ._external_drives ) != 0 :
210271 for drive in self ._external_drives .values ():
211272 try :
212- data .append ({
213- "name" : drive ['url' ],
214- "region" : self ._config .region_name ,
215- "creationDate" : datetime .now ().isoformat (timespec = 'milliseconds' ).replace ('+00:00' , 'Z' ),
216- "mounted" : False if result .name not in self ._content_managers else True ,
217- "provider" : self ._config .provider
218- })
273+ if drive ['url' ] not in self ._excluded_drives :
274+ data .append ({
275+ "name" : drive ['url' ],
276+ "region" : self ._config .region_name if drive ['url' ] not in self ._content_managers else self ._content_managers [drive ['url' ]]["location" ],
277+ "creationDate" : datetime .now ().isoformat (timespec = 'milliseconds' ).replace ('+00:00' , 'Z' ),
278+ "mounted" : False if result .name not in self ._content_managers else True ,
279+ "provider" : self ._config .provider
280+ })
219281 except Exception as e :
220282 raise tornado .web .HTTPError (
221283 status_code = httpx .codes .BAD_REQUEST ,
0 commit comments