use mogh_resolver::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::entities::{
NoData,
repo::{_PartialRepoConfig, Repo},
update::Update,
};
use super::KomodoWriteRequest;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/CreateRepo",
description = "Create a repo.",
request_body(content = CreateRepo),
responses(
(status = 200, description = "The new repo", body = crate::entities::repo::RepoSchema),
),
)]
pub fn create_repo() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Repo)]
#[error(mogh_error::Error)]
pub struct CreateRepo {
pub name: String,
#[serde(default)]
pub config: _PartialRepoConfig,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/CopyRepo",
description = "Copy a repo.",
request_body(content = CopyRepo),
responses(
(status = 200, description = "The new repo", body = crate::entities::repo::RepoSchema),
),
)]
pub fn copy_repo() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Repo)]
#[error(mogh_error::Error)]
pub struct CopyRepo {
pub name: String,
pub id: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DeleteRepo",
description = "Delete a repo.",
request_body(content = DeleteRepo),
responses(
(status = 200, description = "The deleted repo", body = crate::entities::repo::RepoSchema),
),
)]
pub fn delete_repo() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Repo)]
#[error(mogh_error::Error)]
pub struct DeleteRepo {
pub id: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/UpdateRepo",
description = "Update a repo.",
request_body(content = UpdateRepo),
responses(
(status = 200, description = "The updated repo", body = crate::entities::repo::RepoSchema),
),
)]
pub fn update_repo() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Repo)]
#[error(mogh_error::Error)]
pub struct UpdateRepo {
pub id: String,
pub config: _PartialRepoConfig,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/RenameRepo",
description = "Rename a repo.",
request_body(content = RenameRepo),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn rename_repo() {}
#[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 RenameRepo {
pub id: String,
pub name: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/RefreshRepoCache",
description = "Trigger a refresh of the cached latest hash and message.",
request_body(content = RefreshRepoCache),
responses(
(status = 200, description = "Repo cache refreshed.", body = NoData),
),
)]
pub fn refresh_repo_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 RefreshRepoCache {
#[serde(alias = "id", alias = "name")]
pub repo: String,
}
#[typeshare]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum RepoWebhookAction {
Clone,
Pull,
Build,
}