Named data structures present complex JSON objects that can be referred to from either Properties, or Operations parameters, or even from other Structures.
In this document:
The format for declaring a structure follows the JSON Schema:
{
"structures": {
"name1": { /* JSON-schema-1 */ },
"name2": { /* JSON-schema-2 */ },
"name3": { ... }
}
}
A sample “structures” section looks as follows:
{
"structures": {
"Person": {
"type": "object",
"properties": {
"firstName": { "type":"string", "required":true },
"lastName": {"type":"string" },
"books": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
Once declared, it is possible to refer to such a structure by its name, for example:
{
"id": "http://demoapp.apsdemo.org/some/type/1.0"
"properties": {
"owner": {
/* Referencing the "Person" structure */
"type": "Person"
},
"employee": {
/* Referencing the "Person" structure */
"type": "Person"
},
},
...
"structures": {
/* Actual data declaration */
"Person": {
"type": "object",
"properties": {
"firstName": { "type":"string", "required":true },
"lastName": {"type":"string" }
}
}
}
}
It is also possible to refer to such a structure from other APS types through its fully-qualified name:
<APS Type ID>#<Structure Name>
Examples:
http://demoapp.apsdemo.org/some/type/1.0#Person
http://aps-standard.org/types/mail/mailbox/1.0#Socket
To refer to the “Person” structure from another APS type use the following definition:
{
"properties": {
"person": {
"type": "http://demoapp.apsdemo.org/some/type/1.0#Person"
}
}
}
Let us look at one more practical example. Resource counters in APS applications are based on the Counter structure defined in the APS core type Resource as:
{
"apsVersion": "2.0",
"id": "http://aps-standard.org/types/core/resource/1.0",
"name": "Resource",
...
"structures": {
"Counter": {
"type": "object",
"properties": {
"usage": { "type": "integer" },
"limit": { "type": "integer" }
}
},
...
}
}
When adding resource counters to your application, use the following example of property definition:
{
...
"properties": {
...
"diskusage": {
"type": "http://aps-standard.org/types/core/resource/1.0#Counter",
"description": "Diskspace Usage",
"unit": "gb"
},
"cpuusage": {
"type": "http://aps-standard.org/types/core/resource/1.0#Counter",
"description": "CPU usage - number of CPU cores",
"unit": "unit"
},
"memoryusage": {
"type": "http://aps-standard.org/types/core/resource/1.0#Counter",
"description": "Memory usage",
"unit": "mb"
}
}
}