Scan Task - Single File No Gallery Creation

Bare with me I’m just getting back into programming after a 20 year hiatus.
What I’m looking to do is just create a function to run against a gallery (and eventually batch on galleries). If the gallery is a folder zip it, name the zip the same as the folder. Generate a file for the files table, then update the gallery to use the zip file instead of the folder.

Unless I’m missing something I should just be able:
Python generate zip → Create files row for this zip → GQL mutation to strip gallery.folder_id for the gallery in question → mutation generate galleries_files with the new files entry id → do some validation → delete the old folder.

First question: Am I missing something or does that all sound right?
Second question: Is there a particular API/GQL/Function I should be looking at to generate the new item in the files and galleries_files tables? While I’m planning on using Python, I was hoping to avoid directly manipulating the SQlite DB directly with it.

There’s currently no way to reassign galleries to different zip files or folders. This will be the main barrier to what you’re trying to do, and the workaround will have to be to use SQL queries (via execSQL ideally).

I’d like to add the ability to reassign media between files and folders, but there’s a few assumptions remaining that make this a little non-trivial.