]>
Commit | Line | Data |
---|---|---|
39c5db7f | 1 | use serde::{Deserialize, Serialize}; |
60643023 | 2 | use serde_json::Value; |
39c5db7f | 3 | |
6ef1b649 | 4 | use proxmox_schema::{api, ApiType, Schema, StringSchema, ApiStringFormat}; |
39c5db7f | 5 | |
6227654a | 6 | use pbs_api_types::{ |
39c5db7f DM |
7 | DNS_ALIAS_FORMAT, DNS_NAME_FORMAT, PROXMOX_SAFE_ID_FORMAT, |
8 | }; | |
9 | ||
10 | #[api( | |
11 | properties: { | |
12 | "domain": { format: &DNS_NAME_FORMAT }, | |
13 | "alias": { | |
14 | optional: true, | |
15 | format: &DNS_ALIAS_FORMAT, | |
16 | }, | |
17 | "plugin": { | |
18 | optional: true, | |
19 | format: &PROXMOX_SAFE_ID_FORMAT, | |
20 | }, | |
21 | }, | |
22 | default_key: "domain", | |
23 | )] | |
24 | #[derive(Deserialize, Serialize)] | |
25 | /// A domain entry for an ACME certificate. | |
26 | pub struct AcmeDomain { | |
27 | /// The domain to certify for. | |
28 | pub domain: String, | |
29 | ||
30 | /// The domain to use for challenges instead of the default acme challenge domain. | |
31 | /// | |
32 | /// This is useful if you use CNAME entries to redirect `_acme-challenge.*` domains to a | |
33 | /// different DNS server. | |
34 | #[serde(skip_serializing_if = "Option::is_none")] | |
35 | pub alias: Option<String>, | |
36 | ||
37 | /// The plugin to use to validate this domain. | |
38 | /// | |
39 | /// Empty means standalone HTTP validation is used. | |
40 | #[serde(skip_serializing_if = "Option::is_none")] | |
41 | pub plugin: Option<String>, | |
42 | } | |
43 | ||
44 | pub const ACME_DOMAIN_PROPERTY_SCHEMA: Schema = StringSchema::new( | |
45 | "ACME domain configuration string") | |
46 | .format(&ApiStringFormat::PropertyString(&AcmeDomain::API_SCHEMA)) | |
47 | .schema(); | |
48 | ||
49 | #[api( | |
50 | properties: { | |
51 | name: { type: String }, | |
52 | url: { type: String }, | |
53 | }, | |
54 | )] | |
55 | /// An ACME directory endpoint with a name and URL. | |
56 | #[derive(Serialize)] | |
57 | pub struct KnownAcmeDirectory { | |
58 | /// The ACME directory's name. | |
59 | pub name: &'static str, | |
60 | ||
61 | /// The ACME directory's endpoint URL. | |
62 | pub url: &'static str, | |
63 | } | |
64 | ||
6ef1b649 | 65 | proxmox_schema::api_string_type! { |
ee0c5c8e WB |
66 | #[api(format: &PROXMOX_SAFE_ID_FORMAT)] |
67 | /// ACME account name. | |
68 | #[derive(Clone, Eq, PartialEq, Hash, Deserialize, Serialize)] | |
69 | #[serde(transparent)] | |
70 | pub struct AcmeAccountName(String); | |
39c5db7f | 71 | } |
60643023 TL |
72 | |
73 | #[api( | |
74 | properties: { | |
75 | schema: { | |
76 | type: Object, | |
77 | additional_properties: true, | |
78 | properties: {}, | |
79 | }, | |
80 | type: { | |
81 | type: String, | |
82 | }, | |
83 | }, | |
84 | )] | |
85 | #[derive(Serialize)] | |
86 | /// Schema for an ACME challenge plugin. | |
87 | pub struct AcmeChallengeSchema { | |
88 | /// Plugin ID. | |
89 | pub id: String, | |
90 | ||
91 | /// Human readable name, falls back to id. | |
92 | pub name: String, | |
93 | ||
94 | /// Plugin Type. | |
95 | #[serde(rename = "type")] | |
96 | pub ty: &'static str, | |
97 | ||
98 | /// The plugin's parameter schema. | |
99 | pub schema: Value, | |
100 | } |