6
6
7
7
from data_safe_haven .functions import json_safe
8
8
from data_safe_haven .serialisers import AzureSerialisableModel , ContextBase
9
- from data_safe_haven .types import SafeString
9
+ from data_safe_haven .types import SafeString , SoftwarePackageCategory
10
10
11
11
from .config_sections import (
12
12
ConfigSectionAzure ,
@@ -44,8 +44,34 @@ def from_remote_by_name(
44
44
return cls .from_remote (context , filename = sre_config_name (sre_name ))
45
45
46
46
@classmethod
47
- def template (cls : type [Self ]) -> SREConfig :
47
+ def template (cls : type [Self ], tier : int | None = None ) -> SREConfig :
48
48
"""Create SREConfig without validation to allow "replace me" prompts."""
49
+ # Set tier-dependent defaults
50
+ if tier == 0 :
51
+ remote_desktop_allow_copy = True
52
+ remote_desktop_allow_paste = True
53
+ software_packages = SoftwarePackageCategory .ANY
54
+ elif tier == 1 :
55
+ remote_desktop_allow_copy = True
56
+ remote_desktop_allow_paste = True
57
+ software_packages = SoftwarePackageCategory .ANY
58
+ elif tier == 2 : # noqa: PLR2004
59
+ remote_desktop_allow_copy = False
60
+ remote_desktop_allow_paste = False
61
+ software_packages = SoftwarePackageCategory .ANY
62
+ elif tier == 3 : # noqa: PLR2004
63
+ remote_desktop_allow_copy = False
64
+ remote_desktop_allow_paste = False
65
+ software_packages = SoftwarePackageCategory .PRE_APPROVED
66
+ elif tier == 4 : # noqa: PLR2004
67
+ remote_desktop_allow_copy = False
68
+ remote_desktop_allow_paste = False
69
+ software_packages = SoftwarePackageCategory .NONE
70
+ else :
71
+ remote_desktop_allow_copy = "True/False: whether to allow copying text out of the environment." # type: ignore
72
+ remote_desktop_allow_paste = "True/False: whether to allow pasting text into the environment." # type: ignore
73
+ software_packages = "Which Python/R packages to allow users to install: [any/pre-approved/none]" # type: ignore
74
+
49
75
return SREConfig .model_construct (
50
76
azure = ConfigSectionAzure .model_construct (
51
77
location = "Azure location where SRE resources will be deployed." ,
@@ -66,14 +92,14 @@ def template(cls: type[Self]) -> SREConfig:
66
92
"List of IP addresses belonging to data providers"
67
93
],
68
94
remote_desktop = ConfigSubsectionRemoteDesktopOpts .model_construct (
69
- allow_copy = "True/False: whether to allow copying text out of the environment." , # type:ignore
70
- allow_paste = "True/False: whether to allow pasting text into the environment." , # type:ignore
95
+ allow_copy = remote_desktop_allow_copy ,
96
+ allow_paste = remote_desktop_allow_paste ,
71
97
),
72
98
research_user_ip_addresses = ["List of IP addresses belonging to users" ],
73
- software_packages = "Which Python/R packages to allow users to install: [any/pre-approved/none]" , # type:ignore
99
+ software_packages = software_packages ,
74
100
storage_quota_gb = ConfigSubsectionStorageQuotaGB .model_construct (
75
- home = "Total size in GiB across all home directories [minimum: 100]." , # type:ignore
76
- shared = "Total size in GiB for the shared directories [minimum: 100]." , # type:ignore
101
+ home = "Total size in GiB across all home directories [minimum: 100]." , # type: ignore
102
+ shared = "Total size in GiB for the shared directories [minimum: 100]." , # type: ignore
77
103
),
78
104
timezone = "Timezone in pytz format (eg. Europe/London)" ,
79
105
workspace_skus = [
0 commit comments