mesa_dev/client/
api_keys.rs1use crate::low_level::apis::{admin_api, Error};
2use crate::models;
3
4use super::OrgClient;
5
6#[derive(Clone, Debug)]
8pub struct ApiKeysClient<'a> {
9 pub(super) org: &'a OrgClient<'a>,
10}
11
12impl ApiKeysClient<'_> {
13 #[tracing::instrument(skip(self), fields(org = self.org.org), err(Debug))]
19 pub async fn list(
20 &self,
21 ) -> Result<models::GetByOrgApiKeys200Response, Error<admin_api::GetByOrgApiKeysError>> {
22 admin_api::get_by_org_api_keys(self.org.config, self.org.org).await
23 }
24
25 #[tracing::instrument(skip(self, request), fields(org = self.org.org), err(Debug))]
31 pub async fn create(
32 &self,
33 request: models::PostByOrgApiKeysRequest,
34 ) -> Result<models::PostByOrgApiKeys201Response, Error<admin_api::PostByOrgApiKeysError>> {
35 admin_api::post_by_org_api_keys(self.org.config, self.org.org, Some(request)).await
36 }
37
38 #[tracing::instrument(skip(self), fields(org = self.org.org), err(Debug))]
44 pub async fn revoke(
45 &self,
46 id: &str,
47 ) -> Result<
48 models::DeleteByOrgApiKeysById200Response,
49 Error<admin_api::DeleteByOrgApiKeysByIdError>,
50 > {
51 admin_api::delete_by_org_api_keys_by_id(self.org.config, id, self.org.org).await
52 }
53}