use super::responses::{
ListSecretsResponse, ReadConfigurationResponse, ReadSecretMetadataResponse, ReadSecretResponse,
SecretVersionMetadata,
};
use rustify_derive::Endpoint;
use serde_json::Value;
use std::collections::HashMap;
use std::fmt::Debug;
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(path = "{self.mount}/config", method = "POST", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct SetConfigurationRequest {
#[endpoint(skip)]
pub mount: String,
pub delete_version_after: Option<String>,
pub cas_required: Option<bool>,
pub max_versions: Option<u64>,
}
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/config",
response = "ReadConfigurationResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ReadConfigurationRequest {
#[endpoint(skip)]
pub mount: String,
}
#[derive(Builder, Debug, Endpoint)]
#[endpoint(
path = "{self.mount}/data/{self.path}",
response = "ReadSecretResponse",
builder = "true"
)]
#[builder(setter(into))]
pub struct ReadSecretRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub path: String,
#[builder(default = "None")]
#[endpoint(query)]
pub version: Option<u64>,
}
#[derive(Builder, Debug, Endpoint)]
#[endpoint(
path = "{self.mount}/data/{self.path}",
response = "SecretVersionMetadata",
method = "POST",
builder = "true"
)]
#[builder(setter(into))]
pub struct SetSecretRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub path: String,
pub data: Value,
#[builder(setter(strip_option), default)]
pub options: Option<SetSecretRequestOptions>,
}
#[derive(Builder, Clone, Debug, serde::Serialize)]
#[builder(setter(into))]
pub struct SetSecretRequestOptions {
pub cas: u32,
}
#[derive(Builder, Debug, Endpoint)]
#[endpoint(
path = "{self.mount}/data/{self.path}",
method = "DELETE",
builder = "true"
)]
#[builder(setter(into))]
pub struct DeleteLatestSecretVersionRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub path: String,
}
#[derive(Builder, Debug, Endpoint)]
#[endpoint(
path = "{self.mount}/delete/{self.path}",
method = "POST",
builder = "true"
)]
#[builder(setter(into))]
pub struct DeleteSecretVersionsRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub path: String,
pub versions: Vec<u64>,
}
#[derive(Builder, Debug, Endpoint)]
#[endpoint(
path = "{self.mount}/undelete/{self.path}",
method = "POST",
builder = "true"
)]
#[builder(setter(into))]
pub struct UndeleteSecretVersionsRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub path: String,
pub versions: Vec<u64>,
}
#[derive(Builder, Debug, Endpoint)]
#[endpoint(
path = "{self.mount}/destroy/{self.path}",
method = "POST",
builder = "true"
)]
#[builder(setter(into))]
pub struct DestroySecretVersionsRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub path: String,
pub versions: Vec<u64>,
}
#[derive(Builder, Debug, Endpoint)]
#[endpoint(
path = "{self.mount}/metadata/{self.path}",
response = "ListSecretsResponse",
method = "LIST",
builder = "true"
)]
#[builder(setter(into))]
pub struct ListSecretsRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub path: String,
}
#[derive(Builder, Debug, Endpoint)]
#[endpoint(
path = "{self.mount}/metadata/{self.path}",
response = "ReadSecretMetadataResponse",
builder = "true"
)]
#[builder(setter(into))]
pub struct ReadSecretMetadataRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub path: String,
}
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/metadata/{self.path}",
method = "POST",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct SetSecretMetadataRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub path: String,
pub max_versions: Option<u64>,
pub cas_required: Option<bool>,
pub delete_version_after: Option<String>,
pub custom_metadata: Option<HashMap<String, String>>,
}
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/metadata/{self.path}",
method = "DELETE",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct DeleteSecretMetadataRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub path: String,
}