manta_server/backend_dispatcher/
component.rs

1//! [`ComponentTrait`] impl for [`StaticBackendDispatcher`].
2//!
3//! Forwards to the HSM (Hardware State Manager)
4//! `/apis/smd/hsm/v2/State/Components` API. Both CSM and Ochami
5//! implement this trait natively.
6
7use super::*;
8
9impl ComponentTrait for StaticBackendDispatcher {
10  /// `GET /State/Components?type=Node` — every node in HSM. When
11  /// `nid_only` is set, the backend forwards `nid_only=true` to the
12  /// HSM which limits the returned representation to the NID field.
13  async fn get_all_nodes(
14    &self,
15    auth_token: &str,
16    nid_only: Option<&str>,
17  ) -> Result<NodeMetadataArray, Error> {
18    dispatch!(self, get_all_nodes, auth_token, nid_only)
19  }
20
21  /// RBAC-aware node listing: HSM filtered to the components the
22  /// caller's groups grant access to. Used to populate the user's
23  /// visible inventory after auth.
24  async fn get_node_metadata_available(
25    &self,
26    auth_token: &str,
27  ) -> Result<Vec<Component>, Error> {
28    dispatch!(self, get_node_metadata_available, auth_token)
29  }
30
31  /// `GET /State/Components` with the full HSM filter set forwarded
32  /// verbatim. Every `Option<&str>` maps 1:1 to a query parameter on
33  /// the upstream endpoint; the `*_only` parameters restrict the
34  /// returned fields (HSM's "lite" projections).
35  async fn get(
36    &self,
37    auth_token: &str,
38    id: Option<&str>,
39    r#type: Option<&str>,
40    state: Option<&str>,
41    flag: Option<&str>,
42    role: Option<&str>,
43    subrole: Option<&str>,
44    enabled: Option<&str>,
45    software_status: Option<&str>,
46    subtype: Option<&str>,
47    arch: Option<&str>,
48    class: Option<&str>,
49    nid: Option<&str>,
50    nid_start: Option<&str>,
51    nid_end: Option<&str>,
52    partition: Option<&str>,
53    group: Option<&str>,
54    state_only: Option<&str>,
55    flag_only: Option<&str>,
56    role_only: Option<&str>,
57    nid_only: Option<&str>,
58  ) -> Result<NodeMetadataArray, Error> {
59    dispatch!(
60      self,
61      get,
62      auth_token,
63      id,
64      r#type,
65      state,
66      flag,
67      role,
68      subrole,
69      enabled,
70      software_status,
71      subtype,
72      arch,
73      class,
74      nid,
75      nid_start,
76      nid_end,
77      partition,
78      group,
79      state_only,
80      flag_only,
81      role_only,
82      nid_only
83    )
84  }
85
86  /// `POST /State/Components` — bulk-create node components.
87  async fn post_nodes(
88    &self,
89    auth_token: &str,
90    component: ComponentArrayPostArray,
91  ) -> Result<(), Error> {
92    dispatch!(self, post_nodes, auth_token, component)
93  }
94
95  /// `DELETE /State/Components/{id}` — remove a single component
96  /// (typically an xname). The returned `HsmActionResponse` reports
97  /// how many records were affected.
98  async fn delete_node(
99    &self,
100    auth_token: &str,
101    id: &str,
102  ) -> Result<HsmActionResponse, Error> {
103    dispatch!(self, delete_node, auth_token, id)
104  }
105
106  /// Resolve a NID expression (single id, range, or regex when
107  /// `is_regex`) to xnames by scanning HSM nodes. The matching logic
108  /// runs client-side because HSM's NID query parameter does not
109  /// support ranges or patterns.
110  async fn nid_to_xname(
111    &self,
112    auth_token: &str,
113    user_input_nid: &str,
114    is_regex: bool,
115  ) -> Result<Vec<String>, Error> {
116    dispatch!(self, nid_to_xname, auth_token, user_input_nid, is_regex)
117  }
118}