google_cloud_config_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
19/// Implements a client for the Infrastructure Manager API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_config_v1::client::Config;
25/// let client = Config::builder().build().await?;
26/// // use `client` to make requests to the Infrastructure Manager API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Infrastructure Manager is a managed service that automates the deployment and
33/// management of Google Cloud infrastructure resources.
34///
35/// # Configuration
36///
37/// To configure `Config` use the `with_*` methods in the type returned
38/// by [builder()][Config::builder]. The default configuration should
39/// work for most applications. Common configuration changes include
40///
41/// * [with_endpoint()]: by default this client uses the global default endpoint
42/// (`https://config.googleapis.com`). Applications using regional
43/// endpoints or running in restricted networks (e.g. a network configured
44// with [Private Google Access with VPC Service Controls]) may want to
45/// override this default.
46/// * [with_credentials()]: by default this client uses
47/// [Application Default Credentials]. Applications using custom
48/// authentication may need to override this default.
49///
50/// [with_endpoint()]: super::builder::config::ClientBuilder::with_endpoint
51/// [with_credentials()]: super::builder::config::ClientBuilder::credentials
52/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
53/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
54///
55/// # Pooling and Cloning
56///
57/// `Config` holds a connection pool internally, it is advised to
58/// create one and the reuse it. You do not need to wrap `Config` in
59/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
60/// already uses an `Arc` internally.
61#[derive(Clone, Debug)]
62pub struct Config {
63 inner: std::sync::Arc<dyn super::stub::dynamic::Config>,
64}
65
66impl Config {
67 /// Returns a builder for [Config].
68 ///
69 /// ```
70 /// # tokio_test::block_on(async {
71 /// # use google_cloud_config_v1::client::Config;
72 /// let client = Config::builder().build().await?;
73 /// # gax::client_builder::Result::<()>::Ok(()) });
74 /// ```
75 pub fn builder() -> super::builder::config::ClientBuilder {
76 gax::client_builder::internal::new_builder(super::builder::config::client::Factory)
77 }
78
79 /// Creates a new client from the provided stub.
80 ///
81 /// The most common case for calling this function is in tests mocking the
82 /// client's behavior.
83 pub fn from_stub<T>(stub: T) -> Self
84 where
85 T: super::stub::Config + 'static,
86 {
87 Self {
88 inner: std::sync::Arc::new(stub),
89 }
90 }
91
92 pub(crate) async fn new(
93 config: gaxi::options::ClientConfig,
94 ) -> gax::client_builder::Result<Self> {
95 let inner = Self::build_inner(config).await?;
96 Ok(Self { inner })
97 }
98
99 async fn build_inner(
100 conf: gaxi::options::ClientConfig,
101 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Config>> {
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 ) -> gax::client_builder::Result<impl super::stub::Config> {
111 super::transport::Config::new(conf).await
112 }
113
114 async fn build_with_tracing(
115 conf: gaxi::options::ClientConfig,
116 ) -> gax::client_builder::Result<impl super::stub::Config> {
117 Self::build_transport(conf)
118 .await
119 .map(super::tracing::Config::new)
120 }
121
122 /// Lists [Deployment][google.cloud.config.v1.Deployment]s in a given project
123 /// and location.
124 ///
125 /// [google.cloud.config.v1.Deployment]: crate::model::Deployment
126 pub fn list_deployments(&self) -> super::builder::config::ListDeployments {
127 super::builder::config::ListDeployments::new(self.inner.clone())
128 }
129
130 /// Gets details about a [Deployment][google.cloud.config.v1.Deployment].
131 ///
132 /// [google.cloud.config.v1.Deployment]: crate::model::Deployment
133 pub fn get_deployment(&self) -> super::builder::config::GetDeployment {
134 super::builder::config::GetDeployment::new(self.inner.clone())
135 }
136
137 /// Creates a [Deployment][google.cloud.config.v1.Deployment].
138 ///
139 /// [google.cloud.config.v1.Deployment]: crate::model::Deployment
140 ///
141 /// # Long running operations
142 ///
143 /// This method is used to start, and/or poll a [long-running Operation].
144 /// The [Working with long-running operations] chapter in the [user guide]
145 /// covers these operations in detail.
146 ///
147 /// [long-running operation]: https://google.aip.dev/151
148 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
149 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
150 pub fn create_deployment(&self) -> super::builder::config::CreateDeployment {
151 super::builder::config::CreateDeployment::new(self.inner.clone())
152 }
153
154 /// Updates a [Deployment][google.cloud.config.v1.Deployment].
155 ///
156 /// [google.cloud.config.v1.Deployment]: crate::model::Deployment
157 ///
158 /// # Long running operations
159 ///
160 /// This method is used to start, and/or poll a [long-running Operation].
161 /// The [Working with long-running operations] chapter in the [user guide]
162 /// covers these operations in detail.
163 ///
164 /// [long-running operation]: https://google.aip.dev/151
165 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
166 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
167 pub fn update_deployment(&self) -> super::builder::config::UpdateDeployment {
168 super::builder::config::UpdateDeployment::new(self.inner.clone())
169 }
170
171 /// Deletes a [Deployment][google.cloud.config.v1.Deployment].
172 ///
173 /// [google.cloud.config.v1.Deployment]: crate::model::Deployment
174 ///
175 /// # Long running operations
176 ///
177 /// This method is used to start, and/or poll a [long-running Operation].
178 /// The [Working with long-running operations] chapter in the [user guide]
179 /// covers these operations in detail.
180 ///
181 /// [long-running operation]: https://google.aip.dev/151
182 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
183 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
184 pub fn delete_deployment(&self) -> super::builder::config::DeleteDeployment {
185 super::builder::config::DeleteDeployment::new(self.inner.clone())
186 }
187
188 /// Lists [Revision][google.cloud.config.v1.Revision]s of a deployment.
189 ///
190 /// [google.cloud.config.v1.Revision]: crate::model::Revision
191 pub fn list_revisions(&self) -> super::builder::config::ListRevisions {
192 super::builder::config::ListRevisions::new(self.inner.clone())
193 }
194
195 /// Gets details about a [Revision][google.cloud.config.v1.Revision].
196 ///
197 /// [google.cloud.config.v1.Revision]: crate::model::Revision
198 pub fn get_revision(&self) -> super::builder::config::GetRevision {
199 super::builder::config::GetRevision::new(self.inner.clone())
200 }
201
202 /// Gets details about a [Resource][google.cloud.config.v1.Resource] deployed
203 /// by Infra Manager.
204 ///
205 /// [google.cloud.config.v1.Resource]: crate::model::Resource
206 pub fn get_resource(&self) -> super::builder::config::GetResource {
207 super::builder::config::GetResource::new(self.inner.clone())
208 }
209
210 /// Lists [Resources][google.cloud.config.v1.Resource] in a given revision.
211 ///
212 /// [google.cloud.config.v1.Resource]: crate::model::Resource
213 pub fn list_resources(&self) -> super::builder::config::ListResources {
214 super::builder::config::ListResources::new(self.inner.clone())
215 }
216
217 /// Exports Terraform state file from a given deployment.
218 pub fn export_deployment_statefile(&self) -> super::builder::config::ExportDeploymentStatefile {
219 super::builder::config::ExportDeploymentStatefile::new(self.inner.clone())
220 }
221
222 /// Exports Terraform state file from a given revision.
223 pub fn export_revision_statefile(&self) -> super::builder::config::ExportRevisionStatefile {
224 super::builder::config::ExportRevisionStatefile::new(self.inner.clone())
225 }
226
227 /// Imports Terraform state file in a given deployment. The state file does not
228 /// take effect until the Deployment has been unlocked.
229 pub fn import_statefile(&self) -> super::builder::config::ImportStatefile {
230 super::builder::config::ImportStatefile::new(self.inner.clone())
231 }
232
233 /// Deletes Terraform state file in a given deployment.
234 pub fn delete_statefile(&self) -> super::builder::config::DeleteStatefile {
235 super::builder::config::DeleteStatefile::new(self.inner.clone())
236 }
237
238 /// Locks a deployment.
239 ///
240 /// # Long running operations
241 ///
242 /// This method is used to start, and/or poll a [long-running Operation].
243 /// The [Working with long-running operations] chapter in the [user guide]
244 /// covers these operations in detail.
245 ///
246 /// [long-running operation]: https://google.aip.dev/151
247 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
248 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
249 pub fn lock_deployment(&self) -> super::builder::config::LockDeployment {
250 super::builder::config::LockDeployment::new(self.inner.clone())
251 }
252
253 /// Unlocks a locked deployment.
254 ///
255 /// # Long running operations
256 ///
257 /// This method is used to start, and/or poll a [long-running Operation].
258 /// The [Working with long-running operations] chapter in the [user guide]
259 /// covers these operations in detail.
260 ///
261 /// [long-running operation]: https://google.aip.dev/151
262 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
263 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
264 pub fn unlock_deployment(&self) -> super::builder::config::UnlockDeployment {
265 super::builder::config::UnlockDeployment::new(self.inner.clone())
266 }
267
268 /// Exports the lock info on a locked deployment.
269 pub fn export_lock_info(&self) -> super::builder::config::ExportLockInfo {
270 super::builder::config::ExportLockInfo::new(self.inner.clone())
271 }
272
273 /// Creates a [Preview][google.cloud.config.v1.Preview].
274 ///
275 /// [google.cloud.config.v1.Preview]: crate::model::Preview
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 pub fn create_preview(&self) -> super::builder::config::CreatePreview {
287 super::builder::config::CreatePreview::new(self.inner.clone())
288 }
289
290 /// Gets details about a [Preview][google.cloud.config.v1.Preview].
291 ///
292 /// [google.cloud.config.v1.Preview]: crate::model::Preview
293 pub fn get_preview(&self) -> super::builder::config::GetPreview {
294 super::builder::config::GetPreview::new(self.inner.clone())
295 }
296
297 /// Lists [Preview][google.cloud.config.v1.Preview]s in a given project and
298 /// location.
299 ///
300 /// [google.cloud.config.v1.Preview]: crate::model::Preview
301 pub fn list_previews(&self) -> super::builder::config::ListPreviews {
302 super::builder::config::ListPreviews::new(self.inner.clone())
303 }
304
305 /// Deletes a [Preview][google.cloud.config.v1.Preview].
306 ///
307 /// [google.cloud.config.v1.Preview]: crate::model::Preview
308 ///
309 /// # Long running operations
310 ///
311 /// This method is used to start, and/or poll a [long-running Operation].
312 /// The [Working with long-running operations] chapter in the [user guide]
313 /// covers these operations in detail.
314 ///
315 /// [long-running operation]: https://google.aip.dev/151
316 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
317 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
318 pub fn delete_preview(&self) -> super::builder::config::DeletePreview {
319 super::builder::config::DeletePreview::new(self.inner.clone())
320 }
321
322 /// Export [Preview][google.cloud.config.v1.Preview] results.
323 ///
324 /// [google.cloud.config.v1.Preview]: crate::model::Preview
325 pub fn export_preview_result(&self) -> super::builder::config::ExportPreviewResult {
326 super::builder::config::ExportPreviewResult::new(self.inner.clone())
327 }
328
329 /// Lists [TerraformVersion][google.cloud.config.v1.TerraformVersion]s in a
330 /// given project and location.
331 ///
332 /// [google.cloud.config.v1.TerraformVersion]: crate::model::TerraformVersion
333 pub fn list_terraform_versions(&self) -> super::builder::config::ListTerraformVersions {
334 super::builder::config::ListTerraformVersions::new(self.inner.clone())
335 }
336
337 /// Gets details about a
338 /// [TerraformVersion][google.cloud.config.v1.TerraformVersion].
339 ///
340 /// [google.cloud.config.v1.TerraformVersion]: crate::model::TerraformVersion
341 pub fn get_terraform_version(&self) -> super::builder::config::GetTerraformVersion {
342 super::builder::config::GetTerraformVersion::new(self.inner.clone())
343 }
344
345 /// Lists information about the supported locations for this service.
346 pub fn list_locations(&self) -> super::builder::config::ListLocations {
347 super::builder::config::ListLocations::new(self.inner.clone())
348 }
349
350 /// Gets information about a location.
351 pub fn get_location(&self) -> super::builder::config::GetLocation {
352 super::builder::config::GetLocation::new(self.inner.clone())
353 }
354
355 /// Sets the access control policy on the specified resource. Replaces
356 /// any existing policy.
357 ///
358 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
359 /// errors.
360 pub fn set_iam_policy(&self) -> super::builder::config::SetIamPolicy {
361 super::builder::config::SetIamPolicy::new(self.inner.clone())
362 }
363
364 /// Gets the access control policy for a resource. Returns an empty policy
365 /// if the resource exists and does not have a policy set.
366 pub fn get_iam_policy(&self) -> super::builder::config::GetIamPolicy {
367 super::builder::config::GetIamPolicy::new(self.inner.clone())
368 }
369
370 /// Returns permissions that a caller has on the specified resource. If the
371 /// resource does not exist, this will return an empty set of
372 /// permissions, not a `NOT_FOUND` error.
373 ///
374 /// Note: This operation is designed to be used for building
375 /// permission-aware UIs and command-line tools, not for authorization
376 /// checking. This operation may "fail open" without warning.
377 pub fn test_iam_permissions(&self) -> super::builder::config::TestIamPermissions {
378 super::builder::config::TestIamPermissions::new(self.inner.clone())
379 }
380
381 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
382 ///
383 /// [google.longrunning.Operations]: longrunning::client::Operations
384 pub fn list_operations(&self) -> super::builder::config::ListOperations {
385 super::builder::config::ListOperations::new(self.inner.clone())
386 }
387
388 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
389 ///
390 /// [google.longrunning.Operations]: longrunning::client::Operations
391 pub fn get_operation(&self) -> super::builder::config::GetOperation {
392 super::builder::config::GetOperation::new(self.inner.clone())
393 }
394
395 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
396 ///
397 /// [google.longrunning.Operations]: longrunning::client::Operations
398 pub fn delete_operation(&self) -> super::builder::config::DeleteOperation {
399 super::builder::config::DeleteOperation::new(self.inner.clone())
400 }
401
402 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
403 ///
404 /// [google.longrunning.Operations]: longrunning::client::Operations
405 pub fn cancel_operation(&self) -> super::builder::config::CancelOperation {
406 super::builder::config::CancelOperation::new(self.inner.clone())
407 }
408}