Package com.inductiveautomation.ignition.gateway.config.actions


package com.inductiveautomation.ignition.gateway.config.actions

Resource Configuration Actions

This package contains the interfaces and classes for defining resource configuration actions, which are what equips a ResourceTypeMeta with the ability to perform CRUD operations and more as defined in ResourceAction. All ResourceTypeMetas by default include all non validating DefaultResourceActions by default, so in most cases nothing is needed to be done on your part.

ResourceActions are responsible for doing all the necessary work for taking a request and saving it to the configuration system. For example, creating a new resource like a Driver or Database connection and turning that request into a Resource which is then saved in the configuration system.

Defining these ResourceActions happens when defining the ResourceTypeMeta for your resource. via the ResourceActionSet builder. This build is exposed through the DefaultResourceTypeMeta.Builder.buildActionSet(java.util.function.Consumer<com.inductiveautomation.ignition.gateway.config.actions.ResourceActionSet.Builder>) method.

The default implementation handles all of this for you, leaning on that particular resource's ResourceTypeMeta definition. With that being said, there are typically three use cases for interacting with resource actions:

  • Preventing a specific action, like a rename
  • Doing some additional validation of the resource before allowing it to save to the configuration system
  • Rolling your own implementation of the Action because your resource has some out-of-band constraint or requirement that cannot be satisfied by the ResourceTypeMeta or Configuration system in general
  • Preventing an Action

    Preventing an action (for example, Rename) is as simple as
    
     ResourceTypeMeta.newBuilder(MyResourceConfiguration.class)
         .resourceType(MyResourceConfiguration.RESOURCE_TYPE)
         .categoryNameKey("Resources.MyNewResource")
         .buildActionSet(builder -> builder
             .rename(null)
         )
         [...]
     

    Performing Additional Validation

    Sometimes you might want to validate the configuration or settings of the resource prior to saving it to the configuration system. For example, you might want to ensure that a resource's configuration has some unique field across all resources of the same type. In this case, you can use the validating actions on the actions, like ResourceActionSet.Builder.withValidatingCreate(java.util.function.Function<com.inductiveautomation.ignition.gateway.config.actions.DefaultResourceActions.CreateResources<R>, java.util.Optional<com.inductiveautomation.ignition.gateway.config.actions.ResourceAction.ValidationFailure>>)
    
     ResourceTypeMeta.newBuilder(MyResourceConfiguration.class)
         .resourceType(MyResourceConfiguration.RESOURCE_TYPE)
         .categoryNameKey("Resources.MyNewResource")
         .buildActionSet(builder -> builder
             .renameValidate(resource -> validateFooField(resource))
         )
         [...]
     

    Custom Implementation

    This is typically not recommended as the Default actions should cover most use cases. However, if you need to you can implement the appropriate ResourceAction yourself. You can delegate to the default implementation using the ResourceActionSet.DEFAULT implementations.