Skip to main content

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/// # use google_cloud_osconfig_v1::client::OsConfigService;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
28///     let client = OsConfigService::builder().build().await?;
29///     let parent = "parent_value";
30///     let mut list = client.list_patch_jobs()
31///         .set_parent(parent)
32///         .by_item();
33///     while let Some(item) = list.next().await.transpose()? {
34///         println!("{:?}", item);
35///     }
36/// # Ok(()) }
37/// ```
38///
39/// # Service Description
40///
41/// OS Config API
42///
43/// The OS Config service is a server-side component that you can use to
44/// manage package installations and patch jobs for virtual machine instances.
45///
46/// # Configuration
47///
48/// To configure `OsConfigService` use the `with_*` methods in the type returned
49/// by [builder()][OsConfigService::builder]. The default configuration should
50/// work for most applications. Common configuration changes include
51///
52/// * [with_endpoint()]: by default this client uses the global default endpoint
53///   (`https://osconfig.googleapis.com`). Applications using regional
54///   endpoints or running in restricted networks (e.g. a network configured
55//    with [Private Google Access with VPC Service Controls]) may want to
56///   override this default.
57/// * [with_credentials()]: by default this client uses
58///   [Application Default Credentials]. Applications using custom
59///   authentication may need to override this default.
60///
61/// [with_endpoint()]: super::builder::os_config_service::ClientBuilder::with_endpoint
62/// [with_credentials()]: super::builder::os_config_service::ClientBuilder::with_credentials
63/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
64/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
65///
66/// # Pooling and Cloning
67///
68/// `OsConfigService` holds a connection pool internally, it is advised to
69/// create one and reuse it. You do not need to wrap `OsConfigService` in
70/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
71/// already uses an `Arc` internally.
72#[derive(Clone, Debug)]
73pub struct OsConfigService {
74    inner: std::sync::Arc<dyn super::stub::dynamic::OsConfigService>,
75}
76
77impl OsConfigService {
78    /// Returns a builder for [OsConfigService].
79    ///
80    /// ```
81    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
82    /// # use google_cloud_osconfig_v1::client::OsConfigService;
83    /// let client = OsConfigService::builder().build().await?;
84    /// # Ok(()) }
85    /// ```
86    pub fn builder() -> super::builder::os_config_service::ClientBuilder {
87        crate::new_client_builder(super::builder::os_config_service::client::Factory)
88    }
89
90    /// Creates a new client from the provided stub.
91    ///
92    /// The most common case for calling this function is in tests mocking the
93    /// client's behavior.
94    pub fn from_stub<T>(stub: T) -> Self
95    where
96        T: super::stub::OsConfigService + 'static,
97    {
98        Self {
99            inner: std::sync::Arc::new(stub),
100        }
101    }
102
103    pub(crate) async fn new(
104        config: gaxi::options::ClientConfig,
105    ) -> crate::ClientBuilderResult<Self> {
106        let inner = Self::build_inner(config).await?;
107        Ok(Self { inner })
108    }
109
110    async fn build_inner(
111        conf: gaxi::options::ClientConfig,
112    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::OsConfigService>> {
113        if gaxi::options::tracing_enabled(&conf) {
114            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
115        }
116        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
117    }
118
119    async fn build_transport(
120        conf: gaxi::options::ClientConfig,
121    ) -> crate::ClientBuilderResult<impl super::stub::OsConfigService> {
122        super::transport::OsConfigService::new(conf).await
123    }
124
125    async fn build_with_tracing(
126        conf: gaxi::options::ClientConfig,
127    ) -> crate::ClientBuilderResult<impl super::stub::OsConfigService> {
128        Self::build_transport(conf)
129            .await
130            .map(super::tracing::OsConfigService::new)
131    }
132
133    /// Patch VM instances by creating and running a patch job.
134    ///
135    /// # Example
136    /// ```
137    /// # use google_cloud_osconfig_v1::client::OsConfigService;
138    /// use google_cloud_osconfig_v1::Result;
139    /// async fn sample(
140    ///    client: &OsConfigService
141    /// ) -> Result<()> {
142    ///     let response = client.execute_patch_job()
143    ///         /* set fields */
144    ///         .send().await?;
145    ///     println!("response {:?}", response);
146    ///     Ok(())
147    /// }
148    /// ```
149    pub fn execute_patch_job(&self) -> super::builder::os_config_service::ExecutePatchJob {
150        super::builder::os_config_service::ExecutePatchJob::new(self.inner.clone())
151    }
152
153    /// Get the patch job. This can be used to track the progress of an
154    /// ongoing patch job or review the details of completed jobs.
155    ///
156    /// # Example
157    /// ```
158    /// # use google_cloud_osconfig_v1::client::OsConfigService;
159    /// use google_cloud_osconfig_v1::Result;
160    /// async fn sample(
161    ///    client: &OsConfigService, name: &str
162    /// ) -> Result<()> {
163    ///     let response = client.get_patch_job()
164    ///         .set_name(name)
165    ///         .send().await?;
166    ///     println!("response {:?}", response);
167    ///     Ok(())
168    /// }
169    /// ```
170    pub fn get_patch_job(&self) -> super::builder::os_config_service::GetPatchJob {
171        super::builder::os_config_service::GetPatchJob::new(self.inner.clone())
172    }
173
174    /// Cancel a patch job. The patch job must be active. Canceled patch jobs
175    /// cannot be restarted.
176    ///
177    /// # Example
178    /// ```
179    /// # use google_cloud_osconfig_v1::client::OsConfigService;
180    /// use google_cloud_osconfig_v1::Result;
181    /// async fn sample(
182    ///    client: &OsConfigService
183    /// ) -> Result<()> {
184    ///     let response = client.cancel_patch_job()
185    ///         /* set fields */
186    ///         .send().await?;
187    ///     println!("response {:?}", response);
188    ///     Ok(())
189    /// }
190    /// ```
191    pub fn cancel_patch_job(&self) -> super::builder::os_config_service::CancelPatchJob {
192        super::builder::os_config_service::CancelPatchJob::new(self.inner.clone())
193    }
194
195    /// Get a list of patch jobs.
196    ///
197    /// # Example
198    /// ```
199    /// # use google_cloud_osconfig_v1::client::OsConfigService;
200    /// use google_cloud_gax::paginator::ItemPaginator as _;
201    /// use google_cloud_osconfig_v1::Result;
202    /// async fn sample(
203    ///    client: &OsConfigService, parent: &str
204    /// ) -> Result<()> {
205    ///     let mut list = client.list_patch_jobs()
206    ///         .set_parent(parent)
207    ///         .by_item();
208    ///     while let Some(item) = list.next().await.transpose()? {
209    ///         println!("{:?}", item);
210    ///     }
211    ///     Ok(())
212    /// }
213    /// ```
214    pub fn list_patch_jobs(&self) -> super::builder::os_config_service::ListPatchJobs {
215        super::builder::os_config_service::ListPatchJobs::new(self.inner.clone())
216    }
217
218    /// Get a list of instance details for a given patch job.
219    ///
220    /// # Example
221    /// ```
222    /// # use google_cloud_osconfig_v1::client::OsConfigService;
223    /// use google_cloud_gax::paginator::ItemPaginator as _;
224    /// use google_cloud_osconfig_v1::Result;
225    /// async fn sample(
226    ///    client: &OsConfigService
227    /// ) -> Result<()> {
228    ///     let mut list = client.list_patch_job_instance_details()
229    ///         /* set fields */
230    ///         .by_item();
231    ///     while let Some(item) = list.next().await.transpose()? {
232    ///         println!("{:?}", item);
233    ///     }
234    ///     Ok(())
235    /// }
236    /// ```
237    pub fn list_patch_job_instance_details(
238        &self,
239    ) -> super::builder::os_config_service::ListPatchJobInstanceDetails {
240        super::builder::os_config_service::ListPatchJobInstanceDetails::new(self.inner.clone())
241    }
242
243    /// Create an OS Config patch deployment.
244    ///
245    /// # Example
246    /// ```
247    /// # use google_cloud_osconfig_v1::client::OsConfigService;
248    /// use google_cloud_osconfig_v1::model::PatchDeployment;
249    /// use google_cloud_osconfig_v1::Result;
250    /// async fn sample(
251    ///    client: &OsConfigService, parent: &str
252    /// ) -> Result<()> {
253    ///     let response = client.create_patch_deployment()
254    ///         .set_parent(parent)
255    ///         .set_patch_deployment(
256    ///             PatchDeployment::new()/* set fields */
257    ///         )
258    ///         .send().await?;
259    ///     println!("response {:?}", response);
260    ///     Ok(())
261    /// }
262    /// ```
263    pub fn create_patch_deployment(
264        &self,
265    ) -> super::builder::os_config_service::CreatePatchDeployment {
266        super::builder::os_config_service::CreatePatchDeployment::new(self.inner.clone())
267    }
268
269    /// Get an OS Config patch deployment.
270    ///
271    /// # Example
272    /// ```
273    /// # use google_cloud_osconfig_v1::client::OsConfigService;
274    /// use google_cloud_osconfig_v1::Result;
275    /// async fn sample(
276    ///    client: &OsConfigService, name: &str
277    /// ) -> Result<()> {
278    ///     let response = client.get_patch_deployment()
279    ///         .set_name(name)
280    ///         .send().await?;
281    ///     println!("response {:?}", response);
282    ///     Ok(())
283    /// }
284    /// ```
285    pub fn get_patch_deployment(&self) -> super::builder::os_config_service::GetPatchDeployment {
286        super::builder::os_config_service::GetPatchDeployment::new(self.inner.clone())
287    }
288
289    /// Get a page of OS Config patch deployments.
290    ///
291    /// # Example
292    /// ```
293    /// # use google_cloud_osconfig_v1::client::OsConfigService;
294    /// use google_cloud_gax::paginator::ItemPaginator as _;
295    /// use google_cloud_osconfig_v1::Result;
296    /// async fn sample(
297    ///    client: &OsConfigService, parent: &str
298    /// ) -> Result<()> {
299    ///     let mut list = client.list_patch_deployments()
300    ///         .set_parent(parent)
301    ///         .by_item();
302    ///     while let Some(item) = list.next().await.transpose()? {
303    ///         println!("{:?}", item);
304    ///     }
305    ///     Ok(())
306    /// }
307    /// ```
308    pub fn list_patch_deployments(
309        &self,
310    ) -> super::builder::os_config_service::ListPatchDeployments {
311        super::builder::os_config_service::ListPatchDeployments::new(self.inner.clone())
312    }
313
314    /// Delete an OS Config patch deployment.
315    ///
316    /// # Example
317    /// ```
318    /// # use google_cloud_osconfig_v1::client::OsConfigService;
319    /// use google_cloud_osconfig_v1::Result;
320    /// async fn sample(
321    ///    client: &OsConfigService, name: &str
322    /// ) -> Result<()> {
323    ///     client.delete_patch_deployment()
324    ///         .set_name(name)
325    ///         .send().await?;
326    ///     Ok(())
327    /// }
328    /// ```
329    pub fn delete_patch_deployment(
330        &self,
331    ) -> super::builder::os_config_service::DeletePatchDeployment {
332        super::builder::os_config_service::DeletePatchDeployment::new(self.inner.clone())
333    }
334
335    /// Update an OS Config patch deployment.
336    ///
337    /// # Example
338    /// ```
339    /// # use google_cloud_osconfig_v1::client::OsConfigService;
340    /// # extern crate wkt as google_cloud_wkt;
341    /// use google_cloud_wkt::FieldMask;
342    /// use google_cloud_osconfig_v1::model::PatchDeployment;
343    /// use google_cloud_osconfig_v1::Result;
344    /// async fn sample(
345    ///    client: &OsConfigService, name: &str
346    /// ) -> Result<()> {
347    ///     let response = client.update_patch_deployment()
348    ///         .set_patch_deployment(
349    ///             PatchDeployment::new().set_name(name)/* set fields */
350    ///         )
351    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
352    ///         .send().await?;
353    ///     println!("response {:?}", response);
354    ///     Ok(())
355    /// }
356    /// ```
357    pub fn update_patch_deployment(
358        &self,
359    ) -> super::builder::os_config_service::UpdatePatchDeployment {
360        super::builder::os_config_service::UpdatePatchDeployment::new(self.inner.clone())
361    }
362
363    /// Change state of patch deployment to "PAUSED".
364    /// Patch deployment in paused state doesn't generate patch jobs.
365    ///
366    /// # Example
367    /// ```
368    /// # use google_cloud_osconfig_v1::client::OsConfigService;
369    /// use google_cloud_osconfig_v1::Result;
370    /// async fn sample(
371    ///    client: &OsConfigService
372    /// ) -> Result<()> {
373    ///     let response = client.pause_patch_deployment()
374    ///         /* set fields */
375    ///         .send().await?;
376    ///     println!("response {:?}", response);
377    ///     Ok(())
378    /// }
379    /// ```
380    pub fn pause_patch_deployment(
381        &self,
382    ) -> super::builder::os_config_service::PausePatchDeployment {
383        super::builder::os_config_service::PausePatchDeployment::new(self.inner.clone())
384    }
385
386    /// Change state of patch deployment back to "ACTIVE".
387    /// Patch deployment in active state continues to generate patch jobs.
388    ///
389    /// # Example
390    /// ```
391    /// # use google_cloud_osconfig_v1::client::OsConfigService;
392    /// use google_cloud_osconfig_v1::Result;
393    /// async fn sample(
394    ///    client: &OsConfigService
395    /// ) -> Result<()> {
396    ///     let response = client.resume_patch_deployment()
397    ///         /* set fields */
398    ///         .send().await?;
399    ///     println!("response {:?}", response);
400    ///     Ok(())
401    /// }
402    /// ```
403    pub fn resume_patch_deployment(
404        &self,
405    ) -> super::builder::os_config_service::ResumePatchDeployment {
406        super::builder::os_config_service::ResumePatchDeployment::new(self.inner.clone())
407    }
408
409    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
410    ///
411    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
412    ///
413    /// # Example
414    /// ```
415    /// # use google_cloud_osconfig_v1::client::OsConfigService;
416    /// use google_cloud_osconfig_v1::Result;
417    /// async fn sample(
418    ///    client: &OsConfigService
419    /// ) -> Result<()> {
420    ///     let response = client.get_operation()
421    ///         /* set fields */
422    ///         .send().await?;
423    ///     println!("response {:?}", response);
424    ///     Ok(())
425    /// }
426    /// ```
427    pub fn get_operation(&self) -> super::builder::os_config_service::GetOperation {
428        super::builder::os_config_service::GetOperation::new(self.inner.clone())
429    }
430
431    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
432    ///
433    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
434    ///
435    /// # Example
436    /// ```
437    /// # use google_cloud_osconfig_v1::client::OsConfigService;
438    /// use google_cloud_osconfig_v1::Result;
439    /// async fn sample(
440    ///    client: &OsConfigService
441    /// ) -> Result<()> {
442    ///     client.cancel_operation()
443    ///         /* set fields */
444    ///         .send().await?;
445    ///     Ok(())
446    /// }
447    /// ```
448    pub fn cancel_operation(&self) -> super::builder::os_config_service::CancelOperation {
449        super::builder::os_config_service::CancelOperation::new(self.inner.clone())
450    }
451}
452
453/// Implements a client for the OS Config API.
454///
455/// # Example
456/// ```
457/// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
458/// use google_cloud_gax::paginator::ItemPaginator as _;
459/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
460///     let client = OsConfigZonalService::builder().build().await?;
461///     let parent = "parent_value";
462///     let mut list = client.list_os_policy_assignments()
463///         .set_parent(parent)
464///         .by_item();
465///     while let Some(item) = list.next().await.transpose()? {
466///         println!("{:?}", item);
467///     }
468/// # Ok(()) }
469/// ```
470///
471/// # Service Description
472///
473/// Zonal OS Config API
474///
475/// The OS Config service is the server-side component that allows users to
476/// manage package installations and patch jobs for Compute Engine VM instances.
477///
478/// # Configuration
479///
480/// To configure `OsConfigZonalService` use the `with_*` methods in the type returned
481/// by [builder()][OsConfigZonalService::builder]. The default configuration should
482/// work for most applications. Common configuration changes include
483///
484/// * [with_endpoint()]: by default this client uses the global default endpoint
485///   (`https://osconfig.googleapis.com`). Applications using regional
486///   endpoints or running in restricted networks (e.g. a network configured
487//    with [Private Google Access with VPC Service Controls]) may want to
488///   override this default.
489/// * [with_credentials()]: by default this client uses
490///   [Application Default Credentials]. Applications using custom
491///   authentication may need to override this default.
492///
493/// [with_endpoint()]: super::builder::os_config_zonal_service::ClientBuilder::with_endpoint
494/// [with_credentials()]: super::builder::os_config_zonal_service::ClientBuilder::with_credentials
495/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
496/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
497///
498/// # Pooling and Cloning
499///
500/// `OsConfigZonalService` holds a connection pool internally, it is advised to
501/// create one and reuse it. You do not need to wrap `OsConfigZonalService` in
502/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
503/// already uses an `Arc` internally.
504#[derive(Clone, Debug)]
505pub struct OsConfigZonalService {
506    inner: std::sync::Arc<dyn super::stub::dynamic::OsConfigZonalService>,
507}
508
509impl OsConfigZonalService {
510    /// Returns a builder for [OsConfigZonalService].
511    ///
512    /// ```
513    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
514    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
515    /// let client = OsConfigZonalService::builder().build().await?;
516    /// # Ok(()) }
517    /// ```
518    pub fn builder() -> super::builder::os_config_zonal_service::ClientBuilder {
519        crate::new_client_builder(super::builder::os_config_zonal_service::client::Factory)
520    }
521
522    /// Creates a new client from the provided stub.
523    ///
524    /// The most common case for calling this function is in tests mocking the
525    /// client's behavior.
526    pub fn from_stub<T>(stub: T) -> Self
527    where
528        T: super::stub::OsConfigZonalService + 'static,
529    {
530        Self {
531            inner: std::sync::Arc::new(stub),
532        }
533    }
534
535    pub(crate) async fn new(
536        config: gaxi::options::ClientConfig,
537    ) -> crate::ClientBuilderResult<Self> {
538        let inner = Self::build_inner(config).await?;
539        Ok(Self { inner })
540    }
541
542    async fn build_inner(
543        conf: gaxi::options::ClientConfig,
544    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::OsConfigZonalService>>
545    {
546        if gaxi::options::tracing_enabled(&conf) {
547            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
548        }
549        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
550    }
551
552    async fn build_transport(
553        conf: gaxi::options::ClientConfig,
554    ) -> crate::ClientBuilderResult<impl super::stub::OsConfigZonalService> {
555        super::transport::OsConfigZonalService::new(conf).await
556    }
557
558    async fn build_with_tracing(
559        conf: gaxi::options::ClientConfig,
560    ) -> crate::ClientBuilderResult<impl super::stub::OsConfigZonalService> {
561        Self::build_transport(conf)
562            .await
563            .map(super::tracing::OsConfigZonalService::new)
564    }
565
566    /// Create an OS policy assignment.
567    ///
568    /// This method also creates the first revision of the OS policy assignment.
569    ///
570    /// This method returns a long running operation (LRO) that contains the
571    /// rollout details. The rollout can be cancelled by cancelling the LRO.
572    ///
573    /// For more information, see [Method:
574    /// projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).
575    ///
576    /// # Long running operations
577    ///
578    /// This method is used to start, and/or poll a [long-running Operation].
579    /// The [Working with long-running operations] chapter in the [user guide]
580    /// covers these operations in detail.
581    ///
582    /// [long-running operation]: https://google.aip.dev/151
583    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
584    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
585    ///
586    /// # Example
587    /// ```
588    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
589    /// use google_cloud_lro::Poller;
590    /// use google_cloud_osconfig_v1::model::OSPolicyAssignment;
591    /// use google_cloud_osconfig_v1::Result;
592    /// async fn sample(
593    ///    client: &OsConfigZonalService, parent: &str
594    /// ) -> Result<()> {
595    ///     let response = client.create_os_policy_assignment()
596    ///         .set_parent(parent)
597    ///         .set_os_policy_assignment(
598    ///             OSPolicyAssignment::new()/* set fields */
599    ///         )
600    ///         .poller().until_done().await?;
601    ///     println!("response {:?}", response);
602    ///     Ok(())
603    /// }
604    /// ```
605    pub fn create_os_policy_assignment(
606        &self,
607    ) -> super::builder::os_config_zonal_service::CreateOSPolicyAssignment {
608        super::builder::os_config_zonal_service::CreateOSPolicyAssignment::new(self.inner.clone())
609    }
610
611    /// Update an existing OS policy assignment.
612    ///
613    /// This method creates a new revision of the OS policy assignment.
614    ///
615    /// This method returns a long running operation (LRO) that contains the
616    /// rollout details. The rollout can be cancelled by cancelling the LRO.
617    ///
618    /// For more information, see [Method:
619    /// projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).
620    ///
621    /// # Long running operations
622    ///
623    /// This method is used to start, and/or poll a [long-running Operation].
624    /// The [Working with long-running operations] chapter in the [user guide]
625    /// covers these operations in detail.
626    ///
627    /// [long-running operation]: https://google.aip.dev/151
628    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
629    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
630    ///
631    /// # Example
632    /// ```
633    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
634    /// use google_cloud_lro::Poller;
635    /// # extern crate wkt as google_cloud_wkt;
636    /// use google_cloud_wkt::FieldMask;
637    /// use google_cloud_osconfig_v1::model::OSPolicyAssignment;
638    /// use google_cloud_osconfig_v1::Result;
639    /// async fn sample(
640    ///    client: &OsConfigZonalService, name: &str
641    /// ) -> Result<()> {
642    ///     let response = client.update_os_policy_assignment()
643    ///         .set_os_policy_assignment(
644    ///             OSPolicyAssignment::new().set_name(name)/* set fields */
645    ///         )
646    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
647    ///         .poller().until_done().await?;
648    ///     println!("response {:?}", response);
649    ///     Ok(())
650    /// }
651    /// ```
652    pub fn update_os_policy_assignment(
653        &self,
654    ) -> super::builder::os_config_zonal_service::UpdateOSPolicyAssignment {
655        super::builder::os_config_zonal_service::UpdateOSPolicyAssignment::new(self.inner.clone())
656    }
657
658    /// Retrieve an existing OS policy assignment.
659    ///
660    /// This method always returns the latest revision. In order to retrieve a
661    /// previous revision of the assignment, also provide the revision ID in the
662    /// `name` parameter.
663    ///
664    /// # Example
665    /// ```
666    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
667    /// use google_cloud_osconfig_v1::Result;
668    /// async fn sample(
669    ///    client: &OsConfigZonalService, name: &str
670    /// ) -> Result<()> {
671    ///     let response = client.get_os_policy_assignment()
672    ///         .set_name(name)
673    ///         .send().await?;
674    ///     println!("response {:?}", response);
675    ///     Ok(())
676    /// }
677    /// ```
678    pub fn get_os_policy_assignment(
679        &self,
680    ) -> super::builder::os_config_zonal_service::GetOSPolicyAssignment {
681        super::builder::os_config_zonal_service::GetOSPolicyAssignment::new(self.inner.clone())
682    }
683
684    /// List the OS policy assignments under the parent resource.
685    ///
686    /// For each OS policy assignment, the latest revision is returned.
687    ///
688    /// # Example
689    /// ```
690    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
691    /// use google_cloud_gax::paginator::ItemPaginator as _;
692    /// use google_cloud_osconfig_v1::Result;
693    /// async fn sample(
694    ///    client: &OsConfigZonalService, parent: &str
695    /// ) -> Result<()> {
696    ///     let mut list = client.list_os_policy_assignments()
697    ///         .set_parent(parent)
698    ///         .by_item();
699    ///     while let Some(item) = list.next().await.transpose()? {
700    ///         println!("{:?}", item);
701    ///     }
702    ///     Ok(())
703    /// }
704    /// ```
705    pub fn list_os_policy_assignments(
706        &self,
707    ) -> super::builder::os_config_zonal_service::ListOSPolicyAssignments {
708        super::builder::os_config_zonal_service::ListOSPolicyAssignments::new(self.inner.clone())
709    }
710
711    /// List the OS policy assignment revisions for a given OS policy assignment.
712    ///
713    /// # Example
714    /// ```
715    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
716    /// use google_cloud_gax::paginator::ItemPaginator as _;
717    /// use google_cloud_osconfig_v1::Result;
718    /// async fn sample(
719    ///    client: &OsConfigZonalService
720    /// ) -> Result<()> {
721    ///     let mut list = client.list_os_policy_assignment_revisions()
722    ///         /* set fields */
723    ///         .by_item();
724    ///     while let Some(item) = list.next().await.transpose()? {
725    ///         println!("{:?}", item);
726    ///     }
727    ///     Ok(())
728    /// }
729    /// ```
730    pub fn list_os_policy_assignment_revisions(
731        &self,
732    ) -> super::builder::os_config_zonal_service::ListOSPolicyAssignmentRevisions {
733        super::builder::os_config_zonal_service::ListOSPolicyAssignmentRevisions::new(
734            self.inner.clone(),
735        )
736    }
737
738    /// Delete the OS policy assignment.
739    ///
740    /// This method creates a new revision of the OS policy assignment.
741    ///
742    /// This method returns a long running operation (LRO) that contains the
743    /// rollout details. The rollout can be cancelled by cancelling the LRO.
744    ///
745    /// If the LRO completes and is not cancelled, all revisions associated with
746    /// the OS policy assignment are deleted.
747    ///
748    /// For more information, see [Method:
749    /// projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).
750    ///
751    /// # Long running operations
752    ///
753    /// This method is used to start, and/or poll a [long-running Operation].
754    /// The [Working with long-running operations] chapter in the [user guide]
755    /// covers these operations in detail.
756    ///
757    /// [long-running operation]: https://google.aip.dev/151
758    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
759    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
760    ///
761    /// # Example
762    /// ```
763    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
764    /// use google_cloud_lro::Poller;
765    /// use google_cloud_osconfig_v1::Result;
766    /// async fn sample(
767    ///    client: &OsConfigZonalService, name: &str
768    /// ) -> Result<()> {
769    ///     client.delete_os_policy_assignment()
770    ///         .set_name(name)
771    ///         .poller().until_done().await?;
772    ///     Ok(())
773    /// }
774    /// ```
775    pub fn delete_os_policy_assignment(
776        &self,
777    ) -> super::builder::os_config_zonal_service::DeleteOSPolicyAssignment {
778        super::builder::os_config_zonal_service::DeleteOSPolicyAssignment::new(self.inner.clone())
779    }
780
781    /// Get the OS policy asssignment report for the specified Compute Engine VM
782    /// instance.
783    ///
784    /// # Example
785    /// ```
786    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
787    /// use google_cloud_osconfig_v1::Result;
788    /// async fn sample(
789    ///    client: &OsConfigZonalService, name: &str
790    /// ) -> Result<()> {
791    ///     let response = client.get_os_policy_assignment_report()
792    ///         .set_name(name)
793    ///         .send().await?;
794    ///     println!("response {:?}", response);
795    ///     Ok(())
796    /// }
797    /// ```
798    pub fn get_os_policy_assignment_report(
799        &self,
800    ) -> super::builder::os_config_zonal_service::GetOSPolicyAssignmentReport {
801        super::builder::os_config_zonal_service::GetOSPolicyAssignmentReport::new(
802            self.inner.clone(),
803        )
804    }
805
806    /// List OS policy asssignment reports for all Compute Engine VM instances in
807    /// the specified zone.
808    ///
809    /// # Example
810    /// ```
811    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
812    /// use google_cloud_gax::paginator::ItemPaginator as _;
813    /// use google_cloud_osconfig_v1::Result;
814    /// async fn sample(
815    ///    client: &OsConfigZonalService, parent: &str
816    /// ) -> Result<()> {
817    ///     let mut list = client.list_os_policy_assignment_reports()
818    ///         .set_parent(parent)
819    ///         .by_item();
820    ///     while let Some(item) = list.next().await.transpose()? {
821    ///         println!("{:?}", item);
822    ///     }
823    ///     Ok(())
824    /// }
825    /// ```
826    pub fn list_os_policy_assignment_reports(
827        &self,
828    ) -> super::builder::os_config_zonal_service::ListOSPolicyAssignmentReports {
829        super::builder::os_config_zonal_service::ListOSPolicyAssignmentReports::new(
830            self.inner.clone(),
831        )
832    }
833
834    /// Get inventory data for the specified VM instance. If the VM has no
835    /// associated inventory, the message `NOT_FOUND` is returned.
836    ///
837    /// # Example
838    /// ```
839    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
840    /// use google_cloud_osconfig_v1::Result;
841    /// async fn sample(
842    ///    client: &OsConfigZonalService, name: &str
843    /// ) -> Result<()> {
844    ///     let response = client.get_inventory()
845    ///         .set_name(name)
846    ///         .send().await?;
847    ///     println!("response {:?}", response);
848    ///     Ok(())
849    /// }
850    /// ```
851    pub fn get_inventory(&self) -> super::builder::os_config_zonal_service::GetInventory {
852        super::builder::os_config_zonal_service::GetInventory::new(self.inner.clone())
853    }
854
855    /// List inventory data for all VM instances in the specified zone.
856    ///
857    /// # Example
858    /// ```
859    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
860    /// use google_cloud_gax::paginator::ItemPaginator as _;
861    /// use google_cloud_osconfig_v1::Result;
862    /// async fn sample(
863    ///    client: &OsConfigZonalService, parent: &str
864    /// ) -> Result<()> {
865    ///     let mut list = client.list_inventories()
866    ///         .set_parent(parent)
867    ///         .by_item();
868    ///     while let Some(item) = list.next().await.transpose()? {
869    ///         println!("{:?}", item);
870    ///     }
871    ///     Ok(())
872    /// }
873    /// ```
874    pub fn list_inventories(&self) -> super::builder::os_config_zonal_service::ListInventories {
875        super::builder::os_config_zonal_service::ListInventories::new(self.inner.clone())
876    }
877
878    /// Gets the vulnerability report for the specified VM instance. Only VMs with
879    /// inventory data have vulnerability reports associated with them.
880    ///
881    /// # Example
882    /// ```
883    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
884    /// use google_cloud_osconfig_v1::Result;
885    /// async fn sample(
886    ///    client: &OsConfigZonalService, name: &str
887    /// ) -> Result<()> {
888    ///     let response = client.get_vulnerability_report()
889    ///         .set_name(name)
890    ///         .send().await?;
891    ///     println!("response {:?}", response);
892    ///     Ok(())
893    /// }
894    /// ```
895    pub fn get_vulnerability_report(
896        &self,
897    ) -> super::builder::os_config_zonal_service::GetVulnerabilityReport {
898        super::builder::os_config_zonal_service::GetVulnerabilityReport::new(self.inner.clone())
899    }
900
901    /// List vulnerability reports for all VM instances in the specified zone.
902    ///
903    /// # Example
904    /// ```
905    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
906    /// use google_cloud_gax::paginator::ItemPaginator as _;
907    /// use google_cloud_osconfig_v1::Result;
908    /// async fn sample(
909    ///    client: &OsConfigZonalService, parent: &str
910    /// ) -> Result<()> {
911    ///     let mut list = client.list_vulnerability_reports()
912    ///         .set_parent(parent)
913    ///         .by_item();
914    ///     while let Some(item) = list.next().await.transpose()? {
915    ///         println!("{:?}", item);
916    ///     }
917    ///     Ok(())
918    /// }
919    /// ```
920    pub fn list_vulnerability_reports(
921        &self,
922    ) -> super::builder::os_config_zonal_service::ListVulnerabilityReports {
923        super::builder::os_config_zonal_service::ListVulnerabilityReports::new(self.inner.clone())
924    }
925
926    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
927    ///
928    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
929    ///
930    /// # Example
931    /// ```
932    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
933    /// use google_cloud_osconfig_v1::Result;
934    /// async fn sample(
935    ///    client: &OsConfigZonalService
936    /// ) -> Result<()> {
937    ///     let response = client.get_operation()
938    ///         /* set fields */
939    ///         .send().await?;
940    ///     println!("response {:?}", response);
941    ///     Ok(())
942    /// }
943    /// ```
944    pub fn get_operation(&self) -> super::builder::os_config_zonal_service::GetOperation {
945        super::builder::os_config_zonal_service::GetOperation::new(self.inner.clone())
946    }
947
948    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
949    ///
950    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
951    ///
952    /// # Example
953    /// ```
954    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
955    /// use google_cloud_osconfig_v1::Result;
956    /// async fn sample(
957    ///    client: &OsConfigZonalService
958    /// ) -> Result<()> {
959    ///     client.cancel_operation()
960    ///         /* set fields */
961    ///         .send().await?;
962    ///     Ok(())
963    /// }
964    /// ```
965    pub fn cancel_operation(&self) -> super::builder::os_config_zonal_service::CancelOperation {
966        super::builder::os_config_zonal_service::CancelOperation::new(self.inner.clone())
967    }
968}