diff --git a/llama-index-core/llama_index/core/readers/base.py b/llama-index-core/llama_index/core/readers/base.py index e2330582779e9b82b86fe014e3769f11f4830b49..8cfc76cc83640ef7bc1c7f4c33d75154a0aa6cb7 100644 --- a/llama-index-core/llama_index/core/readers/base.py +++ b/llama-index-core/llama_index/core/readers/base.py @@ -82,6 +82,22 @@ class ResourcesReaderMixin(ABC): """ return self.list_resources(*args, **kwargs) + def get_permission_info(self, resource_id: str, *args: Any, **kwargs: Any) -> Dict: + """ + Get a dictionary of information about the permissions of a specific resource. + """ + raise NotImplementedError( + f"{self.__class__.__name__} does not provide get_permission_info method currently" + ) + + async def aget_permission_info( + self, resource_id: str, *args: Any, **kwargs: Any + ) -> Dict: + """ + Get a dictionary of information about the permissions of a specific resource asynchronously. + """ + return self.get_permission_info(resource_id, *args, **kwargs) + @abstractmethod def get_resource_info(self, resource_id: str, *args: Any, **kwargs: Any) -> Dict: """ diff --git a/llama-index-core/pyproject.toml b/llama-index-core/pyproject.toml index ee5d7d7aa804a63b768f703f3362c316d1fa40b8..fabe167ef515f615913c08eb92c076046c406599 100644 --- a/llama-index-core/pyproject.toml +++ b/llama-index-core/pyproject.toml @@ -46,7 +46,7 @@ name = "llama-index-core" packages = [{include = "llama_index"}] readme = "README.md" repository = "https://github.com/run-llama/llama_index" -version = "0.11.23" +version = "0.11.24" [tool.poetry.dependencies] SQLAlchemy = {extras = ["asyncio"], version = ">=1.4.49"} diff --git a/llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/llama_index/readers/microsoft_onedrive/base.py b/llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/llama_index/readers/microsoft_onedrive/base.py index 81cff6103c5c12e6139341006f6caa51b333c2c1..320a2e9b2add5a30e45a0c77d582a2675159c929 100644 --- a/llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/llama_index/readers/microsoft_onedrive/base.py +++ b/llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/llama_index/readers/microsoft_onedrive/base.py @@ -653,6 +653,21 @@ class OneDriveReader(BasePydanticReader, ResourcesReaderMixin, FileSystemReaderM f"An error occurred while loading the data: {e}", exc_info=True ) + def get_permission_info(self, resource_id: str, *args: Any, **kwargs: Any) -> Dict: + payloads = self._get_downloaded_files_metadata( + file_paths=[resource_id], *args, **kwargs + ) + + item = next( + payload.resource_info + for payload in payloads + if payload.resource_info["file_path"] == resource_id + ) + + access_token = self._authenticate_with_msal() + + return self._get_permissions_info(item, self.userprincipalname, access_token) + def _get_permissions_info( self, item: Dict[str, Any], userprincipalname: str, access_token: str ) -> Dict[str, Any]: diff --git a/llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/pyproject.toml b/llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/pyproject.toml index 03c61a94d8b69322c93bc3614cd0138adb156045..432af9e2d87def14e9bf04349ac504a0ee0593de 100644 --- a/llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/pyproject.toml +++ b/llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/pyproject.toml @@ -29,7 +29,7 @@ license = "MIT" maintainers = ["godwin3737"] name = "llama-index-readers-microsoft-onedrive" readme = "README.md" -version = "0.2.2" +version = "0.2.3" [tool.poetry.dependencies] python = ">=3.8.1,<4.0" diff --git a/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/llama_index/readers/microsoft_sharepoint/base.py b/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/llama_index/readers/microsoft_sharepoint/base.py index 12d94bd6f092e69e25c5c45834f54d4f6dc7a2d3..8ec1bac73c89c4a95e9347101954493147556492 100644 --- a/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/llama_index/readers/microsoft_sharepoint/base.py +++ b/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/llama_index/readers/microsoft_sharepoint/base.py @@ -770,13 +770,27 @@ class SharePointReader(BasePydanticReader, ResourcesReaderMixin, FileSystemReade return response.json() + def get_permission_info(self, resource_id: str, **kwargs) -> Dict: + """ + Get a dictionary of information about the permissions of a specific resource. + """ + try: + item = self._get_item_from_path(Path(resource_id)) + return self._get_permissions_info(item) + except Exception as exp: + logger.error( + "An error occurred while fetching file information from SharePoint: %s", + exp, + ) + raise + def get_resource_info(self, resource_id: str, **kwargs) -> Dict: """ Retrieves metadata for a specified file in SharePoint without downloading it. Args: input_file (Path): The path of the file in SharePoint. The path should include - the SharePoint site name and the folder path. e.g. "site_name/folder_path/file_name". + the SharePoint site name and the folder path. e.g. "site_name/folder_path/file_name". """ try: item = self._get_item_from_path(Path(resource_id)) diff --git a/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/pyproject.toml b/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/pyproject.toml index 8101f5f49d6c9ffb497cf257e01ce487b76fa505..3fb136bbd7bb9fc5ac320c9535b2d7311e21c3f5 100644 --- a/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/pyproject.toml +++ b/llama-index-integrations/readers/llama-index-readers-microsoft-sharepoint/pyproject.toml @@ -29,7 +29,7 @@ license = "MIT" maintainers = ["arun-soliton"] name = "llama-index-readers-microsoft-sharepoint" readme = "README.md" -version = "0.4.0" +version = "0.4.1" [tool.poetry.dependencies] python = ">=3.8.1,<4.0"