Delete/Insert sample mappings?

Years ago I made a little tool that has been very useful to me: it uses the file names of samples to automatically generate key mappings. That worked with Renoise 2.8. Then the API changed and the tool didn’t work in the new versions. It didn’t even load. I didn’t have the time or the energy at the time to attempt to make it work in the new versions, and left it at that. I never released the tool. When I needed it, I just used Renoise 2.8. But each time I used it, I thought it would be nice to release it, since I think it could be very useful to others.

Now I want to make it work in Renoise 3.1 and managed to make it load (by changing the version number in the manifest; duh). But there are two functions that aren’t available anymore:

instrument:delete_sample_mapping_at(renoise.Instrument.LAYER_NOTE_ON,
#instrument.sample_mappings[renoise.Instrument.LAYER_NOTE_ON])
instrument:insert_sample_mapping(renoise.Instrument.LAYER_NOTE_ON, baseNotes[i][2], baseNote, range)

My guess is there must be some easy replacement for that code. So the question is: how does one delete and how does one insert a sample mapping in an instrument nowadays?