use std::sync::Arc;
use crate::error::Result;
use crate::http::Config;
use crate::types::{
list_query, ApiKey, ApiKeyToken, CreateApiKeyOptions, DeleteApiKeyResponse, List, ListOptions,
};
#[derive(Clone)]
pub struct ApiKeys(pub(crate) Arc<Config>);
impl ApiKeys {
pub async fn create(&self, api_key: &CreateApiKeyOptions) -> Result<ApiKeyToken> {
self.0.post(&["api-keys"], api_key).await
}
pub async fn list(&self, options: Option<&ListOptions>) -> Result<List<ApiKey>> {
self.0.get(&["api-keys"], &list_query(options)).await
}
pub async fn delete(&self, id: &str) -> Result<DeleteApiKeyResponse> {
self.0.delete(&["api-keys", id]).await
}
}