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