Source code for lucidlink.workspace

"""
Workspace context after successful authentication.
"""

from typing import List, Optional

from .filespace import Filespace
from .filespace_models import FilespaceInfo, SyncMode


[docs] class Workspace: """ Workspace context after successful authentication. Provides access to filespace operations within the authenticated workspace. Returned by ``Daemon.authenticate()``. Example: .. code-block:: python credentials = ServiceAccountCredentials(token) workspace = daemon.authenticate(credentials) print(workspace.id, workspace.name) """ def __init__(self, native_daemon, workspace_id: str, workspace_name: str): """ Initialize workspace context. Args: native_daemon: Native daemon wrapper (internal use) workspace_id: Workspace ID workspace_name: Workspace name Note: This constructor is called internally by ``Daemon.authenticate()``. Users should not construct ``Workspace`` objects directly. """ self._native_daemon = native_daemon self._id = workspace_id self._name = workspace_name self._active_filespace = None @property def id(self) -> str: """Get the workspace ID.""" return self._id @property def name(self) -> str: """Get the workspace name.""" return self._name
[docs] def list_filespaces(self) -> List[FilespaceInfo]: """ List all filespaces in this workspace. Returns: List of FilespaceInfo objects with id, name, and created timestamp. Raises: ConnectionError: If WebService unreachable AuthenticationError: If access token expired RuntimeError: If daemon not running Example: .. code-block:: python filespaces = workspace.list_filespaces() for fs in filespaces: print(f"{fs.name}") """ return [ FilespaceInfo(id=d["id"], name=d["name"], created=d["created"]) for d in self._native_daemon.list_filespaces(self.id) ]
[docs] def stop(self) -> None: """Stop workspace — unlinks active filespace if any. If ``sync_mode`` is ``SYNC_ALL``, calls ``sync_all()`` before unlinking. Safe to call multiple times. """ if self._active_filespace is not None: try: self._active_filespace.unlink() except Exception: pass self._active_filespace = None
def __repr__(self) -> str: return f"Workspace(id='{self.id}', name='{self.name}')"