nsj-rest-lib2 0.0.1__py3-none-any.whl → 0.0.2__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 +190 -159
- {nsj_rest_lib2-0.0.1.dist-info → nsj_rest_lib2-0.0.2.dist-info}/METADATA +1 -1
- {nsj_rest_lib2-0.0.1.dist-info → nsj_rest_lib2-0.0.2.dist-info}/RECORD +5 -5
- {nsj_rest_lib2-0.0.1.dist-info → nsj_rest_lib2-0.0.2.dist-info}/WHEEL +0 -0
- {nsj_rest_lib2-0.0.1.dist-info → nsj_rest_lib2-0.0.2.dist-info}/top_level.txt +0 -0
|
@@ -95,171 +95,202 @@ def setup_dynamic_routes(
|
|
|
95
95
|
|
|
96
96
|
return list_dynamic
|
|
97
97
|
|
|
98
|
-
def
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
entity_loader
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
98
|
+
def get_dynamic_wrapper(injector_factory: Any, *args: Any, **kwargs: Any) -> Any:
|
|
99
|
+
|
|
100
|
+
def get_dynamic(*args: Any, **kwargs: Any):
|
|
101
|
+
# Recuperando o identificador da entidade
|
|
102
|
+
if "entity_id" not in kwargs:
|
|
103
|
+
msg = "Faltando parâmetro identificador da entidade na URL."
|
|
104
|
+
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
105
|
+
entity_id = kwargs.pop("entity_id")
|
|
106
|
+
|
|
107
|
+
# Lendo tenant e grupo_empresarial
|
|
108
|
+
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
109
|
+
|
|
110
|
+
try:
|
|
111
|
+
# Recuperando o código do DTO e Entity correspondente
|
|
112
|
+
entity_loader = EntityLoader()
|
|
113
|
+
dto_class_name, entity_class_name, etities_dict = (
|
|
114
|
+
entity_loader.load_entity_source(
|
|
115
|
+
entity_id, tenant, grupo_empresarial
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# Executando o list pelo RestLib
|
|
120
|
+
route = GetRoute(
|
|
121
|
+
url=ONE_DYNAMIC_ROUTE,
|
|
122
|
+
http_method="GET",
|
|
123
|
+
dto_class=etities_dict[dto_class_name],
|
|
124
|
+
entity_class=etities_dict[entity_class_name],
|
|
125
|
+
injector_factory=injector_factory,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
return route.handle_request(*args, **kwargs)
|
|
129
|
+
except MissingEntityConfigException:
|
|
130
|
+
msg = f"Entity configuration for {entity_id} not found."
|
|
131
|
+
return (format_json_error(msg), 412, {**DEFAULT_RESP_HEADERS})
|
|
132
|
+
|
|
133
|
+
return get_dynamic
|
|
134
|
+
|
|
135
|
+
def post_dynamic_wrapper(injector_factory: Any, *args: Any, **kwargs: Any) -> Any:
|
|
136
|
+
def post_dynamic(*args: Any, **kwargs: Any):
|
|
137
|
+
# Recuperando o identificador da entidade
|
|
138
|
+
if "entity_id" not in kwargs:
|
|
139
|
+
msg = "Faltando parâmetro identificador da entidade na URL."
|
|
140
|
+
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
141
|
+
entity_id = kwargs.pop("entity_id")
|
|
142
|
+
|
|
143
|
+
# Lendo tenant e grupo_empresarial
|
|
144
|
+
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
145
|
+
|
|
146
|
+
try:
|
|
147
|
+
# Recuperando o código do DTO e Entity correspondente
|
|
148
|
+
entity_loader = EntityLoader()
|
|
149
|
+
dto_class_name, entity_class_name, etities_dict = (
|
|
150
|
+
entity_loader.load_entity_source(
|
|
151
|
+
entity_id, tenant, grupo_empresarial
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
# Executando o list pelo RestLib
|
|
156
|
+
route = PostRoute(
|
|
157
|
+
url=COLLECTION_DYNAMIC_ROUTE,
|
|
158
|
+
http_method="POST",
|
|
159
|
+
dto_class=etities_dict[dto_class_name],
|
|
160
|
+
entity_class=etities_dict[entity_class_name],
|
|
161
|
+
injector_factory=injector_factory,
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
return route.handle_request(*args, **kwargs)
|
|
165
|
+
except MissingEntityConfigException:
|
|
166
|
+
msg = f"Entity configuration for {entity_id} not found."
|
|
167
|
+
return (format_json_error(msg), 412, {**DEFAULT_RESP_HEADERS})
|
|
168
|
+
|
|
169
|
+
return post_dynamic
|
|
170
|
+
|
|
171
|
+
def put_dynamic_wrapper(injector_factory: Any, *args: Any, **kwargs: Any) -> Any:
|
|
172
|
+
def put_dynamic(*args: Any, **kwargs: Any):
|
|
173
|
+
# Recuperando o identificador da entidade
|
|
174
|
+
if "entity_id" not in kwargs:
|
|
175
|
+
msg = "Faltando parâmetro identificador da entidade na URL."
|
|
176
|
+
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
177
|
+
entity_id = kwargs.pop("entity_id")
|
|
178
|
+
|
|
179
|
+
# Lendo tenant e grupo_empresarial
|
|
180
|
+
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
181
|
+
|
|
182
|
+
try:
|
|
183
|
+
# Recuperando o código do DTO e Entity correspondente
|
|
184
|
+
entity_loader = EntityLoader()
|
|
185
|
+
dto_class_name, entity_class_name, etities_dict = (
|
|
186
|
+
entity_loader.load_entity_source(
|
|
187
|
+
entity_id, tenant, grupo_empresarial
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
# Executando o list pelo RestLib
|
|
192
|
+
route = PutRoute(
|
|
193
|
+
url=ONE_DYNAMIC_ROUTE,
|
|
194
|
+
http_method="PUT",
|
|
195
|
+
dto_class=etities_dict[dto_class_name],
|
|
196
|
+
entity_class=etities_dict[entity_class_name],
|
|
197
|
+
injector_factory=injector_factory,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
return route.handle_request(*args, **kwargs)
|
|
201
|
+
except MissingEntityConfigException:
|
|
202
|
+
msg = f"Entity configuration for {entity_id} not found."
|
|
203
|
+
return (format_json_error(msg), 412, {**DEFAULT_RESP_HEADERS})
|
|
204
|
+
|
|
205
|
+
return put_dynamic
|
|
206
|
+
|
|
207
|
+
def patch_dynamic_wrapper(injector_factory: Any, *args: Any, **kwargs: Any) -> Any:
|
|
208
|
+
def patch_dynamic(*args: Any, **kwargs: Any):
|
|
209
|
+
# Recuperando o identificador da entidade
|
|
210
|
+
if "entity_id" not in kwargs:
|
|
211
|
+
msg = "Faltando parâmetro identificador da entidade na URL."
|
|
212
|
+
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
213
|
+
entity_id = kwargs.pop("entity_id")
|
|
214
|
+
|
|
215
|
+
# Lendo tenant e grupo_empresarial
|
|
216
|
+
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
217
|
+
|
|
218
|
+
try:
|
|
219
|
+
# Recuperando o código do DTO e Entity correspondente
|
|
220
|
+
entity_loader = EntityLoader()
|
|
221
|
+
dto_class_name, entity_class_name, etities_dict = (
|
|
222
|
+
entity_loader.load_entity_source(
|
|
223
|
+
entity_id, tenant, grupo_empresarial
|
|
224
|
+
)
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
# Executando o list pelo RestLib
|
|
228
|
+
route = PatchRoute(
|
|
229
|
+
url=ONE_DYNAMIC_ROUTE,
|
|
230
|
+
http_method="PATCH",
|
|
231
|
+
dto_class=etities_dict[dto_class_name],
|
|
232
|
+
entity_class=etities_dict[entity_class_name],
|
|
233
|
+
injector_factory=injector_factory,
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
return route.handle_request(*args, **kwargs)
|
|
237
|
+
except MissingEntityConfigException:
|
|
238
|
+
msg = f"Entity configuration for {entity_id} not found."
|
|
239
|
+
return (format_json_error(msg), 412, {**DEFAULT_RESP_HEADERS})
|
|
240
|
+
|
|
241
|
+
return patch_dynamic
|
|
242
|
+
|
|
243
|
+
def delete_dynamic_wrapper(injector_factory: Any, *args: Any, **kwargs: Any) -> Any:
|
|
244
|
+
def delete_dynamic(*args: Any, **kwargs: Any):
|
|
245
|
+
# Recuperando o identificador da entidade
|
|
246
|
+
if "entity_id" not in kwargs:
|
|
247
|
+
msg = "Faltando parâmetro identificador da entidade na URL."
|
|
248
|
+
return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
|
|
249
|
+
entity_id = kwargs.pop("entity_id")
|
|
250
|
+
|
|
251
|
+
# Lendo tenant e grupo_empresarial
|
|
252
|
+
tenant, grupo_empresarial = _get_tenant_grupo()
|
|
253
|
+
|
|
254
|
+
try:
|
|
255
|
+
# Recuperando o código do DTO e Entity correspondente
|
|
256
|
+
entity_loader = EntityLoader()
|
|
257
|
+
dto_class_name, entity_class_name, etities_dict = (
|
|
258
|
+
entity_loader.load_entity_source(
|
|
259
|
+
entity_id, tenant, grupo_empresarial
|
|
260
|
+
)
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
# Executando o list pelo RestLib
|
|
264
|
+
route = DeleteRoute(
|
|
265
|
+
url=ONE_DYNAMIC_ROUTE,
|
|
266
|
+
http_method="DELETE",
|
|
267
|
+
dto_class=etities_dict[dto_class_name],
|
|
268
|
+
entity_class=etities_dict[entity_class_name],
|
|
269
|
+
injector_factory=injector_factory,
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
return route.handle_request(*args, **kwargs)
|
|
273
|
+
except MissingEntityConfigException:
|
|
274
|
+
msg = f"Entity configuration for {entity_id} not found."
|
|
275
|
+
return (format_json_error(msg), 412, {**DEFAULT_RESP_HEADERS})
|
|
276
|
+
|
|
277
|
+
return delete_dynamic
|
|
247
278
|
|
|
248
279
|
# Ajustando para o padrão com multi database (se necessário)
|
|
249
280
|
if multidb:
|
|
250
281
|
list_dynamic = multi_database()(list_dynamic_wrapper(injector_factory))
|
|
251
|
-
get_dynamic = multi_database()(
|
|
252
|
-
post_dynamic = multi_database()(
|
|
253
|
-
put_dynamic = multi_database()(
|
|
254
|
-
patch_dynamic = multi_database()(
|
|
255
|
-
delete_dynamic = multi_database()(
|
|
282
|
+
get_dynamic = multi_database()(get_dynamic_wrapper(injector_factory))
|
|
283
|
+
post_dynamic = multi_database()(post_dynamic_wrapper(injector_factory))
|
|
284
|
+
put_dynamic = multi_database()(put_dynamic_wrapper(injector_factory))
|
|
285
|
+
patch_dynamic = multi_database()(patch_dynamic_wrapper(injector_factory))
|
|
286
|
+
delete_dynamic = multi_database()(delete_dynamic_wrapper(injector_factory))
|
|
256
287
|
else:
|
|
257
288
|
list_dynamic = list_dynamic_wrapper(injector_factory)
|
|
258
|
-
get_dynamic =
|
|
259
|
-
post_dynamic =
|
|
260
|
-
put_dynamic =
|
|
261
|
-
patch_dynamic =
|
|
262
|
-
delete_dynamic =
|
|
289
|
+
get_dynamic = get_dynamic_wrapper(injector_factory)
|
|
290
|
+
post_dynamic = post_dynamic_wrapper(injector_factory)
|
|
291
|
+
put_dynamic = put_dynamic_wrapper(injector_factory)
|
|
292
|
+
patch_dynamic = patch_dynamic_wrapper(injector_factory)
|
|
293
|
+
delete_dynamic = delete_dynamic_wrapper(injector_factory)
|
|
263
294
|
|
|
264
295
|
# Registrando as rotas no flask
|
|
265
296
|
flask_app.add_url_rule(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nsj_rest_lib2
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
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
|
|
@@ -3,10 +3,10 @@ nsj_rest_lib2/exception.py,sha256=E9uMUdoCCQOVQfc8f6gD9b5Pxurf3Q4SytDCcqSlkZ8,56
|
|
|
3
3
|
nsj_rest_lib2/redis_config.py,sha256=4KLcvYS3nJO7PMQgF6F9_j6r-TyqcS7TBbd3LEQuKDU,629
|
|
4
4
|
nsj_rest_lib2/settings.py,sha256=F6y6lOAdLhGzZA6NE01x3t1vSAvrm1pC9ImjLhe61IU,59
|
|
5
5
|
nsj_rest_lib2/controller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
nsj_rest_lib2/controller/dynamic_controller.py,sha256=
|
|
6
|
+
nsj_rest_lib2/controller/dynamic_controller.py,sha256=4HS1__ton8cQ1LSvMoZUv93BQEnGV5f2gE-jW5lD510,13448
|
|
7
7
|
nsj_rest_lib2/service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
nsj_rest_lib2/service/entity_loader.py,sha256=i7ljsgDV4jlG-Flq5u-gmMqJp7SnpNfMRX1MYunln0E,9771
|
|
9
|
-
nsj_rest_lib2-0.0.
|
|
10
|
-
nsj_rest_lib2-0.0.
|
|
11
|
-
nsj_rest_lib2-0.0.
|
|
12
|
-
nsj_rest_lib2-0.0.
|
|
9
|
+
nsj_rest_lib2-0.0.2.dist-info/METADATA,sha256=Z5cHSoCY_AfI8ax7hxGufv236q5ffK6Nbjrw_4RD5bg,1196
|
|
10
|
+
nsj_rest_lib2-0.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
+
nsj_rest_lib2-0.0.2.dist-info/top_level.txt,sha256=L6zh0EfH8_rur7OJ8_V-El-XEMf4qg3bkF8ADgqLVIA,14
|
|
12
|
+
nsj_rest_lib2-0.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|