api: move AcmeChallengeSchema to acme types module
It will be reused in a later patch in another module which should not depend on the actual API implementation (ugly and cyclic) Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
875d53ef6c
commit
60643023ad
@ -14,7 +14,7 @@ use proxmox_acme_rs::account::AccountData as AcmeAccountData;
|
||||
use proxmox_acme_rs::Account;
|
||||
|
||||
use crate::acme::AcmeClient;
|
||||
use crate::api2::types::{AcmeAccountName, Authid, KnownAcmeDirectory};
|
||||
use crate::api2::types::{AcmeAccountName, AcmeChallengeSchema, Authid, KnownAcmeDirectory};
|
||||
use crate::config::acl::PRIV_SYS_MODIFY;
|
||||
use crate::config::acme::plugin::{
|
||||
DnsPlugin, DnsPluginCore, DnsPluginCoreUpdater, PLUGIN_ID_SCHEMA,
|
||||
@ -386,35 +386,6 @@ fn get_directories() -> Result<&'static [KnownAcmeDirectory], Error> {
|
||||
Ok(crate::config::acme::KNOWN_ACME_DIRECTORIES)
|
||||
}
|
||||
|
||||
#[api(
|
||||
properties: {
|
||||
schema: {
|
||||
type: Object,
|
||||
additional_properties: true,
|
||||
properties: {},
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
)]
|
||||
#[derive(Serialize)]
|
||||
/// Schema for an ACME challenge plugin.
|
||||
pub struct ChallengeSchema {
|
||||
/// Plugin ID.
|
||||
id: String,
|
||||
|
||||
/// Human readable name, falls back to id.
|
||||
name: String,
|
||||
|
||||
/// Plugin Type.
|
||||
#[serde(rename = "type")]
|
||||
ty: &'static str,
|
||||
|
||||
/// The plugin's parameter schema.
|
||||
schema: Value,
|
||||
}
|
||||
|
||||
#[api(
|
||||
access: {
|
||||
permission: &Permission::Anybody,
|
||||
@ -422,14 +393,14 @@ pub struct ChallengeSchema {
|
||||
returns: {
|
||||
description: "ACME Challenge Plugin Shema.",
|
||||
type: Array,
|
||||
items: { type: ChallengeSchema },
|
||||
items: { type: AcmeChallengeSchema },
|
||||
},
|
||||
)]
|
||||
/// Get named known ACME directory endpoints.
|
||||
fn get_challenge_schema() -> Result<Vec<ChallengeSchema>, Error> {
|
||||
fn get_challenge_schema() -> Result<Vec<AcmeChallengeSchema>, Error> {
|
||||
let mut out = Vec::new();
|
||||
crate::config::acme::foreach_dns_plugin(|id| {
|
||||
out.push(ChallengeSchema {
|
||||
out.push(AcmeChallengeSchema {
|
||||
id: id.to_owned(),
|
||||
name: id.to_owned(),
|
||||
ty: "dns",
|
||||
|
@ -1,4 +1,5 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::api::{api, schema::{Schema, StringSchema, ApiStringFormat}};
|
||||
|
||||
@ -68,3 +69,32 @@ proxmox::api_string_type! {
|
||||
#[serde(transparent)]
|
||||
pub struct AcmeAccountName(String);
|
||||
}
|
||||
|
||||
#[api(
|
||||
properties: {
|
||||
schema: {
|
||||
type: Object,
|
||||
additional_properties: true,
|
||||
properties: {},
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
)]
|
||||
#[derive(Serialize)]
|
||||
/// Schema for an ACME challenge plugin.
|
||||
pub struct AcmeChallengeSchema {
|
||||
/// Plugin ID.
|
||||
pub id: String,
|
||||
|
||||
/// Human readable name, falls back to id.
|
||||
pub name: String,
|
||||
|
||||
/// Plugin Type.
|
||||
#[serde(rename = "type")]
|
||||
pub ty: &'static str,
|
||||
|
||||
/// The plugin's parameter schema.
|
||||
pub schema: Value,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user