Skip to content

Instantly share code, notes, and snippets.

@ripienaar
Created September 18, 2019 16:43
Show Gist options
  • Save ripienaar/91dd7c251bfa60ebaff1b4250bb9d02d to your computer and use it in GitHub Desktop.
Save ripienaar/91dd7c251bfa60ebaff1b4250bb9d02d to your computer and use it in GitHub Desktop.
{
"$schema": "http://json-schema.org/draft-04/schema",
"id": "https://choria.io/schemas/mcorpc/ddl/v1/agent.json",
"type": "object",
"definitions": {
"shortname": {
"type": "string",
"minLength": 1,
"pattern": "^[a-z0-9_]*$"
},
"base_action_input": {
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "When generating user interfaces use this text to prompt for information",
"minLength": 1
},
"description": {
"type": "string",
"description": "Short description of the specific input",
"minLength": 1
},
"optional": {
"type": "boolean"
}
},
"required": [
"prompt",
"description",
"optional"
]
},
"string_action_input": {
"allOf": [
{
"$ref": "#/definitions/base_action_input"
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The data type the input should be",
"enum": [
"string"
]
},
"validation": {
"type": "string"
},
"maxlength": {
"type": "number"
}
},
"required": [
"type",
"validation",
"maxlength"
]
}
]
},
"other_action_input": {
"allOf": [
{
"$ref": "#/definitions/base_action_input"
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The data type the input should be",
"enum": [
"boolean",
"integer",
"float",
"number",
"Hash",
"Array",
"hash",
"array"
]
}
},
"required": [
"type"
]
}
]
},
"list_action_input": {
"allOf": [
{
"$ref": "#/definitions/base_action_input"
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The data type the input should be",
"enum": [
"list"
]
},
"list": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"type",
"list"
]
}
]
}
},
"properties": {
"metadata": {
"type": "object",
"properties": {
"name": {
"description": "The Agent name",
"$ref": "#/definitions/shortname"
},
"description": {
"description": "Short description of the agent function",
"type": "string",
"minLength": 1
},
"author": {
"description": "The person or entity responsible for maintenance of this agent",
"type": "string",
"minLength": 1,
"examples": [
"R.I.Pienaar <[email protected]>"
]
},
"license": {
"description": "The licence this agent is distributed under",
"type": "string",
"minLength": 1,
"examples": [
"Apache-2.0"
]
},
"version": {
"description": "SemVer version of this agent",
"type": "string",
"pattern": "^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$"
},
"url": {
"description": "URL to visit for more information about the agent",
"type": "string",
"minLength": 1
},
"timeout": {
"description": "How long this agent is allowed to run",
"type": "integer",
"minimum": 2
},
"provider": {
"description": "The name of the provider that hosts this agent, example 'external'",
"type": "string"
}
},
"required": [
"name",
"description",
"author",
"license",
"version",
"url",
"timeout"
]
},
"actions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"action": {
"description": "The action name",
"$ref": "#/definitions/shortname"
},
"description": {
"description": "Short description of what the action does",
"type": "string",
"minLength": 1
},
"input": {
"type": "object",
"patternProperties": {
"^[a-z0-9_]*$": {
"anyOf": [
{
"$ref": "#/definitions/list_action_input"
},
{
"$ref": "#/definitions/other_action_input"
},
{
"$ref": "#/definitions/string_action_input"
}
]
}
}
},
"output": {
"type": "object",
"properties": {
"description": {
"type": "string",
"description": "Short description of what the output means"
},
"default": {
"anyOf": [
{
"type": "array"
},
{
"type": "boolean"
},
{
"type": "integer"
},
{
"type": "null"
},
{
"type": "number"
},
{
"type": "object"
},
{
"type": "string"
}
]
},
"display_as": {
"type": "string",
"description": "Short token to identify the data in the output as"
},
"type": {
"type": "string",
"description": "The data type being held in the output",
"enum": [
"string",
"list",
"boolean",
"integer",
"float",
"number",
"Hash",
"Array",
"hash",
"array"
]
}
}
},
"display": {
"type": "string",
"enum": [
"ok",
"failed",
"always"
]
},
"aggregate": {
"type": "array",
"items": {
"type": "object",
"properties": {
"function": {
"type": "string",
"description": "The name of the aggregation function to use"
},
"args": {
"description": "Arguments passed to the function, exact type depends on the function"
}
}
}
}
},
"required": [
"description",
"action",
"input",
"output"
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment