use std::time::Duration;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use super::restrictions::SecretRestrictions;
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub struct PostSecretRequest {
pub data: String,
#[serde_as(as = "serde_with::DurationSeconds<u64>")]
pub expires_in: Duration,
#[serde(skip_serializing_if = "Option::is_none")]
pub restrictions: Option<SecretRestrictions>,
}
impl PostSecretRequest {
pub fn new(data: String, expires_in: Duration) -> Self {
Self {
data,
expires_in,
restrictions: None,
}
}
pub fn with_restrictions(mut self, restrictions: SecretRestrictions) -> Self {
self.restrictions = Some(restrictions);
self
}
}
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub struct PostSecretResponse {
pub id: uuid::Uuid,
}
impl PostSecretResponse {
pub fn new(id: uuid::Uuid) -> Self {
Self { id }
}
}