renaming authorize_action to assert_action_allowed

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
Francisco Javier Arceo 2025-07-21 15:47:43 -04:00
parent 9a308e0ef1
commit d58c2c5f3c
2 changed files with 11 additions and 11 deletions

View file

@ -210,7 +210,7 @@ class CommonRoutingTableImpl(RoutingTable):
await self.dist_registry.register(obj)
return obj
async def authorize_action(
async def assert_action_allowed(
self,
action: Action,
type: str,

View file

@ -92,7 +92,7 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
self,
vector_store_id: str,
) -> VectorStoreObject:
await self.authorize_action("read", "vector_db", vector_store_id)
await self.assert_action_allowed("read", "vector_db", vector_store_id)
return await self.get_provider_impl(vector_store_id).openai_retrieve_vector_store(vector_store_id)
async def openai_update_vector_store(
@ -102,7 +102,7 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
expires_after: dict[str, Any] | None = None,
metadata: dict[str, Any] | None = None,
) -> VectorStoreObject:
await self.authorize_action("update", "vector_db", vector_store_id)
await self.assert_action_allowed("update", "vector_db", vector_store_id)
return await self.get_provider_impl(vector_store_id).openai_update_vector_store(
vector_store_id=vector_store_id,
name=name,
@ -114,7 +114,7 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
self,
vector_store_id: str,
) -> VectorStoreDeleteResponse:
await self.authorize_action("delete", "vector_db", vector_store_id)
await self.assert_action_allowed("delete", "vector_db", vector_store_id)
result = await self.get_provider_impl(vector_store_id).openai_delete_vector_store(vector_store_id)
await self.unregister_vector_db(vector_store_id)
return result
@ -129,7 +129,7 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
rewrite_query: bool | None = False,
search_mode: str | None = "vector",
) -> VectorStoreSearchResponsePage:
await self.authorize_action("read", "vector_db", vector_store_id)
await self.assert_action_allowed("read", "vector_db", vector_store_id)
return await self.get_provider_impl(vector_store_id).openai_search_vector_store(
vector_store_id=vector_store_id,
query=query,
@ -147,7 +147,7 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
attributes: dict[str, Any] | None = None,
chunking_strategy: VectorStoreChunkingStrategy | None = None,
) -> VectorStoreFileObject:
await self.authorize_action("update", "vector_db", vector_store_id)
await self.assert_action_allowed("update", "vector_db", vector_store_id)
return await self.get_provider_impl(vector_store_id).openai_attach_file_to_vector_store(
vector_store_id=vector_store_id,
file_id=file_id,
@ -164,7 +164,7 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
before: str | None = None,
filter: VectorStoreFileStatus | None = None,
) -> list[VectorStoreFileObject]:
await self.authorize_action("read", "vector_db", vector_store_id)
await self.assert_action_allowed("read", "vector_db", vector_store_id)
return await self.get_provider_impl(vector_store_id).openai_list_files_in_vector_store(
vector_store_id=vector_store_id,
limit=limit,
@ -179,7 +179,7 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
vector_store_id: str,
file_id: str,
) -> VectorStoreFileObject:
await self.authorize_action("read", "vector_db", vector_store_id)
await self.assert_action_allowed("read", "vector_db", vector_store_id)
return await self.get_provider_impl(vector_store_id).openai_retrieve_vector_store_file(
vector_store_id=vector_store_id,
file_id=file_id,
@ -190,7 +190,7 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
vector_store_id: str,
file_id: str,
) -> VectorStoreFileContentsResponse:
await self.authorize_action("read", "vector_db", vector_store_id)
await self.assert_action_allowed("read", "vector_db", vector_store_id)
return await self.get_provider_impl(vector_store_id).openai_retrieve_vector_store_file_contents(
vector_store_id=vector_store_id,
file_id=file_id,
@ -202,7 +202,7 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
file_id: str,
attributes: dict[str, Any],
) -> VectorStoreFileObject:
await self.authorize_action("update", "vector_db", vector_store_id)
await self.assert_action_allowed("update", "vector_db", vector_store_id)
return await self.get_provider_impl(vector_store_id).openai_update_vector_store_file(
vector_store_id=vector_store_id,
file_id=file_id,
@ -214,7 +214,7 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
vector_store_id: str,
file_id: str,
) -> VectorStoreFileDeleteResponse:
await self.authorize_action("delete", "vector_db", vector_store_id)
await self.assert_action_allowed("delete", "vector_db", vector_store_id)
return await self.get_provider_impl(vector_store_id).openai_delete_vector_store_file(
vector_store_id=vector_store_id,
file_id=file_id,