4545 from .utils import MultitenancyConfig
4646
4747from supertokens_python .querier import NormalisedURLPath
48+ from .constants import DEFAULT_TENANT_ID
4849
4950
5051def parse_tenant_config (tenant : Dict [str , Any ]) -> TenantConfigResponse :
@@ -161,7 +162,7 @@ async def get_tenant(
161162 self , tenant_id : Optional [str ], user_context : Dict [str , Any ]
162163 ) -> Optional [GetTenantOkResult ]:
163164 res = await self .querier .send_get_request (
164- NormalisedURLPath (f"{ tenant_id } /recipe/multitenancy/tenant" ),
165+ NormalisedURLPath (f"{ tenant_id or DEFAULT_TENANT_ID } /recipe/multitenancy/tenant" ),
165166 )
166167
167168 if res ["status" ] == "TENANT_NOT_FOUND_ERROR" :
@@ -209,7 +210,7 @@ async def create_or_update_third_party_config(
209210 user_context : Dict [str , Any ],
210211 ) -> CreateOrUpdateThirdPartyConfigOkResult :
211212 response = await self .querier .send_put_request (
212- NormalisedURLPath (f"{ tenant_id } /recipe/multitenancy/config/thirdparty" ),
213+ NormalisedURLPath (f"{ tenant_id or DEFAULT_TENANT_ID } /recipe/multitenancy/config/thirdparty" ),
213214 {
214215 "config" : config .to_json (),
215216 "skipValidation" : skip_validation is True ,
@@ -228,7 +229,7 @@ async def delete_third_party_config(
228229 ) -> DeleteThirdPartyConfigOkResult :
229230 response = await self .querier .send_post_request (
230231 NormalisedURLPath (
231- f"{ tenant_id } /recipe/multitenancy/config/thirdparty/remove"
232+ f"{ tenant_id or DEFAULT_TENANT_ID } /recipe/multitenancy/config/thirdparty/remove"
232233 ),
233234 {
234235 "thirdPartyId" : third_party_id ,
@@ -240,7 +241,7 @@ async def delete_third_party_config(
240241 )
241242
242243 async def associate_user_to_tenant (
243- self , tenant_id : str | None , user_id : str , user_context : Dict [str , Any ]
244+ self , tenant_id : Optional [ str ] , user_id : str , user_context : Dict [str , Any ]
244245 ) -> Union [
245246 AssociateUserToTenantOkResult ,
246247 AssociateUserToTenantUnknownUserIdError ,
@@ -249,7 +250,7 @@ async def associate_user_to_tenant(
249250 AssociateUserToTenantThirdPartyUserAlreadyExistsError ,
250251 ]:
251252 response : Dict [str , Any ] = await self .querier .send_post_request (
252- NormalisedURLPath (f"{ tenant_id } /recipe/multitenancy/tenant/user" ),
253+ NormalisedURLPath (f"{ tenant_id or DEFAULT_TENANT_ID } /recipe/multitenancy/tenant/user" ),
253254 {
254255 "userId" : user_id ,
255256 },
@@ -277,10 +278,10 @@ async def associate_user_to_tenant(
277278 raise Exception ("Should never come here" )
278279
279280 async def dissociate_user_from_tenant (
280- self , tenant_id : str | None , user_id : str , user_context : Dict [str , Any ]
281+ self , tenant_id : Optional [ str ] , user_id : str , user_context : Dict [str , Any ]
281282 ) -> DisassociateUserFromTenantOkResult :
282283 response = await self .querier .send_post_request (
283- NormalisedURLPath (f"{ tenant_id } /recipe/multitenancy/tenant/user/remove" ),
284+ NormalisedURLPath (f"{ tenant_id or DEFAULT_TENANT_ID } /recipe/multitenancy/tenant/user/remove" ),
284285 {
285286 "userId" : user_id ,
286287 },
0 commit comments