Code Reuse for Cloud

For Server/Data Center, there’s the Script Editor menu to write scripts for reuse. In Cloud, there’s no more Script Editor. How can I achieve the same effect?

In particular, I want paging to be handled transparently. If you take a look at the Jira Cloud REST APIs, you will be surprised by how many different styles they got.

e.g. Issue search (api-rest-api-3-search-get)
Takes: startAt, maxResults
Outputs: startAt, maxResults, total

e.g. Get dashboards (api-rest-api-3-dashboard-get)
Takes: startAt, maxResults
Outputs: startAt, maxResults, total… plus next and prev containing URLs

e.g. Get filters (api-rest-api-3-filter-search-get)
Takes: startAt, maxResults
Outputs: startAt, maxResults, total… plus isLast and nextPage

e.g. Search users (api-rest-api-3-user-search-get)
Takes: startAt, maxResults
Outputs: Nothing except the current page of results, won’t even tell you the total, just try to get next page to see if you got everything

Even more styles if you look at Confluence Cloud REST APIs. The one for content restriction is a real gem. Some APIs don’t even return a correct total.

Instead of repeating these pagination handling all over the place, I really need a centralized script to deal with them.

How can I achieve the same effect as Script Editor in Cloud?

I can compile code at runtime like this:

import org.apache.log4j.Logger;
import org.apache.log4j.Level;
import java.lang.reflect.*;
def log = Logger.getLogger("Test");
log.setLevel(Level.DEBUG);
GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
String script = "public class Test { public static String hello() { return \"Hello\"} }";
Class cls = groovyClassLoader.parseClass(script);
log.info(cls.getClass().getCanonicalName());
Method m = cls.getMethod("hello");
log.info(m.invoke(null));
log.info(cls.hello());

Grab the source code from somewhere protected? Still need a way to deal with depedencies.
Any issue with performance?