apexdevkit 1.3.9__tar.gz → 1.3.11__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.3.9 → apexdevkit-1.3.11}/PKG-INFO +1 -1
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/error.py +9 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/fastapi/router.py +10 -1
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/pyproject.toml +1 -1
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/LICENSE +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/README.md +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.3.9 → apexdevkit-1.3.11}/apexdevkit/testing/rest.py +0 -0
|
@@ -38,3 +38,12 @@ class ExistsError(Exception):
|
|
|
38
38
|
@dataclass
|
|
39
39
|
class DoesNotExistError(Exception):
|
|
40
40
|
id: Any = "unknown"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass
|
|
44
|
+
class ForbiddenError(Exception):
|
|
45
|
+
item: Any = field(default_factory=UnknownItem)
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def id(self) -> Any:
|
|
49
|
+
return self.item.id
|
|
@@ -5,7 +5,7 @@ from typing import Annotated, Any, Iterable, Self, TypeVar
|
|
|
5
5
|
from fastapi import APIRouter, Depends, Path
|
|
6
6
|
from fastapi.responses import JSONResponse
|
|
7
7
|
|
|
8
|
-
from apexdevkit.error import DoesNotExistError, ExistsError
|
|
8
|
+
from apexdevkit.error import DoesNotExistError, ExistsError, ForbiddenError
|
|
9
9
|
from apexdevkit.fastapi.schema import DataclassFields, RestfulSchema, SchemaFields
|
|
10
10
|
from apexdevkit.fastapi.service import RawCollection, RawItem, RestfulService
|
|
11
11
|
from apexdevkit.testing import RestfulName
|
|
@@ -55,6 +55,13 @@ class RestfulResponse:
|
|
|
55
55
|
error=f"An item<{name}> with the {e} already exists.",
|
|
56
56
|
)
|
|
57
57
|
|
|
58
|
+
def forbidden(self, e: ForbiddenError) -> dict[str, Any]:
|
|
59
|
+
return self._response(
|
|
60
|
+
403,
|
|
61
|
+
data={"id": str(e.id)},
|
|
62
|
+
error="Forbidden",
|
|
63
|
+
)
|
|
64
|
+
|
|
58
65
|
def created_one(self, item: Any) -> dict[str, Any]:
|
|
59
66
|
return self._response(201, item)
|
|
60
67
|
|
|
@@ -205,6 +212,8 @@ class RestfulRouter:
|
|
|
205
212
|
self.service.update_one(item_id, **updates)
|
|
206
213
|
except DoesNotExistError as e:
|
|
207
214
|
return JSONResponse(self.response.not_found(e), 404)
|
|
215
|
+
except ForbiddenError as e:
|
|
216
|
+
return JSONResponse(self.response.forbidden(e), 403)
|
|
208
217
|
|
|
209
218
|
return self.response.ok()
|
|
210
219
|
|
|
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
|
|
File without changes
|