use serde::{Deserialize, Serialize};
use super::ApiKey;
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ListKeysRequest {
pub api_id: String,
pub owner_id: Option<String>,
pub limit: Option<usize>,
pub cursor: Option<String>,
pub revalidate_cache: Option<bool>,
}
impl ListKeysRequest {
#[must_use]
pub fn new<T: Into<String>>(api_id: T) -> Self {
Self {
api_id: api_id.into(),
owner_id: None,
limit: None,
cursor: None,
revalidate_cache: None,
}
}
#[must_use]
pub fn set_limit(mut self, limit: usize) -> Self {
self.limit = Some(limit);
self
}
#[must_use]
pub fn set_cursor<T: Into<String>>(mut self, cursor: T) -> Self {
self.cursor = Some(cursor.into());
self
}
#[must_use]
pub fn set_owner_id<T: Into<String>>(mut self, owner_id: T) -> Self {
self.owner_id = Some(owner_id.into());
self
}
#[must_use]
pub fn set_revalidate_cache(mut self, revalidate_cache: bool) -> Self {
self.revalidate_cache = Some(revalidate_cache);
self
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct ListKeysResponse {
pub keys: Vec<ApiKey>,
pub total: usize,
pub cursor: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GetApiRequest {
pub api_id: String,
}
impl GetApiRequest {
#[must_use]
pub fn new<T: Into<String>>(api_id: T) -> Self {
Self {
api_id: api_id.into(),
}
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct GetApiResponse {
#[serde(rename = "id")]
pub api_id: String,
pub name: String,
#[serde(rename = "workspaceId")]
pub workspace_id: String,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DeleteApiRequest {
pub api_id: String,
}
impl DeleteApiRequest {
#[must_use]
pub fn new<T: Into<String>>(api_id: T) -> Self {
Self {
api_id: api_id.into(),
}
}
}