Using REST API¶
Unidata products use REST APIs to exchange data between modules within the system, to communicate between products (such as MDM and DG), and third-party systems.
REST services are available at http://<host>:<port>/unidata-backend/api. For example, http://localhost:8081/unidata-backend/api or http://unidata-service/unidata-backend/api.
REST services are separated by function, and correspond to the module architecture. For example, the v2/draft service is responsible for draft-related queries, and v1/license for licensing.
How to Work with Unidata REST API¶
REST API повторяет функциональность, доступную в пользовательском интерфейсе.
First, in Unidata MDM and DG you need to create a data model consisting of several parts. You can get examples of model descriptions by creating test versions in the user interface and exporting them. Structure of the data model:
Data model (main part, contains description of entities and lookup entities).
Data sources.
Units of measurement.
Enumerations.
Data quality model.
Matching model.
Workflows model (for Enterprise Edition only).
Data model queries are placed in unidata-backend/api/v2/meta and unidata-backend/api/v2/data services.
Many data queries will subsequently rely on data model structure, data quality models, etc. For example, when creating a record, fill in attributes according to the data model, and consider the attribute properties specified in the model.
Note
The model.xml file (data model) must be imported after enumerations and units of measurement files, but before the data quality model and matching model files
Data Types Description¶
Model of Entities / Lookup Entities¶
post {
request.uri.path = "/${AppConfig.REST_API_URL}/v1/meta/model/import"
request.contentType = 'multipart/form-data'
request.headers['Authorization'] = token
request.body = multipart {
part 'file', xmlFile.name.toString(), 'text/xml', xmlFile
part 'override', 'true'
}
request.encoder 'multipart/form-data', OkHttpEncoders.&multipart
}
Tip
Use the model.xml file example
Units of Measurement¶
One of the special data types of the system is the “Number” type. It is used as the value type of simple attributes.
To use it, you must first create units of measurement. One way to create units is to import them from the measurement-units.xml file.
Each measurement category and each unit have properties:
name – category or unit name (required; may contain Latin letters, figures, ‘_’ symbol);
displayName – category or unit name displayed in the UI (required; may contain letters of different languages, figures, different symbols including “space”).
post {
request.uri.path = "/${AppConfig.REST_API_URL}/v1/meta/measurement/import"
request.contentType = 'multipart/form-data'
request.headers['Authorization'] = token
request.body = multipart {
part 'file', xmlFile.name.toString(), 'text/xml', xmlFile
part 'override', 'true'
}
request.encoder 'multipart/form-data', OkHttpEncoders.&multipart
}
Tip
Use the measurement-units.xml file example
Enumerations¶
One of the data types of the system is enumDataType. One or more enumerations with values inside can be written in the xml file “enumerations”.
Each enumeration and each enumeration value have properties:
name – enumeration or enumeration value name (required; may contain Latin letters, figures, ‘_’ symbol);
displayName – enumeration or enumeration value name displayed in the UI (required; may contain letters of different languages, figures, different symbols including “space”).
post {
request.uri.path = "/${AppConfig.REST_API_URL}/v1/meta/enumerations/import"
request.contentType = 'multipart/form-data'
request.headers['Authorization'] = token
request.body = multipart {
part 'file', xmlFile.name.toString(), 'text/xml', xmlFile
part 'override', 'true'
}
request.encoder 'multipart/form-data', OkHttpEncoders.&multipart
}
Tip
Use the enumerations.xml file example
Source Systems¶
The Unidata system can work with data from various sources. Some sources systems can be prescribed in the xml-file “source-systems”.
The “unidata” system is used by default. All data added to the UI has this source system.
You can choose not to use the “source-systems” xml-file. In this case, all data will only be added and updated from the “unidata” data source. Using some data sources, you can add records from different systems and merge them into one.
The weight property is important because it defines one of the merging rules. Records and their attributes from sources with a higher weight have a higher priority.
Each source system has properties:
name – source system name (required; may contain Latin letters, figures, ‘_’ symbol);
displayName – source system name displayed in the UI (required; may contain letters of different languages, figures, different symbols including “space”).
post {
request.uri.path = "/${AppConfig.REST_API_URL}/v1/meta/source-systems/import"
request.contentType = 'multipart/form-data'
request.headers['Authorization'] = token
request.body = multipart {
part 'file', xmlFile.name.toString(), 'text/xml', xmlFile
part 'override', 'true'
}
request.encoder 'multipart/form-data', OkHttpEncoders.&multipart
}
Tip
Use the source-systems.xml file example