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/// # Example
25/// ```
26/// # tokio_test::block_on(async {
27/// # use google_cloud_developerconnect_v1::client::DeveloperConnect;
28/// let client = DeveloperConnect::builder().build().await?;
29/// // use `client` to make requests to the {Codec.APITitle}}.
30/// # gax::Result::<()>::Ok(()) });
31/// ```
32///
33/// # Service Description
34///
35/// Service describing handlers for resources
36///
37/// # Configuration
38///
39/// To configure `DeveloperConnect` use the `with_*` methods in the type returned
40/// by [builder()][DeveloperConnect::builder]. The default configuration should
41/// work for most applications. Common configuration changes include
42///
43/// * [with_endpoint()]: by default this client uses the global default endpoint
44///   (`https://developerconnect.googleapis.com`). Applications using regional
45///   endpoints or running in restricted networks (e.g. a network configured
46//    with [Private Google Access with VPC Service Controls]) may want to
47///   override this default.
48/// * [with_credentials()]: by default this client uses
49///   [Application Default Credentials]. Applications using custom
50///   authentication may need to override this default.
51///
52/// [with_endpoint()]: super::builder::developer_connect::ClientBuilder::with_endpoint
53/// [with_credentials()]: super::builder::developer_connect::ClientBuilder::credentials
54/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
55/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
56///
57/// # Pooling and Cloning
58///
59/// `DeveloperConnect` holds a connection pool internally, it is advised to
60/// create one and the reuse it.  You do not need to wrap `DeveloperConnect` in
61/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
62/// internally.
63#[derive(Clone, Debug)]
64pub struct DeveloperConnect {
65    inner: Arc<dyn super::stub::dynamic::DeveloperConnect>,
66}
67
68impl DeveloperConnect {
69    /// Returns a builder for [DeveloperConnect].
70    ///
71    /// ```
72    /// # tokio_test::block_on(async {
73    /// # use google_cloud_developerconnect_v1::client::DeveloperConnect;
74    /// let client = DeveloperConnect::builder().build().await?;
75    /// # gax::Result::<()>::Ok(()) });
76    /// ```
77    pub fn builder() -> super::builder::developer_connect::ClientBuilder {
78        gax::client_builder::internal::new_builder(
79            super::builder::developer_connect::client::Factory,
80        )
81    }
82
83    /// Creates a new client from the provided stub.
84    ///
85    /// The most common case for calling this function is in tests mocking the
86    /// client's behavior.
87    pub fn from_stub<T>(stub: T) -> Self
88    where
89        T: super::stub::DeveloperConnect + 'static,
90    {
91        Self {
92            inner: Arc::new(stub),
93        }
94    }
95
96    pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
97        let inner = Self::build_inner(config).await?;
98        Ok(Self { inner })
99    }
100
101    async fn build_inner(
102        conf: gaxi::options::ClientConfig,
103    ) -> Result<Arc<dyn super::stub::dynamic::DeveloperConnect>> {
104        if gaxi::options::tracing_enabled(&conf) {
105            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
106        }
107        Ok(Arc::new(Self::build_transport(conf).await?))
108    }
109
110    async fn build_transport(
111        conf: gaxi::options::ClientConfig,
112    ) -> Result<impl super::stub::DeveloperConnect> {
113        super::transport::DeveloperConnect::new(conf).await
114    }
115
116    async fn build_with_tracing(
117        conf: gaxi::options::ClientConfig,
118    ) -> Result<impl super::stub::DeveloperConnect> {
119        Self::build_transport(conf)
120            .await
121            .map(super::tracing::DeveloperConnect::new)
122    }
123
124    /// Lists Connections in a given project and location.
125    pub fn list_connections(
126        &self,
127        parent: impl Into<std::string::String>,
128    ) -> super::builder::developer_connect::ListConnections {
129        super::builder::developer_connect::ListConnections::new(self.inner.clone())
130            .set_parent(parent.into())
131    }
132
133    /// Gets details of a single Connection.
134    pub fn get_connection(
135        &self,
136        name: impl Into<std::string::String>,
137    ) -> super::builder::developer_connect::GetConnection {
138        super::builder::developer_connect::GetConnection::new(self.inner.clone())
139            .set_name(name.into())
140    }
141
142    /// Creates a new Connection in a given project and location.
143    ///
144    /// # Long running operations
145    ///
146    /// This method is used to start, and/or poll a [long-running Operation].
147    /// The [Working with long-running operations] chapter in the [user guide]
148    /// covers these operations in detail.
149    ///
150    /// [long-running operation]: https://google.aip.dev/151
151    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
152    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
153    pub fn create_connection(
154        &self,
155        parent: impl Into<std::string::String>,
156    ) -> super::builder::developer_connect::CreateConnection {
157        super::builder::developer_connect::CreateConnection::new(self.inner.clone())
158            .set_parent(parent.into())
159    }
160
161    /// Updates the parameters of a single Connection.
162    ///
163    /// # Long running operations
164    ///
165    /// This method is used to start, and/or poll a [long-running Operation].
166    /// The [Working with long-running operations] chapter in the [user guide]
167    /// covers these operations in detail.
168    ///
169    /// [long-running operation]: https://google.aip.dev/151
170    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
171    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
172    pub fn update_connection(
173        &self,
174        connection: impl Into<crate::model::Connection>,
175    ) -> super::builder::developer_connect::UpdateConnection {
176        super::builder::developer_connect::UpdateConnection::new(self.inner.clone())
177            .set_connection(connection.into())
178    }
179
180    /// Deletes a single Connection.
181    ///
182    /// # Long running operations
183    ///
184    /// This method is used to start, and/or poll a [long-running Operation].
185    /// The [Working with long-running operations] chapter in the [user guide]
186    /// covers these operations in detail.
187    ///
188    /// [long-running operation]: https://google.aip.dev/151
189    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
190    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
191    pub fn delete_connection(
192        &self,
193        name: impl Into<std::string::String>,
194    ) -> super::builder::developer_connect::DeleteConnection {
195        super::builder::developer_connect::DeleteConnection::new(self.inner.clone())
196            .set_name(name.into())
197    }
198
199    /// Creates a GitRepositoryLink. Upon linking a Git Repository, Developer
200    /// Connect will configure the Git Repository to send webhook events to
201    /// Developer Connect. Connections that use Firebase GitHub Application will
202    /// have events forwarded to the Firebase service. All other Connections will
203    /// have events forwarded to Cloud Build.
204    ///
205    /// # Long running operations
206    ///
207    /// This method is used to start, and/or poll a [long-running Operation].
208    /// The [Working with long-running operations] chapter in the [user guide]
209    /// covers these operations in detail.
210    ///
211    /// [long-running operation]: https://google.aip.dev/151
212    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
213    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
214    pub fn create_git_repository_link(
215        &self,
216        parent: impl Into<std::string::String>,
217    ) -> super::builder::developer_connect::CreateGitRepositoryLink {
218        super::builder::developer_connect::CreateGitRepositoryLink::new(self.inner.clone())
219            .set_parent(parent.into())
220    }
221
222    /// Deletes a single GitRepositoryLink.
223    ///
224    /// # Long running operations
225    ///
226    /// This method is used to start, and/or poll a [long-running Operation].
227    /// The [Working with long-running operations] chapter in the [user guide]
228    /// covers these operations in detail.
229    ///
230    /// [long-running operation]: https://google.aip.dev/151
231    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
232    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
233    pub fn delete_git_repository_link(
234        &self,
235        name: impl Into<std::string::String>,
236    ) -> super::builder::developer_connect::DeleteGitRepositoryLink {
237        super::builder::developer_connect::DeleteGitRepositoryLink::new(self.inner.clone())
238            .set_name(name.into())
239    }
240
241    /// Lists GitRepositoryLinks in a given project, location, and connection.
242    pub fn list_git_repository_links(
243        &self,
244        parent: impl Into<std::string::String>,
245    ) -> super::builder::developer_connect::ListGitRepositoryLinks {
246        super::builder::developer_connect::ListGitRepositoryLinks::new(self.inner.clone())
247            .set_parent(parent.into())
248    }
249
250    /// Gets details of a single GitRepositoryLink.
251    pub fn get_git_repository_link(
252        &self,
253        name: impl Into<std::string::String>,
254    ) -> super::builder::developer_connect::GetGitRepositoryLink {
255        super::builder::developer_connect::GetGitRepositoryLink::new(self.inner.clone())
256            .set_name(name.into())
257    }
258
259    /// Fetches read/write token of a given gitRepositoryLink.
260    pub fn fetch_read_write_token(
261        &self,
262        git_repository_link: impl Into<std::string::String>,
263    ) -> super::builder::developer_connect::FetchReadWriteToken {
264        super::builder::developer_connect::FetchReadWriteToken::new(self.inner.clone())
265            .set_git_repository_link(git_repository_link.into())
266    }
267
268    /// Fetches read token of a given gitRepositoryLink.
269    pub fn fetch_read_token(
270        &self,
271        git_repository_link: impl Into<std::string::String>,
272    ) -> super::builder::developer_connect::FetchReadToken {
273        super::builder::developer_connect::FetchReadToken::new(self.inner.clone())
274            .set_git_repository_link(git_repository_link.into())
275    }
276
277    /// FetchLinkableGitRepositories returns a list of git repositories from an SCM
278    /// that are available to be added to a Connection.
279    pub fn fetch_linkable_git_repositories(
280        &self,
281        connection: impl Into<std::string::String>,
282    ) -> super::builder::developer_connect::FetchLinkableGitRepositories {
283        super::builder::developer_connect::FetchLinkableGitRepositories::new(self.inner.clone())
284            .set_connection(connection.into())
285    }
286
287    /// FetchGitHubInstallations returns the list of GitHub Installations that
288    /// are available to be added to a Connection.
289    /// For github.com, only installations accessible to the authorizer token
290    /// are returned. For GitHub Enterprise, all installations are returned.
291    pub fn fetch_git_hub_installations(
292        &self,
293        connection: impl Into<std::string::String>,
294    ) -> super::builder::developer_connect::FetchGitHubInstallations {
295        super::builder::developer_connect::FetchGitHubInstallations::new(self.inner.clone())
296            .set_connection(connection.into())
297    }
298
299    /// Fetch the list of branches or tags for a given repository.
300    pub fn fetch_git_refs(
301        &self,
302        git_repository_link: impl Into<std::string::String>,
303    ) -> super::builder::developer_connect::FetchGitRefs {
304        super::builder::developer_connect::FetchGitRefs::new(self.inner.clone())
305            .set_git_repository_link(git_repository_link.into())
306    }
307
308    /// Lists information about the supported locations for this service.
309    pub fn list_locations(
310        &self,
311        name: impl Into<std::string::String>,
312    ) -> super::builder::developer_connect::ListLocations {
313        super::builder::developer_connect::ListLocations::new(self.inner.clone())
314            .set_name(name.into())
315    }
316
317    /// Gets information about a location.
318    pub fn get_location(
319        &self,
320        name: impl Into<std::string::String>,
321    ) -> super::builder::developer_connect::GetLocation {
322        super::builder::developer_connect::GetLocation::new(self.inner.clone())
323            .set_name(name.into())
324    }
325
326    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
327    ///
328    /// [google.longrunning.Operations]: longrunning::client::Operations
329    pub fn list_operations(
330        &self,
331        name: impl Into<std::string::String>,
332    ) -> super::builder::developer_connect::ListOperations {
333        super::builder::developer_connect::ListOperations::new(self.inner.clone())
334            .set_name(name.into())
335    }
336
337    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
338    ///
339    /// [google.longrunning.Operations]: longrunning::client::Operations
340    pub fn get_operation(
341        &self,
342        name: impl Into<std::string::String>,
343    ) -> super::builder::developer_connect::GetOperation {
344        super::builder::developer_connect::GetOperation::new(self.inner.clone())
345            .set_name(name.into())
346    }
347
348    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
349    ///
350    /// [google.longrunning.Operations]: longrunning::client::Operations
351    pub fn delete_operation(
352        &self,
353        name: impl Into<std::string::String>,
354    ) -> super::builder::developer_connect::DeleteOperation {
355        super::builder::developer_connect::DeleteOperation::new(self.inner.clone())
356            .set_name(name.into())
357    }
358
359    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
360    ///
361    /// [google.longrunning.Operations]: longrunning::client::Operations
362    pub fn cancel_operation(
363        &self,
364        name: impl Into<std::string::String>,
365    ) -> super::builder::developer_connect::CancelOperation {
366        super::builder::developer_connect::CancelOperation::new(self.inner.clone())
367            .set_name(name.into())
368    }
369}