manta_server/backend_dispatcher/
cluster_template.rs

1//! [`ClusterTemplateTrait`] (BOS session template) impl for
2//! [`StaticBackendDispatcher`].
3//!
4//! Forwards to `/apis/bos/v2/sessiontemplates`. Ochami uses the trait
5//! default and returns [`Error::Message`] ("not implemented for this
6//! backend").
7
8use super::*;
9
10impl ClusterTemplateTrait for StaticBackendDispatcher {
11  /// `GET /sessiontemplates/{id}` when an id is supplied, otherwise
12  /// the full list. Returned as a `Vec` for shape parity with the
13  /// list call; a single-id lookup yields a one-element vector.
14  async fn get_template(
15    &self,
16    token: &str,
17    bos_session_template_id_opt: Option<&str>,
18  ) -> Result<Vec<BosSessionTemplate>, Error> {
19    dispatch!(self, get_template, token, bos_session_template_id_opt)
20  }
21
22  /// Fetch templates and apply client-side filtering by visible
23  /// group names, observed xname members, an exact template name, and
24  /// a max result count. BOS does not support these as native query
25  /// params, so the backend over-fetches and narrows in-process.
26  async fn get_and_filter_templates(
27    &self,
28    token: &str,
29    group_name_vec: &[String],
30    group_member_vec: &[String],
31    bos_sessiontemplate_name_opt: Option<&str>,
32    limit_number_opt: Option<&u8>,
33  ) -> Result<Vec<BosSessionTemplate>, Error> {
34    dispatch!(
35      self,
36      get_and_filter_templates,
37      token,
38      group_name_vec,
39      group_member_vec,
40      bos_sessiontemplate_name_opt,
41      limit_number_opt
42    )
43  }
44
45  /// `GET /sessiontemplates` — every template (unfiltered).
46  async fn get_all_templates(
47    &self,
48    token: &str,
49  ) -> Result<Vec<BosSessionTemplate>, Error> {
50    dispatch!(self, get_all_templates, token)
51  }
52
53  /// `PUT /sessiontemplates/{name}` — create-or-replace. Returns the
54  /// persisted template (with backend-assigned timestamps).
55  async fn put_template(
56    &self,
57    token: &str,
58    bos_template: &BosSessionTemplate,
59    bos_template_name: &str,
60  ) -> Result<BosSessionTemplate, Error> {
61    dispatch!(self, put_template, token, bos_template, bos_template_name)
62  }
63
64  /// `DELETE /sessiontemplates/{id}`.
65  async fn delete_template(
66    &self,
67    token: &str,
68    bos_template_id: &str,
69  ) -> Result<(), Error> {
70    dispatch!(self, delete_template, token, bos_template_id)
71  }
72}