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