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
19use crate::Result;
20
21/// Implements a client for the Cloud Build API.
22///
23/// # Example
24/// ```
25/// # tokio_test::block_on(async {
26/// # use google_cloud_build_v2::client::RepositoryManager;
27/// let client = RepositoryManager::builder().build().await?;
28/// // use `client` to make requests to the Cloud Build API.
29/// # gax::Result::<()>::Ok(()) });
30/// ```
31///
32/// # Service Description
33///
34/// Manages connections to source code repositories.
35///
36/// # Configuration
37///
38/// To configure `RepositoryManager` use the `with_*` methods in the type returned
39/// by [builder()][RepositoryManager::builder]. The default configuration should
40/// work for most applications. Common configuration changes include
41///
42/// * [with_endpoint()]: by default this client uses the global default endpoint
43/// (`https://cloudbuild.googleapis.com`). Applications using regional
44/// endpoints or running in restricted networks (e.g. a network configured
45// with [Private Google Access with VPC Service Controls]) may want to
46/// override this default.
47/// * [with_credentials()]: by default this client uses
48/// [Application Default Credentials]. Applications using custom
49/// authentication may need to override this default.
50///
51/// [with_endpoint()]: super::builder::repository_manager::ClientBuilder::with_endpoint
52/// [with_credentials()]: super::builder::repository_manager::ClientBuilder::credentials
53/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
54/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
55///
56/// # Pooling and Cloning
57///
58/// `RepositoryManager` holds a connection pool internally, it is advised to
59/// create one and the reuse it. You do not need to wrap `RepositoryManager` in
60/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
61/// already uses an `Arc` internally.
62#[derive(Clone, Debug)]
63pub struct RepositoryManager {
64 inner: std::sync::Arc<dyn super::stub::dynamic::RepositoryManager>,
65}
66
67impl RepositoryManager {
68 /// Returns a builder for [RepositoryManager].
69 ///
70 /// ```
71 /// # tokio_test::block_on(async {
72 /// # use google_cloud_build_v2::client::RepositoryManager;
73 /// let client = RepositoryManager::builder().build().await?;
74 /// # gax::Result::<()>::Ok(()) });
75 /// ```
76 pub fn builder() -> super::builder::repository_manager::ClientBuilder {
77 gax::client_builder::internal::new_builder(
78 super::builder::repository_manager::client::Factory,
79 )
80 }
81
82 /// Creates a new client from the provided stub.
83 ///
84 /// The most common case for calling this function is in tests mocking the
85 /// client's behavior.
86 pub fn from_stub<T>(stub: T) -> Self
87 where
88 T: super::stub::RepositoryManager + 'static,
89 {
90 Self {
91 inner: std::sync::Arc::new(stub),
92 }
93 }
94
95 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
96 let inner = Self::build_inner(config).await?;
97 Ok(Self { inner })
98 }
99
100 async fn build_inner(
101 conf: gaxi::options::ClientConfig,
102 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::RepositoryManager>> {
103 if gaxi::options::tracing_enabled(&conf) {
104 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
105 }
106 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
107 }
108
109 async fn build_transport(
110 conf: gaxi::options::ClientConfig,
111 ) -> Result<impl super::stub::RepositoryManager> {
112 super::transport::RepositoryManager::new(conf).await
113 }
114
115 async fn build_with_tracing(
116 conf: gaxi::options::ClientConfig,
117 ) -> Result<impl super::stub::RepositoryManager> {
118 Self::build_transport(conf)
119 .await
120 .map(super::tracing::RepositoryManager::new)
121 }
122
123 /// Creates a Connection.
124 ///
125 /// # Long running operations
126 ///
127 /// This method is used to start, and/or poll a [long-running Operation].
128 /// The [Working with long-running operations] chapter in the [user guide]
129 /// covers these operations in detail.
130 ///
131 /// [long-running operation]: https://google.aip.dev/151
132 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
133 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
134 pub fn create_connection(&self) -> super::builder::repository_manager::CreateConnection {
135 super::builder::repository_manager::CreateConnection::new(self.inner.clone())
136 }
137
138 /// Gets details of a single connection.
139 pub fn get_connection(&self) -> super::builder::repository_manager::GetConnection {
140 super::builder::repository_manager::GetConnection::new(self.inner.clone())
141 }
142
143 /// Lists Connections in a given project and location.
144 pub fn list_connections(&self) -> super::builder::repository_manager::ListConnections {
145 super::builder::repository_manager::ListConnections::new(self.inner.clone())
146 }
147
148 /// Updates 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 update_connection(&self) -> super::builder::repository_manager::UpdateConnection {
160 super::builder::repository_manager::UpdateConnection::new(self.inner.clone())
161 }
162
163 /// Deletes a single connection.
164 ///
165 /// # Long running operations
166 ///
167 /// This method is used to start, and/or poll a [long-running Operation].
168 /// The [Working with long-running operations] chapter in the [user guide]
169 /// covers these operations in detail.
170 ///
171 /// [long-running operation]: https://google.aip.dev/151
172 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
173 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
174 pub fn delete_connection(&self) -> super::builder::repository_manager::DeleteConnection {
175 super::builder::repository_manager::DeleteConnection::new(self.inner.clone())
176 }
177
178 /// Creates a Repository.
179 ///
180 /// # Long running operations
181 ///
182 /// This method is used to start, and/or poll a [long-running Operation].
183 /// The [Working with long-running operations] chapter in the [user guide]
184 /// covers these operations in detail.
185 ///
186 /// [long-running operation]: https://google.aip.dev/151
187 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
188 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
189 pub fn create_repository(&self) -> super::builder::repository_manager::CreateRepository {
190 super::builder::repository_manager::CreateRepository::new(self.inner.clone())
191 }
192
193 /// Creates multiple repositories inside a connection.
194 ///
195 /// # Long running operations
196 ///
197 /// This method is used to start, and/or poll a [long-running Operation].
198 /// The [Working with long-running operations] chapter in the [user guide]
199 /// covers these operations in detail.
200 ///
201 /// [long-running operation]: https://google.aip.dev/151
202 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
203 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
204 pub fn batch_create_repositories(
205 &self,
206 ) -> super::builder::repository_manager::BatchCreateRepositories {
207 super::builder::repository_manager::BatchCreateRepositories::new(self.inner.clone())
208 }
209
210 /// Gets details of a single repository.
211 pub fn get_repository(&self) -> super::builder::repository_manager::GetRepository {
212 super::builder::repository_manager::GetRepository::new(self.inner.clone())
213 }
214
215 /// Lists Repositories in a given connection.
216 pub fn list_repositories(&self) -> super::builder::repository_manager::ListRepositories {
217 super::builder::repository_manager::ListRepositories::new(self.inner.clone())
218 }
219
220 /// Deletes a single repository.
221 ///
222 /// # Long running operations
223 ///
224 /// This method is used to start, and/or poll a [long-running Operation].
225 /// The [Working with long-running operations] chapter in the [user guide]
226 /// covers these operations in detail.
227 ///
228 /// [long-running operation]: https://google.aip.dev/151
229 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
230 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
231 pub fn delete_repository(&self) -> super::builder::repository_manager::DeleteRepository {
232 super::builder::repository_manager::DeleteRepository::new(self.inner.clone())
233 }
234
235 /// Fetches read/write token of a given repository.
236 pub fn fetch_read_write_token(
237 &self,
238 ) -> super::builder::repository_manager::FetchReadWriteToken {
239 super::builder::repository_manager::FetchReadWriteToken::new(self.inner.clone())
240 }
241
242 /// Fetches read token of a given repository.
243 pub fn fetch_read_token(&self) -> super::builder::repository_manager::FetchReadToken {
244 super::builder::repository_manager::FetchReadToken::new(self.inner.clone())
245 }
246
247 /// FetchLinkableRepositories get repositories from SCM that are
248 /// accessible and could be added to the connection.
249 pub fn fetch_linkable_repositories(
250 &self,
251 ) -> super::builder::repository_manager::FetchLinkableRepositories {
252 super::builder::repository_manager::FetchLinkableRepositories::new(self.inner.clone())
253 }
254
255 /// Fetch the list of branches or tags for a given repository.
256 pub fn fetch_git_refs(&self) -> super::builder::repository_manager::FetchGitRefs {
257 super::builder::repository_manager::FetchGitRefs::new(self.inner.clone())
258 }
259
260 /// Sets the access control policy on the specified resource. Replaces
261 /// any existing policy.
262 ///
263 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
264 /// errors.
265 pub fn set_iam_policy(&self) -> super::builder::repository_manager::SetIamPolicy {
266 super::builder::repository_manager::SetIamPolicy::new(self.inner.clone())
267 }
268
269 /// Gets the access control policy for a resource. Returns an empty policy
270 /// if the resource exists and does not have a policy set.
271 pub fn get_iam_policy(&self) -> super::builder::repository_manager::GetIamPolicy {
272 super::builder::repository_manager::GetIamPolicy::new(self.inner.clone())
273 }
274
275 /// Returns permissions that a caller has on the specified resource. If the
276 /// resource does not exist, this will return an empty set of
277 /// permissions, not a `NOT_FOUND` error.
278 ///
279 /// Note: This operation is designed to be used for building
280 /// permission-aware UIs and command-line tools, not for authorization
281 /// checking. This operation may "fail open" without warning.
282 pub fn test_iam_permissions(&self) -> super::builder::repository_manager::TestIamPermissions {
283 super::builder::repository_manager::TestIamPermissions::new(self.inner.clone())
284 }
285
286 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
287 ///
288 /// [google.longrunning.Operations]: longrunning::client::Operations
289 pub fn get_operation(&self) -> super::builder::repository_manager::GetOperation {
290 super::builder::repository_manager::GetOperation::new(self.inner.clone())
291 }
292
293 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
294 ///
295 /// [google.longrunning.Operations]: longrunning::client::Operations
296 pub fn cancel_operation(&self) -> super::builder::repository_manager::CancelOperation {
297 super::builder::repository_manager::CancelOperation::new(self.inner.clone())
298 }
299}