use mogh_resolver::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::entities::{
SearchCombinator, U64,
docker::{
config::{SwarmConfigDetails, SwarmConfigListItem},
network::NetworkListItem,
node::{SwarmNode, SwarmNodeListItem},
secret::{SwarmSecret, SwarmSecretListItem},
service::{SwarmService, SwarmServiceListItem},
stack::{SwarmStack, SwarmStackListItem},
swarm::SwarmInspectInfo,
task::{SwarmTask, SwarmTaskListItem},
},
swarm::{Swarm, SwarmActionState, SwarmListItem, SwarmQuery},
update::Log,
};
use super::KomodoReadRequest;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetSwarm",
description = "Get a specific swarm.",
request_body(content = GetSwarm),
responses(
(status = 200, description = "The swarm", body = crate::entities::swarm::SwarmSchema),
),
)]
pub fn get_swarm() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSwarmResponse)]
#[error(mogh_error::Error)]
pub struct GetSwarm {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
}
#[typeshare]
pub type GetSwarmResponse = Swarm;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListSwarms",
description = "List Swarms matching optional query.",
request_body(content = ListSwarms),
responses(
(status = 200, description = "The list of swarms", body = ListSwarmsResponse),
),
)]
pub fn list_swarms() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmsResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarms {
#[serde(default)]
pub query: SwarmQuery,
}
#[typeshare]
pub type ListSwarmsResponse = Vec<SwarmListItem>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListFullSwarms",
description = "List Swarms matching optional query.",
request_body(content = ListFullSwarms),
responses(
(status = 200, description = "The list of swarms", body = ListFullSwarmsResponse),
),
)]
pub fn list_full_swarms() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListFullSwarmsResponse)]
#[error(mogh_error::Error)]
pub struct ListFullSwarms {
#[serde(default)]
pub query: SwarmQuery,
}
#[typeshare]
pub type ListFullSwarmsResponse = Vec<Swarm>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetSwarmActionState",
description = "Get current action state for the swarm.",
request_body(content = GetSwarmActionState),
responses(
(status = 200, description = "The swarm action state", body = GetSwarmActionStateResponse),
),
)]
pub fn get_swarm_action_state() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSwarmActionStateResponse)]
#[error(mogh_error::Error)]
pub struct GetSwarmActionState {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
}
#[typeshare]
pub type GetSwarmActionStateResponse = SwarmActionState;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetSwarmsSummary",
description = "Gets a summary of data relating to all swarms.",
request_body(content = GetSwarmsSummary),
responses(
(status = 200, description = "The swarms summary", body = GetSwarmsSummaryResponse),
),
)]
pub fn get_swarms_summary() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSwarmsSummaryResponse)]
#[error(mogh_error::Error)]
pub struct GetSwarmsSummary {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct GetSwarmsSummaryResponse {
pub total: u32,
pub healthy: u32,
pub unhealthy: u32,
pub down: u32,
pub unknown: u32,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/InspectSwarm",
description = "Inspect information about the swarm.",
request_body(content = InspectSwarm),
responses(
(status = 200, description = "The swarm inspect info", body = InspectSwarmResponse),
),
)]
pub fn inspect_swarm() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarm {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
}
#[typeshare]
pub type InspectSwarmResponse = SwarmInspectInfo;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListSwarmNodes",
description = "List nodes part of the target Swarm.",
request_body(content = ListSwarmNodes),
responses(
(status = 200, description = "The list of swarm nodes", body = ListSwarmNodesResponse),
),
)]
pub fn list_swarm_nodes() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmNodesResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmNodes {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
}
#[typeshare]
pub type ListSwarmNodesResponse = Vec<SwarmNodeListItem>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/InspectSwarmNode",
description = "Inspect a Swarm node.",
request_body(content = InspectSwarmNode),
responses(
(status = 200, description = "The swarm node", body = InspectSwarmNodeResponse),
),
)]
pub fn inspect_swarm_node() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmNodeResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmNode {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
pub node: String,
}
#[typeshare]
pub type InspectSwarmNodeResponse = SwarmNode;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListSwarmServices",
description = "List services on the target Swarm.",
request_body(content = ListSwarmServices),
responses(
(status = 200, description = "The list of swarm services", body = ListSwarmServicesResponse),
),
)]
pub fn list_swarm_services() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmServicesResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmServices {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
}
#[typeshare]
pub type ListSwarmServicesResponse = Vec<SwarmServiceListItem>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/InspectSwarmService",
description = "Inspect a Swarm service.",
request_body(content = InspectSwarmService),
responses(
(status = 200, description = "The swarm service", body = InspectSwarmServiceResponse),
),
)]
pub fn inspect_swarm_service() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmServiceResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmService {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
pub service: String,
}
#[typeshare]
pub type InspectSwarmServiceResponse = SwarmService;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetSwarmServiceLog",
description = "Get a swarm service's logs.",
request_body(content = GetSwarmServiceLog),
responses(
(status = 200, description = "The swarm service log", body = GetSwarmServiceLogResponse),
),
)]
pub fn get_swarm_service_log() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSwarmServiceLogResponse)]
#[error(mogh_error::Error)]
pub struct GetSwarmServiceLog {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
pub service: String,
#[serde(default = "default_tail")]
pub tail: U64,
#[serde(default)]
pub timestamps: bool,
#[serde(default)]
pub no_task_ids: bool,
#[serde(default)]
pub no_resolve: bool,
#[serde(default)]
pub details: bool,
}
fn default_tail() -> u64 {
50
}
#[typeshare]
pub type GetSwarmServiceLogResponse = Log;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/SearchSwarmServiceLog",
description = "Search the swarm service log's tail using `grep`.",
request_body(content = SearchSwarmServiceLog),
responses(
(status = 200, description = "The search results", body = SearchSwarmServiceLogResponse),
),
)]
pub fn search_swarm_service_log() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(SearchSwarmServiceLogResponse)]
#[error(mogh_error::Error)]
pub struct SearchSwarmServiceLog {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
pub service: String,
pub terms: Vec<String>,
#[serde(default)]
pub combinator: SearchCombinator,
#[serde(default)]
pub invert: bool,
#[serde(default)]
pub timestamps: bool,
#[serde(default)]
pub no_task_ids: bool,
#[serde(default)]
pub no_resolve: bool,
#[serde(default)]
pub details: bool,
}
#[typeshare]
pub type SearchSwarmServiceLogResponse = Log;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListSwarmTasks",
description = "List tasks on the target Swarm.",
request_body(content = ListSwarmTasks),
responses(
(status = 200, description = "The list of swarm tasks", body = ListSwarmTasksResponse),
),
)]
pub fn list_swarm_tasks() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmTasksResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmTasks {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
}
#[typeshare]
pub type ListSwarmTasksResponse = Vec<SwarmTaskListItem>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/InspectSwarmTask",
description = "Inspect a Swarm task.",
request_body(content = InspectSwarmTask),
responses(
(status = 200, description = "The swarm task", body = InspectSwarmTaskResponse),
),
)]
pub fn inspect_swarm_task() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmTaskResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmTask {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
pub task: String,
}
#[typeshare]
pub type InspectSwarmTaskResponse = SwarmTask;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListSwarmSecrets",
description = "List secrets on the target Swarm.",
request_body(content = ListSwarmSecrets),
responses(
(status = 200, description = "The list of swarm secrets", body = ListSwarmSecretsResponse),
),
)]
pub fn list_swarm_secrets() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmSecretsResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmSecrets {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
}
#[typeshare]
pub type ListSwarmSecretsResponse = Vec<SwarmSecretListItem>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/InspectSwarmSecret",
description = "Inspect a Swarm secret.",
request_body(content = InspectSwarmSecret),
responses(
(status = 200, description = "The swarm secret", body = InspectSwarmSecretResponse),
),
)]
pub fn inspect_swarm_secret() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmSecretResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmSecret {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
pub secret: String,
}
#[typeshare]
pub type InspectSwarmSecretResponse = SwarmSecret;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListSwarmConfigs",
description = "List configs on the target Swarm.",
request_body(content = ListSwarmConfigs),
responses(
(status = 200, description = "The list of swarm configs", body = ListSwarmConfigsResponse),
),
)]
pub fn list_swarm_configs() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmConfigsResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmConfigs {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
}
#[typeshare]
pub type ListSwarmConfigsResponse = Vec<SwarmConfigListItem>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/InspectSwarmConfig",
description = "Inspect a config on the target Swarm.",
request_body(content = InspectSwarmConfig),
responses(
(status = 200, description = "The swarm config", body = InspectSwarmConfigResponse),
),
)]
pub fn inspect_swarm_config() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmConfigResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmConfig {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
pub config: String,
}
#[typeshare]
pub type InspectSwarmConfigResponse = SwarmConfigDetails;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListSwarmStacks",
description = "List stacks on the target Swarm.",
request_body(content = ListSwarmStacks),
responses(
(status = 200, description = "The list of swarm stacks", body = ListSwarmStacksResponse),
),
)]
pub fn list_swarm_stacks() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmStacksResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmStacks {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
}
#[typeshare]
pub type ListSwarmStacksResponse = Vec<SwarmStackListItem>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/InspectSwarmStack",
description = "Inspect a stack on the target Swarm.",
request_body(content = InspectSwarmStack),
responses(
(status = 200, description = "The swarm stack", body = InspectSwarmStackResponse),
),
)]
pub fn inspect_swarm_stack() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmStackResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmStack {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
pub stack: String,
}
#[typeshare]
pub type InspectSwarmStackResponse = SwarmStack;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListSwarmNetworks",
description = "List the networks on the swarm.",
request_body(content = ListSwarmNetworks),
responses(
(status = 200, description = "The list of swarm networks", body = ListSwarmNetworksResponse),
),
)]
pub fn list_swarm_networks() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmNetworksResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmNetworks {
#[serde(alias = "id", alias = "name")]
pub swarm: String,
}
#[typeshare]
pub type ListSwarmNetworksResponse = Vec<NetworkListItem>;