manta_shared/types/api/
session.rs

1//! HTTP request/response bodies and CLI-built parameter structs for
2//! the CFS session endpoints (`/api/v1/sessions`).
3
4use serde::{Deserialize, Serialize};
5use utoipa::ToSchema;
6
7/// Request body for `POST /api/v1/sessions`.
8///
9/// The CLI submits this when the user runs `manta run session`; the
10/// server deserialises it in `handlers::session::create_session`.
11/// `repo_names` and `repo_last_commit_ids` are parallel-indexed —
12/// `repo_last_commit_ids[i]` is the commit SHA for `repo_names[i]`.
13/// The two vectors must therefore have the same length.
14///
15/// Paired with [`super::responses::CreateSessionResponse`].
16#[derive(Debug, Serialize, Deserialize, ToSchema)]
17pub struct CreateSessionRequest {
18  /// Explicit name for the CFS session and configuration;
19  /// auto-generated when absent.
20  pub cfs_conf_sess_name: Option<String>,
21  /// Ansible playbook filename inside the repository.
22  pub playbook_yaml_file_name: Option<String>,
23  /// Target HSM group name.
24  pub hsm_group: Option<String>,
25  /// Git repository names (parallel-indexed with
26  /// `repo_last_commit_ids`).
27  pub repo_names: Vec<String>,
28  /// Git commit SHAs matching each entry in `repo_names`.
29  pub repo_last_commit_ids: Vec<String>,
30  /// Ansible `--limit` expression restricting which xnames are
31  /// targeted (the service-layer authz check rejects group names —
32  /// pre-resolve them client-side).
33  pub ansible_limit: Option<String>,
34  /// Ansible verbosity level (e.g. `"-v"`, `"-vvv"`).
35  pub ansible_verbosity: Option<String>,
36  /// Extra arguments forwarded verbatim to `ansible-playbook`.
37  pub ansible_passthrough: Option<String>,
38}
39
40/// Typed parameters for fetching CFS sessions.
41pub struct GetSessionParams {
42  /// Group whose sessions should be returned.
43  pub group: Option<String>,
44  /// Filter to sessions whose `ansible_limit` mentions any of these
45  /// xnames. Empty means "no xname filter".
46  pub xnames: Vec<String>,
47  /// Lower-bound session age expressed as a duration string
48  /// (e.g. `"1h"`, `"2d"`).
49  pub min_age: Option<String>,
50  /// Upper-bound session age expressed as a duration string.
51  pub max_age: Option<String>,
52  /// Session type filter: `"image"` or `"runtime"`.
53  pub session_type: Option<String>,
54  /// Status filter: `"pending"`, `"running"`, or `"complete"`.
55  pub status: Option<String>,
56  /// Exact session name.
57  pub name: Option<String>,
58  /// Cap on the number of sessions returned (most recent first).
59  pub limit: Option<u8>,
60}