1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Edge-peer API DTOs.
//!
//! Wire types for the edge-peer endpoints exposed by `zlayer-api`: minting,
//! listing, and revoking short-lived unprivileged `WireGuard` edge peers on a
//! node. NOT related to [`crate::api::edge_cache`] — that module is the
//! CDN-style edge-cache eligibility surface; "edge" here means an ephemeral
//! overlay PEER, not a cache node.
//!
//! The payload types ([`EdgeConfig`], [`EdgePeerStatus`]) live in
//! [`crate::overlayd`] — they are the same shapes that cross the overlayd IPC
//! channel, re-exposed over HTTP without translation.
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
use crate::overlayd::{EdgeConfig, EdgePeerStatus};
/// Request body for the edge-peer mint endpoint.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct EdgeMintRequest {
/// Caller-chosen handle the peer is minted (and later revoked) under.
pub name: String,
/// Seconds until the peer expires and is swept from the mesh.
pub ttl_secs: u64,
/// Overlay CIDRs the edge peer may reach. May be omitted (defaults to
/// empty).
#[serde(default)]
pub allow: Vec<String>,
}
/// Response body for a successful edge-peer mint.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct EdgeMintResponse {
/// The minted peer's full portable config.
pub config: EdgeConfig,
/// The same config in `zledge1.` token form ([`EdgeConfig::to_token`]) —
/// ready to hand to the edge process as a single CLI flag / env var.
pub token: String,
}
/// Response body for the edge-peer list endpoint.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct EdgeListResponse {
/// Every currently minted edge peer on the node.
pub peers: Vec<EdgePeerStatus>,
}
/// Response body for the edge-peer revoke endpoint.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct EdgeRevokeResponse {
/// `true` when a live peer was actually removed; `false` when the name
/// was unknown or already expired (revocation is idempotent).
pub removed: bool,
}