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