diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 23475d118b..6fa1b2469a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -71,3 +71,11 @@ jobs: run: | echo Pubber output logs: cat pubber.out || true + + docs: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - name: schema docs + run: bin/gendocs check diff --git a/bin/gendocs b/bin/gendocs new file mode 100755 index 0000000000..e9fc9152c2 --- /dev/null +++ b/bin/gendocs @@ -0,0 +1,53 @@ +#!/bin/bash -e + +ROOT_DIR=$(realpath $(dirname $0)/..) +cd $ROOT_DIR + +OUTPUT_DIR=$ROOT_DIR/gencode/docs +TMP_DIR=$ROOT_DIR/tmp/schema + +schema_files=`ls schema/*.json` + +if [ "$1" == check ]; then + mkdir -p $TMP_DIR + sha1sum $schema_files > $TMP_DIR/schema.hash + diff $TMP_DIR/schema.hash $OUTPUT_DIR/schema.hash + echo Schema hashes in $OUTPUT_DIR/schema.hash are up-to-date. + git diff --exit-code $OUTPUT_DIR/schema.hash + exit 0 +fi + +rm -rf $OUTPUT_DIR +mkdir -p $OUTPUT_DIR + +sha1sum $schema_files > $OUTPUT_DIR/schema.hash + +# Make a copy of the schema files into a tmp folder for any pre generator fixes +rm -rf $TMP_DIR +mkdir -p $TMP_DIR +cp -r schema/. $TMP_DIR + +# Remove file: prefix from references so document generator works +find $TMP_DIR -type f -exec sed -i '' 's/file://' {} \; + +schemas="state event_system event_pointset event_discovery config metadata envelope" + +for schema in $schemas; do + python3 bin/gendocs.py $schema $TMP_DIR $OUTPUT_DIR +done + +rm -rf $TMP_DIR + +# Convert github doc links to relative links for hosted/downloaded docs +#RELATIVE_LINK="..\/" +#find $OUTPUT_DIR -type f -exec sed -i '' "s/$ABSOLUTE_LINK/$RELATIVE_LINK/" {} \; +#ABSOLUTE_LINK="https:\/\/github.com\/faucetsdn\/udmi\/blob\/master\/docs\/" + +# Create index page with links to different schemas +cp etc/schema_index_template.html $OUTPUT_DIR/index.html + +for schema in $schemas; do + sed -i '' "s//\ +
The config block controls a device's intended behavior. Read more: https://github.com/faucetsdn/udmi/blob/master/docs/config.md
No Additional PropertiesRFC 3339 timestamp the configuration was generated
"2019-01-17T14:02:29.364Z"
+
Major version of the UDMI schema
Value must be greater or equal to 1
and lesser or equal to 1
The minimum loglevel for reporting log messages below which log entries should not be sent.
Value must be greater or equal to 100
and lesser or equal to 800
An array of all the device IDs which are bound to the device
^[A-Z]{3}-[1-9][0-9]{0,2}$
[
+ "AHU-22"
+]
+
All property whose name matches the following regular expression must respect the following conditions
Property name regular expression:^[a-z0-9-]+$
All property whose name matches the following regular expression must respect the following conditions
Property name regular expression:^[a-z][a-z0-9]*(_[a-z0-9]+)*$
Must be at most 32
characters long
An expiry for the the device reverts to its operational state, and sends a state update to notify the cloud of the state change. Read more: https://github.com/faucetsdn/udmi/blob/master/docs/writeback.md
Minimum time between sample updates for the device (including complete and COV updates). Updates more frequent than this should be coalesced into one update.
Value must be greater or equal to 1
and lesser or equal to 86400
Maximum time between samples for the device to send out a complete update. It can send out updates more frequently than this.
Value must be greater or equal to 1
and lesser or equal to 86400
The points defined in this dictionary is the authoritative source indicating the representative points for the device (in both telemetry
and state
messages). Read more: https://github.com/faucetsdn/udmi/blob/master/docs/pointset.md
All property whose name matches the following regular expression must respect the following conditions
Property name regular expression:^[a-z][a-z0-9]*(_[a-z0-9]+)*$
Used for cloud writeback functionality, this field specifies the value for a given point in the device's current units.
22.4
+
The UDMI envelope
is not a message itself, per se, but the attributes and other information that is delivered along with a message. Read more: https://github.com/faucetsdn/udmi/blob/master/docs/envelope.md
^[A-Z]{2,6}-[0-9]{1,6}$
^[0-9]+$
^[a-zA-Z][-a-zA-Z0-9._+~%]*[a-zA-Z0-9]$
^([.a-z]+:)?[a-z][-a-z0-9]*[a-z0-9]$
Additional Properties of any type are allowed.
Type: objectRead more: https://github.com/faucetsdn/udmi/blob/master/docs/discovery.md
No Additional PropertiesRFC 3339 timestamp the discover telemetry event was generated
"2019-01-17T14:02:29.364Z"
+
Major version of the UDMI schema
All property whose name matches the following regular expression must respect the following conditions
Property name regular expression:^[a-z][a-z0-9]*(_[a-z0-9]+)*$
^[-_.:/0-9a-zA-Z]+$
A set of points reporting telemetry data
No Additional PropertiesRFC 3339 timestamp the telemetry event was generated
"2019-01-17T14:02:29.364Z"
+
Major version of the UDMI schema
Value must be greater or equal to 1
and lesser or equal to 1
Collection of point names, defining the representative point set for this device.
No Additional PropertiesAll property whose name matches the following regular expression must respect the following conditions
Property name regular expression:^[a-z][a-z0-9]*(_[a-z0-9]+)*$
Object representation for for a single point
No Additional PropertiesThe specific point data reading
24.1
+
true
+
4
+
RFC 3339 timestamp the event payload was generated
"2019-01-17T14:02:29.364Z"
+
Major version of the UDMI schema
Value must be greater or equal to 1
and lesser or equal to 1
A one-line representation of the triggering condition.
"Point is not writable"
+
An optional be multi-line entry which can include more detail, e.g. a complete program stack-trace.
A device-specific representation of which sub-system the message comes from. In a Java environment, for example, it would be the fully qualified path name of the Class triggering the message.
Must match regular expression:^[a-z][._a-zA-Z]*[a-zA-Z]$
"state.pointset.points.config.invalid"
+
Ttimestamp the condition was triggered, or most recently updated. It might be different than the top-level message timestamp
if the condition is not checked often or is sticky until it's cleared.
"2018-08-26T21:39:28.364Z"
+
The status level
should conform to the numerical Stackdriver LogEntry levels. The DEFAULT
value of 0 is not allowed (lowest value is 100, maximum 800).
Value must be greater or equal to 100
and lesser or equal to 800
and a multiple of 1
600
+
RFC 3339 timestamp the metadata was generated
"2019-01-17T14:02:29.364Z"
+
Major version of the UDMI schema
Value must be greater or equal to 1
and lesser or equal to 1
Automatically generated field that contains the hash of file contents.
Must match regular expression:^[0-9a-z]{8}$
Information specific to how the device communicates with the cloud.
No Additional PropertiesThe key type used for cloud communication.
If the device functions as an IoT Gateway, proxying for other devices using a single logical connection
High-level sytem informaiton about the device.
No Additional PropertiesProperties the expected physical location of the device.
No Additional PropertiesThe site name according to the site model in which a device is installed in
Must match regular expression:^[A-Z]{2}-[A-Z]{3}-[A-Z0-9]{2,9}$
"US-SFO-XYY"
+
^[A-Z0-9-]+$
Information used to print a physical QR code label.
No Additional Properties^[a-z]+://[-0-9a-zA-Z_$]+$
^[A-Z]{2}-[A-Z]{3}-[A-Z0-9]{2,9}$
^[A-Z]{2,6}-[0-9]{1,6}$
^[a-zA-Z0-9-]+$
Read more: https://github.com/faucetsdn/udmi/blob/master/docs/gateway.md
No Additional PropertiesPresent in devices which are proxied by a gateway, this identifies the device ID of the gateway the device is bound to
Must match regular expression:^[A-Z]{2,6}-[0-9]{1,6}$
"GAT-100"
+
^[a-z0-9-]+$
Present in devices which are IoT gateways, this is an array of all the device IDs which are bound to the device
^[A-Z]{2,6}-[0-9]{1,6}$
[
+ "AHU-22"
+]
+
All property whose name matches the following regular expression must respect the following conditions
Property name regular expression:^[a-z0-9-]+$
Pointset representing the abstract system expectation for what the device should be doing, and how it should be configured and operated. This block specifies the expected points that a device holds
No Additional PropertiesInformation about a specific point name of the device.
No Additional PropertiesAll property whose name matches the following regular expression must respect the following conditions
Property name regular expression:^[a-z][a-z0-9]*(_[a-z0-9]+)*$
Information about a specific point name of the device.
No Additional PropertiesExpected unit configuration for the point.
A local network reference for a point, e.g. BACnet address or Modbus register
"AI3.Present_Value"
+
"400070"
+
RFC 3339 Timestamp the state payload was generated
"2019-01-17T14:02:29.364Z"
+
Major version of the UDMI schema
Value must be greater or equal to 1
and lesser or equal to 1
The make and model of the physical device
"Delta Controls O3-DIN-SRC"
+
"Arup Gateway"
+
The serial number of the physical device
"A1B2C3D4"
+
"00001"
+
Information about the physical device firmware
No Additional PropertiesVersion of the local firmware
Time from the timestamp
field of the last successfully parsed config
message (not the timestamp the message was received/processed).
"2019-01-17T14:02:29.364Z"
+
A map of 'sticky' conditions that are keyed on a value that can be used to manage updates by a particular (device dependent) subsystem.
No Additional PropertiesAll property whose name matches the following regular expression must respect the following conditions
Property name regular expression:^[a-z][a-z0-9]*(_[a-z0-9]+)*$
A one-line representation of the triggering condition.
"Point is not writable"
+
An optional be multi-line entry which can include more detail, e.g. a complete program stack-trace.
A device-specific representation of which sub-system the message comes from. In a Java environment, for example, it would be the fully qualified path name of the Class triggering the message.
Must match regular expression:^[a-z][._a-zA-Z]*[a-zA-Z]$
"state.pointset.points.config.invalid"
+
Ttimestamp the condition was triggered, or most recently updated. It might be different than the top-level message timestamp
if the condition is not checked often or is sticky until it's cleared.
"2018-08-26T21:39:28.364Z"
+
The status level
should conform to the numerical Stackdriver LogEntry levels. The DEFAULT
value of 0 is not allowed (lowest value is 100, maximum 800).
Value must be greater or equal to 100
and lesser or equal to 800
and a multiple of 1
600
+
Read more: https://github.com/faucetsdn/udmi/blob/master/docs/gateway.md
No Additional Properties^[A-Z]{3}-[1-9][0-9]{0,2}$
Must be at most 32
characters long
All property whose name matches the following regular expression must respect the following conditions
Property name regular expression:^[a-z][a-z0-9]*(_[a-z0-9]+)*$
A one-line representation of the triggering condition.
"Point is not writable"
+
An optional be multi-line entry which can include more detail, e.g. a complete program stack-trace.
A device-specific representation of which sub-system the message comes from. In a Java environment, for example, it would be the fully qualified path name of the Class triggering the message.
Must match regular expression:^[a-z][._a-zA-Z]*[a-zA-Z]$
"state.pointset.points.config.invalid"
+
Ttimestamp the condition was triggered, or most recently updated. It might be different than the top-level message timestamp
if the condition is not checked often or is sticky until it's cleared.
"2018-08-26T21:39:28.364Z"
+
The status level
should conform to the numerical Stackdriver LogEntry levels. The DEFAULT
value of 0 is not allowed (lowest value is 100, maximum 800).
Value must be greater or equal to 100
and lesser or equal to 800
and a multiple of 1
600
+
A set of points reporting telemetry data.
No Additional PropertiesAn identifier which uniquely represents the state, and used by a device avoid race conditions where the incoming config is based off an obsolete state. Additional information on implementation: https://github.com/faucetsdn/udmi/blob/master/docs/writeback.md
Must be at most 32
characters long
Collection of point names, defining the representative point set for this device.
No Additional PropertiesAll property whose name matches the following regular expression must respect the following conditions
Property name regular expression:^[a-z][a-z0-9]*(_[a-z0-9]+)*$
Object representation for for a single point
No Additional PropertiesOptional enumeration indicating the state of the points value. Valid value_state
settings include:
* set_value
config has been specified, the source is device-native.
* applied: The set_value
config has been successfully applied.
* overridden: The config setting is being overridden by another source.
* invalid: A problem has been identified with the config setting.
* failure: The config is fine, but a problem has been encountered applying the setting.
When the value state indicates an error state, an assosciated status entry should be included
Optional status information about this point, subject to log severity level
No Additional PropertiesA one-line representation of the triggering condition.
"Point is not writable"
+
An optional be multi-line entry which can include more detail, e.g. a complete program stack-trace.
A device-specific representation of which sub-system the message comes from. In a Java environment, for example, it would be the fully qualified path name of the Class triggering the message.
Must match regular expression:^[a-z][._a-zA-Z]*[a-zA-Z]$
"state.pointset.points.config.invalid"
+
Ttimestamp the condition was triggered, or most recently updated. It might be different than the top-level message timestamp
if the condition is not checked often or is sticky until it's cleared.
"2018-08-26T21:39:28.364Z"
+
The status level
should conform to the numerical Stackdriver LogEntry levels. The DEFAULT
value of 0 is not allowed (lowest value is 100, maximum 800).
Value must be greater or equal to 100
and lesser or equal to 800
and a multiple of 1
600
+