1use crate::low_level::apis::{repos_api, Error};
2use crate::models;
3
4use super::{
5 AnalyticsClient, BranchesClient, CommitsClient, ContentClient, DiffClient, LfsClient,
6 OrgClient, SyncClient, WebhooksClient,
7};
8
9#[derive(Clone, Debug)]
11pub struct RepoClient<'a> {
12 pub(super) org: &'a OrgClient<'a>,
13 pub(super) repo: &'a str,
14}
15
16impl RepoClient<'_> {
17 #[tracing::instrument(skip(self), fields(org = self.org.org, repo = self.repo), err(Debug))]
23 pub async fn get(
24 &self,
25 ) -> Result<models::PostByOrgRepos201Response, Error<repos_api::GetByOrgByRepoError>> {
26 repos_api::get_by_org_by_repo(self.org.config, self.org.org, Some(self.repo)).await
27 }
28
29 #[tracing::instrument(skip(self), fields(org = self.org.org, repo = self.repo), err(Debug))]
35 pub async fn delete(
36 &self,
37 ) -> Result<models::DeleteByOrgApiKeysById200Response, Error<repos_api::DeleteByOrgByRepoError>>
38 {
39 repos_api::delete_by_org_by_repo(self.org.config, self.org.org, self.repo).await
40 }
41
42 #[tracing::instrument(skip(self, request), fields(org = self.org.org, repo = self.repo), err(Debug))]
48 pub async fn update(
49 &self,
50 request: models::PatchByOrgByRepoRequest,
51 ) -> Result<models::PostByOrgRepos201Response, Error<repos_api::PatchByOrgByRepoError>> {
52 repos_api::patch_by_org_by_repo(self.org.config, self.org.org, self.repo, Some(request))
53 .await
54 }
55
56 #[must_use]
58 pub fn branches(&self) -> BranchesClient<'_> {
59 BranchesClient { repo: self }
60 }
61
62 #[must_use]
64 pub fn commits(&self) -> CommitsClient<'_> {
65 CommitsClient { repo: self }
66 }
67
68 #[must_use]
70 pub fn content(&self) -> ContentClient<'_> {
71 ContentClient { repo: self }
72 }
73
74 #[must_use]
76 pub fn diff(&self) -> DiffClient<'_> {
77 DiffClient { repo: self }
78 }
79
80 #[must_use]
82 pub fn sync(&self) -> SyncClient<'_> {
83 SyncClient { repo: self }
84 }
85
86 #[must_use]
88 pub fn webhooks(&self) -> WebhooksClient<'_> {
89 WebhooksClient { repo: self }
90 }
91
92 #[must_use]
94 pub fn lfs(&self) -> LfsClient<'_> {
95 LfsClient { repo: self }
96 }
97
98 #[must_use]
100 pub fn analytics(&self) -> AnalyticsClient<'_> {
101 AnalyticsClient { repo: self }
102 }
103}