google_cloud_developerconnect_v1/
client.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19use crate::Result;
20use std::sync::Arc;
21
22/// Implements a client for the Developer Connect API.
23///
24/// # Service Description
25///
26/// Service describing handlers for resources
27///
28/// # Configuration
29///
30/// `DeveloperConnect` has various configuration parameters, the defaults should
31/// work with most applications.
32///
33/// # Pooling and Cloning
34///
35/// `DeveloperConnect` holds a connection pool internally, it is advised to
36/// create one and the reuse it.  You do not need to wrap `DeveloperConnect` in
37/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
38/// internally.
39#[derive(Clone, Debug)]
40pub struct DeveloperConnect {
41    inner: Arc<dyn crate::stubs::dynamic::DeveloperConnect>,
42}
43
44impl DeveloperConnect {
45    /// Creates a new client with the default configuration.
46    pub async fn new() -> Result<Self> {
47        Self::new_with_config(gax::options::ClientConfig::default()).await
48    }
49
50    /// Creates a new client with the specified configuration.
51    pub async fn new_with_config(conf: gax::options::ClientConfig) -> Result<Self> {
52        let inner = Self::build_inner(conf).await?;
53        Ok(Self { inner })
54    }
55
56    /// Creates a new client from the provided stub.
57    ///
58    /// The most common case for calling this function is when mocking the
59    /// client.
60    pub fn from_stub<T>(stub: T) -> Self
61    where
62        T: crate::stubs::DeveloperConnect + 'static,
63    {
64        Self {
65            inner: Arc::new(stub),
66        }
67    }
68
69    async fn build_inner(
70        conf: gax::options::ClientConfig,
71    ) -> Result<Arc<dyn crate::stubs::dynamic::DeveloperConnect>> {
72        if conf.tracing_enabled() {
73            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
74        }
75        Ok(Arc::new(Self::build_transport(conf).await?))
76    }
77
78    async fn build_transport(
79        conf: gax::options::ClientConfig,
80    ) -> Result<impl crate::stubs::DeveloperConnect> {
81        crate::transport::DeveloperConnect::new(conf).await
82    }
83
84    async fn build_with_tracing(
85        conf: gax::options::ClientConfig,
86    ) -> Result<impl crate::stubs::DeveloperConnect> {
87        Self::build_transport(conf)
88            .await
89            .map(crate::tracing::DeveloperConnect::new)
90    }
91
92    /// Lists Connections in a given project and location.
93    pub fn list_connections(
94        &self,
95        parent: impl Into<std::string::String>,
96    ) -> crate::builders::developer_connect::ListConnections {
97        crate::builders::developer_connect::ListConnections::new(self.inner.clone())
98            .set_parent(parent.into())
99    }
100
101    /// Gets details of a single Connection.
102    pub fn get_connection(
103        &self,
104        name: impl Into<std::string::String>,
105    ) -> crate::builders::developer_connect::GetConnection {
106        crate::builders::developer_connect::GetConnection::new(self.inner.clone())
107            .set_name(name.into())
108    }
109
110    /// Creates a new Connection in a given project and location.
111    ///
112    /// # Long running operations
113    ///
114    /// This method is used to start, and/or poll a [long-running Operation].
115    /// The [Working with long-running operations] chapter in the [user guide]
116    /// covers these operations in detail.
117    ///
118    /// [long-running operation]: https://google.aip.dev/151
119    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
120    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
121    pub fn create_connection(
122        &self,
123        parent: impl Into<std::string::String>,
124    ) -> crate::builders::developer_connect::CreateConnection {
125        crate::builders::developer_connect::CreateConnection::new(self.inner.clone())
126            .set_parent(parent.into())
127    }
128
129    /// Updates the parameters of a single Connection.
130    ///
131    /// # Long running operations
132    ///
133    /// This method is used to start, and/or poll a [long-running Operation].
134    /// The [Working with long-running operations] chapter in the [user guide]
135    /// covers these operations in detail.
136    ///
137    /// [long-running operation]: https://google.aip.dev/151
138    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
139    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
140    pub fn update_connection(
141        &self,
142        connection: impl Into<crate::model::Connection>,
143    ) -> crate::builders::developer_connect::UpdateConnection {
144        crate::builders::developer_connect::UpdateConnection::new(self.inner.clone())
145            .set_connection(connection.into())
146    }
147
148    /// Deletes a single Connection.
149    ///
150    /// # Long running operations
151    ///
152    /// This method is used to start, and/or poll a [long-running Operation].
153    /// The [Working with long-running operations] chapter in the [user guide]
154    /// covers these operations in detail.
155    ///
156    /// [long-running operation]: https://google.aip.dev/151
157    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
158    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
159    pub fn delete_connection(
160        &self,
161        name: impl Into<std::string::String>,
162    ) -> crate::builders::developer_connect::DeleteConnection {
163        crate::builders::developer_connect::DeleteConnection::new(self.inner.clone())
164            .set_name(name.into())
165    }
166
167    /// Creates a GitRepositoryLink. Upon linking a Git Repository, Developer
168    /// Connect will configure the Git Repository to send webhook events to
169    /// Developer Connect. Connections that use Firebase GitHub Application will
170    /// have events forwarded to the Firebase service. All other Connections will
171    /// have events forwarded to Cloud Build.
172    ///
173    /// # Long running operations
174    ///
175    /// This method is used to start, and/or poll a [long-running Operation].
176    /// The [Working with long-running operations] chapter in the [user guide]
177    /// covers these operations in detail.
178    ///
179    /// [long-running operation]: https://google.aip.dev/151
180    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
181    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
182    pub fn create_git_repository_link(
183        &self,
184        parent: impl Into<std::string::String>,
185    ) -> crate::builders::developer_connect::CreateGitRepositoryLink {
186        crate::builders::developer_connect::CreateGitRepositoryLink::new(self.inner.clone())
187            .set_parent(parent.into())
188    }
189
190    /// Deletes a single GitRepositoryLink.
191    ///
192    /// # Long running operations
193    ///
194    /// This method is used to start, and/or poll a [long-running Operation].
195    /// The [Working with long-running operations] chapter in the [user guide]
196    /// covers these operations in detail.
197    ///
198    /// [long-running operation]: https://google.aip.dev/151
199    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
200    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
201    pub fn delete_git_repository_link(
202        &self,
203        name: impl Into<std::string::String>,
204    ) -> crate::builders::developer_connect::DeleteGitRepositoryLink {
205        crate::builders::developer_connect::DeleteGitRepositoryLink::new(self.inner.clone())
206            .set_name(name.into())
207    }
208
209    /// Lists GitRepositoryLinks in a given project, location, and connection.
210    pub fn list_git_repository_links(
211        &self,
212        parent: impl Into<std::string::String>,
213    ) -> crate::builders::developer_connect::ListGitRepositoryLinks {
214        crate::builders::developer_connect::ListGitRepositoryLinks::new(self.inner.clone())
215            .set_parent(parent.into())
216    }
217
218    /// Gets details of a single GitRepositoryLink.
219    pub fn get_git_repository_link(
220        &self,
221        name: impl Into<std::string::String>,
222    ) -> crate::builders::developer_connect::GetGitRepositoryLink {
223        crate::builders::developer_connect::GetGitRepositoryLink::new(self.inner.clone())
224            .set_name(name.into())
225    }
226
227    /// Fetches read/write token of a given gitRepositoryLink.
228    pub fn fetch_read_write_token(
229        &self,
230        git_repository_link: impl Into<std::string::String>,
231    ) -> crate::builders::developer_connect::FetchReadWriteToken {
232        crate::builders::developer_connect::FetchReadWriteToken::new(self.inner.clone())
233            .set_git_repository_link(git_repository_link.into())
234    }
235
236    /// Fetches read token of a given gitRepositoryLink.
237    pub fn fetch_read_token(
238        &self,
239        git_repository_link: impl Into<std::string::String>,
240    ) -> crate::builders::developer_connect::FetchReadToken {
241        crate::builders::developer_connect::FetchReadToken::new(self.inner.clone())
242            .set_git_repository_link(git_repository_link.into())
243    }
244
245    /// FetchLinkableGitRepositories returns a list of git repositories from an SCM
246    /// that are available to be added to a Connection.
247    pub fn fetch_linkable_git_repositories(
248        &self,
249        connection: impl Into<std::string::String>,
250    ) -> crate::builders::developer_connect::FetchLinkableGitRepositories {
251        crate::builders::developer_connect::FetchLinkableGitRepositories::new(self.inner.clone())
252            .set_connection(connection.into())
253    }
254
255    /// FetchGitHubInstallations returns the list of GitHub Installations that
256    /// are available to be added to a Connection.
257    /// For github.com, only installations accessible to the authorizer token
258    /// are returned. For GitHub Enterprise, all installations are returned.
259    pub fn fetch_git_hub_installations(
260        &self,
261        connection: impl Into<std::string::String>,
262    ) -> crate::builders::developer_connect::FetchGitHubInstallations {
263        crate::builders::developer_connect::FetchGitHubInstallations::new(self.inner.clone())
264            .set_connection(connection.into())
265    }
266
267    /// Fetch the list of branches or tags for a given repository.
268    pub fn fetch_git_refs(
269        &self,
270        git_repository_link: impl Into<std::string::String>,
271    ) -> crate::builders::developer_connect::FetchGitRefs {
272        crate::builders::developer_connect::FetchGitRefs::new(self.inner.clone())
273            .set_git_repository_link(git_repository_link.into())
274    }
275
276    /// Lists information about the supported locations for this service.
277    pub fn list_locations(
278        &self,
279        name: impl Into<std::string::String>,
280    ) -> crate::builders::developer_connect::ListLocations {
281        crate::builders::developer_connect::ListLocations::new(self.inner.clone())
282            .set_name(name.into())
283    }
284
285    /// Gets information about a location.
286    pub fn get_location(
287        &self,
288        name: impl Into<std::string::String>,
289    ) -> crate::builders::developer_connect::GetLocation {
290        crate::builders::developer_connect::GetLocation::new(self.inner.clone())
291            .set_name(name.into())
292    }
293
294    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
295    ///
296    /// [google.longrunning.Operations]: longrunning::client::Operations
297    pub fn list_operations(
298        &self,
299        name: impl Into<std::string::String>,
300    ) -> crate::builders::developer_connect::ListOperations {
301        crate::builders::developer_connect::ListOperations::new(self.inner.clone())
302            .set_name(name.into())
303    }
304
305    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
306    ///
307    /// [google.longrunning.Operations]: longrunning::client::Operations
308    pub fn get_operation(
309        &self,
310        name: impl Into<std::string::String>,
311    ) -> crate::builders::developer_connect::GetOperation {
312        crate::builders::developer_connect::GetOperation::new(self.inner.clone())
313            .set_name(name.into())
314    }
315
316    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
317    ///
318    /// [google.longrunning.Operations]: longrunning::client::Operations
319    pub fn delete_operation(
320        &self,
321        name: impl Into<std::string::String>,
322    ) -> crate::builders::developer_connect::DeleteOperation {
323        crate::builders::developer_connect::DeleteOperation::new(self.inner.clone())
324            .set_name(name.into())
325    }
326
327    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
328    ///
329    /// [google.longrunning.Operations]: longrunning::client::Operations
330    pub fn cancel_operation(
331        &self,
332        name: impl Into<std::string::String>,
333    ) -> crate::builders::developer_connect::CancelOperation {
334        crate::builders::developer_connect::CancelOperation::new(self.inner.clone())
335            .set_name(name.into())
336    }
337}