google_cloud_build_v2/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
19/// Implements a client for the Cloud Build API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_build_v2::client::RepositoryManager;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
26/// let client = RepositoryManager::builder().build().await?;
27/// let parent = "parent_value";
28/// let mut list = client.list_connections()
29/// .set_parent(parent)
30/// .by_item();
31/// while let Some(item) = list.next().await.transpose()? {
32/// println!("{:?}", item);
33/// }
34/// # Ok(()) }
35/// ```
36///
37/// # Service Description
38///
39/// Manages connections to source code repositories.
40///
41/// # Configuration
42///
43/// To configure `RepositoryManager` use the `with_*` methods in the type returned
44/// by [builder()][RepositoryManager::builder]. The default configuration should
45/// work for most applications. Common configuration changes include
46///
47/// * [with_endpoint()]: by default this client uses the global default endpoint
48/// (`https://cloudbuild.googleapis.com`). Applications using regional
49/// endpoints or running in restricted networks (e.g. a network configured
50// with [Private Google Access with VPC Service Controls]) may want to
51/// override this default.
52/// * [with_credentials()]: by default this client uses
53/// [Application Default Credentials]. Applications using custom
54/// authentication may need to override this default.
55///
56/// [with_endpoint()]: super::builder::repository_manager::ClientBuilder::with_endpoint
57/// [with_credentials()]: super::builder::repository_manager::ClientBuilder::with_credentials
58/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
59/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
60///
61/// # Pooling and Cloning
62///
63/// `RepositoryManager` holds a connection pool internally, it is advised to
64/// create one and reuse it. You do not need to wrap `RepositoryManager` in
65/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
66/// already uses an `Arc` internally.
67#[derive(Clone, Debug)]
68pub struct RepositoryManager {
69 inner: std::sync::Arc<dyn super::stub::dynamic::RepositoryManager>,
70}
71
72impl RepositoryManager {
73 /// Returns a builder for [RepositoryManager].
74 ///
75 /// ```
76 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
77 /// # use google_cloud_build_v2::client::RepositoryManager;
78 /// let client = RepositoryManager::builder().build().await?;
79 /// # Ok(()) }
80 /// ```
81 pub fn builder() -> super::builder::repository_manager::ClientBuilder {
82 crate::new_client_builder(super::builder::repository_manager::client::Factory)
83 }
84
85 /// Creates a new client from the provided stub.
86 ///
87 /// The most common case for calling this function is in tests mocking the
88 /// client's behavior.
89 pub fn from_stub<T>(stub: T) -> Self
90 where
91 T: super::stub::RepositoryManager + 'static,
92 {
93 Self {
94 inner: std::sync::Arc::new(stub),
95 }
96 }
97
98 pub(crate) async fn new(
99 config: gaxi::options::ClientConfig,
100 ) -> crate::ClientBuilderResult<Self> {
101 let inner = Self::build_inner(config).await?;
102 Ok(Self { inner })
103 }
104
105 async fn build_inner(
106 conf: gaxi::options::ClientConfig,
107 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::RepositoryManager>>
108 {
109 if gaxi::options::tracing_enabled(&conf) {
110 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
111 }
112 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
113 }
114
115 async fn build_transport(
116 conf: gaxi::options::ClientConfig,
117 ) -> crate::ClientBuilderResult<impl super::stub::RepositoryManager> {
118 super::transport::RepositoryManager::new(conf).await
119 }
120
121 async fn build_with_tracing(
122 conf: gaxi::options::ClientConfig,
123 ) -> crate::ClientBuilderResult<impl super::stub::RepositoryManager> {
124 Self::build_transport(conf)
125 .await
126 .map(super::tracing::RepositoryManager::new)
127 }
128
129 /// Creates a 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 ///
141 /// # Example
142 /// ```
143 /// # use google_cloud_build_v2::client::RepositoryManager;
144 /// use google_cloud_lro::Poller;
145 /// use google_cloud_build_v2::model::Connection;
146 /// use google_cloud_build_v2::Result;
147 /// async fn sample(
148 /// client: &RepositoryManager, parent: &str
149 /// ) -> Result<()> {
150 /// let response = client.create_connection()
151 /// .set_parent(parent)
152 /// .set_connection_id("connection_id_value")
153 /// .set_connection(
154 /// Connection::new()/* set fields */
155 /// )
156 /// .poller().until_done().await?;
157 /// println!("response {:?}", response);
158 /// Ok(())
159 /// }
160 /// ```
161 pub fn create_connection(&self) -> super::builder::repository_manager::CreateConnection {
162 super::builder::repository_manager::CreateConnection::new(self.inner.clone())
163 }
164
165 /// Gets details of a single connection.
166 ///
167 /// # Example
168 /// ```
169 /// # use google_cloud_build_v2::client::RepositoryManager;
170 /// use google_cloud_build_v2::Result;
171 /// async fn sample(
172 /// client: &RepositoryManager, name: &str
173 /// ) -> Result<()> {
174 /// let response = client.get_connection()
175 /// .set_name(name)
176 /// .send().await?;
177 /// println!("response {:?}", response);
178 /// Ok(())
179 /// }
180 /// ```
181 pub fn get_connection(&self) -> super::builder::repository_manager::GetConnection {
182 super::builder::repository_manager::GetConnection::new(self.inner.clone())
183 }
184
185 /// Lists Connections in a given project and location.
186 ///
187 /// # Example
188 /// ```
189 /// # use google_cloud_build_v2::client::RepositoryManager;
190 /// use google_cloud_gax::paginator::ItemPaginator as _;
191 /// use google_cloud_build_v2::Result;
192 /// async fn sample(
193 /// client: &RepositoryManager, parent: &str
194 /// ) -> Result<()> {
195 /// let mut list = client.list_connections()
196 /// .set_parent(parent)
197 /// .by_item();
198 /// while let Some(item) = list.next().await.transpose()? {
199 /// println!("{:?}", item);
200 /// }
201 /// Ok(())
202 /// }
203 /// ```
204 pub fn list_connections(&self) -> super::builder::repository_manager::ListConnections {
205 super::builder::repository_manager::ListConnections::new(self.inner.clone())
206 }
207
208 /// Updates a single connection.
209 ///
210 /// # Long running operations
211 ///
212 /// This method is used to start, and/or poll a [long-running Operation].
213 /// The [Working with long-running operations] chapter in the [user guide]
214 /// covers these operations in detail.
215 ///
216 /// [long-running operation]: https://google.aip.dev/151
217 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
218 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
219 ///
220 /// # Example
221 /// ```
222 /// # use google_cloud_build_v2::client::RepositoryManager;
223 /// use google_cloud_lro::Poller;
224 /// # extern crate wkt as google_cloud_wkt;
225 /// use google_cloud_wkt::FieldMask;
226 /// use google_cloud_build_v2::model::Connection;
227 /// use google_cloud_build_v2::Result;
228 /// async fn sample(
229 /// client: &RepositoryManager, name: &str
230 /// ) -> Result<()> {
231 /// let response = client.update_connection()
232 /// .set_connection(
233 /// Connection::new().set_name(name)/* set fields */
234 /// )
235 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
236 /// .poller().until_done().await?;
237 /// println!("response {:?}", response);
238 /// Ok(())
239 /// }
240 /// ```
241 pub fn update_connection(&self) -> super::builder::repository_manager::UpdateConnection {
242 super::builder::repository_manager::UpdateConnection::new(self.inner.clone())
243 }
244
245 /// Deletes a single connection.
246 ///
247 /// # Long running operations
248 ///
249 /// This method is used to start, and/or poll a [long-running Operation].
250 /// The [Working with long-running operations] chapter in the [user guide]
251 /// covers these operations in detail.
252 ///
253 /// [long-running operation]: https://google.aip.dev/151
254 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
255 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
256 ///
257 /// # Example
258 /// ```
259 /// # use google_cloud_build_v2::client::RepositoryManager;
260 /// use google_cloud_lro::Poller;
261 /// use google_cloud_build_v2::Result;
262 /// async fn sample(
263 /// client: &RepositoryManager, name: &str
264 /// ) -> Result<()> {
265 /// client.delete_connection()
266 /// .set_name(name)
267 /// .poller().until_done().await?;
268 /// Ok(())
269 /// }
270 /// ```
271 pub fn delete_connection(&self) -> super::builder::repository_manager::DeleteConnection {
272 super::builder::repository_manager::DeleteConnection::new(self.inner.clone())
273 }
274
275 /// Creates a Repository.
276 ///
277 /// # Long running operations
278 ///
279 /// This method is used to start, and/or poll a [long-running Operation].
280 /// The [Working with long-running operations] chapter in the [user guide]
281 /// covers these operations in detail.
282 ///
283 /// [long-running operation]: https://google.aip.dev/151
284 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
285 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
286 ///
287 /// # Example
288 /// ```
289 /// # use google_cloud_build_v2::client::RepositoryManager;
290 /// use google_cloud_lro::Poller;
291 /// use google_cloud_build_v2::model::Repository;
292 /// use google_cloud_build_v2::Result;
293 /// async fn sample(
294 /// client: &RepositoryManager, parent: &str
295 /// ) -> Result<()> {
296 /// let response = client.create_repository()
297 /// .set_parent(parent)
298 /// .set_repository_id("repository_id_value")
299 /// .set_repository(
300 /// Repository::new()/* set fields */
301 /// )
302 /// .poller().until_done().await?;
303 /// println!("response {:?}", response);
304 /// Ok(())
305 /// }
306 /// ```
307 pub fn create_repository(&self) -> super::builder::repository_manager::CreateRepository {
308 super::builder::repository_manager::CreateRepository::new(self.inner.clone())
309 }
310
311 /// Creates multiple repositories inside a connection.
312 ///
313 /// # Long running operations
314 ///
315 /// This method is used to start, and/or poll a [long-running Operation].
316 /// The [Working with long-running operations] chapter in the [user guide]
317 /// covers these operations in detail.
318 ///
319 /// [long-running operation]: https://google.aip.dev/151
320 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
321 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
322 ///
323 /// # Example
324 /// ```
325 /// # use google_cloud_build_v2::client::RepositoryManager;
326 /// use google_cloud_lro::Poller;
327 /// use google_cloud_build_v2::Result;
328 /// async fn sample(
329 /// client: &RepositoryManager
330 /// ) -> Result<()> {
331 /// let response = client.batch_create_repositories()
332 /// /* set fields */
333 /// .poller().until_done().await?;
334 /// println!("response {:?}", response);
335 /// Ok(())
336 /// }
337 /// ```
338 pub fn batch_create_repositories(
339 &self,
340 ) -> super::builder::repository_manager::BatchCreateRepositories {
341 super::builder::repository_manager::BatchCreateRepositories::new(self.inner.clone())
342 }
343
344 /// Gets details of a single repository.
345 ///
346 /// # Example
347 /// ```
348 /// # use google_cloud_build_v2::client::RepositoryManager;
349 /// use google_cloud_build_v2::Result;
350 /// async fn sample(
351 /// client: &RepositoryManager, name: &str
352 /// ) -> Result<()> {
353 /// let response = client.get_repository()
354 /// .set_name(name)
355 /// .send().await?;
356 /// println!("response {:?}", response);
357 /// Ok(())
358 /// }
359 /// ```
360 pub fn get_repository(&self) -> super::builder::repository_manager::GetRepository {
361 super::builder::repository_manager::GetRepository::new(self.inner.clone())
362 }
363
364 /// Lists Repositories in a given connection.
365 ///
366 /// # Example
367 /// ```
368 /// # use google_cloud_build_v2::client::RepositoryManager;
369 /// use google_cloud_gax::paginator::ItemPaginator as _;
370 /// use google_cloud_build_v2::Result;
371 /// async fn sample(
372 /// client: &RepositoryManager, parent: &str
373 /// ) -> Result<()> {
374 /// let mut list = client.list_repositories()
375 /// .set_parent(parent)
376 /// .by_item();
377 /// while let Some(item) = list.next().await.transpose()? {
378 /// println!("{:?}", item);
379 /// }
380 /// Ok(())
381 /// }
382 /// ```
383 pub fn list_repositories(&self) -> super::builder::repository_manager::ListRepositories {
384 super::builder::repository_manager::ListRepositories::new(self.inner.clone())
385 }
386
387 /// Deletes a single repository.
388 ///
389 /// # Long running operations
390 ///
391 /// This method is used to start, and/or poll a [long-running Operation].
392 /// The [Working with long-running operations] chapter in the [user guide]
393 /// covers these operations in detail.
394 ///
395 /// [long-running operation]: https://google.aip.dev/151
396 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
397 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
398 ///
399 /// # Example
400 /// ```
401 /// # use google_cloud_build_v2::client::RepositoryManager;
402 /// use google_cloud_lro::Poller;
403 /// use google_cloud_build_v2::Result;
404 /// async fn sample(
405 /// client: &RepositoryManager, name: &str
406 /// ) -> Result<()> {
407 /// client.delete_repository()
408 /// .set_name(name)
409 /// .poller().until_done().await?;
410 /// Ok(())
411 /// }
412 /// ```
413 pub fn delete_repository(&self) -> super::builder::repository_manager::DeleteRepository {
414 super::builder::repository_manager::DeleteRepository::new(self.inner.clone())
415 }
416
417 /// Fetches read/write token of a given repository.
418 ///
419 /// # Example
420 /// ```
421 /// # use google_cloud_build_v2::client::RepositoryManager;
422 /// use google_cloud_build_v2::Result;
423 /// async fn sample(
424 /// client: &RepositoryManager
425 /// ) -> Result<()> {
426 /// let response = client.fetch_read_write_token()
427 /// /* set fields */
428 /// .send().await?;
429 /// println!("response {:?}", response);
430 /// Ok(())
431 /// }
432 /// ```
433 pub fn fetch_read_write_token(
434 &self,
435 ) -> super::builder::repository_manager::FetchReadWriteToken {
436 super::builder::repository_manager::FetchReadWriteToken::new(self.inner.clone())
437 }
438
439 /// Fetches read token of a given repository.
440 ///
441 /// # Example
442 /// ```
443 /// # use google_cloud_build_v2::client::RepositoryManager;
444 /// use google_cloud_build_v2::Result;
445 /// async fn sample(
446 /// client: &RepositoryManager
447 /// ) -> Result<()> {
448 /// let response = client.fetch_read_token()
449 /// /* set fields */
450 /// .send().await?;
451 /// println!("response {:?}", response);
452 /// Ok(())
453 /// }
454 /// ```
455 pub fn fetch_read_token(&self) -> super::builder::repository_manager::FetchReadToken {
456 super::builder::repository_manager::FetchReadToken::new(self.inner.clone())
457 }
458
459 /// FetchLinkableRepositories get repositories from SCM that are
460 /// accessible and could be added to the connection.
461 ///
462 /// # Example
463 /// ```
464 /// # use google_cloud_build_v2::client::RepositoryManager;
465 /// use google_cloud_gax::paginator::ItemPaginator as _;
466 /// use google_cloud_build_v2::Result;
467 /// async fn sample(
468 /// client: &RepositoryManager
469 /// ) -> Result<()> {
470 /// let mut list = client.fetch_linkable_repositories()
471 /// /* set fields */
472 /// .by_item();
473 /// while let Some(item) = list.next().await.transpose()? {
474 /// println!("{:?}", item);
475 /// }
476 /// Ok(())
477 /// }
478 /// ```
479 pub fn fetch_linkable_repositories(
480 &self,
481 ) -> super::builder::repository_manager::FetchLinkableRepositories {
482 super::builder::repository_manager::FetchLinkableRepositories::new(self.inner.clone())
483 }
484
485 /// Fetch the list of branches or tags for a given repository.
486 ///
487 /// # Example
488 /// ```
489 /// # use google_cloud_build_v2::client::RepositoryManager;
490 /// use google_cloud_build_v2::Result;
491 /// async fn sample(
492 /// client: &RepositoryManager
493 /// ) -> Result<()> {
494 /// let response = client.fetch_git_refs()
495 /// /* set fields */
496 /// .send().await?;
497 /// println!("response {:?}", response);
498 /// Ok(())
499 /// }
500 /// ```
501 pub fn fetch_git_refs(&self) -> super::builder::repository_manager::FetchGitRefs {
502 super::builder::repository_manager::FetchGitRefs::new(self.inner.clone())
503 }
504
505 /// Sets the access control policy on the specified resource. Replaces
506 /// any existing policy.
507 ///
508 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
509 /// errors.
510 ///
511 /// # Example
512 /// ```
513 /// # use google_cloud_build_v2::client::RepositoryManager;
514 /// use google_cloud_build_v2::Result;
515 /// async fn sample(
516 /// client: &RepositoryManager
517 /// ) -> Result<()> {
518 /// let response = client.set_iam_policy()
519 /// /* set fields */
520 /// .send().await?;
521 /// println!("response {:?}", response);
522 /// Ok(())
523 /// }
524 /// ```
525 pub fn set_iam_policy(&self) -> super::builder::repository_manager::SetIamPolicy {
526 super::builder::repository_manager::SetIamPolicy::new(self.inner.clone())
527 }
528
529 /// Gets the access control policy for a resource. Returns an empty policy
530 /// if the resource exists and does not have a policy set.
531 ///
532 /// # Example
533 /// ```
534 /// # use google_cloud_build_v2::client::RepositoryManager;
535 /// use google_cloud_build_v2::Result;
536 /// async fn sample(
537 /// client: &RepositoryManager
538 /// ) -> Result<()> {
539 /// let response = client.get_iam_policy()
540 /// /* set fields */
541 /// .send().await?;
542 /// println!("response {:?}", response);
543 /// Ok(())
544 /// }
545 /// ```
546 pub fn get_iam_policy(&self) -> super::builder::repository_manager::GetIamPolicy {
547 super::builder::repository_manager::GetIamPolicy::new(self.inner.clone())
548 }
549
550 /// Returns permissions that a caller has on the specified resource. If the
551 /// resource does not exist, this will return an empty set of
552 /// permissions, not a `NOT_FOUND` error.
553 ///
554 /// Note: This operation is designed to be used for building
555 /// permission-aware UIs and command-line tools, not for authorization
556 /// checking. This operation may "fail open" without warning.
557 ///
558 /// # Example
559 /// ```
560 /// # use google_cloud_build_v2::client::RepositoryManager;
561 /// use google_cloud_build_v2::Result;
562 /// async fn sample(
563 /// client: &RepositoryManager
564 /// ) -> Result<()> {
565 /// let response = client.test_iam_permissions()
566 /// /* set fields */
567 /// .send().await?;
568 /// println!("response {:?}", response);
569 /// Ok(())
570 /// }
571 /// ```
572 pub fn test_iam_permissions(&self) -> super::builder::repository_manager::TestIamPermissions {
573 super::builder::repository_manager::TestIamPermissions::new(self.inner.clone())
574 }
575
576 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
577 ///
578 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
579 ///
580 /// # Example
581 /// ```
582 /// # use google_cloud_build_v2::client::RepositoryManager;
583 /// use google_cloud_build_v2::Result;
584 /// async fn sample(
585 /// client: &RepositoryManager
586 /// ) -> Result<()> {
587 /// let response = client.get_operation()
588 /// /* set fields */
589 /// .send().await?;
590 /// println!("response {:?}", response);
591 /// Ok(())
592 /// }
593 /// ```
594 pub fn get_operation(&self) -> super::builder::repository_manager::GetOperation {
595 super::builder::repository_manager::GetOperation::new(self.inner.clone())
596 }
597
598 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
599 ///
600 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
601 ///
602 /// # Example
603 /// ```
604 /// # use google_cloud_build_v2::client::RepositoryManager;
605 /// use google_cloud_build_v2::Result;
606 /// async fn sample(
607 /// client: &RepositoryManager
608 /// ) -> Result<()> {
609 /// client.cancel_operation()
610 /// /* set fields */
611 /// .send().await?;
612 /// Ok(())
613 /// }
614 /// ```
615 pub fn cancel_operation(&self) -> super::builder::repository_manager::CancelOperation {
616 super::builder::repository_manager::CancelOperation::new(self.inner.clone())
617 }
618}