Skip to main content

app_facade_api/
runtime.rs

1use serde::{Deserialize, Serialize};
2
3pub const STATUS_CONTRACT: &str = "mhome.runtime.status.v1";
4pub const STATUS_LIST_TARGET: &str = "/app/runtime/status/list";
5pub const STATUS_CHANGED_TARGET: &str = "/app/runtime/status/changed";
6
7#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8#[serde(rename_all = "camelCase")]
9pub enum StatusResourceType {
10    NodeInstance,
11    NodeRuntime,
12    ManagedService,
13    HubConnection,
14    ScopeConnection,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
18#[serde(rename_all = "camelCase")]
19pub struct StatusResource {
20    pub r#type: StatusResourceType,
21    pub id: String,
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
25#[serde(rename_all = "camelCase")]
26pub struct StatusPayload {
27    pub contract: String,
28    pub scope_id: String,
29    pub hub_generation: String,
30    pub hub_revision: u64,
31    pub observed_at_ms: i64,
32    pub resource: StatusResource,
33    pub deleted: bool,
34    #[serde(default)]
35    pub snapshot: Option<serde_json::Value>,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
39#[serde(rename_all = "camelCase")]
40pub struct StatusListResponse {
41    pub contract: String,
42    pub scope_id: String,
43    pub hub_generation: String,
44    #[serde(default)]
45    pub resources: Vec<StatusPayload>,
46    pub observed_at_ms: i64,
47}