nsj-rest-lib2 0.0.23__py3-none-any.whl → 0.0.24__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.
- nsj_rest_lib2/controller/dynamic_controller.py +47 -8
- nsj_rest_lib2/service/entity_loader.py +4 -0
- {nsj_rest_lib2-0.0.23.dist-info → nsj_rest_lib2-0.0.24.dist-info}/METADATA +1 -1
- {nsj_rest_lib2-0.0.23.dist-info → nsj_rest_lib2-0.0.24.dist-info}/RECORD +6 -6
- {nsj_rest_lib2-0.0.23.dist-info → nsj_rest_lib2-0.0.24.dist-info}/WHEEL +0 -0
- {nsj_rest_lib2-0.0.23.dist-info → nsj_rest_lib2-0.0.24.dist-info}/top_level.txt +0 -0
|
@@ -53,10 +53,19 @@ def setup_dynamic_routes(
|
|
|
53
53
|
multidb: bool = True,
|
|
54
54
|
dynamic_root_path: str = "edl1",
|
|
55
55
|
injector_factory: Any = None,
|
|
56
|
+
escopo_in_url: bool = False,
|
|
56
57
|
) -> None:
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
if not escopo_in_url:
|
|
60
|
+
COLLECTION_DYNAMIC_ROUTE = f"/{APP_NAME}/{dynamic_root_path}/<entity_resource>"
|
|
61
|
+
ONE_DYNAMIC_ROUTE = f"/{APP_NAME}/{dynamic_root_path}/<entity_resource>/<id>"
|
|
62
|
+
else:
|
|
63
|
+
COLLECTION_DYNAMIC_ROUTE = (
|
|
64
|
+
f"/{APP_NAME}/{dynamic_root_path}/<entity_escopo>/<entity_resource>"
|
|
65
|
+
)
|
|
66
|
+
ONE_DYNAMIC_ROUTE = (
|
|
67
|
+
f"/{APP_NAME}/{dynamic_root_path}/<entity_escopo>/<entity_resource>/<id>"
|
|
68
|
+
)
|
|
60
69
|
|
|
61
70
|
def list_dynamic_wrapper(injector_factory: Any, *args: Any, **kwargs: Any) -> Any:
|
|
62
71
|
|
|
@@ -67,6 +76,11 @@ def setup_dynamic_routes(
|
|
|
67
76
|
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
68
77
|
entity_resource = kwargs.pop("entity_resource")
|
|
69
78
|
|
|
79
|
+
# Verificando se o identificador do escopo foi passado na URL
|
|
80
|
+
entity_escopo = ""
|
|
81
|
+
if "entity_escopo" in kwargs:
|
|
82
|
+
entity_escopo = kwargs.pop("entity_escopo")
|
|
83
|
+
|
|
70
84
|
# Lendo tenant e grupo_empresarial
|
|
71
85
|
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
72
86
|
|
|
@@ -80,7 +94,7 @@ def setup_dynamic_routes(
|
|
|
80
94
|
api_expose,
|
|
81
95
|
api_verbs,
|
|
82
96
|
) = entity_loader.load_entity_source(
|
|
83
|
-
entity_resource, tenant, grupo_empresarial
|
|
97
|
+
entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
|
|
84
98
|
)
|
|
85
99
|
|
|
86
100
|
# Verificando se essa API deve ser exposta
|
|
@@ -112,6 +126,11 @@ def setup_dynamic_routes(
|
|
|
112
126
|
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
113
127
|
entity_resource = kwargs.pop("entity_resource")
|
|
114
128
|
|
|
129
|
+
# Verificando se o identificador do escopo foi passado na URL
|
|
130
|
+
entity_escopo = ""
|
|
131
|
+
if "entity_escopo" in kwargs:
|
|
132
|
+
entity_escopo = kwargs.pop("entity_escopo")
|
|
133
|
+
|
|
115
134
|
# Lendo tenant e grupo_empresarial
|
|
116
135
|
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
117
136
|
|
|
@@ -125,7 +144,7 @@ def setup_dynamic_routes(
|
|
|
125
144
|
api_expose,
|
|
126
145
|
api_verbs,
|
|
127
146
|
) = entity_loader.load_entity_source(
|
|
128
|
-
entity_resource, tenant, grupo_empresarial
|
|
147
|
+
entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
|
|
129
148
|
)
|
|
130
149
|
|
|
131
150
|
# Verificando se essa API deve ser exposta
|
|
@@ -156,6 +175,11 @@ def setup_dynamic_routes(
|
|
|
156
175
|
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
157
176
|
entity_resource = kwargs.pop("entity_resource")
|
|
158
177
|
|
|
178
|
+
# Verificando se o identificador do escopo foi passado na URL
|
|
179
|
+
entity_escopo = ""
|
|
180
|
+
if "entity_escopo" in kwargs:
|
|
181
|
+
entity_escopo = kwargs.pop("entity_escopo")
|
|
182
|
+
|
|
159
183
|
# Lendo tenant e grupo_empresarial
|
|
160
184
|
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
161
185
|
|
|
@@ -169,7 +193,7 @@ def setup_dynamic_routes(
|
|
|
169
193
|
api_expose,
|
|
170
194
|
api_verbs,
|
|
171
195
|
) = entity_loader.load_entity_source(
|
|
172
|
-
entity_resource, tenant, grupo_empresarial
|
|
196
|
+
entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
|
|
173
197
|
)
|
|
174
198
|
|
|
175
199
|
# Verificando se essa API deve ser exposta
|
|
@@ -200,6 +224,11 @@ def setup_dynamic_routes(
|
|
|
200
224
|
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
201
225
|
entity_resource = kwargs.pop("entity_resource")
|
|
202
226
|
|
|
227
|
+
# Verificando se o identificador do escopo foi passado na URL
|
|
228
|
+
entity_escopo = ""
|
|
229
|
+
if "entity_escopo" in kwargs:
|
|
230
|
+
entity_escopo = kwargs.pop("entity_escopo")
|
|
231
|
+
|
|
203
232
|
# Lendo tenant e grupo_empresarial
|
|
204
233
|
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
205
234
|
|
|
@@ -213,7 +242,7 @@ def setup_dynamic_routes(
|
|
|
213
242
|
api_expose,
|
|
214
243
|
api_verbs,
|
|
215
244
|
) = entity_loader.load_entity_source(
|
|
216
|
-
entity_resource, tenant, grupo_empresarial
|
|
245
|
+
entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
|
|
217
246
|
)
|
|
218
247
|
|
|
219
248
|
# Verificando se essa API deve ser exposta
|
|
@@ -244,6 +273,11 @@ def setup_dynamic_routes(
|
|
|
244
273
|
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
245
274
|
entity_resource = kwargs.pop("entity_resource")
|
|
246
275
|
|
|
276
|
+
# Verificando se o identificador do escopo foi passado na URL
|
|
277
|
+
entity_escopo = ""
|
|
278
|
+
if "entity_escopo" in kwargs:
|
|
279
|
+
entity_escopo = kwargs.pop("entity_escopo")
|
|
280
|
+
|
|
247
281
|
# Lendo tenant e grupo_empresarial
|
|
248
282
|
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
249
283
|
|
|
@@ -257,7 +291,7 @@ def setup_dynamic_routes(
|
|
|
257
291
|
api_expose,
|
|
258
292
|
api_verbs,
|
|
259
293
|
) = entity_loader.load_entity_source(
|
|
260
|
-
entity_resource, tenant, grupo_empresarial
|
|
294
|
+
entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
|
|
261
295
|
)
|
|
262
296
|
|
|
263
297
|
# Verificando se essa API deve ser exposta
|
|
@@ -288,6 +322,11 @@ def setup_dynamic_routes(
|
|
|
288
322
|
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
289
323
|
entity_resource = kwargs.pop("entity_resource")
|
|
290
324
|
|
|
325
|
+
# Verificando se o identificador do escopo foi passado na URL
|
|
326
|
+
entity_escopo = ""
|
|
327
|
+
if "entity_escopo" in kwargs:
|
|
328
|
+
entity_escopo = kwargs.pop("entity_escopo")
|
|
329
|
+
|
|
291
330
|
# Lendo tenant e grupo_empresarial
|
|
292
331
|
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
293
332
|
|
|
@@ -301,7 +340,7 @@ def setup_dynamic_routes(
|
|
|
301
340
|
api_expose,
|
|
302
341
|
api_verbs,
|
|
303
342
|
) = entity_loader.load_entity_source(
|
|
304
|
-
entity_resource, tenant, grupo_empresarial
|
|
343
|
+
entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
|
|
305
344
|
)
|
|
306
345
|
|
|
307
346
|
# Verificando se essa API deve ser exposta
|
|
@@ -48,6 +48,10 @@ class EntityLoader:
|
|
|
48
48
|
grupo_empresarial: str | None,
|
|
49
49
|
escopo: str = ESCOPO_RESTLIB2,
|
|
50
50
|
) -> tuple[str, str, dict, bool, list[str]]:
|
|
51
|
+
# Assumind o escopo default se necessário
|
|
52
|
+
if not escopo:
|
|
53
|
+
escopo = ESCOPO_RESTLIB2
|
|
54
|
+
|
|
51
55
|
# Montando as chaves dos namespaces
|
|
52
56
|
grupo_key, tenant_key, default_key = compile_namespace_keys(
|
|
53
57
|
tenant, grupo_empresarial
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nsj_rest_lib2
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.24
|
|
4
4
|
Summary: Biblioteca para permitir a distribuição de rotas dinâmicas numa API, configuradas por meio de EDLs declarativos (em formato JSON).
|
|
5
5
|
Home-page: https://github.com/Nasajon/nsj_rest_lib2
|
|
6
6
|
Author: Nasajon Sistemas
|
|
@@ -27,10 +27,10 @@ nsj_rest_lib2/compiler/util/str_util.py,sha256=0ReIQ2Vy4zAmVMvGv0FcUehRQw15hlz0e
|
|
|
27
27
|
nsj_rest_lib2/compiler/util/type_naming_util.py,sha256=wTfxPCezCTt-ltSg_hkaYNH7Z05k-mlJKZd-9AMA9ac,768
|
|
28
28
|
nsj_rest_lib2/compiler/util/type_util.py,sha256=HTKOH4uRTOY0YgoM8oUv_6cEcReE_bgKYXFBsQCb-3A,357
|
|
29
29
|
nsj_rest_lib2/controller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
|
-
nsj_rest_lib2/controller/dynamic_controller.py,sha256=
|
|
30
|
+
nsj_rest_lib2/controller/dynamic_controller.py,sha256=RPudLwssBiLjV9an1PWjQPAEcXUVeHw2Z7cUTDCsptQ,16905
|
|
31
31
|
nsj_rest_lib2/service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
-
nsj_rest_lib2/service/entity_loader.py,sha256
|
|
33
|
-
nsj_rest_lib2-0.0.
|
|
34
|
-
nsj_rest_lib2-0.0.
|
|
35
|
-
nsj_rest_lib2-0.0.
|
|
36
|
-
nsj_rest_lib2-0.0.
|
|
32
|
+
nsj_rest_lib2/service/entity_loader.py,sha256=2A-RSX3F7rHpAR60DGN6d7Ctz3V4f982Wa7lGAcAU1o,15697
|
|
33
|
+
nsj_rest_lib2-0.0.24.dist-info/METADATA,sha256=xKcuQysGN2ULhF6FQE92BvpC0FQWBUVzPBWardDus0Y,1094
|
|
34
|
+
nsj_rest_lib2-0.0.24.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
35
|
+
nsj_rest_lib2-0.0.24.dist-info/top_level.txt,sha256=L6zh0EfH8_rur7OJ8_V-El-XEMf4qg3bkF8ADgqLVIA,14
|
|
36
|
+
nsj_rest_lib2-0.0.24.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|