apexdevkit 1.4.5__tar.gz → 1.5.2__tar.gz
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.
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/PKG-INFO +1 -1
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/fastapi/router.py +14 -2
- apexdevkit-1.5.2/apexdevkit/repository/base.py +29 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/repository/in_memory.py +6 -2
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/repository/interface.py +2 -2
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/pyproject.toml +1 -1
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/LICENSE +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/README.md +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/error.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.4.5 → apexdevkit-1.5.2}/apexdevkit/testing/rest.py +0 -0
|
@@ -221,6 +221,8 @@ class RestfulRouter:
|
|
|
221
221
|
item = service.create_one(item)
|
|
222
222
|
except ExistsError as e:
|
|
223
223
|
return JSONResponse(self.response.exists(e), 409)
|
|
224
|
+
except ForbiddenError as e:
|
|
225
|
+
return JSONResponse(self.response.forbidden(e), 403)
|
|
224
226
|
|
|
225
227
|
return self.response.created_one(item)
|
|
226
228
|
|
|
@@ -270,6 +272,8 @@ class RestfulRouter:
|
|
|
270
272
|
return self.response.created_many(service.create_many(items))
|
|
271
273
|
except ExistsError as e:
|
|
272
274
|
return JSONResponse(self.response.exists(e), 409)
|
|
275
|
+
except ForbiddenError as e:
|
|
276
|
+
return JSONResponse(self.response.forbidden(e), 403)
|
|
273
277
|
|
|
274
278
|
return endpoint
|
|
275
279
|
|
|
@@ -317,6 +321,8 @@ class RestfulRouter:
|
|
|
317
321
|
return self.response.found_one(service.read_one(item_id))
|
|
318
322
|
except DoesNotExistError as e:
|
|
319
323
|
return JSONResponse(self.response.not_found(e), 404)
|
|
324
|
+
except ForbiddenError as e:
|
|
325
|
+
return JSONResponse(self.response.forbidden(e), 403)
|
|
320
326
|
|
|
321
327
|
return endpoint
|
|
322
328
|
|
|
@@ -355,8 +361,10 @@ class RestfulRouter:
|
|
|
355
361
|
return JSONResponse(
|
|
356
362
|
RestfulResponse(RestfulName(self.parent)).not_found(e), 404
|
|
357
363
|
)
|
|
358
|
-
|
|
359
|
-
|
|
364
|
+
try:
|
|
365
|
+
return self.response.found_many(list(service.read_all()))
|
|
366
|
+
except ForbiddenError as e:
|
|
367
|
+
return JSONResponse(self.response.forbidden(e), 403)
|
|
360
368
|
|
|
361
369
|
return endpoint
|
|
362
370
|
|
|
@@ -462,6 +470,8 @@ class RestfulRouter:
|
|
|
462
470
|
service.update_many(items)
|
|
463
471
|
except DoesNotExistError as e:
|
|
464
472
|
return JSONResponse(self.response.not_found(e), 404)
|
|
473
|
+
except ForbiddenError as e:
|
|
474
|
+
return JSONResponse(self.response.forbidden(e), 403)
|
|
465
475
|
|
|
466
476
|
return self.response.ok()
|
|
467
477
|
|
|
@@ -511,6 +521,8 @@ class RestfulRouter:
|
|
|
511
521
|
service.delete_one(item_id)
|
|
512
522
|
except DoesNotExistError as e:
|
|
513
523
|
return JSONResponse(self.response.not_found(e), 404)
|
|
524
|
+
except ForbiddenError as e:
|
|
525
|
+
return JSONResponse(self.response.forbidden(e), 403)
|
|
514
526
|
|
|
515
527
|
return self.response.ok()
|
|
516
528
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from typing import Iterator
|
|
2
|
+
|
|
3
|
+
from apexdevkit.repository.interface import IdT, ItemT, Repository
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class RepositoryBase(Repository[IdT, ItemT]): # pragma: no cover
|
|
7
|
+
def create(self, item: ItemT) -> ItemT:
|
|
8
|
+
raise NotImplementedError
|
|
9
|
+
|
|
10
|
+
def create_many(self, items: list[ItemT]) -> list[ItemT]:
|
|
11
|
+
raise NotImplementedError
|
|
12
|
+
|
|
13
|
+
def read(self, item_id: IdT) -> ItemT:
|
|
14
|
+
raise NotImplementedError
|
|
15
|
+
|
|
16
|
+
def update(self, item: ItemT) -> None:
|
|
17
|
+
raise NotImplementedError
|
|
18
|
+
|
|
19
|
+
def update_many(self, items: list[ItemT]) -> None:
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
|
|
22
|
+
def delete(self, item_id: IdT) -> None:
|
|
23
|
+
raise NotImplementedError
|
|
24
|
+
|
|
25
|
+
def __iter__(self) -> Iterator[ItemT]:
|
|
26
|
+
raise NotImplementedError
|
|
27
|
+
|
|
28
|
+
def __len__(self) -> int:
|
|
29
|
+
raise NotImplementedError
|
|
@@ -63,14 +63,18 @@ class InMemoryRepository(Generic[ItemT]):
|
|
|
63
63
|
self.create(item)
|
|
64
64
|
return self
|
|
65
65
|
|
|
66
|
-
def create_many(self, items: list[ItemT]) ->
|
|
66
|
+
def create_many(self, items: list[ItemT]) -> list[ItemT]:
|
|
67
67
|
for item in items:
|
|
68
68
|
self.create(item)
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
return items
|
|
71
|
+
|
|
72
|
+
def create(self, item: ItemT) -> ItemT:
|
|
71
73
|
self._ensure_does_not_exist(item)
|
|
72
74
|
self.items[str(item.id)] = deepcopy(self.formatter.dump(item))
|
|
73
75
|
|
|
76
|
+
return item
|
|
77
|
+
|
|
74
78
|
def _ensure_does_not_exist(self, new: ItemT) -> None:
|
|
75
79
|
for existing in self:
|
|
76
80
|
error = ExistsError(existing)
|
|
@@ -5,10 +5,10 @@ IdT = TypeVar("IdT", contravariant=True)
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class Repository(Protocol[IdT, ItemT]):
|
|
8
|
-
def create(self, item: ItemT) ->
|
|
8
|
+
def create(self, item: ItemT) -> ItemT:
|
|
9
9
|
pass
|
|
10
10
|
|
|
11
|
-
def create_many(self, items: list[ItemT]) ->
|
|
11
|
+
def create_many(self, items: list[ItemT]) -> list[ItemT]:
|
|
12
12
|
pass
|
|
13
13
|
|
|
14
14
|
def read(self, item_id: IdT) -> ItemT:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|