Skip to main content

mesa_dev/client/
org.rs

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