Skip to main content

google_cloud_cloudcontrolspartner_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 Cloud Controls Partner API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// async fn sample(
26///    organization_id: &str,
27///    location_id: &str,
28///    customer_id: &str,
29/// ) -> anyhow::Result<()> {
30///     let client = CloudControlsPartnerCore::builder().build().await?;
31///     let mut list = client.list_workloads()
32///         .set_parent(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}"))
33///         .by_item();
34///     while let Some(item) = list.next().await.transpose()? {
35///         println!("{:?}", item);
36///     }
37///     Ok(())
38/// }
39/// ```
40///
41/// # Service Description
42///
43/// Service describing handlers for resources
44///
45/// # Configuration
46///
47/// To configure `CloudControlsPartnerCore` use the `with_*` methods in the type returned
48/// by [builder()][CloudControlsPartnerCore::builder]. The default configuration should
49/// work for most applications. Common configuration changes include
50///
51/// * [with_endpoint()]: by default this client uses the global default endpoint
52///   (`https://cloudcontrolspartner.googleapis.com`). Applications using regional
53///   endpoints or running in restricted networks (e.g. a network configured
54//    with [Private Google Access with VPC Service Controls]) may want to
55///   override this default.
56/// * [with_credentials()]: by default this client uses
57///   [Application Default Credentials]. Applications using custom
58///   authentication may need to override this default.
59///
60/// [with_endpoint()]: super::builder::cloud_controls_partner_core::ClientBuilder::with_endpoint
61/// [with_credentials()]: super::builder::cloud_controls_partner_core::ClientBuilder::with_credentials
62/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
63/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
64///
65/// # Pooling and Cloning
66///
67/// `CloudControlsPartnerCore` holds a connection pool internally, it is advised to
68/// create one and reuse it. You do not need to wrap `CloudControlsPartnerCore` in
69/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
70/// already uses an `Arc` internally.
71#[derive(Clone, Debug)]
72pub struct CloudControlsPartnerCore {
73    inner: std::sync::Arc<dyn super::stub::dynamic::CloudControlsPartnerCore>,
74}
75
76impl CloudControlsPartnerCore {
77    /// Returns a builder for [CloudControlsPartnerCore].
78    ///
79    /// ```
80    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
81    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
82    /// let client = CloudControlsPartnerCore::builder().build().await?;
83    /// # Ok(()) }
84    /// ```
85    pub fn builder() -> super::builder::cloud_controls_partner_core::ClientBuilder {
86        crate::new_client_builder(super::builder::cloud_controls_partner_core::client::Factory)
87    }
88
89    /// Creates a new client from the provided stub.
90    ///
91    /// The most common case for calling this function is in tests mocking the
92    /// client's behavior.
93    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
94    where
95        T: super::stub::CloudControlsPartnerCore + 'static,
96    {
97        Self { inner: stub.into() }
98    }
99
100    pub(crate) async fn new(
101        config: gaxi::options::ClientConfig,
102    ) -> crate::ClientBuilderResult<Self> {
103        let inner = Self::build_inner(config).await?;
104        Ok(Self { inner })
105    }
106
107    async fn build_inner(
108        conf: gaxi::options::ClientConfig,
109    ) -> crate::ClientBuilderResult<
110        std::sync::Arc<dyn super::stub::dynamic::CloudControlsPartnerCore>,
111    > {
112        if gaxi::options::tracing_enabled(&conf) {
113            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
114        }
115        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
116    }
117
118    async fn build_transport(
119        conf: gaxi::options::ClientConfig,
120    ) -> crate::ClientBuilderResult<impl super::stub::CloudControlsPartnerCore> {
121        super::transport::CloudControlsPartnerCore::new(conf).await
122    }
123
124    async fn build_with_tracing(
125        conf: gaxi::options::ClientConfig,
126    ) -> crate::ClientBuilderResult<impl super::stub::CloudControlsPartnerCore> {
127        Self::build_transport(conf)
128            .await
129            .map(super::tracing::CloudControlsPartnerCore::new)
130    }
131
132    /// Gets details of a single workload
133    ///
134    /// # Example
135    /// ```
136    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
137    /// use google_cloud_cloudcontrolspartner_v1::Result;
138    /// async fn sample(
139    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str, customer_id: &str, workload_id: &str
140    /// ) -> Result<()> {
141    ///     let response = client.get_workload()
142    ///         .set_name(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}/workloads/{workload_id}"))
143    ///         .send().await?;
144    ///     println!("response {:?}", response);
145    ///     Ok(())
146    /// }
147    /// ```
148    pub fn get_workload(&self) -> super::builder::cloud_controls_partner_core::GetWorkload {
149        super::builder::cloud_controls_partner_core::GetWorkload::new(self.inner.clone())
150    }
151
152    /// Lists customer workloads for a given customer org id
153    ///
154    /// # Example
155    /// ```
156    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
157    /// use google_cloud_gax::paginator::ItemPaginator as _;
158    /// use google_cloud_cloudcontrolspartner_v1::Result;
159    /// async fn sample(
160    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str, customer_id: &str
161    /// ) -> Result<()> {
162    ///     let mut list = client.list_workloads()
163    ///         .set_parent(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}"))
164    ///         .by_item();
165    ///     while let Some(item) = list.next().await.transpose()? {
166    ///         println!("{:?}", item);
167    ///     }
168    ///     Ok(())
169    /// }
170    /// ```
171    pub fn list_workloads(&self) -> super::builder::cloud_controls_partner_core::ListWorkloads {
172        super::builder::cloud_controls_partner_core::ListWorkloads::new(self.inner.clone())
173    }
174
175    /// Gets details of a single customer
176    ///
177    /// # Example
178    /// ```
179    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
180    /// use google_cloud_cloudcontrolspartner_v1::Result;
181    /// async fn sample(
182    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str, customer_id: &str
183    /// ) -> Result<()> {
184    ///     let response = client.get_customer()
185    ///         .set_name(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}"))
186    ///         .send().await?;
187    ///     println!("response {:?}", response);
188    ///     Ok(())
189    /// }
190    /// ```
191    pub fn get_customer(&self) -> super::builder::cloud_controls_partner_core::GetCustomer {
192        super::builder::cloud_controls_partner_core::GetCustomer::new(self.inner.clone())
193    }
194
195    /// Lists customers of a partner identified by its Google Cloud organization ID
196    ///
197    /// # Example
198    /// ```
199    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
200    /// use google_cloud_gax::paginator::ItemPaginator as _;
201    /// use google_cloud_cloudcontrolspartner_v1::Result;
202    /// async fn sample(
203    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str
204    /// ) -> Result<()> {
205    ///     let mut list = client.list_customers()
206    ///         .set_parent(format!("organizations/{organization_id}/locations/{location_id}"))
207    ///         .by_item();
208    ///     while let Some(item) = list.next().await.transpose()? {
209    ///         println!("{:?}", item);
210    ///     }
211    ///     Ok(())
212    /// }
213    /// ```
214    pub fn list_customers(&self) -> super::builder::cloud_controls_partner_core::ListCustomers {
215        super::builder::cloud_controls_partner_core::ListCustomers::new(self.inner.clone())
216    }
217
218    /// Gets the EKM connections associated with a workload
219    ///
220    /// # Example
221    /// ```
222    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
223    /// use google_cloud_cloudcontrolspartner_v1::Result;
224    /// async fn sample(
225    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str, customer_id: &str, workload_id: &str
226    /// ) -> Result<()> {
227    ///     let response = client.get_ekm_connections()
228    ///         .set_name(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}/workloads/{workload_id}/ekmConnections"))
229    ///         .send().await?;
230    ///     println!("response {:?}", response);
231    ///     Ok(())
232    /// }
233    /// ```
234    pub fn get_ekm_connections(
235        &self,
236    ) -> super::builder::cloud_controls_partner_core::GetEkmConnections {
237        super::builder::cloud_controls_partner_core::GetEkmConnections::new(self.inner.clone())
238    }
239
240    /// Gets the partner permissions granted for a workload
241    ///
242    /// # Example
243    /// ```
244    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
245    /// use google_cloud_cloudcontrolspartner_v1::Result;
246    /// async fn sample(
247    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str, customer_id: &str, workload_id: &str
248    /// ) -> Result<()> {
249    ///     let response = client.get_partner_permissions()
250    ///         .set_name(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}/workloads/{workload_id}/partnerPermissions"))
251    ///         .send().await?;
252    ///     println!("response {:?}", response);
253    ///     Ok(())
254    /// }
255    /// ```
256    pub fn get_partner_permissions(
257        &self,
258    ) -> super::builder::cloud_controls_partner_core::GetPartnerPermissions {
259        super::builder::cloud_controls_partner_core::GetPartnerPermissions::new(self.inner.clone())
260    }
261
262    /// Deprecated: Only returns access approval requests directly associated with
263    /// an assured workload folder.
264    ///
265    /// # Example
266    /// ```
267    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
268    /// use google_cloud_gax::paginator::ItemPaginator as _;
269    /// use google_cloud_cloudcontrolspartner_v1::Result;
270    /// async fn sample(
271    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str, customer_id: &str, workload_id: &str
272    /// ) -> Result<()> {
273    ///     let mut list = client.list_access_approval_requests()
274    ///         .set_parent(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}/workloads/{workload_id}"))
275    ///         .by_item();
276    ///     while let Some(item) = list.next().await.transpose()? {
277    ///         println!("{:?}", item);
278    ///     }
279    ///     Ok(())
280    /// }
281    /// ```
282    #[deprecated]
283    pub fn list_access_approval_requests(
284        &self,
285    ) -> super::builder::cloud_controls_partner_core::ListAccessApprovalRequests {
286        super::builder::cloud_controls_partner_core::ListAccessApprovalRequests::new(
287            self.inner.clone(),
288        )
289    }
290
291    /// Get details of a Partner.
292    ///
293    /// # Example
294    /// ```
295    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
296    /// use google_cloud_cloudcontrolspartner_v1::Result;
297    /// async fn sample(
298    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str
299    /// ) -> Result<()> {
300    ///     let response = client.get_partner()
301    ///         .set_name(format!("organizations/{organization_id}/locations/{location_id}/partner"))
302    ///         .send().await?;
303    ///     println!("response {:?}", response);
304    ///     Ok(())
305    /// }
306    /// ```
307    pub fn get_partner(&self) -> super::builder::cloud_controls_partner_core::GetPartner {
308        super::builder::cloud_controls_partner_core::GetPartner::new(self.inner.clone())
309    }
310
311    /// Creates a new customer.
312    ///
313    /// # Example
314    /// ```
315    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
316    /// use google_cloud_cloudcontrolspartner_v1::model::Customer;
317    /// use google_cloud_cloudcontrolspartner_v1::Result;
318    /// async fn sample(
319    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str
320    /// ) -> Result<()> {
321    ///     let response = client.create_customer()
322    ///         .set_parent(format!("organizations/{organization_id}/locations/{location_id}"))
323    ///         .set_customer_id("customer_id_value")
324    ///         .set_customer(
325    ///             Customer::new()/* set fields */
326    ///         )
327    ///         .send().await?;
328    ///     println!("response {:?}", response);
329    ///     Ok(())
330    /// }
331    /// ```
332    pub fn create_customer(&self) -> super::builder::cloud_controls_partner_core::CreateCustomer {
333        super::builder::cloud_controls_partner_core::CreateCustomer::new(self.inner.clone())
334    }
335
336    /// Update details of a single customer
337    ///
338    /// # Example
339    /// ```
340    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
341    /// # extern crate wkt as google_cloud_wkt;
342    /// use google_cloud_wkt::FieldMask;
343    /// use google_cloud_cloudcontrolspartner_v1::model::Customer;
344    /// use google_cloud_cloudcontrolspartner_v1::Result;
345    /// async fn sample(
346    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str, customer_id: &str
347    /// ) -> Result<()> {
348    ///     let response = client.update_customer()
349    ///         .set_customer(
350    ///             Customer::new().set_name(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}"))/* set fields */
351    ///         )
352    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
353    ///         .send().await?;
354    ///     println!("response {:?}", response);
355    ///     Ok(())
356    /// }
357    /// ```
358    pub fn update_customer(&self) -> super::builder::cloud_controls_partner_core::UpdateCustomer {
359        super::builder::cloud_controls_partner_core::UpdateCustomer::new(self.inner.clone())
360    }
361
362    /// Delete details of a single customer
363    ///
364    /// # Example
365    /// ```
366    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
367    /// use google_cloud_cloudcontrolspartner_v1::Result;
368    /// async fn sample(
369    ///    client: &CloudControlsPartnerCore, organization_id: &str, location_id: &str, customer_id: &str
370    /// ) -> Result<()> {
371    ///     client.delete_customer()
372    ///         .set_name(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}"))
373    ///         .send().await?;
374    ///     Ok(())
375    /// }
376    /// ```
377    pub fn delete_customer(&self) -> super::builder::cloud_controls_partner_core::DeleteCustomer {
378        super::builder::cloud_controls_partner_core::DeleteCustomer::new(self.inner.clone())
379    }
380}
381
382/// Implements a client for the Cloud Controls Partner API.
383///
384/// # Example
385/// ```
386/// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerMonitoring;
387/// use google_cloud_gax::paginator::ItemPaginator as _;
388/// async fn sample(
389///    organization_id: &str,
390///    location_id: &str,
391///    customer_id: &str,
392///    workload_id: &str,
393/// ) -> anyhow::Result<()> {
394///     let client = CloudControlsPartnerMonitoring::builder().build().await?;
395///     let mut list = client.list_violations()
396///         .set_parent(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}/workloads/{workload_id}"))
397///         .by_item();
398///     while let Some(item) = list.next().await.transpose()? {
399///         println!("{:?}", item);
400///     }
401///     Ok(())
402/// }
403/// ```
404///
405/// # Service Description
406///
407/// Service describing handlers for resources
408///
409/// # Configuration
410///
411/// To configure `CloudControlsPartnerMonitoring` use the `with_*` methods in the type returned
412/// by [builder()][CloudControlsPartnerMonitoring::builder]. The default configuration should
413/// work for most applications. Common configuration changes include
414///
415/// * [with_endpoint()]: by default this client uses the global default endpoint
416///   (`https://cloudcontrolspartner.googleapis.com`). Applications using regional
417///   endpoints or running in restricted networks (e.g. a network configured
418//    with [Private Google Access with VPC Service Controls]) may want to
419///   override this default.
420/// * [with_credentials()]: by default this client uses
421///   [Application Default Credentials]. Applications using custom
422///   authentication may need to override this default.
423///
424/// [with_endpoint()]: super::builder::cloud_controls_partner_monitoring::ClientBuilder::with_endpoint
425/// [with_credentials()]: super::builder::cloud_controls_partner_monitoring::ClientBuilder::with_credentials
426/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
427/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
428///
429/// # Pooling and Cloning
430///
431/// `CloudControlsPartnerMonitoring` holds a connection pool internally, it is advised to
432/// create one and reuse it. You do not need to wrap `CloudControlsPartnerMonitoring` in
433/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
434/// already uses an `Arc` internally.
435#[derive(Clone, Debug)]
436pub struct CloudControlsPartnerMonitoring {
437    inner: std::sync::Arc<dyn super::stub::dynamic::CloudControlsPartnerMonitoring>,
438}
439
440impl CloudControlsPartnerMonitoring {
441    /// Returns a builder for [CloudControlsPartnerMonitoring].
442    ///
443    /// ```
444    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
445    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerMonitoring;
446    /// let client = CloudControlsPartnerMonitoring::builder().build().await?;
447    /// # Ok(()) }
448    /// ```
449    pub fn builder() -> super::builder::cloud_controls_partner_monitoring::ClientBuilder {
450        crate::new_client_builder(
451            super::builder::cloud_controls_partner_monitoring::client::Factory,
452        )
453    }
454
455    /// Creates a new client from the provided stub.
456    ///
457    /// The most common case for calling this function is in tests mocking the
458    /// client's behavior.
459    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
460    where
461        T: super::stub::CloudControlsPartnerMonitoring + 'static,
462    {
463        Self { inner: stub.into() }
464    }
465
466    pub(crate) async fn new(
467        config: gaxi::options::ClientConfig,
468    ) -> crate::ClientBuilderResult<Self> {
469        let inner = Self::build_inner(config).await?;
470        Ok(Self { inner })
471    }
472
473    async fn build_inner(
474        conf: gaxi::options::ClientConfig,
475    ) -> crate::ClientBuilderResult<
476        std::sync::Arc<dyn super::stub::dynamic::CloudControlsPartnerMonitoring>,
477    > {
478        if gaxi::options::tracing_enabled(&conf) {
479            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
480        }
481        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
482    }
483
484    async fn build_transport(
485        conf: gaxi::options::ClientConfig,
486    ) -> crate::ClientBuilderResult<impl super::stub::CloudControlsPartnerMonitoring> {
487        super::transport::CloudControlsPartnerMonitoring::new(conf).await
488    }
489
490    async fn build_with_tracing(
491        conf: gaxi::options::ClientConfig,
492    ) -> crate::ClientBuilderResult<impl super::stub::CloudControlsPartnerMonitoring> {
493        Self::build_transport(conf)
494            .await
495            .map(super::tracing::CloudControlsPartnerMonitoring::new)
496    }
497
498    /// Lists Violations for a workload
499    /// Callers may also choose to read across multiple Customers or for a single
500    /// customer as per
501    /// [AIP-159](https://google.aip.dev/159) by using '-' (the hyphen or dash
502    /// character) as a wildcard character instead of {customer} & {workload}.
503    /// Format:
504    /// `organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}`
505    ///
506    /// # Example
507    /// ```
508    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerMonitoring;
509    /// use google_cloud_gax::paginator::ItemPaginator as _;
510    /// use google_cloud_cloudcontrolspartner_v1::Result;
511    /// async fn sample(
512    ///    client: &CloudControlsPartnerMonitoring, organization_id: &str, location_id: &str, customer_id: &str, workload_id: &str
513    /// ) -> Result<()> {
514    ///     let mut list = client.list_violations()
515    ///         .set_parent(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}/workloads/{workload_id}"))
516    ///         .by_item();
517    ///     while let Some(item) = list.next().await.transpose()? {
518    ///         println!("{:?}", item);
519    ///     }
520    ///     Ok(())
521    /// }
522    /// ```
523    pub fn list_violations(
524        &self,
525    ) -> super::builder::cloud_controls_partner_monitoring::ListViolations {
526        super::builder::cloud_controls_partner_monitoring::ListViolations::new(self.inner.clone())
527    }
528
529    /// Gets details of a single Violation.
530    ///
531    /// # Example
532    /// ```
533    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerMonitoring;
534    /// use google_cloud_cloudcontrolspartner_v1::Result;
535    /// async fn sample(
536    ///    client: &CloudControlsPartnerMonitoring, organization_id: &str, location_id: &str, customer_id: &str, workload_id: &str, violation_id: &str
537    /// ) -> Result<()> {
538    ///     let response = client.get_violation()
539    ///         .set_name(format!("organizations/{organization_id}/locations/{location_id}/customers/{customer_id}/workloads/{workload_id}/violations/{violation_id}"))
540    ///         .send().await?;
541    ///     println!("response {:?}", response);
542    ///     Ok(())
543    /// }
544    /// ```
545    pub fn get_violation(&self) -> super::builder::cloud_controls_partner_monitoring::GetViolation {
546        super::builder::cloud_controls_partner_monitoring::GetViolation::new(self.inner.clone())
547    }
548}