Define Model APIs

To add a new Model API, select "Model" under "Rest APIs" and click "Add Model API Resource" from context menu or toolbar:

Platform provides a standard implementation to read or write models. Alternately, the developer can provide a custom implementation if they want to add custom levels or fields which are not actually on a model. (The developer can extend the Platform's standard implementation class and use the utility methods provided there to speed up their implementation.)

Level

The Level section is used to define the "levels" (i.e. parent/child relationships) of the model, and the fields within each level. The developer can define as many levels as they want, but there can be at most 1 root level. The developer can also add a custom level or custom fields within any level as long as they provide a custom implementation.

images/download/attachments/144835819/ModelAPILevel-version-1-modificationdate-1655930136000-api-v2.png

When adding MDF fields, they will be added under the following hierarchy <Level> -> MDFs -> <ModulePrefix>. The same hierarchy will be maintained in the JSON Object passed through REST.

images/download/attachments/144835819/ModelAPIMDFs-version-1-modificationdate-1655930165000-api-v2.png

KeyObject

The KeyObject section is used to define the Natural Key fields for a root level. This is used to uniquely identify a record from the database. For the standard implementation, the developer should add all the root level model's NK fields. If the developer is using any other combination of fields, they will have to provide a custom implementation.

images/download/attachments/144835819/ModelAPIKeyObject-version-1-modificationdate-1655930188000-api-v2.png

The developer can add fields to the KeyObject section by clicking the "Add" button. This will open a pop-up dialog containing only Natural Key fields from root level defined in the level section of the "Definition" tab.

images/download/attachments/144835819/ModelAPI_AddKeyFields-version-1-modificationdate-1655930214000-api-v2.png

KeyObjects are not overridable by higher module.

Write

The Write section is used to define levels and fields for persisting models to the database. The developer can define as many resource actions as they wish. These do not correspond directly to model actions but are unique names that hold the levels and fields along with the model action.

To add a resource action, the developer should click the "Add" button in the Write tab. This will open a pop-up where the developer must provide a name and optional description, and select one of the actions for the root level model. The name will automatically be prefixed by the module prefix to avoid name conflicts across modules.

images/download/attachments/144835819/ModelAPI_AddAction-version-1-modificationdate-1655930334000-api-v2.png

When the developer clicks the OK button, this will copy all levels and its fields from the "Level" section to the created resource action. If a model action is selected, then the field mask will be based on the mask selected in the action. If a model action is not selected, an OPTIONAL mask will be used for all fields by default.

Once the resource action is created, the developer can choose the levels and fields which are copied from the level section.

images/download/attachments/144835819/ModelAPI_AddWriteFields-version-1-modificationdate-1655930354000-api-v2.png