use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, hash::Hash, vec}; #[derive(Serialize, Deserialize, Debug)] pub struct KvSecret { // TODO: maybe change later for field validation etc. pub data: String, // TODO: options for secrets // pub options: HashMap, pub version: Option, // TODO add all fields } #[derive(Serialize, Deserialize, Debug)] pub struct VersionMeta { pub created_time: DateTime, pub deletion_time: Option>, // optional deletion time pub destroyed: bool, } #[derive(Serialize, Deserialize, Debug)] pub struct SecretMeta { pub cas_required: bool, pub created_time: DateTime, pub current_version: i64, /// In Hashicorp: /// If not set, the backend's configured delete_version_after is used. /// Cannot be greater than the backend's delete_version_after // TODO: implement duration type pub delete_version_after: String, // TODO https://developer.hashicorp.com/vault/docs/concepts/duration-format pub max_versions: i64, pub oldest_version: i64, pub updated_time: DateTime, /// User-provided key-value pairs that are used to describe arbitrary and version-agnostic information about a secret. pub custom_metadata: Option>, pub versions: Vec, } impl Default for SecretMeta { fn default() -> Self { let current = Utc::now(); SecretMeta { cas_required: false, created_time: current, current_version: 1, delete_version_after: "24h00m00s".to_string(), max_versions: 10, oldest_version: 1, updated_time: current, custom_metadata: None, versions: vec![], } } }