NetworkMachineRolesPut network.machine-roles-put@1

Generated at from openvibe-contracts v0.419.0 and openvibe-sdk v0.161.0.

Version
1.0.0
Owner
network
Visibility
first-party
Status
active
Compatibility
backward
Schema
https://openvibe.network/contracts/network/machine-roles-put.v1.json

network.machine-roles-put@1: the roles the owner gives a machine (PUT /api/v1/machines/:id/roles, capability machines.manage). The whole set, not a change: what is not named is turned off. Every id must be in the catalogue (network.machine-roles@1); an unknown role is refused and nothing is changed.

Fields

FieldTypeRequiredDescriptionConstraints
rolesarray of stringyesThe machine's roles after the change. An empty array turns every role off.
  • maxItems 8
  • unique items
  • items: pattern ^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$

Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

Valid: none
{
  "roles": []
}
Valid: two-roles
{
  "roles": [
    "codes.worker",
    "ai.host"
  ]
}
Rejected: duplicate
{
  "roles": [
    "codes.worker",
    "codes.worker"
  ]
}
Rejected: missing
{}
Rejected: not-a-list
{
  "roles": "codes.worker"
}

Validate

const contracts = require('openvibe-contracts');
contracts.validate('network.machine-roles-put@1', value);   // { valid, errors: [{ path, message }] }