...
Code Block | ||
---|---|---|
| ||
{ "modelSchema": { "properties": { "<property-name>": { "type": "<property-type>", ...item1 properties.... }, "<property-name>": { ... } } }, "displayProperty": "<property-name>", "uniquenssRuless": "<property-name1> [, <property-name2>, .....]" } |
Descriptions of the Domain Version Properties
...
property | required | valid values | description |
---|---|---|---|
modelSchema | yes | See Domains and Domains below. | A JSON model describing the schema for the data domain; it defines the properties that make up the domains schema. The root node of the model schema is the properties element. See Domains and Domains below. |
displayProperty | yes | A valid model schema property name | A property defined in the modelSchema that acts as an index for the domain. The data values for the displayProperty must always be unique. See Domains below. |
uniquenessRules | no | One or more valid model schema property names | Required data and their associated rules that are cache'd to make sure duplicate data entries are not POSTed to the domain. This defaults to the displayProperty if it is not provided. See Domains below. |
The Default Domain Version
The first version of a domain is the default version and will remain the default version if more versions of a given domain are created.The PATCH method for the /domains/<domain-uuid> endpoint can be used to change a domain's default version. See the YOUnite API for implementation details.
Creating a Domain is Three-Step Process
...
POST the Domain
For example, to create a simple states domain :
POST /domains
Code Block language js { "name": "states", "zoneUuid": "a1aca070-846f-44e5-9471-c73b46c35f4a", "domainType": "MASTER_CENTRALIZED" }
The location header returned provides the URI for POSTing a domain version below.
e.g.
Location /domains/7f28180b-7d9f-42b5-b5ed-d4a0e7ec09fc
POST a Domain Version
POST /domains/versions/
7f28180b-7d9f-42b5-b5ed-d4a0e7ec09fc
POST Master Data Records to the Domain
Once the domain/version has been created, master data can be POSTed to it using the /mdr endpoint:POST /mdrs
Code Block language js { "name": "states", "version": 1, "json": { "name" : "California", "abbreviation" : "CA" } }
Retrieving Master Data
...
The MDRs for a the default version of a domain can be retrieved with the following:
POST /mdrs?filters=name:<domain-name>
Retrieving the MDRs for a given domain and version:
POST /mdrs?filters=name:<domain-name>,version:<version>
The Display Property
Each domain must have a display property (displayProperty
). The display property acts as a primary key for the domain. For example, the states
domain above uses the abbreviation
property as the display property, Use the /mdrs
endpoint and the appropriate domain and display property to GET an MDR:
GET /mdrs/states/?filters=name:states,displayProperty:CA
If there are multiple versions of a domain, and a domain other than the default is needed, the version number can be included in the URI. For example, assume there are three versions of the states
domain and the current version is version 3. The consumer can retrieve the California
version 1 MDR by using the following:
GET /mdrs/states:1/CA
In addition to the display property, requests for an MDR can be made using the UUID. For example, assume, the UUID for the state MDR for California
is ad8570ae-2172-4179-e9276a03bf2d
. To retrieve the MDR using the UUID:
GET /mdrs/states/data/ad8570ae-2172-4179-927e-e9276a03bf2d
...
?filters=name:states,version:1,displayProperty:CA
Display Property Rules
- The value provided for the
displayProperty
must be unique between all domain entries of a given domain type (e.g. each entry in thestate
domain must have a uniquestateName
). - Only one property in a domain can be the
displayProperty. I
f more than one property is required to ensure uniqueness see the Domains below. - Display properties are limited to type STRING.
- Properties designated as the
displayProperty
are required; i.e. null values are not allowed. - Display properties are case sensitive e.g. "California" is NOT equal to "california".
...
- If both
required
anddefault
are used to define a given property, thendefault
is ignored and POSTing data must include the required property.
POST a Domain Version
Following is a simple example of model for a domain version.
POST /domains/versions/2a556060-e694-4b61-a3bb-67beda37da13
Code Block | ||
---|---|---|
| ||
{
"name": "countries",
"displayProperty": "countrycode",
"modelSchema" {
"properties": {
"name": {
"type": "string",
"min": 2,
"max": 80,
"required": true
},
"countrycode": {
"type": "string",
"min": 3,
"max": 3,
"required": true
},
"population": {
"type": "int",
"required": false
},
"capital": {
"city": {
"type": "string",
"required": true
},
"districtOrState": {
"type": "string",
"required": true
}
}
}
}
} |
Note that inside the value portion of the modelSchema
node, all of the double quotes must be escaped with a backslash (\). Newlines have been added above for readability but they should not be included in the request body. The request should look like this:
Code Block | ||
---|---|---|
| ||
{
"name": "countries179",
"displayProperty": "countrycode"
"modelSchema": "{ \"properties\": { \"name\": { \"type\": \"string\", \"min\": 2, \"max\": 80, \"required\": true }, \"countrycode\": { \"type\": \"string\", \"min\": 3, \"max\": 3, \"required\": true }, \"population\": { \"type\": \"int\", \"required\": false }, \"capital\": { \"city\": { \"type\": \"string\", \"required\": true }, \"districtOrState\": { \"type\": \"string\", \"required\": true } } } }",
"name": "countries179"
} |
...