mirror of
https://github.com/moghtech/komodo.git
synced 2026-07-10 12:01:56 -05:00
work on typescript client
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
target
|
||||
/frontend/build
|
||||
node_modules
|
||||
/lib/ts_client/build
|
||||
dist
|
||||
.env
|
||||
.env.development
|
||||
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@@ -85,7 +85,7 @@
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "typeshare ./lib/types --lang=typescript --output-file=./lib/ts_client/src/types.ts",
|
||||
"command": "typeshare . --lang=typescript --output-file=./lib/ts_client/src/types.ts",
|
||||
"label": "generate typescript types",
|
||||
"problemMatcher": []
|
||||
}
|
||||
|
||||
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -1846,6 +1846,7 @@ dependencies = [
|
||||
"tokio-util",
|
||||
"tower",
|
||||
"tower-http",
|
||||
"typeshare",
|
||||
"urlencoding",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
@@ -36,6 +36,7 @@ async-trait.workspace = true
|
||||
futures.workspace = true
|
||||
aws-config.workspace = true
|
||||
aws-sdk-ec2.workspace = true
|
||||
typeshare.workspace = true
|
||||
# mogh
|
||||
async_timing_util.workspace = true
|
||||
merge_config_files.workspace = true
|
||||
|
||||
@@ -7,6 +7,7 @@ use axum::{
|
||||
use monitor_types::requests::api::*;
|
||||
use resolver_api::{derive::Resolver, Resolve, ResolveToString, Resolver};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
@@ -19,6 +20,7 @@ mod secret;
|
||||
mod server;
|
||||
mod build;
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Resolver)]
|
||||
#[resolver_target(State)]
|
||||
#[resolver_args(RequestUser)]
|
||||
|
||||
@@ -5,9 +5,11 @@ use monitor_types::requests::auth::{
|
||||
};
|
||||
use resolver_api::{derive::Resolver, Resolve, ResolveToString};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
use crate::state::State;
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Resolver)]
|
||||
#[resolver_target(State)]
|
||||
#[serde(tag = "type", content = "params")]
|
||||
|
||||
@@ -2,5 +2,12 @@
|
||||
"name": "monitor_client",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/react-query": "^4.29.19",
|
||||
"axios": "^1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.1.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import axios from "axios";
|
||||
import { ApiResponses, AuthResponses } from "./responses";
|
||||
import { ApiRequest, AuthRequest } from "./types";
|
||||
|
||||
export type ClientOptions = {
|
||||
jwt?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
secret?: string;
|
||||
};
|
||||
|
||||
export async function MonitorClient(base_url: string, options?: ClientOptions) {
|
||||
let jwt = options?.jwt;
|
||||
|
||||
const auth = async <R extends AuthRequest>(type: R["type"], params?: R["params"]): Promise<AuthResponses[R["type"]]> => {
|
||||
return await axios({
|
||||
method: "post",
|
||||
url: base_url + "/auth",
|
||||
data: {
|
||||
type,
|
||||
params: params || {}
|
||||
},
|
||||
}).then(({ data }) => data);
|
||||
}
|
||||
|
||||
if (!jwt) {
|
||||
if (options?.username) {
|
||||
if (options?.password) {
|
||||
const res = await auth("LoginLocalUser", { });
|
||||
} else if (options?.secret) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// const api = async <R extends ApiRequest>(
|
||||
// request: R
|
||||
// ): Promise<ApiResponses[R["type"]]> => {
|
||||
// return await axios({
|
||||
// method: "post",
|
||||
// url: base_url + "/api",
|
||||
// headers: {
|
||||
// Authorization: `Bearer ${jwt}`
|
||||
// },
|
||||
// data: request,
|
||||
// }).then(({ data }) => data);
|
||||
// };
|
||||
|
||||
return {
|
||||
auth,
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
12
lib/ts_client/src/responses.ts
Normal file
12
lib/ts_client/src/responses.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { CreateLocalUserResponse, ExchangeForJwtResponse, GetLoginOptionsResponse, LoginLocalUserResponse, LoginWithSecretResponse } from "./types";
|
||||
|
||||
export type AuthResponses = {
|
||||
GetLoginOptions: GetLoginOptionsResponse;
|
||||
CreateLocalUser: CreateLocalUserResponse;
|
||||
LoginLocalUser: LoginLocalUserResponse;
|
||||
ExchangeForJwt: ExchangeForJwtResponse;
|
||||
LoginWithSecret: LoginWithSecretResponse;
|
||||
};
|
||||
|
||||
export type ApiResponses = {
|
||||
}
|
||||
@@ -97,6 +97,15 @@ export interface AwsBuilder {
|
||||
assign_public_ip: boolean;
|
||||
}
|
||||
|
||||
export type DeploymentImage =
|
||||
| { type: "Image", params: {
|
||||
image: string;
|
||||
}}
|
||||
| { type: "Build", params: {
|
||||
build_id: string;
|
||||
version: Version;
|
||||
}};
|
||||
|
||||
export enum TerminationSignal {
|
||||
SigHup = "SIGHUP",
|
||||
SigInt = "SIGINT",
|
||||
@@ -123,8 +132,7 @@ export enum RestartMode {
|
||||
|
||||
export interface DeploymentConfig {
|
||||
server_id?: string;
|
||||
build_id?: string;
|
||||
image?: string;
|
||||
image?: DeploymentImage;
|
||||
skip_secret_interp?: boolean;
|
||||
redeploy_on_build?: boolean;
|
||||
term_signal_labels: TerminationSignalLabel[];
|
||||
@@ -437,6 +445,7 @@ export interface ServerHealth {
|
||||
mem: StatsState;
|
||||
disk: StatsState;
|
||||
disks: Record<string, StatsState>;
|
||||
temps: Record<string, StatsState>;
|
||||
}
|
||||
|
||||
export type UpdateTarget =
|
||||
@@ -539,10 +548,54 @@ export interface User {
|
||||
updated_at?: I64;
|
||||
}
|
||||
|
||||
export interface GetBuild {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface ListBuilds {
|
||||
query?: MongoDocument;
|
||||
}
|
||||
|
||||
export interface CreateBuild {
|
||||
name: string;
|
||||
config: Partial<BuildConfig>;
|
||||
}
|
||||
|
||||
export interface DeleteBuild {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface UpdateBuild {
|
||||
id: string;
|
||||
config: Partial<BuildConfig>;
|
||||
}
|
||||
|
||||
export interface RunBuild {
|
||||
build_id: string;
|
||||
}
|
||||
|
||||
export interface GetDeployment {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface ListDeployments {
|
||||
query?: MongoDocument;
|
||||
}
|
||||
|
||||
export interface CreateDeployment {
|
||||
name: string;
|
||||
config: Partial<DeploymentConfig>;
|
||||
}
|
||||
|
||||
export interface DeleteDeployment {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface UpdateDeployment {
|
||||
id: string;
|
||||
config: Partial<DeploymentConfig>;
|
||||
}
|
||||
|
||||
export interface RenameDeployment {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -550,6 +603,8 @@ export interface RenameDeployment {
|
||||
|
||||
export interface Deploy {
|
||||
deployment_id: string;
|
||||
stop_signal?: TerminationSignal;
|
||||
stop_time?: number;
|
||||
}
|
||||
|
||||
export interface StartContainer {
|
||||
@@ -581,6 +636,28 @@ export interface DeleteLoginSecret {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface GetServer {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface ListServers {
|
||||
query?: MongoDocument;
|
||||
}
|
||||
|
||||
export interface CreateServer {
|
||||
name: string;
|
||||
config: Partial<ServerConfig>;
|
||||
}
|
||||
|
||||
export interface DeleteServer {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface UpdateServer {
|
||||
id: string;
|
||||
config: Partial<ServerConfig>;
|
||||
}
|
||||
|
||||
export interface RenameServer {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -594,10 +671,62 @@ export interface GetPeripheryVersionResponse {
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface GetSystemInformation {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetAllSystemStats {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetBasicSystemStats {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetCpuUsage {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetDiskUsage {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetNetworkUsage {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetSystemProcesses {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetSystemComponents {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetDockerNetworks {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface PruneDockerNetworks {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetDockerImages {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface PruneDockerImages {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetDockerContainers {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface PruneDockerContainers {
|
||||
server_id: string;
|
||||
}
|
||||
|
||||
export interface GetLoginOptions {
|
||||
}
|
||||
|
||||
@@ -642,6 +771,54 @@ export interface LoginWithSecretResponse {
|
||||
jwt: string;
|
||||
}
|
||||
|
||||
export type ApiRequest =
|
||||
| { type: "CreateLoginSecret", params: CreateLoginSecret }
|
||||
| { type: "DeleteLoginSecret", params: DeleteLoginSecret }
|
||||
| { type: "GetPeripheryVersion", params: GetPeripheryVersion }
|
||||
| { type: "GetSystemInformation", params: GetSystemInformation }
|
||||
| { type: "GetDockerContainers", params: GetDockerContainers }
|
||||
| { type: "GetDockerImages", params: GetDockerImages }
|
||||
| { type: "GetDockerNetworks", params: GetDockerNetworks }
|
||||
| { type: "GetServer", params: GetServer }
|
||||
| { type: "ListServers", params: ListServers }
|
||||
| { type: "CreateServer", params: CreateServer }
|
||||
| { type: "DeleteServer", params: DeleteServer }
|
||||
| { type: "UpdateServer", params: UpdateServer }
|
||||
| { type: "RenameServer", params: RenameServer }
|
||||
| { type: "GetAllSystemStats", params: GetAllSystemStats }
|
||||
| { type: "GetBasicSystemStats", params: GetBasicSystemStats }
|
||||
| { type: "GetCpuUsage", params: GetCpuUsage }
|
||||
| { type: "GetDiskUsage", params: GetDiskUsage }
|
||||
| { type: "GetNetworkUsage", params: GetNetworkUsage }
|
||||
| { type: "GetSystemProcesses", params: GetSystemProcesses }
|
||||
| { type: "GetSystemComponents", params: GetSystemComponents }
|
||||
| { type: "PruneContainers", params: PruneDockerContainers }
|
||||
| { type: "PruneImages", params: PruneDockerImages }
|
||||
| { type: "PruneNetworks", params: PruneDockerNetworks }
|
||||
| { type: "GetDeployment", params: GetDeployment }
|
||||
| { type: "ListDeployments", params: ListDeployments }
|
||||
| { type: "CreateDeployment", params: CreateDeployment }
|
||||
| { type: "DeleteDeployment", params: DeleteDeployment }
|
||||
| { type: "UpdateDeployment", params: UpdateDeployment }
|
||||
| { type: "RenameDeployment", params: RenameDeployment }
|
||||
| { type: "Deploy", params: Deploy }
|
||||
| { type: "StartContainer", params: StartContainer }
|
||||
| { type: "StopContainer", params: StopContainer }
|
||||
| { type: "RemoveContainer", params: RemoveContainer }
|
||||
| { type: "GetBuild", params: GetBuild }
|
||||
| { type: "ListBuilds", params: ListBuilds }
|
||||
| { type: "CreateBuild", params: CreateBuild }
|
||||
| { type: "DeleteBuild", params: DeleteBuild }
|
||||
| { type: "UpdateBuild", params: UpdateBuild }
|
||||
| { type: "RunBuild", params: RunBuild };
|
||||
|
||||
export type AuthRequest =
|
||||
| { type: "GetLoginOptions", params: GetLoginOptions }
|
||||
| { type: "CreateLocalUser", params: CreateLocalUser }
|
||||
| { type: "LoginLocalUser", params: LoginLocalUser }
|
||||
| { type: "LoginWithSecret", params: LoginWithSecret }
|
||||
| { type: "ExchangeForJwt", params: ExchangeForJwt };
|
||||
|
||||
export enum ServerStatus {
|
||||
NotOk = "NotOk",
|
||||
Ok = "Ok",
|
||||
|
||||
12
lib/ts_client/tsconfig.json
Normal file
12
lib/ts_client/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"target": "ESNext",
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": true,
|
||||
"outDir": "build"
|
||||
}
|
||||
}
|
||||
83
lib/ts_client/yarn.lock
Normal file
83
lib/ts_client/yarn.lock
Normal file
@@ -0,0 +1,83 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@tanstack/query-core@4.29.19":
|
||||
version "4.29.19"
|
||||
resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-4.29.19.tgz#49ccbd0606633d1e55baf3b91ab7cc7aef411b1d"
|
||||
integrity sha512-uPe1DukeIpIHpQi6UzIgBcXsjjsDaLnc7hF+zLBKnaUlh7jFE/A+P8t4cU4VzKPMFB/C970n/9SxtpO5hmIRgw==
|
||||
|
||||
"@tanstack/react-query@^4.29.19":
|
||||
version "4.29.19"
|
||||
resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-4.29.19.tgz#6ba187f2d0ea36ae83ff1f67068f53c88ce7b228"
|
||||
integrity sha512-XiTIOHHQ5Cw1WUlHaD4fmVUMhoWjuNJlAeJGq7eM4BraI5z7y8WkZO+NR8PSuRnQGblpuVdjClQbDFtwxTtTUw==
|
||||
dependencies:
|
||||
"@tanstack/query-core" "4.29.19"
|
||||
use-sync-external-store "^1.2.0"
|
||||
|
||||
asynckit@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
|
||||
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
|
||||
|
||||
axios@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f"
|
||||
integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==
|
||||
dependencies:
|
||||
follow-redirects "^1.15.0"
|
||||
form-data "^4.0.0"
|
||||
proxy-from-env "^1.1.0"
|
||||
|
||||
combined-stream@^1.0.8:
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
|
||||
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
|
||||
dependencies:
|
||||
delayed-stream "~1.0.0"
|
||||
|
||||
delayed-stream@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
|
||||
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==
|
||||
|
||||
follow-redirects@^1.15.0:
|
||||
version "1.15.2"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
|
||||
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
|
||||
|
||||
form-data@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
|
||||
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
|
||||
dependencies:
|
||||
asynckit "^0.4.0"
|
||||
combined-stream "^1.0.8"
|
||||
mime-types "^2.1.12"
|
||||
|
||||
mime-db@1.52.0:
|
||||
version "1.52.0"
|
||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
|
||||
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
|
||||
|
||||
mime-types@^2.1.12:
|
||||
version "2.1.35"
|
||||
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
|
||||
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
|
||||
dependencies:
|
||||
mime-db "1.52.0"
|
||||
|
||||
proxy-from-env@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
|
||||
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==
|
||||
|
||||
typescript@^5.1.6:
|
||||
version "5.1.6"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
|
||||
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
|
||||
|
||||
use-sync-external-store@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a"
|
||||
integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==
|
||||
@@ -1,4 +1,3 @@
|
||||
use monitor_macros::derive_crud_requests;
|
||||
use resolver_api::derive::Request;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
@@ -13,7 +12,48 @@ use crate::{
|
||||
|
||||
//
|
||||
|
||||
derive_crud_requests!(Build);
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Build)]
|
||||
pub struct GetBuild {
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Vec<Build>)]
|
||||
pub struct ListBuilds {
|
||||
pub query: Option<MongoDocument>,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Build)]
|
||||
pub struct CreateBuild {
|
||||
pub name: String,
|
||||
pub config: PartialBuildConfig,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Build)]
|
||||
pub struct DeleteBuild {
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Build)]
|
||||
pub struct UpdateBuild {
|
||||
pub id: String,
|
||||
pub config: PartialBuildConfig,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
||||
@@ -1,15 +1,61 @@
|
||||
//
|
||||
|
||||
use monitor_macros::derive_crud_requests;
|
||||
use resolver_api::derive::Request;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
use crate::{MongoDocument, entities::{deployment::{Deployment, PartialDeploymentConfig, TerminationSignal}, update::Update}};
|
||||
use crate::{
|
||||
entities::{
|
||||
deployment::{Deployment, PartialDeploymentConfig, TerminationSignal},
|
||||
update::Update,
|
||||
},
|
||||
MongoDocument,
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
derive_crud_requests!(Deployment);
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Deployment)]
|
||||
pub struct GetDeployment {
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Vec<Deployment>)]
|
||||
pub struct ListDeployments {
|
||||
pub query: Option<MongoDocument>,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Deployment)]
|
||||
pub struct CreateDeployment {
|
||||
pub name: String,
|
||||
pub config: PartialDeploymentConfig,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Deployment)]
|
||||
pub struct DeleteDeployment {
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Deployment)]
|
||||
pub struct UpdateDeployment {
|
||||
pub id: String,
|
||||
pub config: PartialDeploymentConfig,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -17,16 +63,16 @@ derive_crud_requests!(Deployment);
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Update)]
|
||||
pub struct RenameDeployment {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Update)]
|
||||
pub struct Deploy {
|
||||
pub deployment_id: String,
|
||||
pub stop_signal: Option<TerminationSignal>,
|
||||
pub deployment_id: String,
|
||||
pub stop_signal: Option<TerminationSignal>,
|
||||
pub stop_time: Option<i32>,
|
||||
}
|
||||
|
||||
@@ -34,15 +80,15 @@ pub struct Deploy {
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Update)]
|
||||
pub struct StartContainer {
|
||||
pub deployment_id: String,
|
||||
pub deployment_id: String,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Update)]
|
||||
pub struct StopContainer {
|
||||
pub deployment_id: String,
|
||||
pub signal: Option<TerminationSignal>,
|
||||
pub deployment_id: String,
|
||||
pub signal: Option<TerminationSignal>,
|
||||
pub time: Option<i32>,
|
||||
}
|
||||
|
||||
@@ -50,7 +96,7 @@ pub struct StopContainer {
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Update)]
|
||||
pub struct RemoveContainer {
|
||||
pub deployment_id: String,
|
||||
pub deployment_id: String,
|
||||
pub signal: Option<TerminationSignal>,
|
||||
pub time: Option<i32>,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use monitor_macros::derive_crud_requests;
|
||||
use resolver_api::derive::Request;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
@@ -22,7 +21,48 @@ use crate::{
|
||||
|
||||
//
|
||||
|
||||
derive_crud_requests!(Server);
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Server)]
|
||||
pub struct GetServer {
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Vec<Server>)]
|
||||
pub struct ListServers {
|
||||
pub query: Option<MongoDocument>,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Server)]
|
||||
pub struct CreateServer {
|
||||
pub name: String,
|
||||
pub config: PartialServerConfig,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Server)]
|
||||
pub struct DeleteServer {
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Server)]
|
||||
pub struct UpdateServer {
|
||||
pub id: String,
|
||||
pub config: PartialServerConfig,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -51,6 +91,7 @@ pub struct GetPeripheryVersionResponse {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(SystemInformation)]
|
||||
pub struct GetSystemInformation {
|
||||
@@ -68,6 +109,7 @@ pub struct GetAllSystemStats {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(BasicSystemStats)]
|
||||
pub struct GetBasicSystemStats {
|
||||
@@ -76,6 +118,7 @@ pub struct GetBasicSystemStats {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(CpuUsage)]
|
||||
pub struct GetCpuUsage {
|
||||
@@ -84,6 +127,7 @@ pub struct GetCpuUsage {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(DiskUsage)]
|
||||
pub struct GetDiskUsage {
|
||||
@@ -92,6 +136,7 @@ pub struct GetDiskUsage {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(NetworkUsage)]
|
||||
pub struct GetNetworkUsage {
|
||||
@@ -100,6 +145,7 @@ pub struct GetNetworkUsage {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Vec<SystemProcess>)]
|
||||
pub struct GetSystemProcesses {
|
||||
@@ -108,6 +154,7 @@ pub struct GetSystemProcesses {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Vec<SystemComponent>)]
|
||||
pub struct GetSystemComponents {
|
||||
@@ -116,6 +163,7 @@ pub struct GetSystemComponents {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Vec<DockerNetwork>)]
|
||||
pub struct GetDockerNetworks {
|
||||
@@ -124,6 +172,7 @@ pub struct GetDockerNetworks {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Update)]
|
||||
pub struct PruneDockerNetworks {
|
||||
@@ -132,6 +181,7 @@ pub struct PruneDockerNetworks {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Vec<ImageSummary>)]
|
||||
pub struct GetDockerImages {
|
||||
@@ -140,6 +190,7 @@ pub struct GetDockerImages {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Update)]
|
||||
pub struct PruneDockerImages {
|
||||
@@ -148,6 +199,7 @@ pub struct PruneDockerImages {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Vec<BasicContainerInfo>)]
|
||||
pub struct GetDockerContainers {
|
||||
@@ -156,6 +208,7 @@ pub struct GetDockerContainers {
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(Update)]
|
||||
pub struct PruneDockerContainers {
|
||||
|
||||
Reference in New Issue
Block a user