server / stack exec openapi

This commit is contained in:
mbecker20
2026-01-19 22:18:41 -08:00
parent 36ee7ed72e
commit 24ed3cfcb1
2 changed files with 422 additions and 2 deletions

View File

@@ -11,6 +11,18 @@ use super::KomodoExecuteRequest;
// = CONTAINER =
// =============
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/StartContainer",
description = "Starts the container on the target server.",
request_body(content = StartContainer),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn start_container() {}
/// Starts the container on the target server. Response: [Update]
///
/// 1. Runs `docker start ${container_name}`.
@@ -31,6 +43,18 @@ pub struct StartContainer {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/RestartContainer",
description = "Restarts the container on the target server.",
request_body(content = RestartContainer),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn restart_container() {}
/// Restarts the container on the target server. Response: [Update]
///
/// 1. Runs `docker restart ${container_name}`.
@@ -51,6 +75,18 @@ pub struct RestartContainer {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PauseContainer",
description = "Pauses the container on the target server.",
request_body(content = PauseContainer),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn pause_container() {}
/// Pauses the container on the target server. Response: [Update]
///
/// 1. Runs `docker pause ${container_name}`.
@@ -71,6 +107,18 @@ pub struct PauseContainer {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/UnpauseContainer",
description = "Unpauses the container on the target server.",
request_body(content = UnpauseContainer),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn unpause_container() {}
/// Unpauses the container on the target server. Response: [Update]
///
/// 1. Runs `docker unpause ${container_name}`.
@@ -93,6 +141,18 @@ pub struct UnpauseContainer {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/StopContainer",
description = "Stops the container on the target server.",
request_body(content = StopContainer),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn stop_container() {}
/// Stops the container on the target server. Response: [Update]
///
/// 1. Runs `docker stop ${container_name}`.
@@ -117,6 +177,18 @@ pub struct StopContainer {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DestroyContainer",
description = "Stops and destroys the container on the target server.",
request_body(content = DestroyContainer),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn destroy_container() {}
/// Stops and destroys the container on the target server.
/// Reponse: [Update].
///
@@ -142,6 +214,18 @@ pub struct DestroyContainer {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/StartAllContainers",
description = "Starts all containers on the target server.",
request_body(content = StartAllContainers),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn start_all_containers() {}
/// Starts all containers on the target server. Response: [Update]
#[typeshare]
#[derive(
@@ -158,6 +242,18 @@ pub struct StartAllContainers {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/RestartAllContainers",
description = "Restarts all containers on the target server.",
request_body(content = RestartAllContainers),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn restart_all_containers() {}
/// Restarts all containers on the target server. Response: [Update]
#[typeshare]
#[derive(
@@ -174,6 +270,18 @@ pub struct RestartAllContainers {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PauseAllContainers",
description = "Pauses all containers on the target server.",
request_body(content = PauseAllContainers),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn pause_all_containers() {}
/// Pauses all containers on the target server. Response: [Update]
#[typeshare]
#[derive(
@@ -190,6 +298,18 @@ pub struct PauseAllContainers {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/UnpauseAllContainers",
description = "Unpauses all containers on the target server.",
request_body(content = UnpauseAllContainers),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn unpause_all_containers() {}
/// Unpauses all containers on the target server. Response: [Update]
#[typeshare]
#[derive(
@@ -206,6 +326,18 @@ pub struct UnpauseAllContainers {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/StopAllContainers",
description = "Stops all containers on the target server.",
request_body(content = StopAllContainers),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn stop_all_containers() {}
/// Stops all containers on the target server. Response: [Update]
#[typeshare]
#[derive(
@@ -222,6 +354,18 @@ pub struct StopAllContainers {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PruneContainers",
description = "Prunes the docker containers on the target server.",
request_body(content = PruneContainers),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn prune_containers() {}
/// Prunes the docker containers on the target server. Response: [Update].
///
/// 1. Runs `docker container prune -f`.
@@ -242,6 +386,18 @@ pub struct PruneContainers {
// = NETWORK / IMAGE / VOLUME =
// ============================
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DeleteNetwork",
description = "Delete a docker network.",
request_body(content = DeleteNetwork),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn delete_network() {}
/// Delete a docker network.
/// Response: [Update]
#[typeshare]
@@ -261,6 +417,18 @@ pub struct DeleteNetwork {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PruneNetworks",
description = "Prunes the docker networks on the target server.",
request_body(content = PruneNetworks),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn prune_networks() {}
/// Prunes the docker networks on the target server. Response: [Update].
///
/// 1. Runs `docker network prune -f`.
@@ -279,6 +447,18 @@ pub struct PruneNetworks {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DeleteImage",
description = "Delete a docker image.",
request_body(content = DeleteImage),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn delete_image() {}
/// Delete a docker image.
/// Response: [Update]
#[typeshare]
@@ -298,6 +478,18 @@ pub struct DeleteImage {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PruneImages",
description = "Prunes the docker images on the target server.",
request_body(content = PruneImages),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn prune_images() {}
/// Prunes the docker images on the target server. Response: [Update].
///
/// 1. Runs `docker image prune -a -f`.
@@ -316,6 +508,18 @@ pub struct PruneImages {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DeleteVolume",
description = "Delete a docker volume.",
request_body(content = DeleteVolume),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn delete_volume() {}
/// Delete a docker volume.
/// Response: [Update]
#[typeshare]
@@ -335,6 +539,18 @@ pub struct DeleteVolume {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PruneVolumes",
description = "Prunes the docker volumes on the target server.",
request_body(content = PruneVolumes),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn prune_volumes() {}
/// Prunes the docker volumes on the target server. Response: [Update].
///
/// 1. Runs `docker volume prune -a -f`.
@@ -353,7 +569,19 @@ pub struct PruneVolumes {
//
/// Prunes the docker builders (build cache) on the target server. Response: [Update].
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PruneDockerBuilders",
description = "Prunes the docker builders on the target server.",
request_body(content = PruneDockerBuilders),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn prune_docker_builders() {}
/// Prunes the docker builders on the target server. Response: [Update].
///
/// 1. Runs `docker builder prune -a -f`.
#[typeshare]
@@ -371,6 +599,18 @@ pub struct PruneDockerBuilders {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PruneBuildx",
description = "Prunes the docker buildx cache on the target server.",
request_body(content = PruneBuildx),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn prune_buildx() {}
/// Prunes the docker buildx cache on the target server. Response: [Update].
///
/// 1. Runs `docker buildx prune -a -f`.
@@ -389,6 +629,18 @@ pub struct PruneBuildx {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PruneSystem",
description = "Prunes the docker system on the target server, including volumes.",
request_body(content = PruneSystem),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn prune_system() {}
/// Prunes the docker system on the target server, including volumes. Response: [Update].
///
/// 1. Runs `docker system prune -a -f --volumes`.

View File

@@ -9,6 +9,18 @@ use typeshare::typeshare;
use super::{BatchExecutionResponse, KomodoExecuteRequest};
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DeployStack",
description = "Deploys the target stack.",
request_body(content = DeployStack),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn deploy_stack() {}
/// Deploys the target stack. `docker compose up`. Response: [Update]
#[typeshare]
#[derive(
@@ -34,6 +46,18 @@ pub struct DeployStack {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/BatchDeployStack",
description = "Deploys multiple Stacks in parallel that match pattern.",
request_body(content = BatchDeployStack),
responses(
(status = 200, description = "The batch execution response", body = BatchExecutionResponse),
),
)]
pub fn batch_deploy_stack() {}
/// Deploys multiple Stacks in parallel that match pattern. Response: [BatchExecutionResponse].
#[typeshare]
#[derive(
@@ -59,6 +83,18 @@ pub struct BatchDeployStack {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DeployStackIfChanged",
description = "Checks deployed contents vs latest contents and deploys if changed.",
request_body(content = DeployStackIfChanged),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn deploy_stack_if_changed() {}
/// Checks deployed contents vs latest contents,
/// and only if any changes found
/// will `docker compose up`. Response: [Update]
@@ -80,6 +116,18 @@ pub struct DeployStackIfChanged {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/BatchDeployStackIfChanged",
description = "Deploys multiple Stacks if changed in parallel that match pattern.",
request_body(content = BatchDeployStackIfChanged),
responses(
(status = 200, description = "The batch execution response", body = BatchExecutionResponse),
),
)]
pub fn batch_deploy_stack_if_changed() {}
/// Deploys multiple Stacks if changed in parallel that match pattern. Response: [BatchExecutionResponse].
#[typeshare]
#[derive(
@@ -105,6 +153,18 @@ pub struct BatchDeployStackIfChanged {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PullStack",
description = "Pulls images for the target stack.",
request_body(content = PullStack),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn pull_stack() {}
/// Pulls images for the target stack. `docker compose pull`. Response: [Update]
#[typeshare]
#[derive(
@@ -125,6 +185,18 @@ pub struct PullStack {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/BatchPullStack",
description = "Pulls multiple Stacks in parallel that match pattern.",
request_body(content = BatchPullStack),
responses(
(status = 200, description = "The batch execution response", body = BatchExecutionResponse),
),
)]
pub fn batch_pull_stack() {}
/// Pulls multiple Stacks in parallel that match pattern. Response: [BatchExecutionResponse].
#[typeshare]
#[derive(
@@ -150,6 +222,18 @@ pub struct BatchPullStack {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/StartStack",
description = "Starts the target stack.",
request_body(content = StartStack),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn start_stack() {}
/// Starts the target stack. `docker compose start`. Response: [Update]
#[typeshare]
#[derive(
@@ -170,6 +254,18 @@ pub struct StartStack {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/RestartStack",
description = "Restarts the target stack.",
request_body(content = RestartStack),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn restart_stack() {}
/// Restarts the target stack. `docker compose restart`. Response: [Update]
#[typeshare]
#[derive(
@@ -190,6 +286,18 @@ pub struct RestartStack {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/PauseStack",
description = "Pauses the target stack.",
request_body(content = PauseStack),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn pause_stack() {}
/// Pauses the target stack. `docker compose pause`. Response: [Update]
#[typeshare]
#[derive(
@@ -210,6 +318,18 @@ pub struct PauseStack {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/UnpauseStack",
description = "Unpauses the target stack.",
request_body(content = UnpauseStack),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn unpause_stack() {}
/// Unpauses the target stack. `docker compose unpause`. Response: [Update].
///
/// Note. This is the only way to restart a paused container.
@@ -232,6 +352,18 @@ pub struct UnpauseStack {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/StopStack",
description = "Stops the target stack.",
request_body(content = StopStack),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn stop_stack() {}
/// Stops the target stack. `docker compose stop`. Response: [Update]
#[typeshare]
#[derive(
@@ -254,6 +386,18 @@ pub struct StopStack {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DestroyStack",
description = "Destroys the target stack.",
request_body(content = DestroyStack),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn destroy_stack() {}
/// Destoys the target stack. `docker compose down`. Response: [Update]
#[typeshare]
#[derive(
@@ -279,6 +423,18 @@ pub struct DestroyStack {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/RunStackService",
description = "Runs a one-time command against a service using docker compose run.",
request_body(content = RunStackService),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn run_stack_service() {}
/// Runs a one-time command against a service using `docker compose run`. Response: [Update]
#[typeshare]
#[derive(
@@ -331,6 +487,18 @@ fn env_parser(args: &str) -> anyhow::Result<HashMap<String, String>> {
//
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/BatchDestroyStack",
description = "Destroys multiple Stacks in parallel that match pattern.",
request_body(content = BatchDestroyStack),
responses(
(status = 200, description = "The batch execution response", body = BatchExecutionResponse),
),
)]
pub fn batch_destroy_stack() {}
/// Destroys multiple Stacks in parallel that match pattern. Response: [BatchExecutionResponse].
#[typeshare]
#[derive(
@@ -343,7 +511,7 @@ fn env_parser(args: &str) -> anyhow::Result<HashMap<String, String>> {
pub struct BatchDestroyStack {
/// Id or name or wildcard pattern or regex.
/// Supports multiline and comma delineated combinations of the above.
///d
///
/// Example:
/// ```text
/// # match all foo-* stacks