def create_light()

in src/services/region_mutator_service.py [0:0]


    def create_light(self, maestro_name: str, native_name: str, cloud: str,
                     region_id: Optional[str] = None,
                     is_active: Optional[bool] = True):
        """
        Without whole-table scans.
        Judging by dev2 tables, region_id highly resembles MongoDB's ObjectId.
        So, it's always unique, and we need not check collisions.
        If you pass region_id, make sure it's unique or just let us generate it
        """
        assert cloud in CLOUD_PROVIDERS, 'Invalid cloud'
        by_native_name = self.get_region_by_native_name(native_name, cloud)
        if by_native_name:
            raise ModularException(
                code=RESPONSE_CONFLICT_CODE,
                content=f'Region {native_name} already exists in db'
            )
        by_maestro_name = self.get_region(maestro_name)
        if by_maestro_name:
            raise ModularException(
                code=RESPONSE_CONFLICT_CODE,
                content=f'Region {maestro_name} already exists in db'
            )
        return RegionModel(
            maestro_name=maestro_name,
            native_name=native_name,
            cloud=cloud,
            region_id=region_id or str(ObjectId()),
            is_active=is_active
        )