use derive_empty_traits::EmptyTraits;
use resolver_api::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::entities::{
NoData,
repo::{_PartialRepoConfig, Repo},
update::Update,
};
use super::KomodoWriteRequest;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Repo)]
#[error(serror::Error)]
pub struct CreateRepo {
pub name: String,
#[serde(default)]
pub config: _PartialRepoConfig,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Repo)]
#[error(serror::Error)]
pub struct CopyRepo {
pub name: String,
pub id: String,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Repo)]
#[error(serror::Error)]
pub struct DeleteRepo {
pub id: String,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Repo)]
#[error(serror::Error)]
pub struct UpdateRepo {
pub id: String,
pub config: _PartialRepoConfig,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Update)]
#[error(serror::Error)]
pub struct RenameRepo {
pub id: String,
pub name: String,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(NoData)]
#[error(serror::Error)]
pub struct RefreshRepoCache {
#[serde(alias = "id", alias = "name")]
pub repo: String,
}
#[typeshare]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub enum RepoWebhookAction {
Clone,
Pull,
Build,
}