Skip to main content

mesa_dev/client/
org.rs

1use crate::low_level::apis::{org_api, Error};
2use crate::models;
3use crate::MesaClient;
4
5use super::{ApiKeysClient, ReposClient};
6
7/// Client scoped to an organization (`/{org}`).
8#[derive(Clone, Debug)]
9pub struct OrgClient<'a> {
10    pub(super) client: &'a MesaClient,
11    pub(super) org: &'a str,
12}
13
14impl OrgClient<'_> {
15    /// Get organization metadata and repository counts.
16    ///
17    /// # Errors
18    ///
19    /// Returns an error if the API request fails.
20    #[tracing::instrument(skip(self), fields(org = self.org), err(Debug))]
21    pub async fn get(&self) -> Result<models::GetByOrg200Response, Error<org_api::GetByOrgError>> {
22        org_api::get_by_org(&self.client.config, self.org).await
23    }
24
25    /// Access repository listing and creation.
26    #[must_use]
27    pub fn repos(&self) -> ReposClient<'_> {
28        ReposClient { org: self }
29    }
30
31    /// Access API key management.
32    #[must_use]
33    pub fn api_keys(&self) -> ApiKeysClient<'_> {
34        ApiKeysClient { org: self }
35    }
36}