covert_types/methods/system/
mod.rs

1mod entity;
2mod namespace;
3mod policy;
4
5use std::time::Duration;
6
7use serde::{Deserialize, Serialize};
8use uuid::Uuid;
9
10use crate::{
11    backend::{BackendCategory, BackendType},
12    mount::MountConfig,
13    state::StorageState,
14    token::Token,
15};
16pub use entity::*;
17pub use namespace::*;
18pub use policy::*;
19
20#[derive(Debug, Serialize, Deserialize)]
21pub struct InitializeParams {
22    pub shares: u8,
23    pub threshold: u8,
24}
25
26#[derive(Debug, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum InitializeResponse {
29    NewKeyShares(InitializedKeyShares),
30    ExistingKey(InitializedWithExistingKey),
31}
32
33#[derive(Debug, Serialize, Deserialize)]
34pub struct InitializedKeyShares {
35    pub shares: Vec<String>,
36}
37
38#[derive(Debug, Serialize, Deserialize)]
39pub struct InitializedWithExistingKey {
40    pub message: String,
41}
42
43#[derive(Debug, Serialize, Deserialize)]
44pub struct UnsealParams {
45    pub shares: Vec<String>,
46}
47
48#[derive(Debug, Serialize, Deserialize)]
49#[serde(tag = "unseal_status", content = "data")]
50pub enum UnsealResponse {
51    #[serde(rename = "complete")]
52    Complete { root_token: Token },
53    #[serde(rename = "in progress")]
54    InProgress {
55        threshold: u8,
56        key_shares_total: u8,
57        key_shares_provided: usize,
58    },
59}
60
61#[derive(Debug, Serialize, Deserialize)]
62pub struct SealResponse {
63    pub message: String,
64}
65
66#[derive(Debug, Serialize, Deserialize)]
67pub struct StatusResponse {
68    pub state: StorageState,
69}
70
71#[derive(Debug, Deserialize, Serialize)]
72pub struct CreateMountParams {
73    #[serde(rename = "type")]
74    pub variant: BackendType,
75    #[serde(default)]
76    pub config: MountConfig,
77}
78
79#[derive(Debug, Deserialize, Serialize)]
80pub struct CreateMountResponse {
81    #[serde(rename = "type")]
82    pub variant: BackendType,
83    #[serde(default)]
84    pub config: MountConfig,
85    pub id: Uuid,
86    pub path: String,
87}
88
89#[derive(Debug, Deserialize, Serialize)]
90pub struct UpdateMountParams {
91    pub config: MountConfig,
92}
93
94#[derive(Debug, Deserialize, Serialize)]
95pub struct UpdateMountResponse {
96    #[serde(rename = "type")]
97    pub variant: BackendType,
98    #[serde(default)]
99    pub config: MountConfig,
100    pub id: Uuid,
101    pub path: String,
102}
103
104#[derive(Debug, Serialize, Deserialize)]
105pub struct MountsListResponse {
106    pub auth: Vec<MountsListItemResponse>,
107    pub secret: Vec<MountsListItemResponse>,
108}
109
110#[derive(Debug, Serialize, Deserialize)]
111pub struct DisableMountResponse {
112    pub mount: MountsListItemResponse,
113}
114
115#[derive(Debug, Serialize, Deserialize)]
116pub struct MountsListItemResponse {
117    pub id: Uuid,
118    pub path: String,
119    pub category: BackendCategory,
120    #[serde(rename = "type")]
121    pub variant: BackendType,
122    pub config: MountConfig,
123}
124
125#[derive(Debug, Serialize, Deserialize)]
126pub struct LeaseEntry {
127    pub id: String,
128    pub issued_mount_path: String,
129    pub issue_time: String,
130    pub expire_time: String,
131    pub last_renewal_time: String,
132}
133
134#[derive(Debug, Serialize, Deserialize)]
135pub struct RevokedLeasesResponse {
136    pub leases: Vec<LeaseEntry>,
137}
138
139#[derive(Debug, Serialize, Deserialize)]
140pub struct RevokedLeaseResponse {
141    pub lease: LeaseEntry,
142}
143
144#[derive(Debug, Serialize, Deserialize)]
145pub struct LookupLeaseResponse {
146    pub lease: LeaseEntry,
147}
148
149#[derive(Debug, Serialize, Deserialize)]
150pub struct ListLeasesResponse {
151    pub leases: Vec<LeaseEntry>,
152}
153
154#[derive(Debug, Serialize, Deserialize)]
155pub struct RenewLeaseParams {
156    #[serde(with = "humantime_serde")]
157    pub ttl: Option<Duration>,
158}
159
160#[derive(Debug, Serialize, Deserialize)]
161pub struct RenewLeaseResponse {
162    pub lease: LeaseEntry,
163}