|
24 | 24 | from lisapy.langchain import LisaOpenAIEmbeddings
|
25 | 25 | from models.domain_objects import IngestionType, RagDocument
|
26 | 26 | from repository.rag_document_repo import RagDocumentRepository
|
27 |
| -from utilities.common_functions import api_wrapper, get_cert_path, get_id_token, get_username, retry_config |
| 27 | +from utilities.common_functions import api_wrapper, get_cert_path, get_groups, get_id_token, get_username, retry_config |
28 | 28 | from utilities.exceptions import HTTPException
|
29 | 29 | from utilities.file_processing import process_record
|
30 | 30 | from utilities.validation import validate_model_name, ValidationError
|
@@ -186,22 +186,14 @@ def _get_embeddings_pipeline(model_name: str) -> Any:
|
186 | 186 |
|
187 | 187 | @api_wrapper
|
188 | 188 | def list_all(event: dict, context: dict) -> List[Dict[str, Any]]:
|
189 |
| - """Return info on all available repositories. |
190 |
| -
|
191 |
| - Currently, there is no support for dynamic repositories so only a single OpenSearch repository |
192 |
| - is returned. |
193 |
| - """ |
194 |
| - |
195 |
| - user_groups = json.loads(event["requestContext"]["authorizer"]["groups"]) or [] |
| 189 | + """Return info on all available repositories.""" |
| 190 | + user_groups = get_groups(event) |
196 | 191 | registered_repositories = get_registered_repositories()
|
197 |
| - |
198 |
| - return list( |
199 |
| - filter(lambda repository: user_has_group(user_groups, repository["allowedGroups"]), registered_repositories) |
200 |
| - ) |
| 192 | + return [repo for repo in registered_repositories if user_has_group(user_groups, repo["allowedGroups"])] |
201 | 193 |
|
202 | 194 |
|
203 | 195 | def user_has_group(user_groups: List[str], allowed_groups: List[str]) -> bool:
|
204 |
| - """Returns if user groups has at least one intersections with allowed groups. |
| 196 | + """Returns if user groups has at least one intersection with allowed groups. |
205 | 197 |
|
206 | 198 | If allowed groups is empty this will return True.
|
207 | 199 | """
|
@@ -290,8 +282,8 @@ def delete_document(event: dict, context: dict) -> Dict[str, Any]:
|
290 | 282 | path_params = event.get("pathParameters", {})
|
291 | 283 | repository_id = path_params.get("repositoryId")
|
292 | 284 |
|
293 |
| - query_string_params = event["queryStringParameters"] |
294 |
| - collection_id = query_string_params["collectionId"] |
| 285 | + query_string_params = event.get("queryStringParameters", {}) |
| 286 | + collection_id = query_string_params.get("collectionId") |
295 | 287 | document_id = query_string_params.get("documentId")
|
296 | 288 | document_name = query_string_params.get("documentName")
|
297 | 289 |
|
|
0 commit comments