nucliadb 6.9.0.post5131__py3-none-any.whl → 6.9.0.post5134__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of nucliadb might be problematic. Click here for more details.

@@ -44,12 +44,20 @@ from nucliadb_utils.authentication import requires, requires_one
44
44
  )
45
45
  @requires(NucliaDBRoles.MANAGER)
46
46
  @version(1)
47
- async def get_kbs(request: Request, prefix: str = "") -> KnowledgeBoxList:
47
+ async def get_kbs(
48
+ request: Request,
49
+ prefix: str = "",
50
+ x_nucliadb_account: str = Header(default="", include_in_schema=False),
51
+ ) -> KnowledgeBoxList:
48
52
  driver = get_driver()
49
53
  async with driver.ro_transaction() as txn:
50
54
  response = KnowledgeBoxList()
51
55
  async for kbid, slug in datamanagers.kb.get_kbs(txn, prefix=prefix):
52
- response.kbs.append(KnowledgeBoxObjSummary(slug=slug or None, uuid=kbid))
56
+ response.kbs.append(
57
+ KnowledgeBoxObjSummary(
58
+ slug=user_kb_slug(slug, account_id=x_nucliadb_account) or None, uuid=kbid
59
+ )
60
+ )
53
61
  return response
54
62
 
55
63
 
@@ -62,7 +70,9 @@ async def get_kbs(request: Request, prefix: str = "") -> KnowledgeBoxList:
62
70
  )
63
71
  @requires_one([NucliaDBRoles.MANAGER, NucliaDBRoles.READER])
64
72
  @version(1)
65
- async def get_kb(request: Request, kbid: str) -> KnowledgeBoxObj:
73
+ async def get_kb(
74
+ request: Request, kbid: str, x_nucliadb_account: str = Header(default="", include_in_schema=False)
75
+ ) -> KnowledgeBoxObj:
66
76
  driver = get_driver()
67
77
  async with driver.ro_transaction() as txn:
68
78
  kb_config = await datamanagers.kb.get_config(txn, kbid=kbid)
@@ -71,7 +81,7 @@ async def get_kb(request: Request, kbid: str) -> KnowledgeBoxObj:
71
81
 
72
82
  return KnowledgeBoxObj(
73
83
  uuid=kbid,
74
- slug=kb_config.slug,
84
+ slug=user_kb_slug(kb_config.slug, account_id=x_nucliadb_account),
75
85
  config=from_proto.knowledgebox_config(kb_config),
76
86
  )
77
87
 
@@ -104,6 +114,18 @@ async def get_kb_by_slug(
104
114
 
105
115
  return KnowledgeBoxObj(
106
116
  uuid=kbid,
107
- slug=kb_config.slug,
117
+ slug=user_kb_slug(kb_config.slug, account_id=x_nucliadb_account),
108
118
  config=from_proto.knowledgebox_config(kb_config),
109
119
  )
120
+
121
+
122
+ def user_kb_slug(stored_slug: str, account_id: str) -> str:
123
+ if account_id != "":
124
+ # On cloud deployments, backend prepends the account id to the user-defined slug.
125
+ # This is required to make kb slugs reused across different accounts using the same nucliadb.
126
+ # We strip it so the user does not see it.
127
+ return stored_slug.split(f"{account_id}:")[-1]
128
+ else:
129
+ # On on-prem deployments, the account_id is set to "" by default and we don't need to strip
130
+ # anything as the backend is not invovled in the kb creation process.
131
+ return stored_slug
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb
3
- Version: 6.9.0.post5131
3
+ Version: 6.9.0.post5134
4
4
  Summary: NucliaDB
5
5
  Author-email: Nuclia <nucliadb@nuclia.com>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -19,11 +19,11 @@ Classifier: Programming Language :: Python :: 3.12
19
19
  Classifier: Programming Language :: Python :: 3 :: Only
20
20
  Requires-Python: <4,>=3.9
21
21
  Description-Content-Type: text/markdown
22
- Requires-Dist: nucliadb-telemetry[all]>=6.9.0.post5131
23
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.9.0.post5131
24
- Requires-Dist: nucliadb-protos>=6.9.0.post5131
25
- Requires-Dist: nucliadb-models>=6.9.0.post5131
26
- Requires-Dist: nidx-protos>=6.9.0.post5131
22
+ Requires-Dist: nucliadb-telemetry[all]>=6.9.0.post5134
23
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.9.0.post5134
24
+ Requires-Dist: nucliadb-protos>=6.9.0.post5134
25
+ Requires-Dist: nucliadb-models>=6.9.0.post5134
26
+ Requires-Dist: nidx-protos>=6.9.0.post5134
27
27
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
28
28
  Requires-Dist: nuclia-models>=0.50.0
29
29
  Requires-Dist: uvicorn[standard]
@@ -205,7 +205,7 @@ nucliadb/reader/api/models.py,sha256=UHhOPmh8xcHhDjFm8_-8t66yEggXdxRBoY0xV-hI9to
205
205
  nucliadb/reader/api/v1/__init__.py,sha256=ieP8lsCCwG66Jupv8II5MSTj6nh3eCtLcF4utH9JOcU,1102
206
206
  nucliadb/reader/api/v1/download.py,sha256=F48YM3BPwuHwDgYk0jjRHHJHh732QUb4nCAS5xyNqzg,10819
207
207
  nucliadb/reader/api/v1/export_import.py,sha256=x4VBNDFjnlY1nIt5kdq0eZTB_DeRzGzT8T7uB7wUhNU,6448
208
- nucliadb/reader/api/v1/knowledgebox.py,sha256=POvDz6TE8PDE7HqmN0ty8LZfvhxoWrzRxlKXqHbJEHA,4007
208
+ nucliadb/reader/api/v1/knowledgebox.py,sha256=lmKDGbpDC30XTH1yhDWwrHdV8-uc5KGfI73zlmxImGA,4973
209
209
  nucliadb/reader/api/v1/learning_config.py,sha256=wL4k9ZFK0BX17ocq1tUmbh-atLrw-Xag7Ly8wgD1xrQ,6812
210
210
  nucliadb/reader/api/v1/resource.py,sha256=WTBIEywfHfy4sIffnVm9s__3--JpHi9hprVpK0Ddd04,14164
211
211
  nucliadb/reader/api/v1/router.py,sha256=eyNmEGSP9zHkCIG5XlAXl6sukq950B7gFT3X2peMtIE,1011
@@ -384,8 +384,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
384
384
  nucliadb/writer/tus/s3.py,sha256=vu1BGg4VqJ_x2P1u2BxqPKlSfw5orT_a3R-Ln5oPUpU,8483
385
385
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
386
386
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
387
- nucliadb-6.9.0.post5131.dist-info/METADATA,sha256=Oh-fGFwmJ6B2_D4jprcbr78U-8lwid_6iQWI_zfIeUA,4158
388
- nucliadb-6.9.0.post5131.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
389
- nucliadb-6.9.0.post5131.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
390
- nucliadb-6.9.0.post5131.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
391
- nucliadb-6.9.0.post5131.dist-info/RECORD,,
387
+ nucliadb-6.9.0.post5134.dist-info/METADATA,sha256=u9m0m3yydjFA5OGD0VtqvgO5JfIrB0KPtp6PzV2iajU,4158
388
+ nucliadb-6.9.0.post5134.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
389
+ nucliadb-6.9.0.post5134.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
390
+ nucliadb-6.9.0.post5134.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
391
+ nucliadb-6.9.0.post5134.dist-info/RECORD,,