use derive_empty_traits::EmptyTraits;
use resolver_api::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::entities::{
I64, Timelength,
server::{
PeripheryInformation, Server, ServerActionState, ServerListItem,
ServerQuery, ServerState,
},
stats::{
SystemInformation, SystemProcess, SystemStats, SystemStatsRecord,
},
};
use super::KomodoReadRequest;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(Server)]
#[error(serror::Error)]
pub struct GetServer {
#[serde(alias = "id", alias = "name")]
pub server: String,
}
#[typeshare]
pub type GetServerResponse = Server;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Default, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListServersResponse)]
#[error(serror::Error)]
pub struct ListServers {
#[serde(default)]
pub query: ServerQuery,
}
#[typeshare]
pub type ListServersResponse = Vec<ServerListItem>;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Default, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListFullServersResponse)]
#[error(serror::Error)]
pub struct ListFullServers {
#[serde(default)]
pub query: ServerQuery,
}
#[typeshare]
pub type ListFullServersResponse = Vec<Server>;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetServerStateResponse)]
#[error(serror::Error)]
pub struct GetServerState {
#[serde(alias = "id", alias = "name")]
pub server: String,
}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct GetServerStateResponse {
pub status: ServerState,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ServerActionState)]
#[error(serror::Error)]
pub struct GetServerActionState {
#[serde(alias = "id", alias = "name")]
pub server: String,
}
#[typeshare]
pub type GetServerActionStateResponse = ServerActionState;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetPeripheryInformationResponse)]
#[error(serror::Error)]
pub struct GetPeripheryInformation {
#[serde(alias = "id", alias = "name")]
pub server: String,
}
#[typeshare]
pub type GetPeripheryInformationResponse = PeripheryInformation;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSystemInformationResponse)]
#[error(serror::Error)]
pub struct GetSystemInformation {
#[serde(alias = "id", alias = "name")]
pub server: String,
}
#[typeshare]
pub type GetSystemInformationResponse = SystemInformation;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSystemStatsResponse)]
#[error(serror::Error)]
pub struct GetSystemStats {
#[serde(alias = "id", alias = "name")]
pub server: String,
}
#[typeshare]
pub type GetSystemStatsResponse = SystemStats;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSystemProcessesResponse)]
#[error(serror::Error)]
pub struct ListSystemProcesses {
#[serde(alias = "id", alias = "name")]
pub server: String,
}
#[typeshare]
pub type ListSystemProcessesResponse = Vec<SystemProcess>;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetHistoricalServerStatsResponse)]
#[error(serror::Error)]
pub struct GetHistoricalServerStats {
#[serde(alias = "id", alias = "name")]
pub server: String,
pub granularity: Timelength,
#[serde(default)]
pub page: u32,
}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct GetHistoricalServerStatsResponse {
pub stats: Vec<SystemStatsRecord>,
pub next_page: Option<u32>,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetServersSummaryResponse)]
#[error(serror::Error)]
pub struct GetServersSummary {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct GetServersSummaryResponse {
pub total: I64,
pub healthy: I64,
pub warning: I64,
pub unhealthy: I64,
pub disabled: I64,
}