update api, fix tests and examples
This commit is contained in:
		@@ -3,7 +3,27 @@
 | 
			
		||||
  "info": {
 | 
			
		||||
    "title": "Hero Supervisor OpenRPC API",
 | 
			
		||||
    "version": "1.0.0",
 | 
			
		||||
    "description": "OpenRPC API for managing Hero Supervisor runners and jobs"
 | 
			
		||||
    "description": "OpenRPC API for managing Hero Supervisor runners and jobs. Job operations follow the convention: 'jobs.' for general operations and 'job.' for specific job operations."
 | 
			
		||||
  },
 | 
			
		||||
  "components": {
 | 
			
		||||
    "schemas": {
 | 
			
		||||
      "Job": {
 | 
			
		||||
        "type": "object",
 | 
			
		||||
        "properties": {
 | 
			
		||||
          "id": { "type": "string" },
 | 
			
		||||
          "caller_id": { "type": "string" },
 | 
			
		||||
          "context_id": { "type": "string" },
 | 
			
		||||
          "payload": { "type": "string" },
 | 
			
		||||
          "runner": { "type": "string" },
 | 
			
		||||
          "executor": { "type": "string" },
 | 
			
		||||
          "timeout": { "type": "number" },
 | 
			
		||||
          "env_vars": { "type": "object" },
 | 
			
		||||
          "created_at": { "type": "string" },
 | 
			
		||||
          "updated_at": { "type": "string" }
 | 
			
		||||
        },
 | 
			
		||||
        "required": ["id", "caller_id", "context_id", "payload", "runner", "executor", "timeout", "env_vars", "created_at", "updated_at"]
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "methods": [
 | 
			
		||||
    {
 | 
			
		||||
@@ -41,8 +61,8 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "run_job",
 | 
			
		||||
      "description": "Run a job on the appropriate runner",
 | 
			
		||||
      "name": "jobs.create",
 | 
			
		||||
      "description": "Create a new job without queuing it to a runner",
 | 
			
		||||
      "params": [
 | 
			
		||||
        {
 | 
			
		||||
          "name": "params",
 | 
			
		||||
@@ -51,20 +71,42 @@
 | 
			
		||||
            "properties": {
 | 
			
		||||
              "secret": { "type": "string" },
 | 
			
		||||
              "job": {
 | 
			
		||||
                "type": "object",
 | 
			
		||||
                "properties": {
 | 
			
		||||
                  "id": { "type": "string" },
 | 
			
		||||
                  "caller_id": { "type": "string" },
 | 
			
		||||
                  "context_id": { "type": "string" },
 | 
			
		||||
                  "payload": { "type": "string" },
 | 
			
		||||
                  "job_type": { "type": "string" },
 | 
			
		||||
                  "runner_name": { "type": "string" },
 | 
			
		||||
                  "timeout": { "type": "number" },
 | 
			
		||||
                  "env_vars": { "type": "object" },
 | 
			
		||||
                  "created_at": { "type": "string" },
 | 
			
		||||
                  "updated_at": { "type": "string" }
 | 
			
		||||
                },
 | 
			
		||||
                "required": ["id", "caller_id", "context_id", "payload", "job_type", "runner_name", "timeout", "env_vars", "created_at", "updated_at"]
 | 
			
		||||
                "$ref": "#/components/schemas/Job"
 | 
			
		||||
              }
 | 
			
		||||
            },
 | 
			
		||||
            "required": ["secret", "job"]
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      "result": {
 | 
			
		||||
        "name": "job_id",
 | 
			
		||||
        "schema": { "type": "string" }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "jobs.list",
 | 
			
		||||
      "description": "List all jobs",
 | 
			
		||||
      "params": [],
 | 
			
		||||
      "result": {
 | 
			
		||||
        "name": "jobs",
 | 
			
		||||
        "schema": {
 | 
			
		||||
          "type": "array",
 | 
			
		||||
          "items": { "$ref": "#/components/schemas/Job" }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "job.run",
 | 
			
		||||
      "description": "Run a job on the appropriate runner and return the result",
 | 
			
		||||
      "params": [
 | 
			
		||||
        {
 | 
			
		||||
          "name": "params",
 | 
			
		||||
          "schema": {
 | 
			
		||||
            "type": "object",
 | 
			
		||||
            "properties": {
 | 
			
		||||
              "secret": { "type": "string" },
 | 
			
		||||
              "job": {
 | 
			
		||||
                "$ref": "#/components/schemas/Job"
 | 
			
		||||
              }
 | 
			
		||||
            },
 | 
			
		||||
            "required": ["secret", "job"]
 | 
			
		||||
@@ -74,7 +116,101 @@
 | 
			
		||||
      "result": {
 | 
			
		||||
        "name": "result",
 | 
			
		||||
        "schema": {
 | 
			
		||||
          "type": ["string", "null"]
 | 
			
		||||
          "oneOf": [
 | 
			
		||||
            {
 | 
			
		||||
              "type": "object",
 | 
			
		||||
              "properties": {
 | 
			
		||||
                "success": { "type": "string" }
 | 
			
		||||
              },
 | 
			
		||||
              "required": ["success"]
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
              "type": "object", 
 | 
			
		||||
              "properties": {
 | 
			
		||||
                "error": { "type": "string" }
 | 
			
		||||
              },
 | 
			
		||||
              "required": ["error"]
 | 
			
		||||
            }
 | 
			
		||||
          ]
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "job.start",
 | 
			
		||||
      "description": "Start a previously created job by queuing it to its assigned runner",
 | 
			
		||||
      "params": [
 | 
			
		||||
        {
 | 
			
		||||
          "name": "params",
 | 
			
		||||
          "schema": {
 | 
			
		||||
            "type": "object",
 | 
			
		||||
            "properties": {
 | 
			
		||||
              "secret": { "type": "string" },
 | 
			
		||||
              "job_id": { "type": "string" }
 | 
			
		||||
            },
 | 
			
		||||
            "required": ["secret", "job_id"]
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      "result": {
 | 
			
		||||
        "name": "result",
 | 
			
		||||
        "schema": { "type": "null" }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "job.status",
 | 
			
		||||
      "description": "Get the current status of a job",
 | 
			
		||||
      "params": [
 | 
			
		||||
        {
 | 
			
		||||
          "name": "job_id",
 | 
			
		||||
          "schema": { "type": "string" }
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      "result": {
 | 
			
		||||
        "name": "status",
 | 
			
		||||
        "schema": {
 | 
			
		||||
          "type": "object",
 | 
			
		||||
          "properties": {
 | 
			
		||||
            "job_id": { "type": "string" },
 | 
			
		||||
            "status": { 
 | 
			
		||||
              "type": "string",
 | 
			
		||||
              "enum": ["created", "queued", "running", "completed", "failed", "timeout"]
 | 
			
		||||
            },
 | 
			
		||||
            "created_at": { "type": "string" },
 | 
			
		||||
            "started_at": { "type": ["string", "null"] },
 | 
			
		||||
            "completed_at": { "type": ["string", "null"] }
 | 
			
		||||
          },
 | 
			
		||||
          "required": ["job_id", "status", "created_at"]
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "job.result",
 | 
			
		||||
      "description": "Get the result of a completed job (blocks until result is available)",
 | 
			
		||||
      "params": [
 | 
			
		||||
        {
 | 
			
		||||
          "name": "job_id",
 | 
			
		||||
          "schema": { "type": "string" }
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      "result": {
 | 
			
		||||
        "name": "result",
 | 
			
		||||
        "schema": {
 | 
			
		||||
          "oneOf": [
 | 
			
		||||
            {
 | 
			
		||||
              "type": "object",
 | 
			
		||||
              "properties": {
 | 
			
		||||
                "success": { "type": "string" }
 | 
			
		||||
              },
 | 
			
		||||
              "required": ["success"]
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
              "type": "object",
 | 
			
		||||
              "properties": {
 | 
			
		||||
                "error": { "type": "string" }
 | 
			
		||||
              },
 | 
			
		||||
              "required": ["error"]
 | 
			
		||||
            }
 | 
			
		||||
          ]
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
@@ -200,6 +336,48 @@
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "job.stop",
 | 
			
		||||
      "description": "Stop a running job",
 | 
			
		||||
      "params": [
 | 
			
		||||
        {
 | 
			
		||||
          "name": "params",
 | 
			
		||||
          "schema": {
 | 
			
		||||
            "type": "object",
 | 
			
		||||
            "properties": {
 | 
			
		||||
              "secret": { "type": "string" },
 | 
			
		||||
              "job_id": { "type": "string" }
 | 
			
		||||
            },
 | 
			
		||||
            "required": ["secret", "job_id"]
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      "result": {
 | 
			
		||||
        "name": "result",
 | 
			
		||||
        "schema": { "type": "null" }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "job.delete",
 | 
			
		||||
      "description": "Delete a job from the system",
 | 
			
		||||
      "params": [
 | 
			
		||||
        {
 | 
			
		||||
          "name": "params",
 | 
			
		||||
          "schema": {
 | 
			
		||||
            "type": "object",
 | 
			
		||||
            "properties": {
 | 
			
		||||
              "secret": { "type": "string" },
 | 
			
		||||
              "job_id": { "type": "string" }
 | 
			
		||||
            },
 | 
			
		||||
            "required": ["secret", "job_id"]
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      "result": {
 | 
			
		||||
        "name": "result",
 | 
			
		||||
        "schema": { "type": "null" }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "rpc.discover",
 | 
			
		||||
      "description": "OpenRPC discovery method - returns the OpenRPC document describing this API",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user