google_cloud_osconfig_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#![allow(rustdoc::bare_urls)]
19#![allow(rustdoc::invalid_html_tags)]
20
21/// Implements a client for the OS Config API.
22///
23/// # Example
24/// ```
25/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
26/// # use google_cloud_osconfig_v1::client::OsConfigService;
27/// let client = OsConfigService::builder().build().await?;
28/// // use `client` to make requests to the OS Config API.
29/// # Ok(()) }
30/// ```
31///
32/// # Service Description
33///
34/// OS Config API
35///
36/// The OS Config service is a server-side component that you can use to
37/// manage package installations and patch jobs for virtual machine instances.
38///
39/// # Configuration
40///
41/// To configure `OsConfigService` use the `with_*` methods in the type returned
42/// by [builder()][OsConfigService::builder]. The default configuration should
43/// work for most applications. Common configuration changes include
44///
45/// * [with_endpoint()]: by default this client uses the global default endpoint
46/// (`https://osconfig.googleapis.com`). Applications using regional
47/// endpoints or running in restricted networks (e.g. a network configured
48// with [Private Google Access with VPC Service Controls]) may want to
49/// override this default.
50/// * [with_credentials()]: by default this client uses
51/// [Application Default Credentials]. Applications using custom
52/// authentication may need to override this default.
53///
54/// [with_endpoint()]: super::builder::os_config_service::ClientBuilder::with_endpoint
55/// [with_credentials()]: super::builder::os_config_service::ClientBuilder::credentials
56/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
57/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
58///
59/// # Pooling and Cloning
60///
61/// `OsConfigService` holds a connection pool internally, it is advised to
62/// create one and the reuse it. You do not need to wrap `OsConfigService` in
63/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
64/// already uses an `Arc` internally.
65#[derive(Clone, Debug)]
66pub struct OsConfigService {
67 inner: std::sync::Arc<dyn super::stub::dynamic::OsConfigService>,
68}
69
70impl OsConfigService {
71 /// Returns a builder for [OsConfigService].
72 ///
73 /// ```
74 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
75 /// # use google_cloud_osconfig_v1::client::OsConfigService;
76 /// let client = OsConfigService::builder().build().await?;
77 /// # Ok(()) }
78 /// ```
79 pub fn builder() -> super::builder::os_config_service::ClientBuilder {
80 crate::new_client_builder(super::builder::os_config_service::client::Factory)
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::OsConfigService + 'static,
90 {
91 Self {
92 inner: std::sync::Arc::new(stub),
93 }
94 }
95
96 pub(crate) async fn new(
97 config: gaxi::options::ClientConfig,
98 ) -> crate::ClientBuilderResult<Self> {
99 let inner = Self::build_inner(config).await?;
100 Ok(Self { inner })
101 }
102
103 async fn build_inner(
104 conf: gaxi::options::ClientConfig,
105 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::OsConfigService>> {
106 if gaxi::options::tracing_enabled(&conf) {
107 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
108 }
109 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
110 }
111
112 async fn build_transport(
113 conf: gaxi::options::ClientConfig,
114 ) -> crate::ClientBuilderResult<impl super::stub::OsConfigService> {
115 super::transport::OsConfigService::new(conf).await
116 }
117
118 async fn build_with_tracing(
119 conf: gaxi::options::ClientConfig,
120 ) -> crate::ClientBuilderResult<impl super::stub::OsConfigService> {
121 Self::build_transport(conf)
122 .await
123 .map(super::tracing::OsConfigService::new)
124 }
125
126 /// Patch VM instances by creating and running a patch job.
127 pub fn execute_patch_job(&self) -> super::builder::os_config_service::ExecutePatchJob {
128 super::builder::os_config_service::ExecutePatchJob::new(self.inner.clone())
129 }
130
131 /// Get the patch job. This can be used to track the progress of an
132 /// ongoing patch job or review the details of completed jobs.
133 pub fn get_patch_job(&self) -> super::builder::os_config_service::GetPatchJob {
134 super::builder::os_config_service::GetPatchJob::new(self.inner.clone())
135 }
136
137 /// Cancel a patch job. The patch job must be active. Canceled patch jobs
138 /// cannot be restarted.
139 pub fn cancel_patch_job(&self) -> super::builder::os_config_service::CancelPatchJob {
140 super::builder::os_config_service::CancelPatchJob::new(self.inner.clone())
141 }
142
143 /// Get a list of patch jobs.
144 pub fn list_patch_jobs(&self) -> super::builder::os_config_service::ListPatchJobs {
145 super::builder::os_config_service::ListPatchJobs::new(self.inner.clone())
146 }
147
148 /// Get a list of instance details for a given patch job.
149 pub fn list_patch_job_instance_details(
150 &self,
151 ) -> super::builder::os_config_service::ListPatchJobInstanceDetails {
152 super::builder::os_config_service::ListPatchJobInstanceDetails::new(self.inner.clone())
153 }
154
155 /// Create an OS Config patch deployment.
156 pub fn create_patch_deployment(
157 &self,
158 ) -> super::builder::os_config_service::CreatePatchDeployment {
159 super::builder::os_config_service::CreatePatchDeployment::new(self.inner.clone())
160 }
161
162 /// Get an OS Config patch deployment.
163 pub fn get_patch_deployment(&self) -> super::builder::os_config_service::GetPatchDeployment {
164 super::builder::os_config_service::GetPatchDeployment::new(self.inner.clone())
165 }
166
167 /// Get a page of OS Config patch deployments.
168 pub fn list_patch_deployments(
169 &self,
170 ) -> super::builder::os_config_service::ListPatchDeployments {
171 super::builder::os_config_service::ListPatchDeployments::new(self.inner.clone())
172 }
173
174 /// Delete an OS Config patch deployment.
175 pub fn delete_patch_deployment(
176 &self,
177 ) -> super::builder::os_config_service::DeletePatchDeployment {
178 super::builder::os_config_service::DeletePatchDeployment::new(self.inner.clone())
179 }
180
181 /// Update an OS Config patch deployment.
182 pub fn update_patch_deployment(
183 &self,
184 ) -> super::builder::os_config_service::UpdatePatchDeployment {
185 super::builder::os_config_service::UpdatePatchDeployment::new(self.inner.clone())
186 }
187
188 /// Change state of patch deployment to "PAUSED".
189 /// Patch deployment in paused state doesn't generate patch jobs.
190 pub fn pause_patch_deployment(
191 &self,
192 ) -> super::builder::os_config_service::PausePatchDeployment {
193 super::builder::os_config_service::PausePatchDeployment::new(self.inner.clone())
194 }
195
196 /// Change state of patch deployment back to "ACTIVE".
197 /// Patch deployment in active state continues to generate patch jobs.
198 pub fn resume_patch_deployment(
199 &self,
200 ) -> super::builder::os_config_service::ResumePatchDeployment {
201 super::builder::os_config_service::ResumePatchDeployment::new(self.inner.clone())
202 }
203
204 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
205 ///
206 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
207 pub fn get_operation(&self) -> super::builder::os_config_service::GetOperation {
208 super::builder::os_config_service::GetOperation::new(self.inner.clone())
209 }
210
211 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
212 ///
213 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
214 pub fn cancel_operation(&self) -> super::builder::os_config_service::CancelOperation {
215 super::builder::os_config_service::CancelOperation::new(self.inner.clone())
216 }
217}
218
219/// Implements a client for the OS Config API.
220///
221/// # Example
222/// ```
223/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
224/// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
225/// let client = OsConfigZonalService::builder().build().await?;
226/// // use `client` to make requests to the OS Config API.
227/// # Ok(()) }
228/// ```
229///
230/// # Service Description
231///
232/// Zonal OS Config API
233///
234/// The OS Config service is the server-side component that allows users to
235/// manage package installations and patch jobs for Compute Engine VM instances.
236///
237/// # Configuration
238///
239/// To configure `OsConfigZonalService` use the `with_*` methods in the type returned
240/// by [builder()][OsConfigZonalService::builder]. The default configuration should
241/// work for most applications. Common configuration changes include
242///
243/// * [with_endpoint()]: by default this client uses the global default endpoint
244/// (`https://osconfig.googleapis.com`). Applications using regional
245/// endpoints or running in restricted networks (e.g. a network configured
246// with [Private Google Access with VPC Service Controls]) may want to
247/// override this default.
248/// * [with_credentials()]: by default this client uses
249/// [Application Default Credentials]. Applications using custom
250/// authentication may need to override this default.
251///
252/// [with_endpoint()]: super::builder::os_config_zonal_service::ClientBuilder::with_endpoint
253/// [with_credentials()]: super::builder::os_config_zonal_service::ClientBuilder::credentials
254/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
255/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
256///
257/// # Pooling and Cloning
258///
259/// `OsConfigZonalService` holds a connection pool internally, it is advised to
260/// create one and the reuse it. You do not need to wrap `OsConfigZonalService` in
261/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
262/// already uses an `Arc` internally.
263#[derive(Clone, Debug)]
264pub struct OsConfigZonalService {
265 inner: std::sync::Arc<dyn super::stub::dynamic::OsConfigZonalService>,
266}
267
268impl OsConfigZonalService {
269 /// Returns a builder for [OsConfigZonalService].
270 ///
271 /// ```
272 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
273 /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
274 /// let client = OsConfigZonalService::builder().build().await?;
275 /// # Ok(()) }
276 /// ```
277 pub fn builder() -> super::builder::os_config_zonal_service::ClientBuilder {
278 crate::new_client_builder(super::builder::os_config_zonal_service::client::Factory)
279 }
280
281 /// Creates a new client from the provided stub.
282 ///
283 /// The most common case for calling this function is in tests mocking the
284 /// client's behavior.
285 pub fn from_stub<T>(stub: T) -> Self
286 where
287 T: super::stub::OsConfigZonalService + 'static,
288 {
289 Self {
290 inner: std::sync::Arc::new(stub),
291 }
292 }
293
294 pub(crate) async fn new(
295 config: gaxi::options::ClientConfig,
296 ) -> crate::ClientBuilderResult<Self> {
297 let inner = Self::build_inner(config).await?;
298 Ok(Self { inner })
299 }
300
301 async fn build_inner(
302 conf: gaxi::options::ClientConfig,
303 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::OsConfigZonalService>>
304 {
305 if gaxi::options::tracing_enabled(&conf) {
306 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
307 }
308 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
309 }
310
311 async fn build_transport(
312 conf: gaxi::options::ClientConfig,
313 ) -> crate::ClientBuilderResult<impl super::stub::OsConfigZonalService> {
314 super::transport::OsConfigZonalService::new(conf).await
315 }
316
317 async fn build_with_tracing(
318 conf: gaxi::options::ClientConfig,
319 ) -> crate::ClientBuilderResult<impl super::stub::OsConfigZonalService> {
320 Self::build_transport(conf)
321 .await
322 .map(super::tracing::OsConfigZonalService::new)
323 }
324
325 /// Create an OS policy assignment.
326 ///
327 /// This method also creates the first revision of the OS policy assignment.
328 ///
329 /// This method returns a long running operation (LRO) that contains the
330 /// rollout details. The rollout can be cancelled by cancelling the LRO.
331 ///
332 /// For more information, see [Method:
333 /// projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).
334 ///
335 /// # Long running operations
336 ///
337 /// This method is used to start, and/or poll a [long-running Operation].
338 /// The [Working with long-running operations] chapter in the [user guide]
339 /// covers these operations in detail.
340 ///
341 /// [long-running operation]: https://google.aip.dev/151
342 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
343 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
344 pub fn create_os_policy_assignment(
345 &self,
346 ) -> super::builder::os_config_zonal_service::CreateOSPolicyAssignment {
347 super::builder::os_config_zonal_service::CreateOSPolicyAssignment::new(self.inner.clone())
348 }
349
350 /// Update an existing OS policy assignment.
351 ///
352 /// This method creates a new revision of the OS policy assignment.
353 ///
354 /// This method returns a long running operation (LRO) that contains the
355 /// rollout details. The rollout can be cancelled by cancelling the LRO.
356 ///
357 /// For more information, see [Method:
358 /// projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).
359 ///
360 /// # Long running operations
361 ///
362 /// This method is used to start, and/or poll a [long-running Operation].
363 /// The [Working with long-running operations] chapter in the [user guide]
364 /// covers these operations in detail.
365 ///
366 /// [long-running operation]: https://google.aip.dev/151
367 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
368 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
369 pub fn update_os_policy_assignment(
370 &self,
371 ) -> super::builder::os_config_zonal_service::UpdateOSPolicyAssignment {
372 super::builder::os_config_zonal_service::UpdateOSPolicyAssignment::new(self.inner.clone())
373 }
374
375 /// Retrieve an existing OS policy assignment.
376 ///
377 /// This method always returns the latest revision. In order to retrieve a
378 /// previous revision of the assignment, also provide the revision ID in the
379 /// `name` parameter.
380 pub fn get_os_policy_assignment(
381 &self,
382 ) -> super::builder::os_config_zonal_service::GetOSPolicyAssignment {
383 super::builder::os_config_zonal_service::GetOSPolicyAssignment::new(self.inner.clone())
384 }
385
386 /// List the OS policy assignments under the parent resource.
387 ///
388 /// For each OS policy assignment, the latest revision is returned.
389 pub fn list_os_policy_assignments(
390 &self,
391 ) -> super::builder::os_config_zonal_service::ListOSPolicyAssignments {
392 super::builder::os_config_zonal_service::ListOSPolicyAssignments::new(self.inner.clone())
393 }
394
395 /// List the OS policy assignment revisions for a given OS policy assignment.
396 pub fn list_os_policy_assignment_revisions(
397 &self,
398 ) -> super::builder::os_config_zonal_service::ListOSPolicyAssignmentRevisions {
399 super::builder::os_config_zonal_service::ListOSPolicyAssignmentRevisions::new(
400 self.inner.clone(),
401 )
402 }
403
404 /// Delete the OS policy assignment.
405 ///
406 /// This method creates a new revision of the OS policy assignment.
407 ///
408 /// This method returns a long running operation (LRO) that contains the
409 /// rollout details. The rollout can be cancelled by cancelling the LRO.
410 ///
411 /// If the LRO completes and is not cancelled, all revisions associated with
412 /// the OS policy assignment are deleted.
413 ///
414 /// For more information, see [Method:
415 /// projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).
416 ///
417 /// # Long running operations
418 ///
419 /// This method is used to start, and/or poll a [long-running Operation].
420 /// The [Working with long-running operations] chapter in the [user guide]
421 /// covers these operations in detail.
422 ///
423 /// [long-running operation]: https://google.aip.dev/151
424 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
425 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
426 pub fn delete_os_policy_assignment(
427 &self,
428 ) -> super::builder::os_config_zonal_service::DeleteOSPolicyAssignment {
429 super::builder::os_config_zonal_service::DeleteOSPolicyAssignment::new(self.inner.clone())
430 }
431
432 /// Get the OS policy asssignment report for the specified Compute Engine VM
433 /// instance.
434 pub fn get_os_policy_assignment_report(
435 &self,
436 ) -> super::builder::os_config_zonal_service::GetOSPolicyAssignmentReport {
437 super::builder::os_config_zonal_service::GetOSPolicyAssignmentReport::new(
438 self.inner.clone(),
439 )
440 }
441
442 /// List OS policy asssignment reports for all Compute Engine VM instances in
443 /// the specified zone.
444 pub fn list_os_policy_assignment_reports(
445 &self,
446 ) -> super::builder::os_config_zonal_service::ListOSPolicyAssignmentReports {
447 super::builder::os_config_zonal_service::ListOSPolicyAssignmentReports::new(
448 self.inner.clone(),
449 )
450 }
451
452 /// Get inventory data for the specified VM instance. If the VM has no
453 /// associated inventory, the message `NOT_FOUND` is returned.
454 pub fn get_inventory(&self) -> super::builder::os_config_zonal_service::GetInventory {
455 super::builder::os_config_zonal_service::GetInventory::new(self.inner.clone())
456 }
457
458 /// List inventory data for all VM instances in the specified zone.
459 pub fn list_inventories(&self) -> super::builder::os_config_zonal_service::ListInventories {
460 super::builder::os_config_zonal_service::ListInventories::new(self.inner.clone())
461 }
462
463 /// Gets the vulnerability report for the specified VM instance. Only VMs with
464 /// inventory data have vulnerability reports associated with them.
465 pub fn get_vulnerability_report(
466 &self,
467 ) -> super::builder::os_config_zonal_service::GetVulnerabilityReport {
468 super::builder::os_config_zonal_service::GetVulnerabilityReport::new(self.inner.clone())
469 }
470
471 /// List vulnerability reports for all VM instances in the specified zone.
472 pub fn list_vulnerability_reports(
473 &self,
474 ) -> super::builder::os_config_zonal_service::ListVulnerabilityReports {
475 super::builder::os_config_zonal_service::ListVulnerabilityReports::new(self.inner.clone())
476 }
477
478 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
479 ///
480 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
481 pub fn get_operation(&self) -> super::builder::os_config_zonal_service::GetOperation {
482 super::builder::os_config_zonal_service::GetOperation::new(self.inner.clone())
483 }
484
485 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
486 ///
487 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
488 pub fn cancel_operation(&self) -> super::builder::os_config_zonal_service::CancelOperation {
489 super::builder::os_config_zonal_service::CancelOperation::new(self.inner.clone())
490 }
491}