1use crate::low_level::apis::{repos_api, Error};
2use crate::models;
3
4use super::{
5 BranchesClient, ChangeClient, CommitsClient, ContentClient, OrgClient, WebhooksClient,
6};
7
8#[derive(Clone, Debug)]
10pub struct RepoClient<'a> {
11 pub(super) org: &'a OrgClient<'a>,
12 pub(super) repo: &'a str,
13}
14
15impl RepoClient<'_> {
16 #[tracing::instrument(skip(self), fields(org = self.org.org, repo = self.repo), err(Debug))]
22 pub async fn get(
23 &self,
24 ) -> Result<models::PostByOrgRepos201Response, Error<repos_api::GetByOrgByRepoError>> {
25 repos_api::get_by_org_by_repo(&self.org.client.config, self.org.org, Some(self.repo)).await
26 }
27
28 #[tracing::instrument(skip(self), fields(org = self.org.org, repo = self.repo), err(Debug))]
34 pub async fn delete(
35 &self,
36 ) -> Result<models::DeleteByOrgApiKeysById200Response, Error<repos_api::DeleteByOrgByRepoError>>
37 {
38 repos_api::delete_by_org_by_repo(&self.org.client.config, self.org.org, self.repo).await
39 }
40
41 #[tracing::instrument(skip(self, request), fields(org = self.org.org, repo = self.repo), err(Debug))]
47 pub async fn update(
48 &self,
49 request: models::PatchByOrgByRepoRequest,
50 ) -> Result<models::PostByOrgRepos201Response, Error<repos_api::PatchByOrgByRepoError>> {
51 repos_api::patch_by_org_by_repo(
52 &self.org.client.config,
53 self.org.org,
54 self.repo,
55 Some(request),
56 )
57 .await
58 }
59
60 #[must_use]
62 pub fn branches(&self) -> BranchesClient<'_> {
63 BranchesClient { repo: self }
64 }
65
66 #[must_use]
68 pub fn commits(&self) -> CommitsClient<'_> {
69 CommitsClient { repo: self }
70 }
71
72 #[must_use]
74 pub fn content(&self) -> ContentClient<'_> {
75 ContentClient { repo: self }
76 }
77
78 #[must_use]
80 pub fn webhooks(&self) -> WebhooksClient<'_> {
81 WebhooksClient { repo: self }
82 }
83
84 pub async fn change(&self) -> Result<ChangeClient, Error<repos_api::GetByOrgByRepoError>> {
93 let repo_meta = self.get().await?;
94 Ok(ChangeClient::new(
95 &self.org.client.grpc_channel,
96 self.org.client.config.bearer_access_token.as_deref(),
97 repo_meta.id,
98 ))
99 }
100}