ohmyapi 0.1.21__tar.gz → 0.1.22__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.
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/PKG-INFO +67 -24
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/README.md +66 -23
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/pyproject.toml +1 -1
- ohmyapi-0.1.22/src/ohmyapi/core/templates/app/routes.py.j2 +41 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/router.py +2 -0
- ohmyapi-0.1.21/src/ohmyapi/core/templates/app/routes.py.j2 +0 -17
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/__init__.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/__main__.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/builtin/auth/__init__.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/builtin/auth/models.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/builtin/auth/permissions.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/builtin/auth/routes.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/cli.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/core/__init__.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/core/runtime.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/core/scaffolding.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/core/templates/app/__init__.py.j2 +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/core/templates/app/models.py.j2 +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/core/templates/project/README.md.j2 +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/core/templates/project/pyproject.toml.j2 +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/core/templates/project/settings.py.j2 +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/db/__init__.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/db/exceptions.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/db/model/__init__.py +0 -0
- {ohmyapi-0.1.21 → ohmyapi-0.1.22}/src/ohmyapi/db/model/model.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ohmyapi
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.22
|
4
4
|
Summary: A Django-like but async web-framework based on FastAPI and TortoiseORM.
|
5
5
|
License-Expression: MIT
|
6
6
|
Keywords: fastapi,tortoise,orm,async,web-framework
|
@@ -157,7 +157,7 @@ class Team(Model):
|
|
157
157
|
Next, create your endpoints in `tournament/routes.py`:
|
158
158
|
|
159
159
|
```python
|
160
|
-
from ohmyapi.router import APIRouter, HTTPException
|
160
|
+
from ohmyapi.router import APIRouter, HTTPException, HTTPStatus
|
161
161
|
from ohmyapi.db.exceptions import DoesNotExist
|
162
162
|
|
163
163
|
from .models import Tournament
|
@@ -167,20 +167,25 @@ from .models import Tournament
|
|
167
167
|
# Tags improve the UX of the OpenAPI docs at /docs.
|
168
168
|
router = APIRouter(prefix="/tournament", tags=['Tournament'])
|
169
169
|
|
170
|
-
|
171
170
|
@router.get("/")
|
172
171
|
async def list():
|
173
172
|
queryset = Tournament.all()
|
174
173
|
return await Tournament.Schema.model.from_queryset(queryset)
|
175
174
|
|
176
175
|
|
176
|
+
@router.post("/", status_code=HTTPStatus.CREATED)
|
177
|
+
async def post(tournament: Tournament.Schema.readonly):
|
178
|
+
queryset = Tournament.create(**payload.model_dump())
|
179
|
+
return await Tournament.Schema.model.from_queryset(queryset)
|
180
|
+
|
181
|
+
|
177
182
|
@router.get("/:id")
|
178
183
|
async def get(id: str):
|
179
184
|
try:
|
180
|
-
|
185
|
+
queryset = Tournament.get(id=id)
|
181
186
|
return await Tournament.Schema.model.from_queryset_single(tournament)
|
182
187
|
except DoesNotExist:
|
183
|
-
raise HTTPException(status_code=404, detail="
|
188
|
+
raise HTTPException(status_code=404, detail="not found")
|
184
189
|
|
185
190
|
...
|
186
191
|
```
|
@@ -350,28 +355,66 @@ Find your loaded project singleton via identifier: `p`
|
|
350
355
|
|
351
356
|
```python
|
352
357
|
In [1]: p
|
353
|
-
Out[1]: <ohmyapi.core.runtime.Project at
|
358
|
+
Out[1]: <ohmyapi.core.runtime.Project at 0x7f00c43dbcb0>
|
354
359
|
|
355
360
|
In [2]: p.apps
|
356
361
|
Out[2]:
|
357
|
-
{'ohmyapi_auth':
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
362
|
+
{'ohmyapi_auth': {
|
363
|
+
"models": [
|
364
|
+
"Group",
|
365
|
+
"User"
|
366
|
+
],
|
367
|
+
"routes": [
|
368
|
+
{
|
369
|
+
"path": "/auth/login",
|
370
|
+
"name": "login",
|
371
|
+
"methods": [
|
372
|
+
"POST"
|
373
|
+
],
|
374
|
+
"endpoint": "login",
|
375
|
+
"response_model": null,
|
376
|
+
"tags": [
|
377
|
+
"auth"
|
378
|
+
]
|
379
|
+
},
|
380
|
+
{
|
381
|
+
"path": "/auth/refresh",
|
382
|
+
"name": "refresh_token",
|
383
|
+
"methods": [
|
384
|
+
"POST"
|
385
|
+
],
|
386
|
+
"endpoint": "refresh_token",
|
387
|
+
"response_model": null,
|
388
|
+
"tags": [
|
389
|
+
"auth"
|
390
|
+
]
|
391
|
+
},
|
392
|
+
{
|
393
|
+
"path": "/auth/introspect",
|
394
|
+
"name": "introspect",
|
395
|
+
"methods": [
|
396
|
+
"GET"
|
397
|
+
],
|
398
|
+
"endpoint": "introspect",
|
399
|
+
"response_model": null,
|
400
|
+
"tags": [
|
401
|
+
"auth"
|
402
|
+
]
|
403
|
+
},
|
404
|
+
{
|
405
|
+
"path": "/auth/me",
|
406
|
+
"name": "me",
|
407
|
+
"methods": [
|
408
|
+
"GET"
|
409
|
+
],
|
410
|
+
"endpoint": "me",
|
411
|
+
"response_model": null,
|
412
|
+
"tags": [
|
413
|
+
"auth"
|
414
|
+
]
|
415
|
+
}
|
416
|
+
]
|
417
|
+
}}
|
375
418
|
```
|
376
419
|
|
377
420
|
|
@@ -125,7 +125,7 @@ class Team(Model):
|
|
125
125
|
Next, create your endpoints in `tournament/routes.py`:
|
126
126
|
|
127
127
|
```python
|
128
|
-
from ohmyapi.router import APIRouter, HTTPException
|
128
|
+
from ohmyapi.router import APIRouter, HTTPException, HTTPStatus
|
129
129
|
from ohmyapi.db.exceptions import DoesNotExist
|
130
130
|
|
131
131
|
from .models import Tournament
|
@@ -135,20 +135,25 @@ from .models import Tournament
|
|
135
135
|
# Tags improve the UX of the OpenAPI docs at /docs.
|
136
136
|
router = APIRouter(prefix="/tournament", tags=['Tournament'])
|
137
137
|
|
138
|
-
|
139
138
|
@router.get("/")
|
140
139
|
async def list():
|
141
140
|
queryset = Tournament.all()
|
142
141
|
return await Tournament.Schema.model.from_queryset(queryset)
|
143
142
|
|
144
143
|
|
144
|
+
@router.post("/", status_code=HTTPStatus.CREATED)
|
145
|
+
async def post(tournament: Tournament.Schema.readonly):
|
146
|
+
queryset = Tournament.create(**payload.model_dump())
|
147
|
+
return await Tournament.Schema.model.from_queryset(queryset)
|
148
|
+
|
149
|
+
|
145
150
|
@router.get("/:id")
|
146
151
|
async def get(id: str):
|
147
152
|
try:
|
148
|
-
|
153
|
+
queryset = Tournament.get(id=id)
|
149
154
|
return await Tournament.Schema.model.from_queryset_single(tournament)
|
150
155
|
except DoesNotExist:
|
151
|
-
raise HTTPException(status_code=404, detail="
|
156
|
+
raise HTTPException(status_code=404, detail="not found")
|
152
157
|
|
153
158
|
...
|
154
159
|
```
|
@@ -318,27 +323,65 @@ Find your loaded project singleton via identifier: `p`
|
|
318
323
|
|
319
324
|
```python
|
320
325
|
In [1]: p
|
321
|
-
Out[1]: <ohmyapi.core.runtime.Project at
|
326
|
+
Out[1]: <ohmyapi.core.runtime.Project at 0x7f00c43dbcb0>
|
322
327
|
|
323
328
|
In [2]: p.apps
|
324
329
|
Out[2]:
|
325
|
-
{'ohmyapi_auth':
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
330
|
+
{'ohmyapi_auth': {
|
331
|
+
"models": [
|
332
|
+
"Group",
|
333
|
+
"User"
|
334
|
+
],
|
335
|
+
"routes": [
|
336
|
+
{
|
337
|
+
"path": "/auth/login",
|
338
|
+
"name": "login",
|
339
|
+
"methods": [
|
340
|
+
"POST"
|
341
|
+
],
|
342
|
+
"endpoint": "login",
|
343
|
+
"response_model": null,
|
344
|
+
"tags": [
|
345
|
+
"auth"
|
346
|
+
]
|
347
|
+
},
|
348
|
+
{
|
349
|
+
"path": "/auth/refresh",
|
350
|
+
"name": "refresh_token",
|
351
|
+
"methods": [
|
352
|
+
"POST"
|
353
|
+
],
|
354
|
+
"endpoint": "refresh_token",
|
355
|
+
"response_model": null,
|
356
|
+
"tags": [
|
357
|
+
"auth"
|
358
|
+
]
|
359
|
+
},
|
360
|
+
{
|
361
|
+
"path": "/auth/introspect",
|
362
|
+
"name": "introspect",
|
363
|
+
"methods": [
|
364
|
+
"GET"
|
365
|
+
],
|
366
|
+
"endpoint": "introspect",
|
367
|
+
"response_model": null,
|
368
|
+
"tags": [
|
369
|
+
"auth"
|
370
|
+
]
|
371
|
+
},
|
372
|
+
{
|
373
|
+
"path": "/auth/me",
|
374
|
+
"name": "me",
|
375
|
+
"methods": [
|
376
|
+
"GET"
|
377
|
+
],
|
378
|
+
"endpoint": "me",
|
379
|
+
"response_model": null,
|
380
|
+
"tags": [
|
381
|
+
"auth"
|
382
|
+
]
|
383
|
+
}
|
384
|
+
]
|
385
|
+
}}
|
343
386
|
```
|
344
387
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
from ohmyapi.router import APIRouter, HTTPException, HTTPStatus
|
2
|
+
|
3
|
+
from . import models
|
4
|
+
|
5
|
+
from typing import List
|
6
|
+
|
7
|
+
# Expose your app's routes via `router = fastapi.APIRouter`.
|
8
|
+
# Use prefixes wisely to avoid cross-app namespace-collisions.
|
9
|
+
# Tags improve the UX of the OpenAPI docs at /docs.
|
10
|
+
router = APIRouter(prefix="/{{ app_name }}", tags=['{{ app_name }}'])
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
@router.get("/")
|
15
|
+
async def list():
|
16
|
+
"""List all ..."""
|
17
|
+
return []
|
18
|
+
|
19
|
+
|
20
|
+
@router.post("/")
|
21
|
+
async def post():
|
22
|
+
"""Create ..."""
|
23
|
+
return HTTPException(status_code=HTTPStatus.CREATED)
|
24
|
+
|
25
|
+
|
26
|
+
@router.get("/{id}")
|
27
|
+
async def get(id: str):
|
28
|
+
"""Get single ..."""
|
29
|
+
return {}
|
30
|
+
|
31
|
+
|
32
|
+
@router.put("/{id}")
|
33
|
+
async def put(id: str):
|
34
|
+
"""Update ..."""
|
35
|
+
return HTTPException(status_code=HTTPStatus.ACCEPTED)
|
36
|
+
|
37
|
+
|
38
|
+
@router.delete("/{id}")
|
39
|
+
async def delete(id: str):
|
40
|
+
return HTTPException(status_code=HTTPStatus.ACCEPTED)
|
41
|
+
|
@@ -1,17 +0,0 @@
|
|
1
|
-
from ohmyapi.router import APIRouter
|
2
|
-
|
3
|
-
from .models import ...
|
4
|
-
|
5
|
-
# Expose your app's routes via `router = fastapi.APIRouter`.
|
6
|
-
# Use prefixes wisely to avoid cross-app namespace-collisions.
|
7
|
-
# Tags improve the UX of the OpenAPI docs at /docs.
|
8
|
-
router = APIRouter(prefix="/{{ app_name }}", tags=['{{ app_name }}'])
|
9
|
-
|
10
|
-
|
11
|
-
@router.get("/")
|
12
|
-
def hello_world():
|
13
|
-
return {
|
14
|
-
"project": "{{ project_name }}",
|
15
|
-
"app": "{{ app_name }}",
|
16
|
-
}
|
17
|
-
|
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
|