Skip to content
Snippets Groups Projects
Unverified Commit 023697e7 authored by Emanuel Ferreira's avatar Emanuel Ferreira Committed by GitHub
Browse files

feat: add get_permission_info to resource reader mixin + readers (#16835)

parent c31f7c0c
No related branches found
No related tags found
No related merge requests found
......@@ -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:
"""
......
......@@ -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"}
......
......@@ -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]:
......
......@@ -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"
......
......@@ -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))
......
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment