Create an Operation Rule

View as Markdown
Create a new Operation Rule on the target Site. The rule definition is validated server-side by Flow; on validation failure no state changes (the request acts as a dry-run by way of its own validation step). Rules are site-scoped and per (operationType, operationCode) tuple. The response echoes the submitted body with the assigned `id`. Org must have an Infrastructure Provider entity. User must have authorization role with `PROVIDER_ADMIN` suffix.

Authentication

AuthorizationBearer
``` export JWT_BEARER_TOKEN="<jwt-bearer-token>" # Example org name: "acme-inc export ORG_NAME=<org-name> # Use the JWT bearer token in your API request auth header: curl -v -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $JWT_BEARER_TOKEN" https://nico-rest-api.nico.svc.cluster.local/v2/org/$ORG_NAME/nico/user/current ```

Path parameters

orgstringRequired
Name of the Org

Request

This endpoint expects an object.
siteIdstringRequiredformat: "uuid"
ID of the Site to create the rule on.
namestringRequired

Human-readable name of the rule.

operationTypeenumRequired
Operation type the rule applies to.
operationCodestringRequired

Operation code within the operation type. For PowerControl, accepted values are power_on, force_power_on, power_off, force_power_off, restart, force_restart, warm_reset, and cold_reset. For FirmwareControl, accepted values are upgrade, downgrade, and rollback. The server validates the code against the selected type.

ruleDefinitionobjectRequired

Executable definition of a rule. Structurally identical to Flow’s own rule schema, so an existing YAML rule file maps across field for field. The fields declared here use camelCase (componentType, mainOperation, pollInterval) rather than the snake_case of Flow’s YAML; keys inside the free-form parameters map pass through unchanged and stay snake_case (expected_status, component_types).

descriptionstringOptional

Optional free-form description.

Response

Rule was created.
idstringformat: "uuid"
Unique identifier of the rule.
namestring

Human-readable name of the rule. Required and non-empty.

operationTypeenum
Type of operation this rule applies to. Immutable after creation.
operationCodestring

Operation code within the operation type. For PowerControl, accepted values are power_on, force_power_on, power_off, force_power_off, restart, force_restart, warm_reset, and cold_reset. For FirmwareControl, accepted values are upgrade, downgrade, and rollback. The server validates the code against the selected type. Immutable after creation.

ruleDefinitionobject

Executable definition of a rule. Structurally identical to Flow’s own rule schema, so an existing YAML rule file maps across field for field. The fields declared here use camelCase (componentType, mainOperation, pollInterval) rather than the snake_case of Flow’s YAML; keys inside the free-form parameters map pass through unchanged and stay snake_case (expected_status, component_types).

isDefaultboolean

Whether this rule is currently the default for its (operationType, operationCode) tuple.

createddatetime
Timestamp when the rule was created.
updateddatetime
Timestamp when the rule was last updated.
descriptionstringOptional

Optional free-form description.

Errors

400
Bad Request Error
403
Forbidden Error
504
Gateway Timeout Error