Authoring reference

REST schema items

The rest: realm brings explicitly declared HTTP properties and commands into the Schema. A REST service sets the connection and path boundary; its children describe the values Pinman can read or write and the actions a Profile can invoke.

Pinman usually tracks configuration on a particular machine, so REST is especially useful for services running on that machine. Pinman's audio, input, and overlay services, for example, expose settings through REST APIs. A Schema can also bring external-service data into Captures when it contributes to the machine's operating context, such as network status, weather conditions, or another environmental input.

REST declarations use the same locations, inheritance, and property metadata as other Schema Items. See Schema items for that shared model and Schema property fields for datatypes, I/O modes, formats, and UI controls.

Service structure#

This example reads and writes an audio service's volume property:

items:
  - itemtype: rest_root
    label: Services
    items:
      - selector: audio
        itemtype: rest_service
        service: api
        path_prefix: /api/controls
        items:
          - selector: volume
            itemtype: rest_property
            datatype: float
            read:
              path: /api/controls
              pointer: payload.volume_level
            write:
              method: POST
              path: /api/controls/volume
              pointer: volume

The resulting property belongs to the audio service beneath the rest: realm. Its read block extracts payload.volume_level from the response, while its write block sends the new value as volume.

rest_service#

FieldRequiredMeaning
path_prefixYesPath subtree that contains every declared operation.
serviceNoConfigured Pinman service slug; defaults to api.
base_urlNoExplicit endpoint for a third-party service.

service selects a connection already configured in Pinman. base_url supplies a fixed endpoint instead. In either case, path_prefix bounds every declared read, write, and command path.

rest_property#

A REST property represents state. Its read and write blocks are separate because a service may return several properties from one endpoint and accept updates at another.

BlockFields
readHTTP path and response pointer.
writeHTTP method, path, and request pointer.

Properties with the same write method and path form one composite resource. Before writing one property, Pinman reads the other declared fields and sends a combined request that preserves their values.

A connection failure gives the property an unreadable state. REST values are read live, so Backup has no file content to retain for them.

rest_command#

A REST command represents an action rather than a value. A Profile invokes the action through its invoke block; Captures and comparisons continue to describe the service properties that hold state.

This command sends a request to restart the service:

- selector: restart
  itemtype: rest_command
  label: Restart service
  invoke:
    method: POST
    path: /api/controls/restart

The command has no stored value. It runs only when a Profile explicitly invokes it.

Itemtypes#

ItemtypeChildrenPurpose
rest_rootrest_serviceRoot of the REST realm.
rest_serviceproperties, commandsConnection and path boundary.
rest_propertynoneReadable and optionally writable service value.
rest_commandnoneAction invoked explicitly by a Profile.