I have a custom module with 3 settings, and in 8.3 I’ve created a React app with Webpack and have all that working. The module has a single SettingsResource with the three settings. Everything works, except on install I don’t get a default resource/config.json. What code do I need to run to create the defaults? More specifically.
Here is my resource code:
<public static final ResourceTypeMeta<SettingsResource> META = ResourceTypeMeta.newBuilder(SettingsResource.class)
.resourceType(RESOURCE_TYPE)
.categoryName("myCat")
.defaultConfig(DEFAULT)
.buildRouteDelegate(routes -> routes.configSchema(SettingsResource.class)
.openApiGroupName("My Group")
.openApiTagName("My API Tag"))
.singleton()
.build();
/>
Then in my gateway class I do the following on setup:
namedResourceHandler = NamedResourceHandler.newBuilder(SettingsResource.META)
.context(context)
.onResourceUpdated(resource -> {
// My code on change here
})
.build();
Then I call start/stop on resourcehandler in the gateway start/stop overrides.
My problem is on install in the Ignition directory under data/config/resources/core/my module id/my resource doesn't exist. I get a 404 when I hit my config page saying the resource isn't found. If I manually create the directory and add the config.json and resource.json files, everything works fine.
I looked at the SDK examples, and there is a MongoDB one that looks like it's using a UserExtensionPoint to maybe do the init, but otherwise I'm not seeing it, and I'm not using ExtensionPoints.
In 8.1 there was a way to initial/update the record on startup. Is there a way to do this in 8.3?