|
| 1 | +from typing import Dict, Literal, Optional, TypedDict, overload |
| 2 | + |
| 3 | +from typing_extensions import NotRequired, Required, Unpack |
| 4 | + |
1 | 5 | from .resources import ( |
2 | 6 | ActiveCreatorMethods, |
3 | 7 | ActiveDestroyerMethods, |
|
7 | 11 |
|
8 | 12 |
|
9 | 13 | class Environment(ActiveUpdaterMethods, ActiveDestroyerMethods): |
10 | | - pass |
| 14 | + class _UpdateEnvironment(TypedDict, total=False): |
| 15 | + title: Required[str] |
| 16 | + description: NotRequired[Optional[str]] |
| 17 | + matching: NotRequired[Optional[Literal["any", "exact", "none"]]] |
| 18 | + supervisor: NotRequired[Optional[str]] |
| 19 | + python: NotRequired[Dict] |
| 20 | + quarto: NotRequired[Dict] |
| 21 | + r: NotRequired[Dict] |
| 22 | + tensorflow: NotRequired[Dict] |
| 23 | + |
| 24 | + @overload |
| 25 | + def update(self, /, **attributes: Unpack[_UpdateEnvironment]): ... |
| 26 | + |
| 27 | + @overload |
| 28 | + def update(self, /, **attributes): ... |
| 29 | + |
| 30 | + def update(self, /, **attributes): |
| 31 | + return super().update(**attributes) |
11 | 32 |
|
12 | 33 |
|
13 | 34 | class Environments(ActiveFinderMethods[Environment], ActiveCreatorMethods[Environment]): |
14 | 35 | def __init__(self, ctx, path, pathinfo="environments", uid="guid"): |
15 | 36 | super().__init__(ctx, path, pathinfo, uid) |
16 | 37 |
|
| 38 | + class _CreateEnvironment(TypedDict, total=False): |
| 39 | + title: Required[str] |
| 40 | + description: NotRequired[Optional[str]] |
| 41 | + cluster_name: Required[Literal["Kubernetes"]] |
| 42 | + name: Required[str] |
| 43 | + matching: NotRequired[Optional[Literal["any", "exact", "none"]]] |
| 44 | + supervisor: NotRequired[Optional[str]] |
| 45 | + python: NotRequired[Dict] |
| 46 | + quarto: NotRequired[Dict] |
| 47 | + r: NotRequired[Dict] |
| 48 | + tensorflow: NotRequired[Dict] |
| 49 | + |
| 50 | + @overload |
| 51 | + def create(self, **attributes: Unpack[_CreateEnvironment]): ... |
| 52 | + |
| 53 | + @overload |
| 54 | + def create(self, **attributes): ... |
| 55 | + |
| 56 | + def create(self, **attributes): |
| 57 | + return super().create(**attributes) |
| 58 | + |
17 | 59 | def _create_instance(self, path, pathinfo, /, **attributes): |
18 | 60 | return Environment(self._ctx, path, pathinfo, **attributes) |
0 commit comments