Hello, I’m working on creating some custom alarm notification profiles and I’m trying to figure out how to reference the account settings from a custom record. I already have my extension points set up for my notification profile, as well as the record backing it, following the Slack example in the IA repo. Following along with the Slack example, I noticed the FormFieldType.REFERENCE could be used to point to another record, so I created a new AccountConfig record/named resource and stored it under the ignition/data/config/resources/core/ignition path by defining the ResourceType and the META. The AccountConfig is created/updated by a custom React page I have, and I can see the account details saving into the path defined in the ResourceType. When I try to create a new instance of my notification profile, I see in the top right corner the error message “No route match for path: /v1/resources/names/ignition/account-config”, even when I do have an account record ready.
I also tried adding an AccountExtensionPoint and having my AccountConfig implement the ExtensionPointProfileConfig as well, but I didn’t have any luck there either. Any help would be appreciated, thanks.
It looks like the 'reference' field type is explicitly set up to only account for references to other configuration resources by name.
So you pass a FormReferenceType value of e.g. "ignition/audit-profile" (which is the string representation of a ResourceType), and the frontend form component automatically fetches all the extant names for that particular resource type and provides them in your edit form.
It sounds like you might just need to change the first part of your value to reference your custom module ID? That's the first half of the resource type tuple - so it would be com.your.module.id/account-config, in theory.
1 Like
Hi Paul,
Thanks for responding. I should have led with saying I already tried that formula before. I just get a slightly different message, “No route match for path: /v1/resources/names/moduleId/account-config”. I changed it to use “ignition” as the module ID because I thought that folder was somehow privileged for listing resources referenced elsewhere, like the audit-profile or database-connection folders.
For your custom account-config resource type:
- Are you registering a ResourceTypeMeta for it with the central registry?
- Are you opting-in that route to being exposed on the REST API?
- Are you customizing the ResourceActionSet provided by that meta in any way?
No, you need to call gwContext.getConfigurationManager().getResourceTypeMetaRegistry().register()
Not a route handler on gateway hook, but a route delegate on the type meta:
If you don't call buildRouteDelegate or withRouteDelegate, the automatic resource CRUD routes are not exposed (api/v1/resources/*) - distinct from any custom route handlers you may be providing in your hook.
Hi Paul,
Do you have an example of how I can properly setup the route delegate? I’ve registered the meta in my gatewayhook’s setup, but I don’t think I’m doing my route delegate properly. I currently have this invocation:
public static final ResourceTypeMeta<AccountConfig> META = ResourceTypeMeta.newBuilder(AccountConfig.class)
.resourceType(TYPE)
.categoryName("Account Config")
.defaultConfig(DEFAULT)
.buildReferenceDelegate(
builderConsumer -> {
new DefaultResourceReferenceDelegate.Builder(TYPE, new GsonResourceCodec<>(AccountConfig.class, new GsonBuilder().create()));
}
)
.build();
It compiles, but I’m still seeing that error message.
routeDelegate, not referenceDelegate.
Something like:
public static final ResourceTypeMeta<AccountConfig> META = ResourceTypeMeta.newBuilder(AccountConfig.class)
.resourceType(TYPE)
.categoryName("Account Config")
.defaultConfig(DEFAULT)
.buildRouteDelegate(
routes -> routes
.openApiGroupName("My Module")
.openApiTagName("config-account")
)
.build();
That seems to have done the trick. Thank you for your help Paul.
1 Like