@@ -240,6 +240,11 @@ def application_id(self) -> str:
240240 assert self ._service_principal .application_id is not None
241241 return self ._service_principal .application_id
242242
243+ @property
244+ def id (self ) -> str :
245+ assert self ._service_principal .id is not None
246+ return self ._service_principal .id
247+
243248 def __repr__ (self ):
244249 return f'RunAs({ self .display_name } )'
245250
@@ -339,8 +344,7 @@ def create(*, account_groups: list[str] | None = None):
339344 workspace_id = ws .get_workspace_id ()
340345 service_principal = acc .service_principals .create (display_name = f'spn-{ make_random ()} ' )
341346 assert service_principal .id is not None
342- service_principal_id = int (service_principal .id )
343- created_secret = acc .service_principal_secrets .create (service_principal_id )
347+ created_secret = acc .service_principal_secrets .create (service_principal .id )
344348 if account_groups :
345349 group_mapping = {}
346350 for group in acc .groups .list (attributes = 'id,displayName' ):
@@ -354,15 +358,15 @@ def create(*, account_groups: list[str] | None = None):
354358 acc .groups .patch (
355359 group_id ,
356360 operations = [
357- Patch (PatchOp .ADD , 'members' , [ComplexValue (value = str (service_principal_id )).as_dict ()]),
361+ Patch (PatchOp .ADD , 'members' , [ComplexValue (value = str (service_principal . id )).as_dict ()]),
358362 ],
359363 schemas = [PatchSchema .URN_IETF_PARAMS_SCIM_API_MESSAGES_2_0_PATCH_OP ],
360364 )
361365 permissions = [WorkspacePermission .USER ]
362- acc .workspace_assignment .update (workspace_id , service_principal_id , permissions = permissions )
366+ acc .workspace_assignment .update (workspace_id , int ( service_principal . id ) , permissions = permissions )
363367 ws_as_spn = _make_workspace_client (ws , created_secret , service_principal )
364368
365- log_account_link ('account service principal' , f'users/serviceprincipals/{ service_principal_id } ' )
369+ log_account_link ('account service principal' , f'users/serviceprincipals/{ service_principal . id } ' )
366370
367371 return RunAs (service_principal , ws_as_spn , env_or_skip )
368372
0 commit comments