@@ -42,21 +42,21 @@ class ClusterAccessRights(BaseModel):
4242
4343
4444class BaseAuthentication (BaseModel ):
45- type : str
45+ discriminator_type : str
4646
4747 model_config = ConfigDict (frozen = True , extra = "forbid" )
4848
4949
5050class SimpleAuthentication (BaseAuthentication ):
51- type : Literal ["simple" ] = "simple"
51+ discriminator_type : Literal ["simple" ] = "simple"
5252 username : str
5353 password : SecretStr
5454
5555 model_config = ConfigDict (
5656 json_schema_extra = {
5757 "examples" : [
5858 {
59- "type " : "simple" ,
59+ "discriminator_type " : "simple" ,
6060 "username" : "someuser" ,
6161 "password" : "somepassword" ,
6262 },
@@ -66,40 +66,45 @@ class SimpleAuthentication(BaseAuthentication):
6666
6767
6868class KerberosAuthentication (BaseAuthentication ):
69- type : Literal ["kerberos" ] = "kerberos"
69+ discriminator_type : Literal ["kerberos" ] = "kerberos"
7070
7171 model_config = ConfigDict (
7272 json_schema_extra = {
7373 "examples" : [
7474 {
75- "type " : "kerberos" ,
75+ "discriminator_type " : "kerberos" ,
7676 },
7777 ]
7878 }
7979 )
8080
8181
8282class JupyterHubTokenAuthentication (BaseAuthentication ):
83- type : Literal ["jupyterhub" ] = "jupyterhub"
83+ discriminator_type : Literal ["jupyterhub" ] = "jupyterhub"
8484 api_token : str
8585
8686 model_config = ConfigDict (
8787 json_schema_extra = {
8888 "examples" : [
89- {"type" : "jupyterhub" , "api_token" : "some_jupyterhub_token" },
89+ {
90+ "discriminator_type" : "jupyterhub" ,
91+ "api_token" : "some_jupyterhub_token" ,
92+ },
9093 ]
9194 }
9295 )
9396
9497
9598class NoAuthentication (BaseAuthentication ):
96- type : Literal ["none" ] = "none"
99+ discriminator_type : Literal ["none" ] = "none"
97100
98- model_config = ConfigDict (json_schema_extra = {"examples" : [{"type" : "none" }]})
101+ model_config = ConfigDict (
102+ json_schema_extra = {"examples" : [{"discriminator_type" : "none" }]}
103+ )
99104
100105
101106class TLSAuthentication (BaseAuthentication ):
102- type : Literal ["tls" ] = "tls"
107+ discriminator_type : Literal ["tls" ] = "tls"
103108 tls_ca_file : Path
104109 tls_client_cert : Path
105110 tls_client_key : Path
@@ -108,7 +113,7 @@ class TLSAuthentication(BaseAuthentication):
108113 json_schema_extra = {
109114 "examples" : [
110115 {
111- "type " : "tls" ,
116+ "discriminator_type " : "tls" ,
112117 "tls_ca_file" : "/path/to/ca_file" ,
113118 "tls_client_cert" : "/path/to/cert_file" ,
114119 "tls_client_key" : "/path/to/key_file" ,
@@ -140,7 +145,9 @@ class BaseCluster(BaseModel):
140145 )
141146 endpoint : AnyUrl
142147 authentication : ClusterAuthentication = Field (
143- ..., description = "Dask gateway authentication"
148+ ...,
149+ description = "Dask gateway authentication" ,
150+ discriminator = "discriminator_type" ,
144151 )
145152 access_rights : dict [GroupID , ClusterAccessRights ] = Field (default_factory = dict )
146153
@@ -169,7 +176,7 @@ class Cluster(BaseCluster):
169176 "owner" : 1456 ,
170177 "endpoint" : "tcp://default-dask-scheduler:8786" ,
171178 "authentication" : {
172- "type " : "simple" ,
179+ "discriminator_type " : "simple" ,
173180 "username" : "someuser" ,
174181 "password" : "somepassword" ,
175182 },
@@ -181,7 +188,7 @@ class Cluster(BaseCluster):
181188 "owner" : 12 ,
182189 "endpoint" : "https://registry.osparc-development.fake.dev" ,
183190 "authentication" : {
184- "type " : "simple" ,
191+ "discriminator_type " : "simple" ,
185192 "username" : "someuser" ,
186193 "password" : "somepassword" ,
187194 },
@@ -193,7 +200,7 @@ class Cluster(BaseCluster):
193200 "type" : ClusterTypeInModel .AWS ,
194201 "owner" : 154 ,
195202 "endpoint" : "https://registry.osparc-development.fake.dev" ,
196- "authentication" : {"type " : "kerberos" },
203+ "authentication" : {"discriminator_type " : "kerberos" },
197204 "access_rights" : {
198205 154 : CLUSTER_ADMIN_RIGHTS , # type: ignore[dict-item]
199206 12 : CLUSTER_MANAGER_RIGHTS , # type: ignore[dict-item]
@@ -208,7 +215,7 @@ class Cluster(BaseCluster):
208215 "owner" : 2321 ,
209216 "endpoint" : "https://registry.osparc-development.fake2.dev" ,
210217 "authentication" : {
211- "type " : "jupyterhub" ,
218+ "discriminator_type " : "jupyterhub" ,
212219 "api_token" : "some_fake_token" ,
213220 },
214221 "access_rights" : {
0 commit comments