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