arpakitlib 1.7.215__py3-none-any.whl → 1.7.217__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.
- arpakitlib/ar_arpakit_schedule_uust_api_client_util.py +113 -61
- arpakitlib/ar_fastapi_util.py +7 -2
- {arpakitlib-1.7.215.dist-info → arpakitlib-1.7.217.dist-info}/METADATA +2 -1
- {arpakitlib-1.7.215.dist-info → arpakitlib-1.7.217.dist-info}/RECORD +7 -7
- {arpakitlib-1.7.215.dist-info → arpakitlib-1.7.217.dist-info}/LICENSE +0 -0
- {arpakitlib-1.7.215.dist-info → arpakitlib-1.7.217.dist-info}/WHEEL +0 -0
- {arpakitlib-1.7.215.dist-info → arpakitlib-1.7.217.dist-info}/entry_points.txt +0 -0
@@ -68,8 +68,10 @@ class CurrentWeekAPIModel(BaseAPIModel):
|
|
68
68
|
|
69
69
|
class GroupAPIModel(BaseAPIModel):
|
70
70
|
id: int
|
71
|
+
long_id: str
|
71
72
|
creation_dt: datetime
|
72
|
-
|
73
|
+
entity_type: str
|
74
|
+
actualization_dt: datetime
|
73
75
|
uust_api_id: int
|
74
76
|
title: str
|
75
77
|
faculty: str | None
|
@@ -80,8 +82,10 @@ class GroupAPIModel(BaseAPIModel):
|
|
80
82
|
|
81
83
|
class TeacherAPIModel(BaseAPIModel):
|
82
84
|
id: int
|
85
|
+
long_id: str
|
83
86
|
creation_dt: datetime
|
84
|
-
|
87
|
+
entity_type: str
|
88
|
+
actualization_dt: datetime
|
85
89
|
uust_api_id: int
|
86
90
|
name: str | None
|
87
91
|
surname: str | None
|
@@ -98,8 +102,10 @@ class TeacherAPIModel(BaseAPIModel):
|
|
98
102
|
|
99
103
|
class GroupLessonAPIModel(BaseAPIModel):
|
100
104
|
id: int
|
105
|
+
long_id: str
|
101
106
|
creation_dt: datetime
|
102
|
-
|
107
|
+
entity_type: str
|
108
|
+
actualization_dt: datetime
|
103
109
|
uust_api_id: int
|
104
110
|
type: str
|
105
111
|
title: str
|
@@ -134,8 +140,10 @@ class GroupLessonAPIModel(BaseAPIModel):
|
|
134
140
|
|
135
141
|
class TeacherLessonAPIModel(BaseAPIModel):
|
136
142
|
id: int
|
143
|
+
long_id: str
|
137
144
|
creation_dt: datetime
|
138
|
-
|
145
|
+
entity_type: str
|
146
|
+
actualization_dt: datetime
|
139
147
|
uust_api_id: int
|
140
148
|
type: str
|
141
149
|
title: str
|
@@ -209,7 +217,7 @@ class ARPAKITScheduleUUSTAPIClient:
|
|
209
217
|
if self.ttl_cache is not None:
|
210
218
|
self.ttl_cache.clear()
|
211
219
|
|
212
|
-
async def
|
220
|
+
async def _async_make_http_request(
|
213
221
|
self,
|
214
222
|
*,
|
215
223
|
method: str = "GET",
|
@@ -228,41 +236,44 @@ class ARPAKITScheduleUUSTAPIClient:
|
|
228
236
|
return response
|
229
237
|
|
230
238
|
async def check_auth(self) -> dict[str, Any]:
|
231
|
-
response = await self.
|
239
|
+
response = await self._async_make_http_request(method="GET", url=urljoin(self.base_url, "check_auth"))
|
232
240
|
json_data = await response.json()
|
233
241
|
return json_data
|
234
242
|
|
235
243
|
async def get_current_week(self) -> CurrentWeekAPIModel | None:
|
236
|
-
response = await self.
|
244
|
+
response = await self._async_make_http_request(
|
245
|
+
method="GET", url=urljoin(self.base_url, "get_current_week")
|
246
|
+
)
|
237
247
|
json_data = await response.json()
|
238
248
|
if json_data is None:
|
239
249
|
return None
|
240
250
|
return CurrentWeekAPIModel.model_validate(json_data)
|
241
251
|
|
242
252
|
async def get_current_semester(self) -> CurrentSemesterAPIModel | None:
|
243
|
-
response = await self.
|
253
|
+
response = await self._async_make_http_request(
|
254
|
+
method="GET", url=urljoin(self.base_url, "get_current_semester")
|
255
|
+
)
|
244
256
|
json_data = await response.json()
|
245
257
|
if json_data is None:
|
246
258
|
return None
|
247
259
|
return CurrentSemesterAPIModel.model_validate(json_data)
|
248
260
|
|
249
261
|
async def get_weather_in_ufa(self) -> WeatherInUfaAPIModel:
|
250
|
-
response = await self.
|
262
|
+
response = await self._async_make_http_request(
|
263
|
+
method="GET", url=urljoin(self.base_url, "get_weather_in_ufa")
|
264
|
+
)
|
251
265
|
json_data = await response.json()
|
252
266
|
return WeatherInUfaAPIModel.model_validate(json_data)
|
253
267
|
|
254
268
|
async def get_log_file_content(self) -> str | None:
|
255
|
-
|
256
|
-
response = await self._async_make_request(method="GET", url=urljoin(self.base_url, "extra/get_log_file"))
|
257
|
-
response.raise_for_status()
|
269
|
+
response = await self._async_make_http_request(method="GET", url=urljoin(self.base_url, "get_log_file"))
|
258
270
|
text_data = await response.text()
|
259
271
|
return text_data
|
260
272
|
|
261
273
|
async def get_groups(self) -> list[GroupAPIModel]:
|
262
|
-
response = await self.
|
263
|
-
response.raise_for_status()
|
274
|
+
response = await self._async_make_http_request(method="GET", url=urljoin(self.base_url, "get_groups"))
|
264
275
|
json_data = await response.json()
|
265
|
-
return [GroupAPIModel.
|
276
|
+
return [GroupAPIModel.model_validate(d) for d in json_data]
|
266
277
|
|
267
278
|
async def get_group(
|
268
279
|
self, *, filter_id: int | None = None, filter_uust_api_id: int | None = None
|
@@ -272,34 +283,25 @@ class ARPAKITScheduleUUSTAPIClient:
|
|
272
283
|
params["filter_id"] = filter_id
|
273
284
|
if filter_uust_api_id is not None:
|
274
285
|
params["filter_uust_api_id"] = filter_uust_api_id
|
275
|
-
response = await self.
|
276
|
-
|
277
|
-
url=urljoin(self.base_url, "group/get_group"),
|
278
|
-
params=params
|
279
|
-
)
|
286
|
+
response = await self._async_make_http_request(method="GET", url=urljoin(self.base_url, "get_group"),
|
287
|
+
params=params)
|
280
288
|
json_data = await response.json()
|
281
|
-
if
|
289
|
+
if json_data is None:
|
282
290
|
return None
|
283
|
-
|
284
|
-
return GroupAPIModel.from_arpakit_uust_api_data(arpakit_uust_api_data=json_data)
|
291
|
+
return GroupAPIModel.model_validate(json_data)
|
285
292
|
|
286
293
|
async def find_groups(
|
287
294
|
self, *, q: str
|
288
295
|
) -> list[GroupAPIModel]:
|
289
|
-
response = await self.
|
290
|
-
|
291
|
-
url=urljoin(self.base_url, "group/find_groups"),
|
292
|
-
params={"q": q.strip()}
|
293
|
-
)
|
294
|
-
response.raise_for_status()
|
296
|
+
response = await self._async_make_http_request(method="GET", url=urljoin(self.base_url, "find_groups"),
|
297
|
+
params={"q": q.strip()})
|
295
298
|
json_data = await response.json()
|
296
|
-
return [GroupAPIModel.
|
299
|
+
return [GroupAPIModel.model_validate(d) for d in json_data]
|
297
300
|
|
298
301
|
async def get_teachers(self) -> list[TeacherAPIModel]:
|
299
|
-
response = await self.
|
300
|
-
response.raise_for_status()
|
302
|
+
response = await self._async_make_http_request(method="GET", url=urljoin(self.base_url, "get_teachers"))
|
301
303
|
json_data = await response.json()
|
302
|
-
return [TeacherAPIModel.
|
304
|
+
return [TeacherAPIModel.model_validate(d) for d in json_data]
|
303
305
|
|
304
306
|
async def get_teacher(
|
305
307
|
self, *, filter_id: int | None = None, filter_uust_api_id: int | None = None
|
@@ -309,28 +311,37 @@ class ARPAKITScheduleUUSTAPIClient:
|
|
309
311
|
params["filter_id"] = filter_id
|
310
312
|
if filter_uust_api_id is not None:
|
311
313
|
params["filter_uust_api_id"] = filter_uust_api_id
|
312
|
-
response = await self.
|
313
|
-
|
314
|
-
url=urljoin(self.base_url, "teacher/get_teacher"),
|
315
|
-
params=params
|
316
|
-
)
|
314
|
+
response = await self._async_make_http_request(method="GET", url=urljoin(self.base_url, "get_teacher"),
|
315
|
+
params=params)
|
317
316
|
json_data = await response.json()
|
318
|
-
if
|
317
|
+
if json_data is None:
|
319
318
|
return None
|
320
|
-
|
321
|
-
return TeacherAPIModel.from_arpakit_uust_api_data(arpakit_uust_api_data=json_data)
|
319
|
+
return TeacherAPIModel.model_validate(json_data)
|
322
320
|
|
323
321
|
async def find_teachers(
|
324
322
|
self, *, q: str
|
325
323
|
) -> list[TeacherAPIModel]:
|
326
|
-
response = await self.
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
324
|
+
response = await self._async_make_http_request(method="GET", url=urljoin(self.base_url, "find_teachers"),
|
325
|
+
params={"q": q.strip()})
|
326
|
+
json_data = await response.json()
|
327
|
+
return [TeacherAPIModel.model_validate(d) for d in json_data]
|
328
|
+
|
329
|
+
async def find_any(
|
330
|
+
self, *, q: str
|
331
|
+
) -> list[TeacherAPIModel | GroupLessonAPIModel]:
|
332
|
+
response = await self._async_make_http_request(method="GET", url=urljoin(self.base_url, "find_any"),
|
333
|
+
params={"q": q.strip()})
|
332
334
|
json_data = await response.json()
|
333
|
-
|
335
|
+
|
336
|
+
results = []
|
337
|
+
for i in json_data:
|
338
|
+
if i.get("entity_type") == "group":
|
339
|
+
results.append(GroupAPIModel.model_validate(i))
|
340
|
+
elif i.get("entity_type") == "teacher":
|
341
|
+
results.append(TeacherAPIModel.model_validate(i))
|
342
|
+
else:
|
343
|
+
pass
|
344
|
+
return results
|
334
345
|
|
335
346
|
async def get_group_lessons(
|
336
347
|
self,
|
@@ -343,14 +354,11 @@ class ARPAKITScheduleUUSTAPIClient:
|
|
343
354
|
params["filter_group_id"] = filter_group_id
|
344
355
|
if filter_group_uust_api_id is not None:
|
345
356
|
params["filter_group_uust_api_id"] = filter_group_uust_api_id
|
346
|
-
response = await self.
|
347
|
-
method="GET",
|
348
|
-
url=urljoin(self.base_url, "group_lesson/get_group_lessons"),
|
349
|
-
params=params
|
357
|
+
response = await self._async_make_http_request(
|
358
|
+
method="GET", url=urljoin(self.base_url, "get_group_lessons"), params=params
|
350
359
|
)
|
351
|
-
response.raise_for_status()
|
352
360
|
json_data = await response.json()
|
353
|
-
return [GroupLessonAPIModel.
|
361
|
+
return [GroupLessonAPIModel.model_validate(d) for d in json_data]
|
354
362
|
|
355
363
|
async def get_teacher_lessons(
|
356
364
|
self,
|
@@ -363,14 +371,11 @@ class ARPAKITScheduleUUSTAPIClient:
|
|
363
371
|
params["filter_teacher_id"] = filter_teacher_id
|
364
372
|
if filter_teacher_uust_api_id is not None:
|
365
373
|
params["filter_teacher_uust_api_id"] = filter_teacher_uust_api_id
|
366
|
-
response = await self.
|
367
|
-
method="GET",
|
368
|
-
url=urljoin(self.base_url, "teacher_lesson/get_teacher_lessons"),
|
369
|
-
params=params
|
374
|
+
response = await self._async_make_http_request(
|
375
|
+
method="GET", url=urljoin(self.base_url, "get_teacher_lessons"), params=params
|
370
376
|
)
|
371
|
-
response.raise_for_status()
|
372
377
|
json_data = await response.json()
|
373
|
-
return [TeacherLessonAPIModel.
|
378
|
+
return [TeacherLessonAPIModel.model_validate(d) for d in json_data]
|
374
379
|
|
375
380
|
|
376
381
|
def __example():
|
@@ -382,7 +387,6 @@ async def __async_example():
|
|
382
387
|
|
383
388
|
print(f"check_auth")
|
384
389
|
print(safely_transfer_obj_to_json_str(await client.check_auth()))
|
385
|
-
print()
|
386
390
|
|
387
391
|
print(f"get_weather_in_ufa")
|
388
392
|
print(safely_transfer_obj_to_json_str((await client.get_weather_in_ufa()).model_dump()))
|
@@ -393,6 +397,54 @@ async def __async_example():
|
|
393
397
|
print(f"get_current_semester")
|
394
398
|
print(safely_transfer_obj_to_json_str((await client.get_current_semester()).model_dump()))
|
395
399
|
|
400
|
+
# Group
|
401
|
+
print(f"get_groups")
|
402
|
+
print(safely_transfer_obj_to_json_str((await client.get_groups())))
|
403
|
+
|
404
|
+
print(f"get_group")
|
405
|
+
if await client.get_group(filter_id=25285, filter_uust_api_id=6674):
|
406
|
+
print(safely_transfer_obj_to_json_str(
|
407
|
+
(await client.get_group(filter_id=25285, filter_uust_api_id=6674)).model_dump()))
|
408
|
+
else:
|
409
|
+
print("Group is none")
|
410
|
+
|
411
|
+
print(f"find_groups")
|
412
|
+
print(safely_transfer_obj_to_json_str((await client.find_groups(q="ПИ-427Б"))))
|
413
|
+
|
414
|
+
# Teacher
|
415
|
+
print(f"get_teachers")
|
416
|
+
print(safely_transfer_obj_to_json_str((await client.get_teachers())))
|
417
|
+
|
418
|
+
print(f"get_teacher")
|
419
|
+
if await client.get_teacher(filter_id=16975, filter_uust_api_id=112978):
|
420
|
+
print(safely_transfer_obj_to_json_str(
|
421
|
+
(await client.get_teacher(filter_id=16975, filter_uust_api_id=112978)).model_dump()))
|
422
|
+
else:
|
423
|
+
print("Teacher is none")
|
424
|
+
|
425
|
+
print(f"find_teachers")
|
426
|
+
print(safely_transfer_obj_to_json_str((await client.find_teachers(q="Казанцев"))))
|
427
|
+
|
428
|
+
# Group Lesson
|
429
|
+
print(f"get_group_lessons")
|
430
|
+
if await client.get_group_lessons(filter_group_id=25285, filter_group_uust_api_id=6674):
|
431
|
+
print(safely_transfer_obj_to_json_str((await client.get_group_lessons(filter_group_id=25285,
|
432
|
+
filter_group_uust_api_id=6674))))
|
433
|
+
else:
|
434
|
+
print("Group lessons is none")
|
435
|
+
|
436
|
+
# Teacher Lesson
|
437
|
+
print(f"get_teacher_lessons")
|
438
|
+
if await client.get_teacher_lessons(filter_teacher_id=16975, filter_teacher_uust_api_id=112978):
|
439
|
+
print(safely_transfer_obj_to_json_str((await client.get_teacher_lessons(filter_teacher_id=16975,
|
440
|
+
filter_teacher_uust_api_id=112978))))
|
441
|
+
else:
|
442
|
+
print("Teacher lessons is none")
|
443
|
+
|
444
|
+
# Find Any
|
445
|
+
print(f"find_any")
|
446
|
+
print(safely_transfer_obj_to_json_str((await client.find_any(q="ПИ"))))
|
447
|
+
|
396
448
|
|
397
449
|
if __name__ == '__main__':
|
398
450
|
__example()
|
arpakitlib/ar_fastapi_util.py
CHANGED
@@ -282,7 +282,8 @@ def create_handle_exception(
|
|
282
282
|
def create_story_log_before_response_in_handle_exception(
|
283
283
|
*,
|
284
284
|
sqlalchemy_db: SQLAlchemyDB,
|
285
|
-
|
285
|
+
ignore_api_error_codes: list[str] | None = None,
|
286
|
+
ignore_status_codes: list[int] | None = None
|
286
287
|
) -> Callable:
|
287
288
|
def func(
|
288
289
|
*,
|
@@ -292,8 +293,12 @@ def create_story_log_before_response_in_handle_exception(
|
|
292
293
|
exception: Exception,
|
293
294
|
**kwargs
|
294
295
|
) -> (int, ErrorSO, dict[str, Any]):
|
295
|
-
if
|
296
|
+
if ignore_api_error_codes and error_so.error_code in ignore_api_error_codes:
|
296
297
|
return status_code, error_so, kwargs
|
298
|
+
|
299
|
+
if ignore_status_codes and status_code in ignore_status_codes:
|
300
|
+
return status_code, error_so, kwargs
|
301
|
+
|
297
302
|
sqlalchemy_db.init()
|
298
303
|
traceback_str = "".join(traceback.format_exception(type(exception), exception, exception.__traceback__))
|
299
304
|
with sqlalchemy_db.new_session() as session:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: arpakitlib
|
3
|
-
Version: 1.7.
|
3
|
+
Version: 1.7.217
|
4
4
|
Summary: arpakitlib
|
5
5
|
License: Apache-2.0
|
6
6
|
Keywords: arpakitlib,arpakit,arpakit-company,arpakitcompany,arpakit_company
|
@@ -51,6 +51,7 @@ Requires-Dist: uvicorn (>=0.34.0,<0.35.0)
|
|
51
51
|
Project-URL: Documentation, https://github.com/ARPAKIT-Company/arpakitlib
|
52
52
|
Project-URL: Homepage, https://github.com/ARPAKIT-Company/arpakitlib
|
53
53
|
Project-URL: Repository, https://github.com/ARPAKIT-Company/arpakitlib
|
54
|
+
Project-URL: telegram_channel, https://t.me/arpakitlib
|
54
55
|
Description-Content-Type: text/markdown
|
55
56
|
|
56
57
|
# arpakitlib
|
@@ -120,7 +120,7 @@ arpakitlib/ar_aiogram_util.py,sha256=5JPCDZpdBGTE-EIWPRez9amCZAX7XemFIVu5YrQK7Pw
|
|
120
120
|
arpakitlib/ar_api_key_util.py,sha256=E84JlJXiDHtxLQmV8BNHvqNKu_G8-Dox0XxknYJQ37Q,422
|
121
121
|
arpakitlib/ar_arpakit_lib_module_util.py,sha256=UEPU8wk29R_bBP_RENnhXYzNbj_RF9FWjowrj_yxWLA,5931
|
122
122
|
arpakitlib/ar_arpakit_project_template_util.py,sha256=c7yc8w2IvZGH5hH8eOpL7JuD005hUxZ0GVDcSkJF5iI,3705
|
123
|
-
arpakitlib/ar_arpakit_schedule_uust_api_client_util.py,sha256=
|
123
|
+
arpakitlib/ar_arpakit_schedule_uust_api_client_util.py,sha256=006JstWvs6JTuxRCg3toSNQvtKO0KM5pqyPJa1PRDNA,14998
|
124
124
|
arpakitlib/ar_arpakitlib_cli_util.py,sha256=8lhEDxnwMSRX2PGV2xQtQru1AYKSA92SVolol5u7iBk,3154
|
125
125
|
arpakitlib/ar_base64_util.py,sha256=aZkg2cZTuAaP2IWeG_LXJ6RO7qhyskVwec-Lks0iM-k,676
|
126
126
|
arpakitlib/ar_base_worker_util.py,sha256=Qm_C7PFH5W-LPu1AGX1zp29zbqZ04i71Su1U-eeQBkA,5674
|
@@ -152,7 +152,7 @@ arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css,sha256=jzPZlgJTFwSdSphk9C
|
|
152
152
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css.map,sha256=5wq8eXMLU6Zxb45orZPL1zAsBFJReFw6GjYqGpUX3hg,262650
|
153
153
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js,sha256=ffrLZHHEQ_g84A-ul3yWa10Kk09waOAxHcQXPuZuavg,339292
|
154
154
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js.map,sha256=9UhIW7MqCOZPAz1Sl1IKfZUuhWU0p-LJqrnjjJD9Xhc,1159454
|
155
|
-
arpakitlib/ar_fastapi_util.py,sha256=
|
155
|
+
arpakitlib/ar_fastapi_util.py,sha256=Otm6sa-xB3qUZ7ttp0A52FVEaBN3yRHQx2JKWKYDEGg,26567
|
156
156
|
arpakitlib/ar_file_storage_in_dir_util.py,sha256=D3e3rGuHoI6xqAA5mVvEpVVpOWY1jyjNsjj2UhyHRbE,3674
|
157
157
|
arpakitlib/ar_file_util.py,sha256=GUdJYm1tUZnYpY-SIPRHAZBHGra8NKy1eYEI0D5AfhY,489
|
158
158
|
arpakitlib/ar_func_util.py,sha256=bCuWbSMoFXBaMNhb89sevj2oaXRk4Jk6Qjot8OXMDT4,1319
|
@@ -183,8 +183,8 @@ arpakitlib/ar_str_util.py,sha256=yU5gOwNXUQaH5b_tM5t6fXUn9oUcv5EQbVnq2wXXIpQ,337
|
|
183
183
|
arpakitlib/ar_type_util.py,sha256=9C3ErtUVs0tAUqtK-foFzjJOykfBOntfCz2IogDOgfA,4134
|
184
184
|
arpakitlib/ar_yookassa_api_client_util.py,sha256=sh4fcUkAkdOetFn9JYoTvjcSXP-M1wU04KEY-ECLfLg,5137
|
185
185
|
arpakitlib/ar_zabbix_api_client_util.py,sha256=Q-VR4MvoZ9aHwZeYZr9G3LwN-ANx1T5KFmF6pvPM-9M,6402
|
186
|
-
arpakitlib-1.7.
|
187
|
-
arpakitlib-1.7.
|
188
|
-
arpakitlib-1.7.
|
189
|
-
arpakitlib-1.7.
|
190
|
-
arpakitlib-1.7.
|
186
|
+
arpakitlib-1.7.217.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
|
187
|
+
arpakitlib-1.7.217.dist-info/METADATA,sha256=Ea_m3a7vx9YPAmRWV4vKYz1cOJkRKNec_DSiYn0g6C0,3231
|
188
|
+
arpakitlib-1.7.217.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
189
|
+
arpakitlib-1.7.217.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
|
190
|
+
arpakitlib-1.7.217.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|