use mogh_resolver::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::entities::{I64, onboarding_key::OnboardingKey};
use super::KomodoWriteRequest;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/CreateOnboardingKey",
description = "**Admin only.** Create a Server onboarding key.",
request_body(content = CreateOnboardingKey),
responses(
(status = 200, description = "The create response", body = CreateOnboardingKeyResponse),
),
)]
pub fn create_onboarding_key() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(CreateOnboardingKeyResponse)]
#[error(mogh_error::Error)]
pub struct CreateOnboardingKey {
pub name: String,
#[serde(default)]
pub expires: I64,
pub private_key: Option<String>,
#[serde(default)]
pub tags: Vec<String>,
#[serde(default)]
pub privileged: bool,
#[serde(default)]
pub copy_server: String,
#[serde(default)]
pub create_builder: bool,
}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct CreateOnboardingKeyResponse {
pub private_key: String,
pub created: OnboardingKey,
}
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/UpdateOnboardingKey",
description = "**Admin only.** Update an onboarding key.",
request_body(content = UpdateOnboardingKey),
responses(
(status = 200, description = "The updated onboarding key", body = UpdateOnboardingKeyResponse),
),
)]
pub fn update_onboarding_key() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(UpdateOnboardingKeyResponse)]
#[error(mogh_error::Error)]
pub struct UpdateOnboardingKey {
pub public_key: String,
pub enabled: Option<bool>,
pub name: Option<String>,
pub expires: Option<I64>,
pub tags: Option<Vec<String>>,
pub privileged: Option<bool>,
pub copy_server: Option<String>,
pub create_builder: Option<bool>,
}
impl UpdateOnboardingKey {
pub fn is_none(&self) -> bool {
self.enabled.is_none()
&& self.name.is_none()
&& self.expires.is_none()
&& self.tags.is_none()
&& self.privileged.is_none()
&& self.copy_server.is_none()
&& self.create_builder.is_none()
}
}
#[typeshare]
pub type UpdateOnboardingKeyResponse = OnboardingKey;
#[cfg(feature = "utoipa")]
#[utoipa::path(
post,
path = "/DeleteOnboardingKey",
description = "**Admin only.** Delete an onboarding key.",
request_body(content = DeleteOnboardingKey),
responses(
(status = 200, description = "The deleted onboarding key", body = DeleteOnboardingKeyResponse),
),
)]
pub fn delete_onboarding_key() {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoWriteRequest)]
#[response(DeleteOnboardingKeyResponse)]
#[error(mogh_error::Error)]
pub struct DeleteOnboardingKey {
pub public_key: String,
}
#[typeshare]
pub type DeleteOnboardingKeyResponse = OnboardingKey;