manta_server/backend_dispatcher/hardware_inventory.rs
1//! [`HardwareInventory`] impl for [`StaticBackendDispatcher`].
2//!
3//! Forwards to HSM's `/apis/smd/hsm/v2/Inventory/Hardware` endpoints.
4//! Both CSM and Ochami implement this trait natively.
5
6use super::*;
7
8impl HardwareInventory for StaticBackendDispatcher {
9 /// `GET /Inventory/Hardware/Query/{xname}` projected to a
10 /// `NodeSummary` (CPU model count, memory, accelerator count, …).
11 /// The thin per-node view used by listings.
12 async fn get_inventory_hardware(
13 &self,
14 auth_token: &str,
15 xname: &str,
16 ) -> Result<NodeSummary, Error> {
17 dispatch!(self, get_inventory_hardware, auth_token, xname)
18 }
19
20 /// `GET /Inventory/Hardware/Query/{xname}` with the full HSM query
21 /// parameter set — `type`, `children`, `parents`, `partition`,
22 /// `format`. Returns the raw [`HWInventory`] tree.
23 async fn get_inventory_hardware_query(
24 &self,
25 auth_token: &str,
26 xname: &str,
27 r#type: Option<&str>,
28 children: Option<bool>,
29 parents: Option<bool>,
30 partition: Option<&str>,
31 format: Option<&str>,
32 ) -> Result<HWInventory, Error> {
33 dispatch!(
34 self,
35 get_inventory_hardware_query,
36 auth_token,
37 xname,
38 r#type,
39 children,
40 parents,
41 partition,
42 format
43 )
44 }
45
46 /// `POST /Inventory/Hardware` — push a hardware-by-location list
47 /// into HSM (used by discovery / restore flows). The returned
48 /// `HsmActionResponse` reports how many records were inserted or
49 /// updated.
50 async fn post_inventory_hardware(
51 &self,
52 auth_token: &str,
53 hardware: HWInventoryByLocationList,
54 ) -> Result<HsmActionResponse, Error> {
55 dispatch!(self, post_inventory_hardware, auth_token, hardware)
56 }
57}