How to change the share permissions on dashboards and filters from a Server/DC plugin?

We are moving to Jira cloud and I have thousands of filters and dashboards that are shared with the public. I’ve written a plugin to find and/or delete dashboards and filters but can’t figure out how to change their permissions.

A pointer to the right Java incantations would be appreciated.

Check out ShareManager, that should get you right