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#[derive(Debug, Serialize, Deserialize, ToSchema)]
14pub struct CreateSessionRequest {
15 /// Explicit name for the CFS session and configuration;
16 /// auto-generated when absent.
17 pub cfs_conf_sess_name: Option<String>,
18 /// Ansible playbook filename inside the repository.
19 pub playbook_yaml_file_name: Option<String>,
20 /// Target HSM group name.
21 pub hsm_group: Option<String>,
22 /// Git repository names (parallel-indexed with
23 /// `repo_last_commit_ids`).
24 pub repo_names: Vec<String>,
25 /// Git commit SHAs matching each entry in `repo_names`.
26 pub repo_last_commit_ids: Vec<String>,
27 /// Ansible `--limit` expression restricting which xnames are
28 /// targeted (the service-layer authz check rejects group names —
29 /// pre-resolve them client-side).
30 pub ansible_limit: Option<String>,
31 /// Ansible verbosity level (e.g. `"-v"`, `"-vvv"`).
32 pub ansible_verbosity: Option<String>,
33 /// Extra arguments forwarded verbatim to `ansible-playbook`.
34 pub ansible_passthrough: Option<String>,
35}
36
37/// Typed parameters for fetching CFS sessions.
38pub struct GetSessionParams {
39 /// Group whose sessions should be returned.
40 pub group: Option<String>,
41 /// Filter to sessions whose `ansible_limit` mentions any of these
42 /// xnames. Empty means "no xname filter".
43 pub xnames: Vec<String>,
44 /// Lower-bound session age expressed as a duration string
45 /// (e.g. `"1h"`, `"2d"`).
46 pub min_age: Option<String>,
47 /// Upper-bound session age expressed as a duration string.
48 pub max_age: Option<String>,
49 /// Session type filter: `"image"` or `"runtime"`.
50 pub session_type: Option<String>,
51 /// Status filter: `"pending"`, `"running"`, or `"complete"`.
52 pub status: Option<String>,
53 /// Exact session name.
54 pub name: Option<String>,
55 /// Cap on the number of sessions returned (most recent first).
56 pub limit: Option<u8>,
57}