use clap::Parser;
use mogh_resolver::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::entities::{
sync::{_PartialResourceSyncConfig, ResourceSync},
update::Update,
};
use super::KomodoWriteRequest;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/CreateResourceSync",
description = "Create a resource sync.",
request_body(content = CreateResourceSync),
responses(
(status = 200, description = "The created resource sync", body = crate::entities::sync::ResourceSyncSchema),
),
)]
pub fn create_resource_sync() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(ResourceSync)]
#[error(mogh_error::Error)]
pub struct CreateResourceSync {
pub name: String,
#[serde(default)]
pub config: _PartialResourceSyncConfig,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/CopyResourceSync",
description = "Copy a resource sync.",
request_body(content = CopyResourceSync),
responses(
(status = 200, description = "The copied resource sync", body = crate::entities::sync::ResourceSyncSchema),
),
)]
pub fn copy_resource_sync() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(ResourceSync)]
#[error(mogh_error::Error)]
pub struct CopyResourceSync {
pub name: String,
pub id: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DeleteResourceSync",
description = "Delete a resource sync.",
request_body(content = DeleteResourceSync),
responses(
(status = 200, description = "The deleted resource sync", body = crate::entities::sync::ResourceSyncSchema),
),
)]
pub fn delete_resource_sync() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(ResourceSync)]
#[error(mogh_error::Error)]
pub struct DeleteResourceSync {
pub id: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/UpdateResourceSync",
description = "Update a resource sync.",
request_body(content = UpdateResourceSync),
responses(
(status = 200, description = "The updated resource sync", body = crate::entities::sync::ResourceSyncSchema),
),
)]
pub fn update_resource_sync() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(ResourceSync)]
#[error(mogh_error::Error)]
pub struct UpdateResourceSync {
pub id: String,
pub config: _PartialResourceSyncConfig,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/RenameResourceSync",
description = "Rename a resource sync.",
request_body(content = RenameResourceSync),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn rename_resource_sync() {}
#[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 RenameResourceSync {
pub id: String,
pub name: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/RefreshResourceSyncPending",
description = "Refresh resource sync pending state.",
request_body(content = RefreshResourceSyncPending),
responses(
(status = 200, description = "The refreshed sync", body = crate::entities::sync::ResourceSyncSchema),
),
)]
pub fn refresh_resource_sync_pending() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(ResourceSync)]
#[error(mogh_error::Error)]
pub struct RefreshResourceSyncPending {
#[serde(alias = "id", alias = "name")]
pub sync: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/WriteSyncFileContents",
description = "Write to the sync toml file contents.",
request_body(content = WriteSyncFileContents),
responses(
(status = 200, description = "The update result", body = Update),
),
)]
pub fn write_sync_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 WriteSyncFileContents {
#[serde(alias = "id", alias = "name")]
pub sync: String,
pub resource_path: String,
pub file_path: String,
pub contents: String,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/CommitSync",
description = "Exports matching resources, and writes to the target sync's resource file.",
request_body(content = CommitSync),
responses(
(status = 200, description = "The update", body = Update),
),
)]
pub fn commit_sync() {}
#[typeshare]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, Resolve, Parser,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(Update)]
#[error(mogh_error::Error)]
pub struct CommitSync {
#[serde(alias = "id", alias = "name")]
pub sync: String,
}
#[typeshare]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum SyncWebhookAction {
Refresh,
Sync,
}