56 lines
1.8 KiB
Rust
56 lines
1.8 KiB
Rust
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<String, String>,
|
|
pub version: Option<i64>,
|
|
// TODO add all fields
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
pub struct VersionMeta {
|
|
pub created_time: DateTime<Utc>,
|
|
pub deletion_time: Option<DateTime<Utc>>, // optional deletion time
|
|
pub destroyed: bool,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
pub struct SecretMeta {
|
|
pub cas_required: bool,
|
|
pub created_time: DateTime<Utc>,
|
|
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<Utc>,
|
|
/// User-provided key-value pairs that are used to describe arbitrary and version-agnostic information about a secret.
|
|
pub custom_metadata: Option<HashMap<String, String>>,
|
|
pub versions: Vec<VersionMeta>,
|
|
}
|
|
|
|
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![],
|
|
}
|
|
}
|
|
}
|