|
3 | 3 |
|
4 | 4 | from pydantic import BaseModel, ConfigDict, StringConstraints |
5 | 5 |
|
6 | | -from ..products import ProductName |
7 | 6 | from ..progress_bar import ProgressReport |
8 | | -from ..users import UserID |
9 | 7 |
|
10 | 8 | AsyncJobId: TypeAlias = UUID |
11 | 9 | AsyncJobName: TypeAlias = Annotated[ |
12 | 10 | str, StringConstraints(strip_whitespace=True, min_length=1) |
13 | 11 | ] |
14 | 12 |
|
15 | 13 |
|
16 | | -class AsyncJobFilterBase(BaseModel): |
17 | | - """Base class for async job filters""" |
18 | | - |
19 | | - model_config = ConfigDict(extra="forbid") |
20 | | - |
21 | | - |
22 | 14 | class AsyncJobStatus(BaseModel): |
23 | 15 | job_id: AsyncJobId |
24 | 16 | progress: ProgressReport |
@@ -50,24 +42,20 @@ class AsyncJobAbort(BaseModel): |
50 | 42 | job_id: AsyncJobId |
51 | 43 |
|
52 | 44 |
|
53 | | -class AsyncJobFilter(AsyncJobFilterBase): |
| 45 | +class AsyncJobFilter(BaseModel): |
54 | 46 | """Data for controlling access to an async job""" |
55 | 47 |
|
56 | 48 | model_config = ConfigDict( |
| 49 | + extra="allow", |
57 | 50 | json_schema_extra={ |
58 | 51 | "examples": [ |
59 | 52 | { |
60 | 53 | "product_name": "osparc", |
61 | 54 | "user_id": 123, |
62 | | - "client_name": "web_client", |
| 55 | + "task_owner": "web_client", |
63 | 56 | } |
64 | 57 | ] |
65 | 58 | }, |
66 | 59 | ) |
67 | 60 |
|
68 | | - product_name: ProductName |
69 | | - user_id: UserID |
70 | | - task_owner: Annotated[ # this is the name of the app which *submits* the async job. It is mainly used for filtering purposes |
71 | | - str, |
72 | | - StringConstraints(min_length=1, pattern=r"^[^\s]+$"), |
73 | | - ] |
| 61 | + task_owner: Annotated[str, StringConstraints(min_length=1, pattern=r"^[a-z_-]+$")] |
0 commit comments