use std::sync::Arc;
use crate::client::InnerClient;
use crate::error::CencoriError;
use crate::types::{APIKey, CreateAPIKeyParams, KeyUsageStats};
const MANAGEMENT_AUTH_ERROR: &str =
"API-key management is not available with a project API key. Use the Cencori dashboard until a separately scoped management credential is supported.";
#[derive(Debug, Clone)]
pub struct APIKeysModule {
_inner: Arc<InnerClient>,
}
impl APIKeysModule {
pub(crate) fn new(inner: Arc<InnerClient>) -> Self {
Self { _inner: inner }
}
fn unsupported<T>() -> Result<T, CencoriError> {
Err(CencoriError::NotImplemented(MANAGEMENT_AUTH_ERROR.into()))
}
pub fn list(&self, _project_id: &str, _environment: &str) -> Result<Vec<APIKey>, CencoriError> {
Self::unsupported()
}
pub fn create(
&self,
_project_id: &str,
_params: &CreateAPIKeyParams,
) -> Result<APIKey, CencoriError> {
Self::unsupported()
}
pub fn revoke(&self, _project_id: &str, _key_id: &str) -> Result<(), CencoriError> {
Self::unsupported()
}
pub fn get_stats(&self, _project_id: &str, _key_id: &str) -> Result<KeyUsageStats, CencoriError> {
Self::unsupported()
}
}