Start in on implementing the OpenAPI for the agent side of the equation
This commit is contained in:
parent
59c01e0e34
commit
0e3f874870
|
@ -24,4 +24,5 @@ pretty_env_logger = "~0.3.1"
|
|||
serde_json = "~1.0.0"
|
||||
sqlx = { version = "~0.5.1", features = ["chrono", "json", "migrate", "offline", "sqlite", "uuid", "runtime-async-std-rustls"] }
|
||||
tide = "0"
|
||||
uuid = { version = "~0.8.1", features = ["v4", "serde"]}
|
||||
uuid = { version = "0", features = ["v4", "serde"]}
|
||||
url = "2"
|
||||
|
|
|
@ -22,19 +22,12 @@ intended to be a production system you can actually use.
|
|||
│ Server │http │ │
|
||||
│ │ws └──────┬─────┘
|
||||
└───┬────┘ │
|
||||
│ │
|
||||
│ What are your caps? │
|
||||
├──────────────────────────────────────────────────►│
|
||||
│ │
|
||||
│ │
|
||||
│ git,svn,bash,rustc,cargo,websocket │
|
||||
│◄──────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ great, here's some commands │
|
||||
├──────────────────────────────────────────────────►│
|
||||
│ │
|
||||
│ │
|
||||
│ kewl, here's the logs, id, etc │
|
||||
│◄──────────────────────────────────────────────────┤
|
||||
│ │
|
||||
----
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
openapi: "3.0.0"
|
||||
info:
|
||||
description: |
|
||||
Janky Agent API defintion
|
||||
version: "1.0.0"
|
||||
title: Janky APIs
|
||||
contact:
|
||||
email: "rtyler+janky@brokenco.de"
|
||||
license:
|
||||
name: "AGPL v3.0"
|
||||
url: "https://www.gnu.org/licenses/agpl-3.0.en.html"
|
||||
servers:
|
||||
- url: 'http://localhost:9000/api/v1'
|
||||
description: Local dev agent (APIv1)
|
||||
|
||||
paths:
|
||||
/capabilities:
|
||||
get:
|
||||
summary: "Retrieve a list of capabilities of this agent"
|
||||
description:
|
||||
responses:
|
||||
200:
|
||||
description: Getting capabilities
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CapsResponse'
|
||||
|
||||
components:
|
||||
schemas:
|
||||
CapsResponse:
|
||||
type: array
|
||||
properties:
|
||||
caps:
|
||||
$ref: '#/components/schemas/Capability'
|
||||
Capability:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
path:
|
||||
type: string
|
||||
data:
|
||||
type: object
|
|
@ -0,0 +1,43 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
struct Capability {
|
||||
name: String,
|
||||
path: PathBuf,
|
||||
data: serde_json::Value,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
struct CapsRequest {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
struct CapsResponse {
|
||||
caps: Vec<Capability>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
struct Command {
|
||||
script: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
struct CommandRequest {
|
||||
commands: Vec<Command>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
struct CommandResponse {
|
||||
uuid: Uuid,
|
||||
stream_url: Option<Url>,
|
||||
task_url: Url,
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
}
|
Loading…
Reference in New Issue