zlayer-types 0.14.2

Shared wire types for the ZLayer platform — API DTOs, OCI image references, and related serde types.
Documentation
//! 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,
}