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