use mogh_resolver::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::entities::{
SearchCombinator, U64,
docker::{
container::Container, service::SwarmService, stack::SwarmStack,
},
stack::{
Stack, StackActionState, StackListItem, StackQuery, StackService,
},
update::Log,
};
use super::KomodoReadRequest;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetStack",
description = "Get a specific stack.",
request_body(content = GetStack),
responses(
(status = 200, description = "The stack", body = crate::entities::stack::StackSchema),
),
)]
pub fn get_stack() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetStackResponse)]
#[error(mogh_error::Error)]
pub struct GetStack {
#[serde(alias = "id", alias = "name")]
pub stack: String,
}
#[typeshare]
pub type GetStackResponse = Stack;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListStackServices",
description = "Lists a specific stacks services (the containers).",
request_body(content = ListStackServices),
responses(
(status = 200, description = "The list of services", body = ListStackServicesResponse),
),
)]
pub fn list_stack_services() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListStackServicesResponse)]
#[error(mogh_error::Error)]
pub struct ListStackServices {
#[serde(alias = "id", alias = "name")]
pub stack: String,
}
#[typeshare]
pub type ListStackServicesResponse = Vec<StackService>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/InspectStackContainer",
description = "Inspect a docker container associated with a Stack.",
request_body(content = InspectStackContainer),
responses(
(status = 200, description = "The container", body = InspectStackContainerResponse),
),
)]
pub fn inspect_stack_container() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectStackContainerResponse)]
#[error(mogh_error::Error)]
pub struct InspectStackContainer {
#[serde(alias = "id", alias = "name")]
pub stack: String,
pub service: String,
}
#[typeshare]
pub type InspectStackContainerResponse = Container;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/InspectStackSwarmService",
description = "Inspect a swarm service associated with a Stack.",
request_body(content = InspectStackSwarmService),
responses(
(status = 200, description = "The swarm service", body = InspectStackSwarmServiceResponse),
),
)]
pub fn inspect_stack_swarm_service() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectStackSwarmServiceResponse)]
#[error(mogh_error::Error)]
pub struct InspectStackSwarmService {
#[serde(alias = "id", alias = "name")]
pub stack: String,
pub service: String,
}
#[typeshare]
pub type InspectStackSwarmServiceResponse = SwarmService;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/InspectStackSwarmInfo",
description = "Inspect swarm info associated with a Stack.",
request_body(content = InspectStackSwarmInfo),
responses(
(status = 200, description = "The swarm info", body = InspectStackSwarmInfoResponse),
),
)]
pub fn inspect_stack_swarm_info() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectStackSwarmInfoResponse)]
#[error(mogh_error::Error)]
pub struct InspectStackSwarmInfo {
#[serde(alias = "id", alias = "name")]
pub stack: String,
}
#[typeshare]
pub type InspectStackSwarmInfoResponse = SwarmStack;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetStackLog",
description = "Get a stack's logs. Filter down included services.",
request_body(content = GetStackLog),
responses(
(status = 200, description = "The stack log", body = GetStackLogResponse),
),
)]
pub fn get_stack_log() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetStackLogResponse)]
#[error(mogh_error::Error)]
pub struct GetStackLog {
#[serde(alias = "id", alias = "name")]
pub stack: String,
pub services: Vec<String>,
#[serde(default = "default_tail")]
pub tail: U64,
#[serde(default)]
pub timestamps: bool,
}
fn default_tail() -> u64 {
50
}
#[typeshare]
pub type GetStackLogResponse = Log;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/SearchStackLog",
description = "Search the stack log's tail using `grep`.",
request_body(content = SearchStackLog),
responses(
(status = 200, description = "The search results", body = SearchStackLogResponse),
),
)]
pub fn search_stack_log() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(SearchStackLogResponse)]
#[error(mogh_error::Error)]
pub struct SearchStackLog {
#[serde(alias = "id", alias = "name")]
pub stack: String,
pub services: Vec<String>,
pub terms: Vec<String>,
#[serde(default)]
pub combinator: SearchCombinator,
#[serde(default)]
pub invert: bool,
#[serde(default)]
pub timestamps: bool,
}
#[typeshare]
pub type SearchStackLogResponse = Log;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListCommonStackExtraArgs",
description = "Gets a list of existing values used as extra args across other stacks.",
request_body(content = ListCommonStackExtraArgs),
responses(
(status = 200, description = "The list of extra args", body = ListCommonStackExtraArgsResponse),
),
)]
pub fn list_common_stack_extra_args() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListCommonStackExtraArgsResponse)]
#[error(mogh_error::Error)]
pub struct ListCommonStackExtraArgs {
#[serde(default)]
pub query: StackQuery,
}
#[typeshare]
pub type ListCommonStackExtraArgsResponse = Vec<String>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListCommonStackBuildExtraArgs",
description = "Gets a list of existing values used as build extra args across other stacks.",
request_body(content = ListCommonStackBuildExtraArgs),
responses(
(status = 200, description = "The list of build extra args", body = ListCommonStackBuildExtraArgsResponse),
),
)]
pub fn list_common_stack_build_extra_args() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListCommonStackBuildExtraArgsResponse)]
#[error(mogh_error::Error)]
pub struct ListCommonStackBuildExtraArgs {
#[serde(default)]
pub query: StackQuery,
}
#[typeshare]
pub type ListCommonStackBuildExtraArgsResponse = Vec<String>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListStacks",
description = "List stacks matching optional query.",
request_body(content = ListStacks),
responses(
(status = 200, description = "The list of stacks", body = ListStacksResponse),
),
)]
pub fn list_stacks() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListStacksResponse)]
#[error(mogh_error::Error)]
pub struct ListStacks {
#[serde(default)]
pub query: StackQuery,
}
#[typeshare]
pub type ListStacksResponse = Vec<StackListItem>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListFullStacks",
description = "List stacks matching optional query.",
request_body(content = ListFullStacks),
responses(
(status = 200, description = "The list of stacks", body = ListFullStacksResponse),
),
)]
pub fn list_full_stacks() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListFullStacksResponse)]
#[error(mogh_error::Error)]
pub struct ListFullStacks {
#[serde(default)]
pub query: StackQuery,
}
#[typeshare]
pub type ListFullStacksResponse = Vec<Stack>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetStackActionState",
description = "Get current action state for the stack.",
request_body(content = GetStackActionState),
responses(
(status = 200, description = "The stack action state", body = GetStackActionStateResponse),
),
)]
pub fn get_stack_action_state() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetStackActionStateResponse)]
#[error(mogh_error::Error)]
pub struct GetStackActionState {
#[serde(alias = "id", alias = "name")]
pub stack: String,
}
#[typeshare]
pub type GetStackActionStateResponse = StackActionState;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetStacksSummary",
description = "Gets a summary of data relating to all syncs.",
request_body(content = GetStacksSummary),
responses(
(status = 200, description = "The stacks summary", body = GetStacksSummaryResponse),
),
)]
pub fn get_stacks_summary() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetStacksSummaryResponse)]
#[error(mogh_error::Error)]
pub struct GetStacksSummary {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct GetStacksSummaryResponse {
pub total: u32,
pub running: u32,
pub stopped: u32,
pub down: u32,
pub unhealthy: u32,
pub unknown: u32,
}