use mogh_resolver::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::entities::{
NoData,
stack::{_PartialStackConfig, Stack, StackServiceWithUpdate},
update::Update,
};
use super::KomodoWriteRequest;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/CreateStack",
description = "Create a stack.",
request_body(content = CreateStack),
responses(
(status = 200, description = "The created stack", body = crate::entities::stack::StackSchema),
),
)]
pub fn create_stack() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Stack)]
#[error(mogh_error::Error)]
pub struct CreateStack {
pub name: String,
#[serde(default)]
pub config: _PartialStackConfig,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/CopyStack",
description = "Copy a stack.",
request_body(content = CopyStack),
responses(
(status = 200, description = "The new stack", body = crate::entities::stack::StackSchema),
),
)]
pub fn copy_stack() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Stack)]
#[error(mogh_error::Error)]
pub struct CopyStack {
pub name: String,
pub id: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DeleteStack",
description = "Delete a stack.",
request_body(content = DeleteStack),
responses(
(status = 200, description = "The deleted stack", body = crate::entities::stack::StackSchema),
),
)]
pub fn delete_stack() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Stack)]
#[error(mogh_error::Error)]
pub struct DeleteStack {
pub id: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/UpdateStack",
description = "Update a stack.",
request_body(content = UpdateStack),
responses(
(status = 200, description = "The updated stack", body = crate::entities::stack::StackSchema),
),
)]
pub fn update_stack() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Stack)]
#[error(mogh_error::Error)]
pub struct UpdateStack {
pub id: String,
pub config: _PartialStackConfig,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/RenameStack",
description = "Rename a stack.",
request_body(content = RenameStack),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn rename_stack() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Update)]
#[error(mogh_error::Error)]
pub struct RenameStack {
pub id: String,
pub name: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/WriteStackFileContents",
description = "Write file contents to a stack.",
request_body(content = WriteStackFileContents),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn write_stack_file_contents() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Update)]
#[error(mogh_error::Error)]
pub struct WriteStackFileContents {
#[serde(alias = "id", alias = "name")]
pub stack: String,
pub file_path: String,
pub contents: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/RefreshStackCache",
description = "Trigger a refresh of the cached compose file contents.",
request_body(content = RefreshStackCache),
responses(
(status = 200, description = "No data", body = NoData),
),
)]
pub fn refresh_stack_cache() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(NoData)]
#[error(mogh_error::Error)]
pub struct RefreshStackCache {
#[serde(alias = "id", alias = "name")]
pub stack: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/CheckStackForUpdate",
description = "Checks for new images.",
request_body(content = CheckStackForUpdate),
responses(
(status = 200, description = "Checked for updates", body = CheckStackForUpdateResponse),
),
)]
pub fn check_stack_for_update() {}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, PartialEq, Resolve,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(CheckStackForUpdateResponse)]
#[error(mogh_error::Error)]
pub struct CheckStackForUpdate {
pub stack: String,
#[serde(default)]
pub skip_auto_update: bool,
#[serde(default)]
pub wait_for_auto_update: bool,
#[serde(default)]
pub skip_cache_refresh: bool,
}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct CheckStackForUpdateResponse {
pub stack: String,
pub services: Vec<StackServiceWithUpdate>,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/BatchCheckStackForUpdate",
description = "Checks for new images.",
request_body(content = BatchCheckStackForUpdate),
responses(
(status = 200, description = "Stack / service level results", body = BatchCheckStackForUpdateResponse),
),
)]
pub fn batch_check_stack_for_update() {}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, PartialEq, Resolve,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(BatchCheckStackForUpdateResponse)]
#[error(mogh_error::Error)]
pub struct BatchCheckStackForUpdate {
pub pattern: String,
#[serde(default)]
pub skip_auto_update: bool,
#[serde(default)]
pub wait_for_auto_update: bool,
#[serde(default)]
pub skip_cache_refresh: bool,
}
#[typeshare]
pub type BatchCheckStackForUpdateResponse =
Vec<CheckStackForUpdateResponse>;
#[typeshare]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum StackWebhookAction {
Refresh,
Deploy,
}