def try_to_import_space( space: Space, space_service: SpaceService, do_update: bool) -> SpaceImportDataResult: if is_blank(space.spaceId): space_service.redress_storable_id(space) space_service.create(space) else: existing_space: Optional[Space] = space_service.find_by_id(space.spaceId) if existing_space is None: space_service.create(space) elif do_update: space.version = existing_space.version space_service.update(space) else: return SpaceImportDataResult( spaceId=space.spaceId, name=space.name, passed=False, reason='Space already exists.') return SpaceImportDataResult(spaceId=space.spaceId, name=space.name, passed=True)
def get_space_service( connected_space_service: ConnectedSpaceService) -> SpaceService: return SpaceService(connected_space_service.storage, connected_space_service.snowflakeGenerator, connected_space_service.principalService)
def get_space_service(principal_service: PrincipalService) -> SpaceService: return SpaceService(ask_meta_storage(), ask_snowflake_generator(), principal_service)
def get_space_service(user_service: UserService) -> SpaceService: return SpaceService(user_service.storage, user_service.snowflakeGenerator, user_service.principalService)
def get_space_service(subject_service: SubjectService) -> SpaceService: return SpaceService(subject_service.storage, subject_service.snowflakeGenerator, subject_service.principalService)