{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://raw.githubusercontent.com/api-evangelist/canonical/main/json-schema/canonical-prompting-rule-action-add-schema.json", "title": "PromptingRuleActionAdd", "description": "The schema the API uses for the 'add' action of /v2/interfaces/rules.", "x-generated": "2026-10-04", "x-method": "derived", "x-generator": "derive-json-schema.py", "x-source": "openapi/canonical-experimental-api-openapi.yml#/components/schemas/PromptingRuleActionAdd", "type": "object", "required": [ "action", "rule" ], "properties": { "action": { "type": "string", "description": "The action to perform on the rules endpoint.", "enum": [ "add" ] }, "rule": { "type": "object", "properties": { "snap": { "type": "string", "description": "The snap for which to add the rule." }, "interface": { "type": "string", "description": "The interface for which to add the rule." }, "constraints": { "oneOf": [ { "$ref": "#/$defs/PromptingConstraintsCamera" }, { "$ref": "#/$defs/PromptingConstraintsHome" } ] } } } }, "$defs": { "PromptingConstraintsCamera": { "type": "object", "description": "Details about the applicability of the new rule to requests.", "required": [ "permissions" ], "properties": { "permissions": { "type": "object", "description": "A map from permission name to the information about that permission.", "additionalProperties": { "$ref": "#/$defs/PromptingPermissionEntry" } } } }, "PromptingConstraintsHome": { "type": "object", "description": "Details about the applicability of the new rule to requests.", "required": [ "path-pattern", "permissions" ], "properties": { "path-pattern": { "type": "string", "description": "Path glob matching filepaths for which the rule applies." }, "permissions": { "type": "object", "description": "A map from permission name to the information about that permission.", "additionalProperties": { "$ref": "#/$defs/PromptingPermissionEntry" } } } }, "PromptingPermissionEntry": { "type": "object", "required": [ "outcome", "lifespan" ], "properties": { "outcome": { "type": "string", "enum": [ "allow", "deny" ] }, "lifespan": { "type": "string", "description": "The lifespan for which the permission applies.\n\ntimespan: the permission applies for the given duration specified by the\nduration field or until it is deleted\n\nsession: the permission applies until the user logs out (specifically,\nuntil the systemd user session ends)\n\nforever: the permission applies until it is deleted", "enum": [ "timespan", "session", "forever" ] }, "duration": { "type": "string", "description": "The duration for which the permission is valid. Required if lifespan is\ntimespan, otherwise must be omitted.", "format": "Go duration" } } } } }