Object Model API (OMAPI) Configurations
- optional
A Template Package can include a Object Model API configuration to be deployed to Twinit by configuring an OMAPI config definition in manifest.omapiConfig array and matching files containing the content of the user configs in the packages 'omapiConfig' folder. While the manifest configuration for omapiConfig is an array, you are limited to only one OMAPI config definition.
An OMAPI config definition should include the _name, _description, and _shortName for the config like so:
// manifest.json"omapiConfig": [ { "_name": "Sample API Config", "_shortName": "sampleapic", "_description": "A sample API config" }]While omapiConfig is an array, you are limited to only one definition. This is because only one API config can be deployed to The Twinit Object Model API Service for project or workspace.
A _userType is not required for OMAPI configs, as the _userType will automatically be set to 'api-config' when deployed.
Each OMAPI config definition must map to a .json file in the package's omapiConfig folder, where the _name of the API config definition matches the name of the .json file. The content of the .json should be the .json content of the API config.
Options#
- doNotDeploy - the omapiConfig can take an optional
doNotDeployoption. If se to true, the omapi config will be updated but will not be immediately deployed to the Object Model API Service.
Complete Example:#
// manifest.json{ "Template Name": "Water Treatment Operations Digital Twin", "Template Version": "1.0.5", "omapiConfig": [ { "_name": "Sample API Config", "_shortName": "sampleapic", "_description": "A sample API config" } ]}// Package Zip FileWater Treatment Template.zip /||-- omapiConfig /| |-- Sample API Config.json||-- manifest.json// Sample OMAPI Config.json[ { "endpoints": { "sampleResource": { "paths": [ { "path": "/sampleResource", "method": "OPTIONS", "script": { "_userType": "omapi-script", "_scriptName": "returnStatus" } }, { "path": "/sampleResource", "method": "GET", "script": { "_userType": "omapi-script", "_scriptName": "getResource" } }, ] } }, "schema_version": 2, "settings": { "apiConfig": true } }]Note: OMAPI configs rely on scripts having been deployed to the Twinit project or workspace. If deploying an OMAPI config, you will also want to deploy scripts.
Deploying API Configs#
When the Template Package is deployed, if the defined API config does not exist it will be created. If an API config with the same _name already exists, a new version of the API config will be created.
After the API config is created or versioned in Twinit, by default it will be auto-deployed to the Object Model API Service so that your custom API endpoints accessible.
**If you do not wish for the API config to be auto-deployed, provide a 'doNotDeploy' field set to true in the API config definition like so:
// manifest.json"omapiConfig": [ { "_name": "Sample API Config", "_shortName": "sampleapic", "_description": "A sample API config", "doNotDeploy": true }]Deploying multiple versions of the same API config is also possible. See Support for Deploying Versioned Items