use mogh_resolver::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::entities::repo::{
Repo, RepoActionState, RepoListItem, RepoQuery,
};
use super::KomodoReadRequest;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetRepo",
description = "Get a specific repo.",
request_body(content = GetRepo),
responses(
(status = 200, description = "The repo", body = crate::entities::repo::RepoSchema),
),
)]
pub fn get_repo() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(Repo)]
#[error(mogh_error::Error)]
pub struct GetRepo {
#[serde(alias = "id", alias = "name")]
pub repo: String,
}
#[typeshare]
pub type GetRepoResponse = Repo;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListRepos",
description = "List repos matching optional query.",
request_body(content = ListRepos),
responses(
(status = 200, description = "The list of repos", body = ListReposResponse),
),
)]
pub fn list_repos() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListReposResponse)]
#[error(mogh_error::Error)]
pub struct ListRepos {
#[serde(default)]
pub query: RepoQuery,
}
#[typeshare]
pub type ListReposResponse = Vec<RepoListItem>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/ListFullRepos",
description = "List repos matching optional query.",
request_body(content = ListFullRepos),
responses(
(status = 200, description = "The list of repos", body = ListFullReposResponse),
),
)]
pub fn list_full_repos() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListFullReposResponse)]
#[error(mogh_error::Error)]
pub struct ListFullRepos {
#[serde(default)]
pub query: RepoQuery,
}
#[typeshare]
pub type ListFullReposResponse = Vec<Repo>;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetRepoActionState",
description = "Get current action state for the repo.",
request_body(content = GetRepoActionState),
responses(
(status = 200, description = "The repo action state", body = GetRepoActionStateResponse),
),
)]
pub fn get_repo_action_state() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetRepoActionStateResponse)]
#[error(mogh_error::Error)]
pub struct GetRepoActionState {
#[serde(alias = "id", alias = "name")]
pub repo: String,
}
#[typeshare]
pub type GetRepoActionStateResponse = RepoActionState;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/GetReposSummary",
description = "Gets a summary of data relating to all repos.",
request_body(content = GetReposSummary),
responses(
(status = 200, description = "The repos summary", body = GetReposSummaryResponse),
),
)]
pub fn get_repos_summary() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetReposSummaryResponse)]
#[error(mogh_error::Error)]
pub struct GetReposSummary {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct GetReposSummaryResponse {
pub total: u32,
pub ok: u32,
pub cloning: u32,
pub pulling: u32,
pub building: u32,
pub failed: u32,
pub unknown: u32,
}