Start in on implementing the OpenAPI for the agent side of the equation

This commit is contained in:
R Tyler Croy 2023-01-28 15:31:04 -08:00
parent 59c01e0e34
commit 0e3f874870
No known key found for this signature in database
GPG Key ID: E5C92681BEF6CEA2
4 changed files with 90 additions and 8 deletions

View File

@ -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"

View File

@ -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 │
│◄──────────────────────────────────────────────────┤
│ │
----

45
agent-api-description.yml Normal file
View File

@ -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

43
src/lib.rs Normal file
View File

@ -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 {
}