google_cloud_networkconnectivity_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 Network Connectivity API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28/// parent: &str,
29/// ) -> anyhow::Result<()> {
30/// let client = CrossNetworkAutomationService::builder().build().await?;
31/// let mut list = client.list_service_connection_maps()
32/// .set_parent(parent)
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/// The service for CrossNetworkAutomation resources.
44///
45/// # Configuration
46///
47/// To configure `CrossNetworkAutomationService` use the `with_*` methods in the type returned
48/// by [builder()][CrossNetworkAutomationService::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://networkconnectivity.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::cross_network_automation_service::ClientBuilder::with_endpoint
61/// [with_credentials()]: super::builder::cross_network_automation_service::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/// `CrossNetworkAutomationService` holds a connection pool internally, it is advised to
68/// create one and reuse it. You do not need to wrap `CrossNetworkAutomationService` 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 CrossNetworkAutomationService {
73 inner: std::sync::Arc<dyn super::stub::dynamic::CrossNetworkAutomationService>,
74}
75
76impl CrossNetworkAutomationService {
77 /// Returns a builder for [CrossNetworkAutomationService].
78 ///
79 /// ```
80 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
81 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
82 /// let client = CrossNetworkAutomationService::builder().build().await?;
83 /// # Ok(()) }
84 /// ```
85 pub fn builder() -> super::builder::cross_network_automation_service::ClientBuilder {
86 crate::new_client_builder(super::builder::cross_network_automation_service::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::CrossNetworkAutomationService + '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::CrossNetworkAutomationService>,
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::CrossNetworkAutomationService> {
121 super::transport::CrossNetworkAutomationService::new(conf).await
122 }
123
124 async fn build_with_tracing(
125 conf: gaxi::options::ClientConfig,
126 ) -> crate::ClientBuilderResult<impl super::stub::CrossNetworkAutomationService> {
127 Self::build_transport(conf)
128 .await
129 .map(super::tracing::CrossNetworkAutomationService::new)
130 }
131
132 /// Lists ServiceConnectionMaps in a given project and location.
133 ///
134 /// # Example
135 /// ```
136 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
137 /// use google_cloud_gax::paginator::ItemPaginator as _;
138 /// use google_cloud_networkconnectivity_v1::Result;
139 /// async fn sample(
140 /// client: &CrossNetworkAutomationService, parent: &str
141 /// ) -> Result<()> {
142 /// let mut list = client.list_service_connection_maps()
143 /// .set_parent(parent)
144 /// .by_item();
145 /// while let Some(item) = list.next().await.transpose()? {
146 /// println!("{:?}", item);
147 /// }
148 /// Ok(())
149 /// }
150 /// ```
151 pub fn list_service_connection_maps(
152 &self,
153 ) -> super::builder::cross_network_automation_service::ListServiceConnectionMaps {
154 super::builder::cross_network_automation_service::ListServiceConnectionMaps::new(
155 self.inner.clone(),
156 )
157 }
158
159 /// Gets details of a single ServiceConnectionMap.
160 ///
161 /// # Example
162 /// ```
163 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
164 /// use google_cloud_networkconnectivity_v1::Result;
165 /// async fn sample(
166 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_connection_map_id: &str
167 /// ) -> Result<()> {
168 /// let response = client.get_service_connection_map()
169 /// .set_name(format!("projects/{project_id}/locations/{location_id}/serviceConnectionMaps/{service_connection_map_id}"))
170 /// .send().await?;
171 /// println!("response {:?}", response);
172 /// Ok(())
173 /// }
174 /// ```
175 pub fn get_service_connection_map(
176 &self,
177 ) -> super::builder::cross_network_automation_service::GetServiceConnectionMap {
178 super::builder::cross_network_automation_service::GetServiceConnectionMap::new(
179 self.inner.clone(),
180 )
181 }
182
183 /// Creates a new ServiceConnectionMap in a given project and location.
184 ///
185 /// # Long running operations
186 ///
187 /// This method is used to start, and/or poll a [long-running Operation].
188 /// The [Working with long-running operations] chapter in the [user guide]
189 /// covers these operations in detail.
190 ///
191 /// [long-running operation]: https://google.aip.dev/151
192 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
193 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
194 ///
195 /// # Example
196 /// ```
197 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
198 /// use google_cloud_lro::Poller;
199 /// use google_cloud_networkconnectivity_v1::model::ServiceConnectionMap;
200 /// use google_cloud_networkconnectivity_v1::Result;
201 /// async fn sample(
202 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str
203 /// ) -> Result<()> {
204 /// let response = client.create_service_connection_map()
205 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
206 /// .set_service_connection_map(
207 /// ServiceConnectionMap::new()/* set fields */
208 /// )
209 /// .poller().until_done().await?;
210 /// println!("response {:?}", response);
211 /// Ok(())
212 /// }
213 /// ```
214 pub fn create_service_connection_map(
215 &self,
216 ) -> super::builder::cross_network_automation_service::CreateServiceConnectionMap {
217 super::builder::cross_network_automation_service::CreateServiceConnectionMap::new(
218 self.inner.clone(),
219 )
220 }
221
222 /// Updates the parameters of a single ServiceConnectionMap.
223 ///
224 /// # Long running operations
225 ///
226 /// This method is used to start, and/or poll a [long-running Operation].
227 /// The [Working with long-running operations] chapter in the [user guide]
228 /// covers these operations in detail.
229 ///
230 /// [long-running operation]: https://google.aip.dev/151
231 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
232 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
233 ///
234 /// # Example
235 /// ```
236 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
237 /// use google_cloud_lro::Poller;
238 /// # extern crate wkt as google_cloud_wkt;
239 /// use google_cloud_wkt::FieldMask;
240 /// use google_cloud_networkconnectivity_v1::model::ServiceConnectionMap;
241 /// use google_cloud_networkconnectivity_v1::Result;
242 /// async fn sample(
243 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_connection_map_id: &str
244 /// ) -> Result<()> {
245 /// let response = client.update_service_connection_map()
246 /// .set_service_connection_map(
247 /// ServiceConnectionMap::new().set_name(format!("projects/{project_id}/locations/{location_id}/serviceConnectionMaps/{service_connection_map_id}"))/* set fields */
248 /// )
249 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
250 /// .poller().until_done().await?;
251 /// println!("response {:?}", response);
252 /// Ok(())
253 /// }
254 /// ```
255 pub fn update_service_connection_map(
256 &self,
257 ) -> super::builder::cross_network_automation_service::UpdateServiceConnectionMap {
258 super::builder::cross_network_automation_service::UpdateServiceConnectionMap::new(
259 self.inner.clone(),
260 )
261 }
262
263 /// Deletes a single ServiceConnectionMap.
264 ///
265 /// # Long running operations
266 ///
267 /// This method is used to start, and/or poll a [long-running Operation].
268 /// The [Working with long-running operations] chapter in the [user guide]
269 /// covers these operations in detail.
270 ///
271 /// [long-running operation]: https://google.aip.dev/151
272 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
273 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
274 ///
275 /// # Example
276 /// ```
277 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
278 /// use google_cloud_lro::Poller;
279 /// use google_cloud_networkconnectivity_v1::Result;
280 /// async fn sample(
281 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_connection_map_id: &str
282 /// ) -> Result<()> {
283 /// client.delete_service_connection_map()
284 /// .set_name(format!("projects/{project_id}/locations/{location_id}/serviceConnectionMaps/{service_connection_map_id}"))
285 /// .poller().until_done().await?;
286 /// Ok(())
287 /// }
288 /// ```
289 pub fn delete_service_connection_map(
290 &self,
291 ) -> super::builder::cross_network_automation_service::DeleteServiceConnectionMap {
292 super::builder::cross_network_automation_service::DeleteServiceConnectionMap::new(
293 self.inner.clone(),
294 )
295 }
296
297 /// Lists ServiceConnectionPolicies in a given project and location.
298 ///
299 /// # Example
300 /// ```
301 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
302 /// use google_cloud_gax::paginator::ItemPaginator as _;
303 /// use google_cloud_networkconnectivity_v1::Result;
304 /// async fn sample(
305 /// client: &CrossNetworkAutomationService, parent: &str
306 /// ) -> Result<()> {
307 /// let mut list = client.list_service_connection_policies()
308 /// .set_parent(parent)
309 /// .by_item();
310 /// while let Some(item) = list.next().await.transpose()? {
311 /// println!("{:?}", item);
312 /// }
313 /// Ok(())
314 /// }
315 /// ```
316 pub fn list_service_connection_policies(
317 &self,
318 ) -> super::builder::cross_network_automation_service::ListServiceConnectionPolicies {
319 super::builder::cross_network_automation_service::ListServiceConnectionPolicies::new(
320 self.inner.clone(),
321 )
322 }
323
324 /// Gets details of a single ServiceConnectionPolicy.
325 ///
326 /// # Example
327 /// ```
328 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
329 /// use google_cloud_networkconnectivity_v1::Result;
330 /// async fn sample(
331 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_connection_policy_id: &str
332 /// ) -> Result<()> {
333 /// let response = client.get_service_connection_policy()
334 /// .set_name(format!("projects/{project_id}/locations/{location_id}/serviceConnectionPolicies/{service_connection_policy_id}"))
335 /// .send().await?;
336 /// println!("response {:?}", response);
337 /// Ok(())
338 /// }
339 /// ```
340 pub fn get_service_connection_policy(
341 &self,
342 ) -> super::builder::cross_network_automation_service::GetServiceConnectionPolicy {
343 super::builder::cross_network_automation_service::GetServiceConnectionPolicy::new(
344 self.inner.clone(),
345 )
346 }
347
348 /// Creates a new ServiceConnectionPolicy in a given project and location.
349 ///
350 /// # Long running operations
351 ///
352 /// This method is used to start, and/or poll a [long-running Operation].
353 /// The [Working with long-running operations] chapter in the [user guide]
354 /// covers these operations in detail.
355 ///
356 /// [long-running operation]: https://google.aip.dev/151
357 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
358 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
359 ///
360 /// # Example
361 /// ```
362 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
363 /// use google_cloud_lro::Poller;
364 /// use google_cloud_networkconnectivity_v1::model::ServiceConnectionPolicy;
365 /// use google_cloud_networkconnectivity_v1::Result;
366 /// async fn sample(
367 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str
368 /// ) -> Result<()> {
369 /// let response = client.create_service_connection_policy()
370 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
371 /// .set_service_connection_policy(
372 /// ServiceConnectionPolicy::new()/* set fields */
373 /// )
374 /// .poller().until_done().await?;
375 /// println!("response {:?}", response);
376 /// Ok(())
377 /// }
378 /// ```
379 pub fn create_service_connection_policy(
380 &self,
381 ) -> super::builder::cross_network_automation_service::CreateServiceConnectionPolicy {
382 super::builder::cross_network_automation_service::CreateServiceConnectionPolicy::new(
383 self.inner.clone(),
384 )
385 }
386
387 /// Updates the parameters of a single ServiceConnectionPolicy.
388 ///
389 /// # Long running operations
390 ///
391 /// This method is used to start, and/or poll a [long-running Operation].
392 /// The [Working with long-running operations] chapter in the [user guide]
393 /// covers these operations in detail.
394 ///
395 /// [long-running operation]: https://google.aip.dev/151
396 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
397 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
398 ///
399 /// # Example
400 /// ```
401 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
402 /// use google_cloud_lro::Poller;
403 /// # extern crate wkt as google_cloud_wkt;
404 /// use google_cloud_wkt::FieldMask;
405 /// use google_cloud_networkconnectivity_v1::model::ServiceConnectionPolicy;
406 /// use google_cloud_networkconnectivity_v1::Result;
407 /// async fn sample(
408 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_connection_policy_id: &str
409 /// ) -> Result<()> {
410 /// let response = client.update_service_connection_policy()
411 /// .set_service_connection_policy(
412 /// ServiceConnectionPolicy::new().set_name(format!("projects/{project_id}/locations/{location_id}/serviceConnectionPolicies/{service_connection_policy_id}"))/* set fields */
413 /// )
414 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
415 /// .poller().until_done().await?;
416 /// println!("response {:?}", response);
417 /// Ok(())
418 /// }
419 /// ```
420 pub fn update_service_connection_policy(
421 &self,
422 ) -> super::builder::cross_network_automation_service::UpdateServiceConnectionPolicy {
423 super::builder::cross_network_automation_service::UpdateServiceConnectionPolicy::new(
424 self.inner.clone(),
425 )
426 }
427
428 /// Deletes a single ServiceConnectionPolicy.
429 ///
430 /// # Long running operations
431 ///
432 /// This method is used to start, and/or poll a [long-running Operation].
433 /// The [Working with long-running operations] chapter in the [user guide]
434 /// covers these operations in detail.
435 ///
436 /// [long-running operation]: https://google.aip.dev/151
437 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
438 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
439 ///
440 /// # Example
441 /// ```
442 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
443 /// use google_cloud_lro::Poller;
444 /// use google_cloud_networkconnectivity_v1::Result;
445 /// async fn sample(
446 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_connection_policy_id: &str
447 /// ) -> Result<()> {
448 /// client.delete_service_connection_policy()
449 /// .set_name(format!("projects/{project_id}/locations/{location_id}/serviceConnectionPolicies/{service_connection_policy_id}"))
450 /// .poller().until_done().await?;
451 /// Ok(())
452 /// }
453 /// ```
454 pub fn delete_service_connection_policy(
455 &self,
456 ) -> super::builder::cross_network_automation_service::DeleteServiceConnectionPolicy {
457 super::builder::cross_network_automation_service::DeleteServiceConnectionPolicy::new(
458 self.inner.clone(),
459 )
460 }
461
462 /// Lists ServiceClasses in a given project and location.
463 ///
464 /// # Example
465 /// ```
466 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
467 /// use google_cloud_gax::paginator::ItemPaginator as _;
468 /// use google_cloud_networkconnectivity_v1::Result;
469 /// async fn sample(
470 /// client: &CrossNetworkAutomationService, parent: &str
471 /// ) -> Result<()> {
472 /// let mut list = client.list_service_classes()
473 /// .set_parent(parent)
474 /// .by_item();
475 /// while let Some(item) = list.next().await.transpose()? {
476 /// println!("{:?}", item);
477 /// }
478 /// Ok(())
479 /// }
480 /// ```
481 pub fn list_service_classes(
482 &self,
483 ) -> super::builder::cross_network_automation_service::ListServiceClasses {
484 super::builder::cross_network_automation_service::ListServiceClasses::new(
485 self.inner.clone(),
486 )
487 }
488
489 /// Gets details of a single ServiceClass.
490 ///
491 /// # Example
492 /// ```
493 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
494 /// use google_cloud_networkconnectivity_v1::Result;
495 /// async fn sample(
496 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_class_id: &str
497 /// ) -> Result<()> {
498 /// let response = client.get_service_class()
499 /// .set_name(format!("projects/{project_id}/locations/{location_id}/serviceClasses/{service_class_id}"))
500 /// .send().await?;
501 /// println!("response {:?}", response);
502 /// Ok(())
503 /// }
504 /// ```
505 pub fn get_service_class(
506 &self,
507 ) -> super::builder::cross_network_automation_service::GetServiceClass {
508 super::builder::cross_network_automation_service::GetServiceClass::new(self.inner.clone())
509 }
510
511 /// Updates the parameters of a single ServiceClass.
512 ///
513 /// # Long running operations
514 ///
515 /// This method is used to start, and/or poll a [long-running Operation].
516 /// The [Working with long-running operations] chapter in the [user guide]
517 /// covers these operations in detail.
518 ///
519 /// [long-running operation]: https://google.aip.dev/151
520 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
521 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
522 ///
523 /// # Example
524 /// ```
525 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
526 /// use google_cloud_lro::Poller;
527 /// # extern crate wkt as google_cloud_wkt;
528 /// use google_cloud_wkt::FieldMask;
529 /// use google_cloud_networkconnectivity_v1::model::ServiceClass;
530 /// use google_cloud_networkconnectivity_v1::Result;
531 /// async fn sample(
532 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_class_id: &str
533 /// ) -> Result<()> {
534 /// let response = client.update_service_class()
535 /// .set_service_class(
536 /// ServiceClass::new().set_name(format!("projects/{project_id}/locations/{location_id}/serviceClasses/{service_class_id}"))/* set fields */
537 /// )
538 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
539 /// .poller().until_done().await?;
540 /// println!("response {:?}", response);
541 /// Ok(())
542 /// }
543 /// ```
544 pub fn update_service_class(
545 &self,
546 ) -> super::builder::cross_network_automation_service::UpdateServiceClass {
547 super::builder::cross_network_automation_service::UpdateServiceClass::new(
548 self.inner.clone(),
549 )
550 }
551
552 /// Deletes a single ServiceClass.
553 ///
554 /// # Long running operations
555 ///
556 /// This method is used to start, and/or poll a [long-running Operation].
557 /// The [Working with long-running operations] chapter in the [user guide]
558 /// covers these operations in detail.
559 ///
560 /// [long-running operation]: https://google.aip.dev/151
561 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
562 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
563 ///
564 /// # Example
565 /// ```
566 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
567 /// use google_cloud_lro::Poller;
568 /// use google_cloud_networkconnectivity_v1::Result;
569 /// async fn sample(
570 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_class_id: &str
571 /// ) -> Result<()> {
572 /// client.delete_service_class()
573 /// .set_name(format!("projects/{project_id}/locations/{location_id}/serviceClasses/{service_class_id}"))
574 /// .poller().until_done().await?;
575 /// Ok(())
576 /// }
577 /// ```
578 pub fn delete_service_class(
579 &self,
580 ) -> super::builder::cross_network_automation_service::DeleteServiceClass {
581 super::builder::cross_network_automation_service::DeleteServiceClass::new(
582 self.inner.clone(),
583 )
584 }
585
586 /// Gets details of a single ServiceConnectionToken.
587 ///
588 /// # Example
589 /// ```
590 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
591 /// use google_cloud_networkconnectivity_v1::Result;
592 /// async fn sample(
593 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_connection_token_id: &str
594 /// ) -> Result<()> {
595 /// let response = client.get_service_connection_token()
596 /// .set_name(format!("projects/{project_id}/locations/{location_id}/serviceConnectionTokens/{service_connection_token_id}"))
597 /// .send().await?;
598 /// println!("response {:?}", response);
599 /// Ok(())
600 /// }
601 /// ```
602 pub fn get_service_connection_token(
603 &self,
604 ) -> super::builder::cross_network_automation_service::GetServiceConnectionToken {
605 super::builder::cross_network_automation_service::GetServiceConnectionToken::new(
606 self.inner.clone(),
607 )
608 }
609
610 /// Lists ServiceConnectionTokens in a given project and location.
611 ///
612 /// # Example
613 /// ```
614 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
615 /// use google_cloud_gax::paginator::ItemPaginator as _;
616 /// use google_cloud_networkconnectivity_v1::Result;
617 /// async fn sample(
618 /// client: &CrossNetworkAutomationService, parent: &str
619 /// ) -> Result<()> {
620 /// let mut list = client.list_service_connection_tokens()
621 /// .set_parent(parent)
622 /// .by_item();
623 /// while let Some(item) = list.next().await.transpose()? {
624 /// println!("{:?}", item);
625 /// }
626 /// Ok(())
627 /// }
628 /// ```
629 pub fn list_service_connection_tokens(
630 &self,
631 ) -> super::builder::cross_network_automation_service::ListServiceConnectionTokens {
632 super::builder::cross_network_automation_service::ListServiceConnectionTokens::new(
633 self.inner.clone(),
634 )
635 }
636
637 /// Creates a new ServiceConnectionToken in a given project and location.
638 ///
639 /// # Long running operations
640 ///
641 /// This method is used to start, and/or poll a [long-running Operation].
642 /// The [Working with long-running operations] chapter in the [user guide]
643 /// covers these operations in detail.
644 ///
645 /// [long-running operation]: https://google.aip.dev/151
646 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
647 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
648 ///
649 /// # Example
650 /// ```
651 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
652 /// use google_cloud_lro::Poller;
653 /// use google_cloud_networkconnectivity_v1::model::ServiceConnectionToken;
654 /// use google_cloud_networkconnectivity_v1::Result;
655 /// async fn sample(
656 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str
657 /// ) -> Result<()> {
658 /// let response = client.create_service_connection_token()
659 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
660 /// .set_service_connection_token(
661 /// ServiceConnectionToken::new()/* set fields */
662 /// )
663 /// .poller().until_done().await?;
664 /// println!("response {:?}", response);
665 /// Ok(())
666 /// }
667 /// ```
668 pub fn create_service_connection_token(
669 &self,
670 ) -> super::builder::cross_network_automation_service::CreateServiceConnectionToken {
671 super::builder::cross_network_automation_service::CreateServiceConnectionToken::new(
672 self.inner.clone(),
673 )
674 }
675
676 /// Deletes a single ServiceConnectionToken.
677 ///
678 /// # Long running operations
679 ///
680 /// This method is used to start, and/or poll a [long-running Operation].
681 /// The [Working with long-running operations] chapter in the [user guide]
682 /// covers these operations in detail.
683 ///
684 /// [long-running operation]: https://google.aip.dev/151
685 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
686 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
687 ///
688 /// # Example
689 /// ```
690 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
691 /// use google_cloud_lro::Poller;
692 /// use google_cloud_networkconnectivity_v1::Result;
693 /// async fn sample(
694 /// client: &CrossNetworkAutomationService, project_id: &str, location_id: &str, service_connection_token_id: &str
695 /// ) -> Result<()> {
696 /// client.delete_service_connection_token()
697 /// .set_name(format!("projects/{project_id}/locations/{location_id}/serviceConnectionTokens/{service_connection_token_id}"))
698 /// .poller().until_done().await?;
699 /// Ok(())
700 /// }
701 /// ```
702 pub fn delete_service_connection_token(
703 &self,
704 ) -> super::builder::cross_network_automation_service::DeleteServiceConnectionToken {
705 super::builder::cross_network_automation_service::DeleteServiceConnectionToken::new(
706 self.inner.clone(),
707 )
708 }
709
710 /// Lists information about the supported locations for this service.
711 ///
712 /// # Example
713 /// ```
714 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
715 /// use google_cloud_gax::paginator::ItemPaginator as _;
716 /// use google_cloud_networkconnectivity_v1::Result;
717 /// async fn sample(
718 /// client: &CrossNetworkAutomationService
719 /// ) -> Result<()> {
720 /// let mut list = client.list_locations()
721 /// /* set fields */
722 /// .by_item();
723 /// while let Some(item) = list.next().await.transpose()? {
724 /// println!("{:?}", item);
725 /// }
726 /// Ok(())
727 /// }
728 /// ```
729 pub fn list_locations(
730 &self,
731 ) -> super::builder::cross_network_automation_service::ListLocations {
732 super::builder::cross_network_automation_service::ListLocations::new(self.inner.clone())
733 }
734
735 /// Gets information about a location.
736 ///
737 /// # Example
738 /// ```
739 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
740 /// use google_cloud_networkconnectivity_v1::Result;
741 /// async fn sample(
742 /// client: &CrossNetworkAutomationService
743 /// ) -> Result<()> {
744 /// let response = client.get_location()
745 /// /* set fields */
746 /// .send().await?;
747 /// println!("response {:?}", response);
748 /// Ok(())
749 /// }
750 /// ```
751 pub fn get_location(&self) -> super::builder::cross_network_automation_service::GetLocation {
752 super::builder::cross_network_automation_service::GetLocation::new(self.inner.clone())
753 }
754
755 /// Sets the access control policy on the specified resource. Replaces
756 /// any existing policy.
757 ///
758 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
759 /// errors.
760 ///
761 /// # Example
762 /// ```
763 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
764 /// use google_cloud_networkconnectivity_v1::Result;
765 /// async fn sample(
766 /// client: &CrossNetworkAutomationService
767 /// ) -> Result<()> {
768 /// let response = client.set_iam_policy()
769 /// /* set fields */
770 /// .send().await?;
771 /// println!("response {:?}", response);
772 /// Ok(())
773 /// }
774 /// ```
775 pub fn set_iam_policy(&self) -> super::builder::cross_network_automation_service::SetIamPolicy {
776 super::builder::cross_network_automation_service::SetIamPolicy::new(self.inner.clone())
777 }
778
779 /// Gets the access control policy for a resource. Returns an empty policy
780 /// if the resource exists and does not have a policy set.
781 ///
782 /// # Example
783 /// ```
784 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
785 /// use google_cloud_networkconnectivity_v1::Result;
786 /// async fn sample(
787 /// client: &CrossNetworkAutomationService
788 /// ) -> Result<()> {
789 /// let response = client.get_iam_policy()
790 /// /* set fields */
791 /// .send().await?;
792 /// println!("response {:?}", response);
793 /// Ok(())
794 /// }
795 /// ```
796 pub fn get_iam_policy(&self) -> super::builder::cross_network_automation_service::GetIamPolicy {
797 super::builder::cross_network_automation_service::GetIamPolicy::new(self.inner.clone())
798 }
799
800 /// Returns permissions that a caller has on the specified resource. If the
801 /// resource does not exist, this will return an empty set of
802 /// permissions, not a `NOT_FOUND` error.
803 ///
804 /// Note: This operation is designed to be used for building
805 /// permission-aware UIs and command-line tools, not for authorization
806 /// checking. This operation may "fail open" without warning.
807 ///
808 /// # Example
809 /// ```
810 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
811 /// use google_cloud_networkconnectivity_v1::Result;
812 /// async fn sample(
813 /// client: &CrossNetworkAutomationService
814 /// ) -> Result<()> {
815 /// let response = client.test_iam_permissions()
816 /// /* set fields */
817 /// .send().await?;
818 /// println!("response {:?}", response);
819 /// Ok(())
820 /// }
821 /// ```
822 pub fn test_iam_permissions(
823 &self,
824 ) -> super::builder::cross_network_automation_service::TestIamPermissions {
825 super::builder::cross_network_automation_service::TestIamPermissions::new(
826 self.inner.clone(),
827 )
828 }
829
830 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
831 ///
832 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
833 ///
834 /// # Example
835 /// ```
836 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
837 /// use google_cloud_gax::paginator::ItemPaginator as _;
838 /// use google_cloud_networkconnectivity_v1::Result;
839 /// async fn sample(
840 /// client: &CrossNetworkAutomationService
841 /// ) -> Result<()> {
842 /// let mut list = client.list_operations()
843 /// /* set fields */
844 /// .by_item();
845 /// while let Some(item) = list.next().await.transpose()? {
846 /// println!("{:?}", item);
847 /// }
848 /// Ok(())
849 /// }
850 /// ```
851 pub fn list_operations(
852 &self,
853 ) -> super::builder::cross_network_automation_service::ListOperations {
854 super::builder::cross_network_automation_service::ListOperations::new(self.inner.clone())
855 }
856
857 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
858 ///
859 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
860 ///
861 /// # Example
862 /// ```
863 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
864 /// use google_cloud_networkconnectivity_v1::Result;
865 /// async fn sample(
866 /// client: &CrossNetworkAutomationService
867 /// ) -> Result<()> {
868 /// let response = client.get_operation()
869 /// /* set fields */
870 /// .send().await?;
871 /// println!("response {:?}", response);
872 /// Ok(())
873 /// }
874 /// ```
875 pub fn get_operation(&self) -> super::builder::cross_network_automation_service::GetOperation {
876 super::builder::cross_network_automation_service::GetOperation::new(self.inner.clone())
877 }
878
879 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
880 ///
881 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
882 ///
883 /// # Example
884 /// ```
885 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
886 /// use google_cloud_networkconnectivity_v1::Result;
887 /// async fn sample(
888 /// client: &CrossNetworkAutomationService
889 /// ) -> Result<()> {
890 /// client.delete_operation()
891 /// /* set fields */
892 /// .send().await?;
893 /// Ok(())
894 /// }
895 /// ```
896 pub fn delete_operation(
897 &self,
898 ) -> super::builder::cross_network_automation_service::DeleteOperation {
899 super::builder::cross_network_automation_service::DeleteOperation::new(self.inner.clone())
900 }
901
902 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
903 ///
904 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
905 ///
906 /// # Example
907 /// ```
908 /// # use google_cloud_networkconnectivity_v1::client::CrossNetworkAutomationService;
909 /// use google_cloud_networkconnectivity_v1::Result;
910 /// async fn sample(
911 /// client: &CrossNetworkAutomationService
912 /// ) -> Result<()> {
913 /// client.cancel_operation()
914 /// /* set fields */
915 /// .send().await?;
916 /// Ok(())
917 /// }
918 /// ```
919 pub fn cancel_operation(
920 &self,
921 ) -> super::builder::cross_network_automation_service::CancelOperation {
922 super::builder::cross_network_automation_service::CancelOperation::new(self.inner.clone())
923 }
924}
925
926/// Implements a client for the Network Connectivity API.
927///
928/// # Example
929/// ```
930/// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
931/// use google_cloud_gax::paginator::ItemPaginator as _;
932/// async fn sample(
933/// parent: &str,
934/// ) -> anyhow::Result<()> {
935/// let client = DataTransferService::builder().build().await?;
936/// let mut list = client.list_multicloud_data_transfer_configs()
937/// .set_parent(parent)
938/// .by_item();
939/// while let Some(item) = list.next().await.transpose()? {
940/// println!("{:?}", item);
941/// }
942/// Ok(())
943/// }
944/// ```
945///
946/// # Service Description
947///
948/// DataTransferService is the service for the Data Transfer API.
949///
950/// # Configuration
951///
952/// To configure `DataTransferService` use the `with_*` methods in the type returned
953/// by [builder()][DataTransferService::builder]. The default configuration should
954/// work for most applications. Common configuration changes include
955///
956/// * [with_endpoint()]: by default this client uses the global default endpoint
957/// (`https://networkconnectivity.googleapis.com`). Applications using regional
958/// endpoints or running in restricted networks (e.g. a network configured
959/// with [Private Google Access with VPC Service Controls]) may want to
960/// override this default.
961/// * [with_credentials()]: by default this client uses
962/// [Application Default Credentials]. Applications using custom
963/// authentication may need to override this default.
964///
965/// [with_endpoint()]: super::builder::data_transfer_service::ClientBuilder::with_endpoint
966/// [with_credentials()]: super::builder::data_transfer_service::ClientBuilder::with_credentials
967/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
968/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
969///
970/// # Pooling and Cloning
971///
972/// `DataTransferService` holds a connection pool internally, it is advised to
973/// create one and reuse it. You do not need to wrap `DataTransferService` in
974/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
975/// already uses an `Arc` internally.
976#[derive(Clone, Debug)]
977pub struct DataTransferService {
978 inner: std::sync::Arc<dyn super::stub::dynamic::DataTransferService>,
979}
980
981impl DataTransferService {
982 /// Returns a builder for [DataTransferService].
983 ///
984 /// ```
985 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
986 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
987 /// let client = DataTransferService::builder().build().await?;
988 /// # Ok(()) }
989 /// ```
990 pub fn builder() -> super::builder::data_transfer_service::ClientBuilder {
991 crate::new_client_builder(super::builder::data_transfer_service::client::Factory)
992 }
993
994 /// Creates a new client from the provided stub.
995 ///
996 /// The most common case for calling this function is in tests mocking the
997 /// client's behavior.
998 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
999 where
1000 T: super::stub::DataTransferService + 'static,
1001 {
1002 Self { inner: stub.into() }
1003 }
1004
1005 pub(crate) async fn new(
1006 config: gaxi::options::ClientConfig,
1007 ) -> crate::ClientBuilderResult<Self> {
1008 let inner = Self::build_inner(config).await?;
1009 Ok(Self { inner })
1010 }
1011
1012 async fn build_inner(
1013 conf: gaxi::options::ClientConfig,
1014 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::DataTransferService>>
1015 {
1016 if gaxi::options::tracing_enabled(&conf) {
1017 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1018 }
1019 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1020 }
1021
1022 async fn build_transport(
1023 conf: gaxi::options::ClientConfig,
1024 ) -> crate::ClientBuilderResult<impl super::stub::DataTransferService> {
1025 super::transport::DataTransferService::new(conf).await
1026 }
1027
1028 async fn build_with_tracing(
1029 conf: gaxi::options::ClientConfig,
1030 ) -> crate::ClientBuilderResult<impl super::stub::DataTransferService> {
1031 Self::build_transport(conf)
1032 .await
1033 .map(super::tracing::DataTransferService::new)
1034 }
1035
1036 /// Lists the `MulticloudDataTransferConfig` resources in a specified project
1037 /// and location.
1038 ///
1039 /// # Example
1040 /// ```
1041 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1042 /// use google_cloud_gax::paginator::ItemPaginator as _;
1043 /// use google_cloud_networkconnectivity_v1::Result;
1044 /// async fn sample(
1045 /// client: &DataTransferService, parent: &str
1046 /// ) -> Result<()> {
1047 /// let mut list = client.list_multicloud_data_transfer_configs()
1048 /// .set_parent(parent)
1049 /// .by_item();
1050 /// while let Some(item) = list.next().await.transpose()? {
1051 /// println!("{:?}", item);
1052 /// }
1053 /// Ok(())
1054 /// }
1055 /// ```
1056 pub fn list_multicloud_data_transfer_configs(
1057 &self,
1058 ) -> super::builder::data_transfer_service::ListMulticloudDataTransferConfigs {
1059 super::builder::data_transfer_service::ListMulticloudDataTransferConfigs::new(
1060 self.inner.clone(),
1061 )
1062 }
1063
1064 /// Gets the details of a `MulticloudDataTransferConfig` resource.
1065 ///
1066 /// # Example
1067 /// ```
1068 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1069 /// use google_cloud_networkconnectivity_v1::Result;
1070 /// async fn sample(
1071 /// client: &DataTransferService, project_id: &str, location_id: &str, multicloud_data_transfer_config_id: &str
1072 /// ) -> Result<()> {
1073 /// let response = client.get_multicloud_data_transfer_config()
1074 /// .set_name(format!("projects/{project_id}/locations/{location_id}/multicloudDataTransferConfigs/{multicloud_data_transfer_config_id}"))
1075 /// .send().await?;
1076 /// println!("response {:?}", response);
1077 /// Ok(())
1078 /// }
1079 /// ```
1080 pub fn get_multicloud_data_transfer_config(
1081 &self,
1082 ) -> super::builder::data_transfer_service::GetMulticloudDataTransferConfig {
1083 super::builder::data_transfer_service::GetMulticloudDataTransferConfig::new(
1084 self.inner.clone(),
1085 )
1086 }
1087
1088 /// Creates a `MulticloudDataTransferConfig` resource in a specified project
1089 /// and location.
1090 ///
1091 /// # Long running operations
1092 ///
1093 /// This method is used to start, and/or poll a [long-running Operation].
1094 /// The [Working with long-running operations] chapter in the [user guide]
1095 /// covers these operations in detail.
1096 ///
1097 /// [long-running operation]: https://google.aip.dev/151
1098 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1099 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1100 ///
1101 /// # Example
1102 /// ```
1103 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1104 /// use google_cloud_lro::Poller;
1105 /// use google_cloud_networkconnectivity_v1::model::MulticloudDataTransferConfig;
1106 /// use google_cloud_networkconnectivity_v1::Result;
1107 /// async fn sample(
1108 /// client: &DataTransferService, parent: &str
1109 /// ) -> Result<()> {
1110 /// let response = client.create_multicloud_data_transfer_config()
1111 /// .set_parent(parent)
1112 /// .set_multicloud_data_transfer_config(
1113 /// MulticloudDataTransferConfig::new()/* set fields */
1114 /// )
1115 /// .poller().until_done().await?;
1116 /// println!("response {:?}", response);
1117 /// Ok(())
1118 /// }
1119 /// ```
1120 pub fn create_multicloud_data_transfer_config(
1121 &self,
1122 ) -> super::builder::data_transfer_service::CreateMulticloudDataTransferConfig {
1123 super::builder::data_transfer_service::CreateMulticloudDataTransferConfig::new(
1124 self.inner.clone(),
1125 )
1126 }
1127
1128 /// Updates a `MulticloudDataTransferConfig` resource in a specified project
1129 /// and location.
1130 ///
1131 /// # Long running operations
1132 ///
1133 /// This method is used to start, and/or poll a [long-running Operation].
1134 /// The [Working with long-running operations] chapter in the [user guide]
1135 /// covers these operations in detail.
1136 ///
1137 /// [long-running operation]: https://google.aip.dev/151
1138 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1139 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1140 ///
1141 /// # Example
1142 /// ```
1143 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1144 /// use google_cloud_lro::Poller;
1145 /// # extern crate wkt as google_cloud_wkt;
1146 /// use google_cloud_wkt::FieldMask;
1147 /// use google_cloud_networkconnectivity_v1::model::MulticloudDataTransferConfig;
1148 /// use google_cloud_networkconnectivity_v1::Result;
1149 /// async fn sample(
1150 /// client: &DataTransferService, project_id: &str, location_id: &str, multicloud_data_transfer_config_id: &str
1151 /// ) -> Result<()> {
1152 /// let response = client.update_multicloud_data_transfer_config()
1153 /// .set_multicloud_data_transfer_config(
1154 /// MulticloudDataTransferConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/multicloudDataTransferConfigs/{multicloud_data_transfer_config_id}"))/* set fields */
1155 /// )
1156 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1157 /// .poller().until_done().await?;
1158 /// println!("response {:?}", response);
1159 /// Ok(())
1160 /// }
1161 /// ```
1162 pub fn update_multicloud_data_transfer_config(
1163 &self,
1164 ) -> super::builder::data_transfer_service::UpdateMulticloudDataTransferConfig {
1165 super::builder::data_transfer_service::UpdateMulticloudDataTransferConfig::new(
1166 self.inner.clone(),
1167 )
1168 }
1169
1170 /// Deletes a `MulticloudDataTransferConfig` resource.
1171 ///
1172 /// # Long running operations
1173 ///
1174 /// This method is used to start, and/or poll a [long-running Operation].
1175 /// The [Working with long-running operations] chapter in the [user guide]
1176 /// covers these operations in detail.
1177 ///
1178 /// [long-running operation]: https://google.aip.dev/151
1179 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1180 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1181 ///
1182 /// # Example
1183 /// ```
1184 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1185 /// use google_cloud_lro::Poller;
1186 /// use google_cloud_networkconnectivity_v1::Result;
1187 /// async fn sample(
1188 /// client: &DataTransferService, project_id: &str, location_id: &str, multicloud_data_transfer_config_id: &str
1189 /// ) -> Result<()> {
1190 /// client.delete_multicloud_data_transfer_config()
1191 /// .set_name(format!("projects/{project_id}/locations/{location_id}/multicloudDataTransferConfigs/{multicloud_data_transfer_config_id}"))
1192 /// .poller().until_done().await?;
1193 /// Ok(())
1194 /// }
1195 /// ```
1196 pub fn delete_multicloud_data_transfer_config(
1197 &self,
1198 ) -> super::builder::data_transfer_service::DeleteMulticloudDataTransferConfig {
1199 super::builder::data_transfer_service::DeleteMulticloudDataTransferConfig::new(
1200 self.inner.clone(),
1201 )
1202 }
1203
1204 /// Lists the `Destination` resources in a specified project and location.
1205 ///
1206 /// # Example
1207 /// ```
1208 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1209 /// use google_cloud_gax::paginator::ItemPaginator as _;
1210 /// use google_cloud_networkconnectivity_v1::Result;
1211 /// async fn sample(
1212 /// client: &DataTransferService, project_id: &str, location_id: &str, multicloud_data_transfer_config_id: &str
1213 /// ) -> Result<()> {
1214 /// let mut list = client.list_destinations()
1215 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/multicloudDataTransferConfigs/{multicloud_data_transfer_config_id}"))
1216 /// .by_item();
1217 /// while let Some(item) = list.next().await.transpose()? {
1218 /// println!("{:?}", item);
1219 /// }
1220 /// Ok(())
1221 /// }
1222 /// ```
1223 pub fn list_destinations(&self) -> super::builder::data_transfer_service::ListDestinations {
1224 super::builder::data_transfer_service::ListDestinations::new(self.inner.clone())
1225 }
1226
1227 /// Gets the details of a `Destination` resource.
1228 ///
1229 /// # Example
1230 /// ```
1231 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1232 /// use google_cloud_networkconnectivity_v1::Result;
1233 /// async fn sample(
1234 /// client: &DataTransferService, project_id: &str, location_id: &str, multicloud_data_transfer_config_id: &str, destination_id: &str
1235 /// ) -> Result<()> {
1236 /// let response = client.get_destination()
1237 /// .set_name(format!("projects/{project_id}/locations/{location_id}/multicloudDataTransferConfigs/{multicloud_data_transfer_config_id}/destinations/{destination_id}"))
1238 /// .send().await?;
1239 /// println!("response {:?}", response);
1240 /// Ok(())
1241 /// }
1242 /// ```
1243 pub fn get_destination(&self) -> super::builder::data_transfer_service::GetDestination {
1244 super::builder::data_transfer_service::GetDestination::new(self.inner.clone())
1245 }
1246
1247 /// Creates a `Destination` resource in a specified project and location.
1248 ///
1249 /// # Long running operations
1250 ///
1251 /// This method is used to start, and/or poll a [long-running Operation].
1252 /// The [Working with long-running operations] chapter in the [user guide]
1253 /// covers these operations in detail.
1254 ///
1255 /// [long-running operation]: https://google.aip.dev/151
1256 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1257 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1258 ///
1259 /// # Example
1260 /// ```
1261 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1262 /// use google_cloud_lro::Poller;
1263 /// use google_cloud_networkconnectivity_v1::model::Destination;
1264 /// use google_cloud_networkconnectivity_v1::Result;
1265 /// async fn sample(
1266 /// client: &DataTransferService, project_id: &str, location_id: &str, multicloud_data_transfer_config_id: &str
1267 /// ) -> Result<()> {
1268 /// let response = client.create_destination()
1269 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/multicloudDataTransferConfigs/{multicloud_data_transfer_config_id}"))
1270 /// .set_destination_id("destination_id_value")
1271 /// .set_destination(
1272 /// Destination::new()/* set fields */
1273 /// )
1274 /// .poller().until_done().await?;
1275 /// println!("response {:?}", response);
1276 /// Ok(())
1277 /// }
1278 /// ```
1279 pub fn create_destination(&self) -> super::builder::data_transfer_service::CreateDestination {
1280 super::builder::data_transfer_service::CreateDestination::new(self.inner.clone())
1281 }
1282
1283 /// Updates a `Destination` resource in a specified project and location.
1284 ///
1285 /// # Long running operations
1286 ///
1287 /// This method is used to start, and/or poll a [long-running Operation].
1288 /// The [Working with long-running operations] chapter in the [user guide]
1289 /// covers these operations in detail.
1290 ///
1291 /// [long-running operation]: https://google.aip.dev/151
1292 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1293 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1294 ///
1295 /// # Example
1296 /// ```
1297 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1298 /// use google_cloud_lro::Poller;
1299 /// # extern crate wkt as google_cloud_wkt;
1300 /// use google_cloud_wkt::FieldMask;
1301 /// use google_cloud_networkconnectivity_v1::model::Destination;
1302 /// use google_cloud_networkconnectivity_v1::Result;
1303 /// async fn sample(
1304 /// client: &DataTransferService, project_id: &str, location_id: &str, multicloud_data_transfer_config_id: &str, destination_id: &str
1305 /// ) -> Result<()> {
1306 /// let response = client.update_destination()
1307 /// .set_destination(
1308 /// Destination::new().set_name(format!("projects/{project_id}/locations/{location_id}/multicloudDataTransferConfigs/{multicloud_data_transfer_config_id}/destinations/{destination_id}"))/* set fields */
1309 /// )
1310 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1311 /// .poller().until_done().await?;
1312 /// println!("response {:?}", response);
1313 /// Ok(())
1314 /// }
1315 /// ```
1316 pub fn update_destination(&self) -> super::builder::data_transfer_service::UpdateDestination {
1317 super::builder::data_transfer_service::UpdateDestination::new(self.inner.clone())
1318 }
1319
1320 /// Deletes a `Destination` resource.
1321 ///
1322 /// # Long running operations
1323 ///
1324 /// This method is used to start, and/or poll a [long-running Operation].
1325 /// The [Working with long-running operations] chapter in the [user guide]
1326 /// covers these operations in detail.
1327 ///
1328 /// [long-running operation]: https://google.aip.dev/151
1329 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1330 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1331 ///
1332 /// # Example
1333 /// ```
1334 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1335 /// use google_cloud_lro::Poller;
1336 /// use google_cloud_networkconnectivity_v1::Result;
1337 /// async fn sample(
1338 /// client: &DataTransferService, project_id: &str, location_id: &str, multicloud_data_transfer_config_id: &str, destination_id: &str
1339 /// ) -> Result<()> {
1340 /// client.delete_destination()
1341 /// .set_name(format!("projects/{project_id}/locations/{location_id}/multicloudDataTransferConfigs/{multicloud_data_transfer_config_id}/destinations/{destination_id}"))
1342 /// .poller().until_done().await?;
1343 /// Ok(())
1344 /// }
1345 /// ```
1346 pub fn delete_destination(&self) -> super::builder::data_transfer_service::DeleteDestination {
1347 super::builder::data_transfer_service::DeleteDestination::new(self.inner.clone())
1348 }
1349
1350 /// Gets the details of a service that is supported for Data Transfer
1351 /// Essentials.
1352 ///
1353 /// # Example
1354 /// ```
1355 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1356 /// use google_cloud_networkconnectivity_v1::Result;
1357 /// async fn sample(
1358 /// client: &DataTransferService, project_id: &str, location_id: &str, multicloud_data_transfer_supported_service_id: &str
1359 /// ) -> Result<()> {
1360 /// let response = client.get_multicloud_data_transfer_supported_service()
1361 /// .set_name(format!("projects/{project_id}/locations/{location_id}/multicloudDataTransferSupportedServices/{multicloud_data_transfer_supported_service_id}"))
1362 /// .send().await?;
1363 /// println!("response {:?}", response);
1364 /// Ok(())
1365 /// }
1366 /// ```
1367 pub fn get_multicloud_data_transfer_supported_service(
1368 &self,
1369 ) -> super::builder::data_transfer_service::GetMulticloudDataTransferSupportedService {
1370 super::builder::data_transfer_service::GetMulticloudDataTransferSupportedService::new(
1371 self.inner.clone(),
1372 )
1373 }
1374
1375 /// Lists the services in the project for a region that are supported for
1376 /// Data Transfer Essentials.
1377 ///
1378 /// # Example
1379 /// ```
1380 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1381 /// use google_cloud_gax::paginator::ItemPaginator as _;
1382 /// use google_cloud_networkconnectivity_v1::Result;
1383 /// async fn sample(
1384 /// client: &DataTransferService, parent: &str
1385 /// ) -> Result<()> {
1386 /// let mut list = client.list_multicloud_data_transfer_supported_services()
1387 /// .set_parent(parent)
1388 /// .by_item();
1389 /// while let Some(item) = list.next().await.transpose()? {
1390 /// println!("{:?}", item);
1391 /// }
1392 /// Ok(())
1393 /// }
1394 /// ```
1395 pub fn list_multicloud_data_transfer_supported_services(
1396 &self,
1397 ) -> super::builder::data_transfer_service::ListMulticloudDataTransferSupportedServices {
1398 super::builder::data_transfer_service::ListMulticloudDataTransferSupportedServices::new(
1399 self.inner.clone(),
1400 )
1401 }
1402
1403 /// Lists information about the supported locations for this service.
1404 ///
1405 /// # Example
1406 /// ```
1407 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1408 /// use google_cloud_gax::paginator::ItemPaginator as _;
1409 /// use google_cloud_networkconnectivity_v1::Result;
1410 /// async fn sample(
1411 /// client: &DataTransferService
1412 /// ) -> Result<()> {
1413 /// let mut list = client.list_locations()
1414 /// /* set fields */
1415 /// .by_item();
1416 /// while let Some(item) = list.next().await.transpose()? {
1417 /// println!("{:?}", item);
1418 /// }
1419 /// Ok(())
1420 /// }
1421 /// ```
1422 pub fn list_locations(&self) -> super::builder::data_transfer_service::ListLocations {
1423 super::builder::data_transfer_service::ListLocations::new(self.inner.clone())
1424 }
1425
1426 /// Gets information about a location.
1427 ///
1428 /// # Example
1429 /// ```
1430 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1431 /// use google_cloud_networkconnectivity_v1::Result;
1432 /// async fn sample(
1433 /// client: &DataTransferService
1434 /// ) -> Result<()> {
1435 /// let response = client.get_location()
1436 /// /* set fields */
1437 /// .send().await?;
1438 /// println!("response {:?}", response);
1439 /// Ok(())
1440 /// }
1441 /// ```
1442 pub fn get_location(&self) -> super::builder::data_transfer_service::GetLocation {
1443 super::builder::data_transfer_service::GetLocation::new(self.inner.clone())
1444 }
1445
1446 /// Sets the access control policy on the specified resource. Replaces
1447 /// any existing policy.
1448 ///
1449 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
1450 /// errors.
1451 ///
1452 /// # Example
1453 /// ```
1454 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1455 /// use google_cloud_networkconnectivity_v1::Result;
1456 /// async fn sample(
1457 /// client: &DataTransferService
1458 /// ) -> Result<()> {
1459 /// let response = client.set_iam_policy()
1460 /// /* set fields */
1461 /// .send().await?;
1462 /// println!("response {:?}", response);
1463 /// Ok(())
1464 /// }
1465 /// ```
1466 pub fn set_iam_policy(&self) -> super::builder::data_transfer_service::SetIamPolicy {
1467 super::builder::data_transfer_service::SetIamPolicy::new(self.inner.clone())
1468 }
1469
1470 /// Gets the access control policy for a resource. Returns an empty policy
1471 /// if the resource exists and does not have a policy set.
1472 ///
1473 /// # Example
1474 /// ```
1475 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1476 /// use google_cloud_networkconnectivity_v1::Result;
1477 /// async fn sample(
1478 /// client: &DataTransferService
1479 /// ) -> Result<()> {
1480 /// let response = client.get_iam_policy()
1481 /// /* set fields */
1482 /// .send().await?;
1483 /// println!("response {:?}", response);
1484 /// Ok(())
1485 /// }
1486 /// ```
1487 pub fn get_iam_policy(&self) -> super::builder::data_transfer_service::GetIamPolicy {
1488 super::builder::data_transfer_service::GetIamPolicy::new(self.inner.clone())
1489 }
1490
1491 /// Returns permissions that a caller has on the specified resource. If the
1492 /// resource does not exist, this will return an empty set of
1493 /// permissions, not a `NOT_FOUND` error.
1494 ///
1495 /// Note: This operation is designed to be used for building
1496 /// permission-aware UIs and command-line tools, not for authorization
1497 /// checking. This operation may "fail open" without warning.
1498 ///
1499 /// # Example
1500 /// ```
1501 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1502 /// use google_cloud_networkconnectivity_v1::Result;
1503 /// async fn sample(
1504 /// client: &DataTransferService
1505 /// ) -> Result<()> {
1506 /// let response = client.test_iam_permissions()
1507 /// /* set fields */
1508 /// .send().await?;
1509 /// println!("response {:?}", response);
1510 /// Ok(())
1511 /// }
1512 /// ```
1513 pub fn test_iam_permissions(
1514 &self,
1515 ) -> super::builder::data_transfer_service::TestIamPermissions {
1516 super::builder::data_transfer_service::TestIamPermissions::new(self.inner.clone())
1517 }
1518
1519 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1520 ///
1521 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1522 ///
1523 /// # Example
1524 /// ```
1525 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1526 /// use google_cloud_gax::paginator::ItemPaginator as _;
1527 /// use google_cloud_networkconnectivity_v1::Result;
1528 /// async fn sample(
1529 /// client: &DataTransferService
1530 /// ) -> Result<()> {
1531 /// let mut list = client.list_operations()
1532 /// /* set fields */
1533 /// .by_item();
1534 /// while let Some(item) = list.next().await.transpose()? {
1535 /// println!("{:?}", item);
1536 /// }
1537 /// Ok(())
1538 /// }
1539 /// ```
1540 pub fn list_operations(&self) -> super::builder::data_transfer_service::ListOperations {
1541 super::builder::data_transfer_service::ListOperations::new(self.inner.clone())
1542 }
1543
1544 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1545 ///
1546 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1547 ///
1548 /// # Example
1549 /// ```
1550 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1551 /// use google_cloud_networkconnectivity_v1::Result;
1552 /// async fn sample(
1553 /// client: &DataTransferService
1554 /// ) -> Result<()> {
1555 /// let response = client.get_operation()
1556 /// /* set fields */
1557 /// .send().await?;
1558 /// println!("response {:?}", response);
1559 /// Ok(())
1560 /// }
1561 /// ```
1562 pub fn get_operation(&self) -> super::builder::data_transfer_service::GetOperation {
1563 super::builder::data_transfer_service::GetOperation::new(self.inner.clone())
1564 }
1565
1566 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1567 ///
1568 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1569 ///
1570 /// # Example
1571 /// ```
1572 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1573 /// use google_cloud_networkconnectivity_v1::Result;
1574 /// async fn sample(
1575 /// client: &DataTransferService
1576 /// ) -> Result<()> {
1577 /// client.delete_operation()
1578 /// /* set fields */
1579 /// .send().await?;
1580 /// Ok(())
1581 /// }
1582 /// ```
1583 pub fn delete_operation(&self) -> super::builder::data_transfer_service::DeleteOperation {
1584 super::builder::data_transfer_service::DeleteOperation::new(self.inner.clone())
1585 }
1586
1587 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1588 ///
1589 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1590 ///
1591 /// # Example
1592 /// ```
1593 /// # use google_cloud_networkconnectivity_v1::client::DataTransferService;
1594 /// use google_cloud_networkconnectivity_v1::Result;
1595 /// async fn sample(
1596 /// client: &DataTransferService
1597 /// ) -> Result<()> {
1598 /// client.cancel_operation()
1599 /// /* set fields */
1600 /// .send().await?;
1601 /// Ok(())
1602 /// }
1603 /// ```
1604 pub fn cancel_operation(&self) -> super::builder::data_transfer_service::CancelOperation {
1605 super::builder::data_transfer_service::CancelOperation::new(self.inner.clone())
1606 }
1607}
1608
1609/// Implements a client for the Network Connectivity API.
1610///
1611/// # Example
1612/// ```
1613/// # use google_cloud_networkconnectivity_v1::client::HubService;
1614/// use google_cloud_gax::paginator::ItemPaginator as _;
1615/// async fn sample(
1616/// parent: &str,
1617/// ) -> anyhow::Result<()> {
1618/// let client = HubService::builder().build().await?;
1619/// let mut list = client.list_hubs()
1620/// .set_parent(parent)
1621/// .by_item();
1622/// while let Some(item) = list.next().await.transpose()? {
1623/// println!("{:?}", item);
1624/// }
1625/// Ok(())
1626/// }
1627/// ```
1628///
1629/// # Service Description
1630///
1631/// Network Connectivity Center is a hub-and-spoke abstraction for network
1632/// connectivity management in Google Cloud. It reduces operational complexity
1633/// through a simple, centralized connectivity management model.
1634///
1635/// # Configuration
1636///
1637/// To configure `HubService` use the `with_*` methods in the type returned
1638/// by [builder()][HubService::builder]. The default configuration should
1639/// work for most applications. Common configuration changes include
1640///
1641/// * [with_endpoint()]: by default this client uses the global default endpoint
1642/// (`https://networkconnectivity.googleapis.com`). Applications using regional
1643/// endpoints or running in restricted networks (e.g. a network configured
1644/// with [Private Google Access with VPC Service Controls]) may want to
1645/// override this default.
1646/// * [with_credentials()]: by default this client uses
1647/// [Application Default Credentials]. Applications using custom
1648/// authentication may need to override this default.
1649///
1650/// [with_endpoint()]: super::builder::hub_service::ClientBuilder::with_endpoint
1651/// [with_credentials()]: super::builder::hub_service::ClientBuilder::with_credentials
1652/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1653/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1654///
1655/// # Pooling and Cloning
1656///
1657/// `HubService` holds a connection pool internally, it is advised to
1658/// create one and reuse it. You do not need to wrap `HubService` in
1659/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1660/// already uses an `Arc` internally.
1661#[derive(Clone, Debug)]
1662pub struct HubService {
1663 inner: std::sync::Arc<dyn super::stub::dynamic::HubService>,
1664}
1665
1666impl HubService {
1667 /// Returns a builder for [HubService].
1668 ///
1669 /// ```
1670 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1671 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1672 /// let client = HubService::builder().build().await?;
1673 /// # Ok(()) }
1674 /// ```
1675 pub fn builder() -> super::builder::hub_service::ClientBuilder {
1676 crate::new_client_builder(super::builder::hub_service::client::Factory)
1677 }
1678
1679 /// Creates a new client from the provided stub.
1680 ///
1681 /// The most common case for calling this function is in tests mocking the
1682 /// client's behavior.
1683 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1684 where
1685 T: super::stub::HubService + 'static,
1686 {
1687 Self { inner: stub.into() }
1688 }
1689
1690 pub(crate) async fn new(
1691 config: gaxi::options::ClientConfig,
1692 ) -> crate::ClientBuilderResult<Self> {
1693 let inner = Self::build_inner(config).await?;
1694 Ok(Self { inner })
1695 }
1696
1697 async fn build_inner(
1698 conf: gaxi::options::ClientConfig,
1699 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::HubService>> {
1700 if gaxi::options::tracing_enabled(&conf) {
1701 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1702 }
1703 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1704 }
1705
1706 async fn build_transport(
1707 conf: gaxi::options::ClientConfig,
1708 ) -> crate::ClientBuilderResult<impl super::stub::HubService> {
1709 super::transport::HubService::new(conf).await
1710 }
1711
1712 async fn build_with_tracing(
1713 conf: gaxi::options::ClientConfig,
1714 ) -> crate::ClientBuilderResult<impl super::stub::HubService> {
1715 Self::build_transport(conf)
1716 .await
1717 .map(super::tracing::HubService::new)
1718 }
1719
1720 /// Lists the Network Connectivity Center hubs associated with a given project.
1721 ///
1722 /// # Example
1723 /// ```
1724 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1725 /// use google_cloud_gax::paginator::ItemPaginator as _;
1726 /// use google_cloud_networkconnectivity_v1::Result;
1727 /// async fn sample(
1728 /// client: &HubService, parent: &str
1729 /// ) -> Result<()> {
1730 /// let mut list = client.list_hubs()
1731 /// .set_parent(parent)
1732 /// .by_item();
1733 /// while let Some(item) = list.next().await.transpose()? {
1734 /// println!("{:?}", item);
1735 /// }
1736 /// Ok(())
1737 /// }
1738 /// ```
1739 pub fn list_hubs(&self) -> super::builder::hub_service::ListHubs {
1740 super::builder::hub_service::ListHubs::new(self.inner.clone())
1741 }
1742
1743 /// Gets details about a Network Connectivity Center hub.
1744 ///
1745 /// # Example
1746 /// ```
1747 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1748 /// use google_cloud_networkconnectivity_v1::Result;
1749 /// async fn sample(
1750 /// client: &HubService, project_id: &str, hub_id: &str
1751 /// ) -> Result<()> {
1752 /// let response = client.get_hub()
1753 /// .set_name(format!("projects/{project_id}/locations/global/hubs/{hub_id}"))
1754 /// .send().await?;
1755 /// println!("response {:?}", response);
1756 /// Ok(())
1757 /// }
1758 /// ```
1759 pub fn get_hub(&self) -> super::builder::hub_service::GetHub {
1760 super::builder::hub_service::GetHub::new(self.inner.clone())
1761 }
1762
1763 /// Creates a new Network Connectivity Center hub in the specified project.
1764 ///
1765 /// # Long running operations
1766 ///
1767 /// This method is used to start, and/or poll a [long-running Operation].
1768 /// The [Working with long-running operations] chapter in the [user guide]
1769 /// covers these operations in detail.
1770 ///
1771 /// [long-running operation]: https://google.aip.dev/151
1772 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1773 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1774 ///
1775 /// # Example
1776 /// ```
1777 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1778 /// use google_cloud_lro::Poller;
1779 /// use google_cloud_networkconnectivity_v1::model::Hub;
1780 /// use google_cloud_networkconnectivity_v1::Result;
1781 /// async fn sample(
1782 /// client: &HubService, parent: &str
1783 /// ) -> Result<()> {
1784 /// let response = client.create_hub()
1785 /// .set_parent(parent)
1786 /// .set_hub_id("hub_id_value")
1787 /// .set_hub(
1788 /// Hub::new()/* set fields */
1789 /// )
1790 /// .poller().until_done().await?;
1791 /// println!("response {:?}", response);
1792 /// Ok(())
1793 /// }
1794 /// ```
1795 pub fn create_hub(&self) -> super::builder::hub_service::CreateHub {
1796 super::builder::hub_service::CreateHub::new(self.inner.clone())
1797 }
1798
1799 /// Updates the description and/or labels of a Network Connectivity Center
1800 /// hub.
1801 ///
1802 /// # Long running operations
1803 ///
1804 /// This method is used to start, and/or poll a [long-running Operation].
1805 /// The [Working with long-running operations] chapter in the [user guide]
1806 /// covers these operations in detail.
1807 ///
1808 /// [long-running operation]: https://google.aip.dev/151
1809 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1810 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1811 ///
1812 /// # Example
1813 /// ```
1814 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1815 /// use google_cloud_lro::Poller;
1816 /// # extern crate wkt as google_cloud_wkt;
1817 /// use google_cloud_wkt::FieldMask;
1818 /// use google_cloud_networkconnectivity_v1::model::Hub;
1819 /// use google_cloud_networkconnectivity_v1::Result;
1820 /// async fn sample(
1821 /// client: &HubService, project_id: &str, hub_id: &str
1822 /// ) -> Result<()> {
1823 /// let response = client.update_hub()
1824 /// .set_hub(
1825 /// Hub::new().set_name(format!("projects/{project_id}/locations/global/hubs/{hub_id}"))/* set fields */
1826 /// )
1827 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1828 /// .poller().until_done().await?;
1829 /// println!("response {:?}", response);
1830 /// Ok(())
1831 /// }
1832 /// ```
1833 pub fn update_hub(&self) -> super::builder::hub_service::UpdateHub {
1834 super::builder::hub_service::UpdateHub::new(self.inner.clone())
1835 }
1836
1837 /// Deletes a Network Connectivity Center hub.
1838 ///
1839 /// # Long running operations
1840 ///
1841 /// This method is used to start, and/or poll a [long-running Operation].
1842 /// The [Working with long-running operations] chapter in the [user guide]
1843 /// covers these operations in detail.
1844 ///
1845 /// [long-running operation]: https://google.aip.dev/151
1846 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1847 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1848 ///
1849 /// # Example
1850 /// ```
1851 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1852 /// use google_cloud_lro::Poller;
1853 /// use google_cloud_networkconnectivity_v1::Result;
1854 /// async fn sample(
1855 /// client: &HubService, project_id: &str, hub_id: &str
1856 /// ) -> Result<()> {
1857 /// client.delete_hub()
1858 /// .set_name(format!("projects/{project_id}/locations/global/hubs/{hub_id}"))
1859 /// .poller().until_done().await?;
1860 /// Ok(())
1861 /// }
1862 /// ```
1863 pub fn delete_hub(&self) -> super::builder::hub_service::DeleteHub {
1864 super::builder::hub_service::DeleteHub::new(self.inner.clone())
1865 }
1866
1867 /// Lists the Network Connectivity Center spokes associated with a
1868 /// specified hub and location. The list includes both spokes that are attached
1869 /// to the hub and spokes that have been proposed but not yet accepted.
1870 ///
1871 /// # Example
1872 /// ```
1873 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1874 /// use google_cloud_gax::paginator::ItemPaginator as _;
1875 /// use google_cloud_networkconnectivity_v1::Result;
1876 /// async fn sample(
1877 /// client: &HubService
1878 /// ) -> Result<()> {
1879 /// let mut list = client.list_hub_spokes()
1880 /// /* set fields */
1881 /// .by_item();
1882 /// while let Some(item) = list.next().await.transpose()? {
1883 /// println!("{:?}", item);
1884 /// }
1885 /// Ok(())
1886 /// }
1887 /// ```
1888 pub fn list_hub_spokes(&self) -> super::builder::hub_service::ListHubSpokes {
1889 super::builder::hub_service::ListHubSpokes::new(self.inner.clone())
1890 }
1891
1892 /// Query the Private Service Connect propagation status of a Network
1893 /// Connectivity Center hub.
1894 ///
1895 /// # Example
1896 /// ```
1897 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1898 /// use google_cloud_gax::paginator::ItemPaginator as _;
1899 /// use google_cloud_networkconnectivity_v1::Result;
1900 /// async fn sample(
1901 /// client: &HubService
1902 /// ) -> Result<()> {
1903 /// let mut list = client.query_hub_status()
1904 /// /* set fields */
1905 /// .by_item();
1906 /// while let Some(item) = list.next().await.transpose()? {
1907 /// println!("{:?}", item);
1908 /// }
1909 /// Ok(())
1910 /// }
1911 /// ```
1912 pub fn query_hub_status(&self) -> super::builder::hub_service::QueryHubStatus {
1913 super::builder::hub_service::QueryHubStatus::new(self.inner.clone())
1914 }
1915
1916 /// Lists the Network Connectivity Center spokes in a specified project and
1917 /// location.
1918 ///
1919 /// # Example
1920 /// ```
1921 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1922 /// use google_cloud_gax::paginator::ItemPaginator as _;
1923 /// use google_cloud_networkconnectivity_v1::Result;
1924 /// async fn sample(
1925 /// client: &HubService, parent: &str
1926 /// ) -> Result<()> {
1927 /// let mut list = client.list_spokes()
1928 /// .set_parent(parent)
1929 /// .by_item();
1930 /// while let Some(item) = list.next().await.transpose()? {
1931 /// println!("{:?}", item);
1932 /// }
1933 /// Ok(())
1934 /// }
1935 /// ```
1936 pub fn list_spokes(&self) -> super::builder::hub_service::ListSpokes {
1937 super::builder::hub_service::ListSpokes::new(self.inner.clone())
1938 }
1939
1940 /// Gets details about a Network Connectivity Center spoke.
1941 ///
1942 /// # Example
1943 /// ```
1944 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1945 /// use google_cloud_networkconnectivity_v1::Result;
1946 /// async fn sample(
1947 /// client: &HubService, project_id: &str, location_id: &str, spoke_id: &str
1948 /// ) -> Result<()> {
1949 /// let response = client.get_spoke()
1950 /// .set_name(format!("projects/{project_id}/locations/{location_id}/spokes/{spoke_id}"))
1951 /// .send().await?;
1952 /// println!("response {:?}", response);
1953 /// Ok(())
1954 /// }
1955 /// ```
1956 pub fn get_spoke(&self) -> super::builder::hub_service::GetSpoke {
1957 super::builder::hub_service::GetSpoke::new(self.inner.clone())
1958 }
1959
1960 /// Creates a Network Connectivity Center spoke.
1961 ///
1962 /// # Long running operations
1963 ///
1964 /// This method is used to start, and/or poll a [long-running Operation].
1965 /// The [Working with long-running operations] chapter in the [user guide]
1966 /// covers these operations in detail.
1967 ///
1968 /// [long-running operation]: https://google.aip.dev/151
1969 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1970 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1971 ///
1972 /// # Example
1973 /// ```
1974 /// # use google_cloud_networkconnectivity_v1::client::HubService;
1975 /// use google_cloud_lro::Poller;
1976 /// use google_cloud_networkconnectivity_v1::model::Spoke;
1977 /// use google_cloud_networkconnectivity_v1::Result;
1978 /// async fn sample(
1979 /// client: &HubService, parent: &str
1980 /// ) -> Result<()> {
1981 /// let response = client.create_spoke()
1982 /// .set_parent(parent)
1983 /// .set_spoke_id("spoke_id_value")
1984 /// .set_spoke(
1985 /// Spoke::new()/* set fields */
1986 /// )
1987 /// .poller().until_done().await?;
1988 /// println!("response {:?}", response);
1989 /// Ok(())
1990 /// }
1991 /// ```
1992 pub fn create_spoke(&self) -> super::builder::hub_service::CreateSpoke {
1993 super::builder::hub_service::CreateSpoke::new(self.inner.clone())
1994 }
1995
1996 /// Updates the parameters of a Network Connectivity Center spoke.
1997 ///
1998 /// # Long running operations
1999 ///
2000 /// This method is used to start, and/or poll a [long-running Operation].
2001 /// The [Working with long-running operations] chapter in the [user guide]
2002 /// covers these operations in detail.
2003 ///
2004 /// [long-running operation]: https://google.aip.dev/151
2005 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2006 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2007 ///
2008 /// # Example
2009 /// ```
2010 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2011 /// use google_cloud_lro::Poller;
2012 /// # extern crate wkt as google_cloud_wkt;
2013 /// use google_cloud_wkt::FieldMask;
2014 /// use google_cloud_networkconnectivity_v1::model::Spoke;
2015 /// use google_cloud_networkconnectivity_v1::Result;
2016 /// async fn sample(
2017 /// client: &HubService, project_id: &str, location_id: &str, spoke_id: &str
2018 /// ) -> Result<()> {
2019 /// let response = client.update_spoke()
2020 /// .set_spoke(
2021 /// Spoke::new().set_name(format!("projects/{project_id}/locations/{location_id}/spokes/{spoke_id}"))/* set fields */
2022 /// )
2023 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2024 /// .poller().until_done().await?;
2025 /// println!("response {:?}", response);
2026 /// Ok(())
2027 /// }
2028 /// ```
2029 pub fn update_spoke(&self) -> super::builder::hub_service::UpdateSpoke {
2030 super::builder::hub_service::UpdateSpoke::new(self.inner.clone())
2031 }
2032
2033 /// Rejects a Network Connectivity Center spoke from being attached to a hub.
2034 /// If the spoke was previously in the `ACTIVE` state, it
2035 /// transitions to the `INACTIVE` state and is no longer able to
2036 /// connect to other spokes that are attached to the hub.
2037 ///
2038 /// # Long running operations
2039 ///
2040 /// This method is used to start, and/or poll a [long-running Operation].
2041 /// The [Working with long-running operations] chapter in the [user guide]
2042 /// covers these operations in detail.
2043 ///
2044 /// [long-running operation]: https://google.aip.dev/151
2045 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2046 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2047 ///
2048 /// # Example
2049 /// ```
2050 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2051 /// use google_cloud_lro::Poller;
2052 /// use google_cloud_networkconnectivity_v1::Result;
2053 /// async fn sample(
2054 /// client: &HubService
2055 /// ) -> Result<()> {
2056 /// let response = client.reject_hub_spoke()
2057 /// /* set fields */
2058 /// .poller().until_done().await?;
2059 /// println!("response {:?}", response);
2060 /// Ok(())
2061 /// }
2062 /// ```
2063 pub fn reject_hub_spoke(&self) -> super::builder::hub_service::RejectHubSpoke {
2064 super::builder::hub_service::RejectHubSpoke::new(self.inner.clone())
2065 }
2066
2067 /// Accepts a proposal to attach a Network Connectivity Center spoke
2068 /// to a hub.
2069 ///
2070 /// # Long running operations
2071 ///
2072 /// This method is used to start, and/or poll a [long-running Operation].
2073 /// The [Working with long-running operations] chapter in the [user guide]
2074 /// covers these operations in detail.
2075 ///
2076 /// [long-running operation]: https://google.aip.dev/151
2077 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2078 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2079 ///
2080 /// # Example
2081 /// ```
2082 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2083 /// use google_cloud_lro::Poller;
2084 /// use google_cloud_networkconnectivity_v1::Result;
2085 /// async fn sample(
2086 /// client: &HubService
2087 /// ) -> Result<()> {
2088 /// let response = client.accept_hub_spoke()
2089 /// /* set fields */
2090 /// .poller().until_done().await?;
2091 /// println!("response {:?}", response);
2092 /// Ok(())
2093 /// }
2094 /// ```
2095 pub fn accept_hub_spoke(&self) -> super::builder::hub_service::AcceptHubSpoke {
2096 super::builder::hub_service::AcceptHubSpoke::new(self.inner.clone())
2097 }
2098
2099 /// Accepts a proposal to update a Network Connectivity Center spoke in a hub.
2100 ///
2101 /// # Long running operations
2102 ///
2103 /// This method is used to start, and/or poll a [long-running Operation].
2104 /// The [Working with long-running operations] chapter in the [user guide]
2105 /// covers these operations in detail.
2106 ///
2107 /// [long-running operation]: https://google.aip.dev/151
2108 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2109 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2110 ///
2111 /// # Example
2112 /// ```
2113 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2114 /// use google_cloud_lro::Poller;
2115 /// use google_cloud_networkconnectivity_v1::Result;
2116 /// async fn sample(
2117 /// client: &HubService
2118 /// ) -> Result<()> {
2119 /// let response = client.accept_spoke_update()
2120 /// /* set fields */
2121 /// .poller().until_done().await?;
2122 /// println!("response {:?}", response);
2123 /// Ok(())
2124 /// }
2125 /// ```
2126 pub fn accept_spoke_update(&self) -> super::builder::hub_service::AcceptSpokeUpdate {
2127 super::builder::hub_service::AcceptSpokeUpdate::new(self.inner.clone())
2128 }
2129
2130 /// Rejects a proposal to update a Network Connectivity Center spoke in a hub.
2131 ///
2132 /// # Long running operations
2133 ///
2134 /// This method is used to start, and/or poll a [long-running Operation].
2135 /// The [Working with long-running operations] chapter in the [user guide]
2136 /// covers these operations in detail.
2137 ///
2138 /// [long-running operation]: https://google.aip.dev/151
2139 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2140 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2141 ///
2142 /// # Example
2143 /// ```
2144 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2145 /// use google_cloud_lro::Poller;
2146 /// use google_cloud_networkconnectivity_v1::Result;
2147 /// async fn sample(
2148 /// client: &HubService
2149 /// ) -> Result<()> {
2150 /// let response = client.reject_spoke_update()
2151 /// /* set fields */
2152 /// .poller().until_done().await?;
2153 /// println!("response {:?}", response);
2154 /// Ok(())
2155 /// }
2156 /// ```
2157 pub fn reject_spoke_update(&self) -> super::builder::hub_service::RejectSpokeUpdate {
2158 super::builder::hub_service::RejectSpokeUpdate::new(self.inner.clone())
2159 }
2160
2161 /// Deletes a Network Connectivity Center spoke.
2162 ///
2163 /// # Long running operations
2164 ///
2165 /// This method is used to start, and/or poll a [long-running Operation].
2166 /// The [Working with long-running operations] chapter in the [user guide]
2167 /// covers these operations in detail.
2168 ///
2169 /// [long-running operation]: https://google.aip.dev/151
2170 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2171 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2172 ///
2173 /// # Example
2174 /// ```
2175 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2176 /// use google_cloud_lro::Poller;
2177 /// use google_cloud_networkconnectivity_v1::Result;
2178 /// async fn sample(
2179 /// client: &HubService, project_id: &str, location_id: &str, spoke_id: &str
2180 /// ) -> Result<()> {
2181 /// client.delete_spoke()
2182 /// .set_name(format!("projects/{project_id}/locations/{location_id}/spokes/{spoke_id}"))
2183 /// .poller().until_done().await?;
2184 /// Ok(())
2185 /// }
2186 /// ```
2187 pub fn delete_spoke(&self) -> super::builder::hub_service::DeleteSpoke {
2188 super::builder::hub_service::DeleteSpoke::new(self.inner.clone())
2189 }
2190
2191 /// Gets details about a Network Connectivity Center route table.
2192 ///
2193 /// # Example
2194 /// ```
2195 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2196 /// use google_cloud_networkconnectivity_v1::Result;
2197 /// async fn sample(
2198 /// client: &HubService, project_id: &str, hub_id: &str, route_table_id: &str
2199 /// ) -> Result<()> {
2200 /// let response = client.get_route_table()
2201 /// .set_name(format!("projects/{project_id}/locations/global/hubs/{hub_id}/routeTables/{route_table_id}"))
2202 /// .send().await?;
2203 /// println!("response {:?}", response);
2204 /// Ok(())
2205 /// }
2206 /// ```
2207 pub fn get_route_table(&self) -> super::builder::hub_service::GetRouteTable {
2208 super::builder::hub_service::GetRouteTable::new(self.inner.clone())
2209 }
2210
2211 /// Gets details about the specified route.
2212 ///
2213 /// # Example
2214 /// ```
2215 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2216 /// use google_cloud_networkconnectivity_v1::Result;
2217 /// async fn sample(
2218 /// client: &HubService, project_id: &str, hub_id: &str, route_table_id: &str, route_id: &str
2219 /// ) -> Result<()> {
2220 /// let response = client.get_route()
2221 /// .set_name(format!("projects/{project_id}/locations/global/hubs/{hub_id}/routeTables/{route_table_id}/routes/{route_id}"))
2222 /// .send().await?;
2223 /// println!("response {:?}", response);
2224 /// Ok(())
2225 /// }
2226 /// ```
2227 pub fn get_route(&self) -> super::builder::hub_service::GetRoute {
2228 super::builder::hub_service::GetRoute::new(self.inner.clone())
2229 }
2230
2231 /// Lists routes in a given route table.
2232 ///
2233 /// # Example
2234 /// ```
2235 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2236 /// use google_cloud_gax::paginator::ItemPaginator as _;
2237 /// use google_cloud_networkconnectivity_v1::Result;
2238 /// async fn sample(
2239 /// client: &HubService, project_id: &str, hub_id: &str, route_table_id: &str
2240 /// ) -> Result<()> {
2241 /// let mut list = client.list_routes()
2242 /// .set_parent(format!("projects/{project_id}/locations/global/hubs/{hub_id}/routeTables/{route_table_id}"))
2243 /// .by_item();
2244 /// while let Some(item) = list.next().await.transpose()? {
2245 /// println!("{:?}", item);
2246 /// }
2247 /// Ok(())
2248 /// }
2249 /// ```
2250 pub fn list_routes(&self) -> super::builder::hub_service::ListRoutes {
2251 super::builder::hub_service::ListRoutes::new(self.inner.clone())
2252 }
2253
2254 /// Lists route tables in a given hub.
2255 ///
2256 /// # Example
2257 /// ```
2258 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2259 /// use google_cloud_gax::paginator::ItemPaginator as _;
2260 /// use google_cloud_networkconnectivity_v1::Result;
2261 /// async fn sample(
2262 /// client: &HubService, project_id: &str, hub_id: &str
2263 /// ) -> Result<()> {
2264 /// let mut list = client.list_route_tables()
2265 /// .set_parent(format!("projects/{project_id}/locations/global/hubs/{hub_id}"))
2266 /// .by_item();
2267 /// while let Some(item) = list.next().await.transpose()? {
2268 /// println!("{:?}", item);
2269 /// }
2270 /// Ok(())
2271 /// }
2272 /// ```
2273 pub fn list_route_tables(&self) -> super::builder::hub_service::ListRouteTables {
2274 super::builder::hub_service::ListRouteTables::new(self.inner.clone())
2275 }
2276
2277 /// Gets details about a Network Connectivity Center group.
2278 ///
2279 /// # Example
2280 /// ```
2281 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2282 /// use google_cloud_networkconnectivity_v1::Result;
2283 /// async fn sample(
2284 /// client: &HubService, project_id: &str, hub_id: &str, group_id: &str
2285 /// ) -> Result<()> {
2286 /// let response = client.get_group()
2287 /// .set_name(format!("projects/{project_id}/locations/global/hubs/{hub_id}/groups/{group_id}"))
2288 /// .send().await?;
2289 /// println!("response {:?}", response);
2290 /// Ok(())
2291 /// }
2292 /// ```
2293 pub fn get_group(&self) -> super::builder::hub_service::GetGroup {
2294 super::builder::hub_service::GetGroup::new(self.inner.clone())
2295 }
2296
2297 /// Lists groups in a given hub.
2298 ///
2299 /// # Example
2300 /// ```
2301 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2302 /// use google_cloud_gax::paginator::ItemPaginator as _;
2303 /// use google_cloud_networkconnectivity_v1::Result;
2304 /// async fn sample(
2305 /// client: &HubService, project_id: &str, hub_id: &str
2306 /// ) -> Result<()> {
2307 /// let mut list = client.list_groups()
2308 /// .set_parent(format!("projects/{project_id}/locations/global/hubs/{hub_id}"))
2309 /// .by_item();
2310 /// while let Some(item) = list.next().await.transpose()? {
2311 /// println!("{:?}", item);
2312 /// }
2313 /// Ok(())
2314 /// }
2315 /// ```
2316 pub fn list_groups(&self) -> super::builder::hub_service::ListGroups {
2317 super::builder::hub_service::ListGroups::new(self.inner.clone())
2318 }
2319
2320 /// Updates the parameters of a Network Connectivity Center group.
2321 ///
2322 /// # Long running operations
2323 ///
2324 /// This method is used to start, and/or poll a [long-running Operation].
2325 /// The [Working with long-running operations] chapter in the [user guide]
2326 /// covers these operations in detail.
2327 ///
2328 /// [long-running operation]: https://google.aip.dev/151
2329 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2330 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2331 ///
2332 /// # Example
2333 /// ```
2334 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2335 /// use google_cloud_lro::Poller;
2336 /// # extern crate wkt as google_cloud_wkt;
2337 /// use google_cloud_wkt::FieldMask;
2338 /// use google_cloud_networkconnectivity_v1::model::Group;
2339 /// use google_cloud_networkconnectivity_v1::Result;
2340 /// async fn sample(
2341 /// client: &HubService, project_id: &str, hub_id: &str, group_id: &str
2342 /// ) -> Result<()> {
2343 /// let response = client.update_group()
2344 /// .set_group(
2345 /// Group::new().set_name(format!("projects/{project_id}/locations/global/hubs/{hub_id}/groups/{group_id}"))/* set fields */
2346 /// )
2347 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2348 /// .poller().until_done().await?;
2349 /// println!("response {:?}", response);
2350 /// Ok(())
2351 /// }
2352 /// ```
2353 pub fn update_group(&self) -> super::builder::hub_service::UpdateGroup {
2354 super::builder::hub_service::UpdateGroup::new(self.inner.clone())
2355 }
2356
2357 /// Lists information about the supported locations for this service.
2358 ///
2359 /// # Example
2360 /// ```
2361 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2362 /// use google_cloud_gax::paginator::ItemPaginator as _;
2363 /// use google_cloud_networkconnectivity_v1::Result;
2364 /// async fn sample(
2365 /// client: &HubService
2366 /// ) -> Result<()> {
2367 /// let mut list = client.list_locations()
2368 /// /* set fields */
2369 /// .by_item();
2370 /// while let Some(item) = list.next().await.transpose()? {
2371 /// println!("{:?}", item);
2372 /// }
2373 /// Ok(())
2374 /// }
2375 /// ```
2376 pub fn list_locations(&self) -> super::builder::hub_service::ListLocations {
2377 super::builder::hub_service::ListLocations::new(self.inner.clone())
2378 }
2379
2380 /// Gets information about a location.
2381 ///
2382 /// # Example
2383 /// ```
2384 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2385 /// use google_cloud_networkconnectivity_v1::Result;
2386 /// async fn sample(
2387 /// client: &HubService
2388 /// ) -> Result<()> {
2389 /// let response = client.get_location()
2390 /// /* set fields */
2391 /// .send().await?;
2392 /// println!("response {:?}", response);
2393 /// Ok(())
2394 /// }
2395 /// ```
2396 pub fn get_location(&self) -> super::builder::hub_service::GetLocation {
2397 super::builder::hub_service::GetLocation::new(self.inner.clone())
2398 }
2399
2400 /// Sets the access control policy on the specified resource. Replaces
2401 /// any existing policy.
2402 ///
2403 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
2404 /// errors.
2405 ///
2406 /// # Example
2407 /// ```
2408 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2409 /// use google_cloud_networkconnectivity_v1::Result;
2410 /// async fn sample(
2411 /// client: &HubService
2412 /// ) -> Result<()> {
2413 /// let response = client.set_iam_policy()
2414 /// /* set fields */
2415 /// .send().await?;
2416 /// println!("response {:?}", response);
2417 /// Ok(())
2418 /// }
2419 /// ```
2420 pub fn set_iam_policy(&self) -> super::builder::hub_service::SetIamPolicy {
2421 super::builder::hub_service::SetIamPolicy::new(self.inner.clone())
2422 }
2423
2424 /// Gets the access control policy for a resource. Returns an empty policy
2425 /// if the resource exists and does not have a policy set.
2426 ///
2427 /// # Example
2428 /// ```
2429 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2430 /// use google_cloud_networkconnectivity_v1::Result;
2431 /// async fn sample(
2432 /// client: &HubService
2433 /// ) -> Result<()> {
2434 /// let response = client.get_iam_policy()
2435 /// /* set fields */
2436 /// .send().await?;
2437 /// println!("response {:?}", response);
2438 /// Ok(())
2439 /// }
2440 /// ```
2441 pub fn get_iam_policy(&self) -> super::builder::hub_service::GetIamPolicy {
2442 super::builder::hub_service::GetIamPolicy::new(self.inner.clone())
2443 }
2444
2445 /// Returns permissions that a caller has on the specified resource. If the
2446 /// resource does not exist, this will return an empty set of
2447 /// permissions, not a `NOT_FOUND` error.
2448 ///
2449 /// Note: This operation is designed to be used for building
2450 /// permission-aware UIs and command-line tools, not for authorization
2451 /// checking. This operation may "fail open" without warning.
2452 ///
2453 /// # Example
2454 /// ```
2455 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2456 /// use google_cloud_networkconnectivity_v1::Result;
2457 /// async fn sample(
2458 /// client: &HubService
2459 /// ) -> Result<()> {
2460 /// let response = client.test_iam_permissions()
2461 /// /* set fields */
2462 /// .send().await?;
2463 /// println!("response {:?}", response);
2464 /// Ok(())
2465 /// }
2466 /// ```
2467 pub fn test_iam_permissions(&self) -> super::builder::hub_service::TestIamPermissions {
2468 super::builder::hub_service::TestIamPermissions::new(self.inner.clone())
2469 }
2470
2471 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2472 ///
2473 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2474 ///
2475 /// # Example
2476 /// ```
2477 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2478 /// use google_cloud_gax::paginator::ItemPaginator as _;
2479 /// use google_cloud_networkconnectivity_v1::Result;
2480 /// async fn sample(
2481 /// client: &HubService
2482 /// ) -> Result<()> {
2483 /// let mut list = client.list_operations()
2484 /// /* set fields */
2485 /// .by_item();
2486 /// while let Some(item) = list.next().await.transpose()? {
2487 /// println!("{:?}", item);
2488 /// }
2489 /// Ok(())
2490 /// }
2491 /// ```
2492 pub fn list_operations(&self) -> super::builder::hub_service::ListOperations {
2493 super::builder::hub_service::ListOperations::new(self.inner.clone())
2494 }
2495
2496 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2497 ///
2498 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2499 ///
2500 /// # Example
2501 /// ```
2502 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2503 /// use google_cloud_networkconnectivity_v1::Result;
2504 /// async fn sample(
2505 /// client: &HubService
2506 /// ) -> Result<()> {
2507 /// let response = client.get_operation()
2508 /// /* set fields */
2509 /// .send().await?;
2510 /// println!("response {:?}", response);
2511 /// Ok(())
2512 /// }
2513 /// ```
2514 pub fn get_operation(&self) -> super::builder::hub_service::GetOperation {
2515 super::builder::hub_service::GetOperation::new(self.inner.clone())
2516 }
2517
2518 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2519 ///
2520 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2521 ///
2522 /// # Example
2523 /// ```
2524 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2525 /// use google_cloud_networkconnectivity_v1::Result;
2526 /// async fn sample(
2527 /// client: &HubService
2528 /// ) -> Result<()> {
2529 /// client.delete_operation()
2530 /// /* set fields */
2531 /// .send().await?;
2532 /// Ok(())
2533 /// }
2534 /// ```
2535 pub fn delete_operation(&self) -> super::builder::hub_service::DeleteOperation {
2536 super::builder::hub_service::DeleteOperation::new(self.inner.clone())
2537 }
2538
2539 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2540 ///
2541 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2542 ///
2543 /// # Example
2544 /// ```
2545 /// # use google_cloud_networkconnectivity_v1::client::HubService;
2546 /// use google_cloud_networkconnectivity_v1::Result;
2547 /// async fn sample(
2548 /// client: &HubService
2549 /// ) -> Result<()> {
2550 /// client.cancel_operation()
2551 /// /* set fields */
2552 /// .send().await?;
2553 /// Ok(())
2554 /// }
2555 /// ```
2556 pub fn cancel_operation(&self) -> super::builder::hub_service::CancelOperation {
2557 super::builder::hub_service::CancelOperation::new(self.inner.clone())
2558 }
2559}
2560
2561/// Implements a client for the Network Connectivity API.
2562///
2563/// # Example
2564/// ```
2565/// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2566/// use google_cloud_gax::paginator::ItemPaginator as _;
2567/// async fn sample(
2568/// parent: &str,
2569/// ) -> anyhow::Result<()> {
2570/// let client = InternalRangeService::builder().build().await?;
2571/// let mut list = client.list_internal_ranges()
2572/// .set_parent(parent)
2573/// .by_item();
2574/// while let Some(item) = list.next().await.transpose()? {
2575/// println!("{:?}", item);
2576/// }
2577/// Ok(())
2578/// }
2579/// ```
2580///
2581/// # Service Description
2582///
2583/// The CLH-based service for internal range resources used to perform IPAM
2584/// operations within a VPC network.
2585///
2586/// # Configuration
2587///
2588/// To configure `InternalRangeService` use the `with_*` methods in the type returned
2589/// by [builder()][InternalRangeService::builder]. The default configuration should
2590/// work for most applications. Common configuration changes include
2591///
2592/// * [with_endpoint()]: by default this client uses the global default endpoint
2593/// (`https://networkconnectivity.googleapis.com`). Applications using regional
2594/// endpoints or running in restricted networks (e.g. a network configured
2595/// with [Private Google Access with VPC Service Controls]) may want to
2596/// override this default.
2597/// * [with_credentials()]: by default this client uses
2598/// [Application Default Credentials]. Applications using custom
2599/// authentication may need to override this default.
2600///
2601/// [with_endpoint()]: super::builder::internal_range_service::ClientBuilder::with_endpoint
2602/// [with_credentials()]: super::builder::internal_range_service::ClientBuilder::with_credentials
2603/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2604/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2605///
2606/// # Pooling and Cloning
2607///
2608/// `InternalRangeService` holds a connection pool internally, it is advised to
2609/// create one and reuse it. You do not need to wrap `InternalRangeService` in
2610/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2611/// already uses an `Arc` internally.
2612#[derive(Clone, Debug)]
2613pub struct InternalRangeService {
2614 inner: std::sync::Arc<dyn super::stub::dynamic::InternalRangeService>,
2615}
2616
2617impl InternalRangeService {
2618 /// Returns a builder for [InternalRangeService].
2619 ///
2620 /// ```
2621 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2622 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2623 /// let client = InternalRangeService::builder().build().await?;
2624 /// # Ok(()) }
2625 /// ```
2626 pub fn builder() -> super::builder::internal_range_service::ClientBuilder {
2627 crate::new_client_builder(super::builder::internal_range_service::client::Factory)
2628 }
2629
2630 /// Creates a new client from the provided stub.
2631 ///
2632 /// The most common case for calling this function is in tests mocking the
2633 /// client's behavior.
2634 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2635 where
2636 T: super::stub::InternalRangeService + 'static,
2637 {
2638 Self { inner: stub.into() }
2639 }
2640
2641 pub(crate) async fn new(
2642 config: gaxi::options::ClientConfig,
2643 ) -> crate::ClientBuilderResult<Self> {
2644 let inner = Self::build_inner(config).await?;
2645 Ok(Self { inner })
2646 }
2647
2648 async fn build_inner(
2649 conf: gaxi::options::ClientConfig,
2650 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::InternalRangeService>>
2651 {
2652 if gaxi::options::tracing_enabled(&conf) {
2653 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2654 }
2655 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2656 }
2657
2658 async fn build_transport(
2659 conf: gaxi::options::ClientConfig,
2660 ) -> crate::ClientBuilderResult<impl super::stub::InternalRangeService> {
2661 super::transport::InternalRangeService::new(conf).await
2662 }
2663
2664 async fn build_with_tracing(
2665 conf: gaxi::options::ClientConfig,
2666 ) -> crate::ClientBuilderResult<impl super::stub::InternalRangeService> {
2667 Self::build_transport(conf)
2668 .await
2669 .map(super::tracing::InternalRangeService::new)
2670 }
2671
2672 /// Lists internal ranges in a given project and location.
2673 ///
2674 /// # Example
2675 /// ```
2676 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2677 /// use google_cloud_gax::paginator::ItemPaginator as _;
2678 /// use google_cloud_networkconnectivity_v1::Result;
2679 /// async fn sample(
2680 /// client: &InternalRangeService, parent: &str
2681 /// ) -> Result<()> {
2682 /// let mut list = client.list_internal_ranges()
2683 /// .set_parent(parent)
2684 /// .by_item();
2685 /// while let Some(item) = list.next().await.transpose()? {
2686 /// println!("{:?}", item);
2687 /// }
2688 /// Ok(())
2689 /// }
2690 /// ```
2691 pub fn list_internal_ranges(
2692 &self,
2693 ) -> super::builder::internal_range_service::ListInternalRanges {
2694 super::builder::internal_range_service::ListInternalRanges::new(self.inner.clone())
2695 }
2696
2697 /// Gets details of a single internal range.
2698 ///
2699 /// # Example
2700 /// ```
2701 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2702 /// use google_cloud_networkconnectivity_v1::Result;
2703 /// async fn sample(
2704 /// client: &InternalRangeService, project_id: &str, location_id: &str, internal_range_id: &str
2705 /// ) -> Result<()> {
2706 /// let response = client.get_internal_range()
2707 /// .set_name(format!("projects/{project_id}/locations/{location_id}/internalRanges/{internal_range_id}"))
2708 /// .send().await?;
2709 /// println!("response {:?}", response);
2710 /// Ok(())
2711 /// }
2712 /// ```
2713 pub fn get_internal_range(&self) -> super::builder::internal_range_service::GetInternalRange {
2714 super::builder::internal_range_service::GetInternalRange::new(self.inner.clone())
2715 }
2716
2717 /// Creates a new internal range in a given project and location.
2718 ///
2719 /// # Long running operations
2720 ///
2721 /// This method is used to start, and/or poll a [long-running Operation].
2722 /// The [Working with long-running operations] chapter in the [user guide]
2723 /// covers these operations in detail.
2724 ///
2725 /// [long-running operation]: https://google.aip.dev/151
2726 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2727 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2728 ///
2729 /// # Example
2730 /// ```
2731 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2732 /// use google_cloud_lro::Poller;
2733 /// use google_cloud_networkconnectivity_v1::model::InternalRange;
2734 /// use google_cloud_networkconnectivity_v1::Result;
2735 /// async fn sample(
2736 /// client: &InternalRangeService, project_id: &str, location_id: &str
2737 /// ) -> Result<()> {
2738 /// let response = client.create_internal_range()
2739 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
2740 /// .set_internal_range(
2741 /// InternalRange::new()/* set fields */
2742 /// )
2743 /// .poller().until_done().await?;
2744 /// println!("response {:?}", response);
2745 /// Ok(())
2746 /// }
2747 /// ```
2748 pub fn create_internal_range(
2749 &self,
2750 ) -> super::builder::internal_range_service::CreateInternalRange {
2751 super::builder::internal_range_service::CreateInternalRange::new(self.inner.clone())
2752 }
2753
2754 /// Updates the parameters of a single internal range.
2755 ///
2756 /// # Long running operations
2757 ///
2758 /// This method is used to start, and/or poll a [long-running Operation].
2759 /// The [Working with long-running operations] chapter in the [user guide]
2760 /// covers these operations in detail.
2761 ///
2762 /// [long-running operation]: https://google.aip.dev/151
2763 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2764 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2765 ///
2766 /// # Example
2767 /// ```
2768 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2769 /// use google_cloud_lro::Poller;
2770 /// # extern crate wkt as google_cloud_wkt;
2771 /// use google_cloud_wkt::FieldMask;
2772 /// use google_cloud_networkconnectivity_v1::model::InternalRange;
2773 /// use google_cloud_networkconnectivity_v1::Result;
2774 /// async fn sample(
2775 /// client: &InternalRangeService, project_id: &str, location_id: &str, internal_range_id: &str
2776 /// ) -> Result<()> {
2777 /// let response = client.update_internal_range()
2778 /// .set_internal_range(
2779 /// InternalRange::new().set_name(format!("projects/{project_id}/locations/{location_id}/internalRanges/{internal_range_id}"))/* set fields */
2780 /// )
2781 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2782 /// .poller().until_done().await?;
2783 /// println!("response {:?}", response);
2784 /// Ok(())
2785 /// }
2786 /// ```
2787 pub fn update_internal_range(
2788 &self,
2789 ) -> super::builder::internal_range_service::UpdateInternalRange {
2790 super::builder::internal_range_service::UpdateInternalRange::new(self.inner.clone())
2791 }
2792
2793 /// Deletes a single internal range.
2794 ///
2795 /// # Long running operations
2796 ///
2797 /// This method is used to start, and/or poll a [long-running Operation].
2798 /// The [Working with long-running operations] chapter in the [user guide]
2799 /// covers these operations in detail.
2800 ///
2801 /// [long-running operation]: https://google.aip.dev/151
2802 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2803 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2804 ///
2805 /// # Example
2806 /// ```
2807 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2808 /// use google_cloud_lro::Poller;
2809 /// use google_cloud_networkconnectivity_v1::Result;
2810 /// async fn sample(
2811 /// client: &InternalRangeService, project_id: &str, location_id: &str, internal_range_id: &str
2812 /// ) -> Result<()> {
2813 /// client.delete_internal_range()
2814 /// .set_name(format!("projects/{project_id}/locations/{location_id}/internalRanges/{internal_range_id}"))
2815 /// .poller().until_done().await?;
2816 /// Ok(())
2817 /// }
2818 /// ```
2819 pub fn delete_internal_range(
2820 &self,
2821 ) -> super::builder::internal_range_service::DeleteInternalRange {
2822 super::builder::internal_range_service::DeleteInternalRange::new(self.inner.clone())
2823 }
2824
2825 /// Lists information about the supported locations for this service.
2826 ///
2827 /// # Example
2828 /// ```
2829 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2830 /// use google_cloud_gax::paginator::ItemPaginator as _;
2831 /// use google_cloud_networkconnectivity_v1::Result;
2832 /// async fn sample(
2833 /// client: &InternalRangeService
2834 /// ) -> Result<()> {
2835 /// let mut list = client.list_locations()
2836 /// /* set fields */
2837 /// .by_item();
2838 /// while let Some(item) = list.next().await.transpose()? {
2839 /// println!("{:?}", item);
2840 /// }
2841 /// Ok(())
2842 /// }
2843 /// ```
2844 pub fn list_locations(&self) -> super::builder::internal_range_service::ListLocations {
2845 super::builder::internal_range_service::ListLocations::new(self.inner.clone())
2846 }
2847
2848 /// Gets information about a location.
2849 ///
2850 /// # Example
2851 /// ```
2852 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2853 /// use google_cloud_networkconnectivity_v1::Result;
2854 /// async fn sample(
2855 /// client: &InternalRangeService
2856 /// ) -> Result<()> {
2857 /// let response = client.get_location()
2858 /// /* set fields */
2859 /// .send().await?;
2860 /// println!("response {:?}", response);
2861 /// Ok(())
2862 /// }
2863 /// ```
2864 pub fn get_location(&self) -> super::builder::internal_range_service::GetLocation {
2865 super::builder::internal_range_service::GetLocation::new(self.inner.clone())
2866 }
2867
2868 /// Sets the access control policy on the specified resource. Replaces
2869 /// any existing policy.
2870 ///
2871 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
2872 /// errors.
2873 ///
2874 /// # Example
2875 /// ```
2876 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2877 /// use google_cloud_networkconnectivity_v1::Result;
2878 /// async fn sample(
2879 /// client: &InternalRangeService
2880 /// ) -> Result<()> {
2881 /// let response = client.set_iam_policy()
2882 /// /* set fields */
2883 /// .send().await?;
2884 /// println!("response {:?}", response);
2885 /// Ok(())
2886 /// }
2887 /// ```
2888 pub fn set_iam_policy(&self) -> super::builder::internal_range_service::SetIamPolicy {
2889 super::builder::internal_range_service::SetIamPolicy::new(self.inner.clone())
2890 }
2891
2892 /// Gets the access control policy for a resource. Returns an empty policy
2893 /// if the resource exists and does not have a policy set.
2894 ///
2895 /// # Example
2896 /// ```
2897 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2898 /// use google_cloud_networkconnectivity_v1::Result;
2899 /// async fn sample(
2900 /// client: &InternalRangeService
2901 /// ) -> Result<()> {
2902 /// let response = client.get_iam_policy()
2903 /// /* set fields */
2904 /// .send().await?;
2905 /// println!("response {:?}", response);
2906 /// Ok(())
2907 /// }
2908 /// ```
2909 pub fn get_iam_policy(&self) -> super::builder::internal_range_service::GetIamPolicy {
2910 super::builder::internal_range_service::GetIamPolicy::new(self.inner.clone())
2911 }
2912
2913 /// Returns permissions that a caller has on the specified resource. If the
2914 /// resource does not exist, this will return an empty set of
2915 /// permissions, not a `NOT_FOUND` error.
2916 ///
2917 /// Note: This operation is designed to be used for building
2918 /// permission-aware UIs and command-line tools, not for authorization
2919 /// checking. This operation may "fail open" without warning.
2920 ///
2921 /// # Example
2922 /// ```
2923 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2924 /// use google_cloud_networkconnectivity_v1::Result;
2925 /// async fn sample(
2926 /// client: &InternalRangeService
2927 /// ) -> Result<()> {
2928 /// let response = client.test_iam_permissions()
2929 /// /* set fields */
2930 /// .send().await?;
2931 /// println!("response {:?}", response);
2932 /// Ok(())
2933 /// }
2934 /// ```
2935 pub fn test_iam_permissions(
2936 &self,
2937 ) -> super::builder::internal_range_service::TestIamPermissions {
2938 super::builder::internal_range_service::TestIamPermissions::new(self.inner.clone())
2939 }
2940
2941 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2942 ///
2943 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2944 ///
2945 /// # Example
2946 /// ```
2947 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2948 /// use google_cloud_gax::paginator::ItemPaginator as _;
2949 /// use google_cloud_networkconnectivity_v1::Result;
2950 /// async fn sample(
2951 /// client: &InternalRangeService
2952 /// ) -> Result<()> {
2953 /// let mut list = client.list_operations()
2954 /// /* set fields */
2955 /// .by_item();
2956 /// while let Some(item) = list.next().await.transpose()? {
2957 /// println!("{:?}", item);
2958 /// }
2959 /// Ok(())
2960 /// }
2961 /// ```
2962 pub fn list_operations(&self) -> super::builder::internal_range_service::ListOperations {
2963 super::builder::internal_range_service::ListOperations::new(self.inner.clone())
2964 }
2965
2966 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2967 ///
2968 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2969 ///
2970 /// # Example
2971 /// ```
2972 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2973 /// use google_cloud_networkconnectivity_v1::Result;
2974 /// async fn sample(
2975 /// client: &InternalRangeService
2976 /// ) -> Result<()> {
2977 /// let response = client.get_operation()
2978 /// /* set fields */
2979 /// .send().await?;
2980 /// println!("response {:?}", response);
2981 /// Ok(())
2982 /// }
2983 /// ```
2984 pub fn get_operation(&self) -> super::builder::internal_range_service::GetOperation {
2985 super::builder::internal_range_service::GetOperation::new(self.inner.clone())
2986 }
2987
2988 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2989 ///
2990 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2991 ///
2992 /// # Example
2993 /// ```
2994 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
2995 /// use google_cloud_networkconnectivity_v1::Result;
2996 /// async fn sample(
2997 /// client: &InternalRangeService
2998 /// ) -> Result<()> {
2999 /// client.delete_operation()
3000 /// /* set fields */
3001 /// .send().await?;
3002 /// Ok(())
3003 /// }
3004 /// ```
3005 pub fn delete_operation(&self) -> super::builder::internal_range_service::DeleteOperation {
3006 super::builder::internal_range_service::DeleteOperation::new(self.inner.clone())
3007 }
3008
3009 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3010 ///
3011 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3012 ///
3013 /// # Example
3014 /// ```
3015 /// # use google_cloud_networkconnectivity_v1::client::InternalRangeService;
3016 /// use google_cloud_networkconnectivity_v1::Result;
3017 /// async fn sample(
3018 /// client: &InternalRangeService
3019 /// ) -> Result<()> {
3020 /// client.cancel_operation()
3021 /// /* set fields */
3022 /// .send().await?;
3023 /// Ok(())
3024 /// }
3025 /// ```
3026 pub fn cancel_operation(&self) -> super::builder::internal_range_service::CancelOperation {
3027 super::builder::internal_range_service::CancelOperation::new(self.inner.clone())
3028 }
3029}
3030
3031/// Implements a client for the Network Connectivity API.
3032///
3033/// # Example
3034/// ```
3035/// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3036/// use google_cloud_gax::paginator::ItemPaginator as _;
3037/// async fn sample(
3038/// parent: &str,
3039/// ) -> anyhow::Result<()> {
3040/// let client = PolicyBasedRoutingService::builder().build().await?;
3041/// let mut list = client.list_policy_based_routes()
3042/// .set_parent(parent)
3043/// .by_item();
3044/// while let Some(item) = list.next().await.transpose()? {
3045/// println!("{:?}", item);
3046/// }
3047/// Ok(())
3048/// }
3049/// ```
3050///
3051/// # Service Description
3052///
3053/// Policy-Based Routing allows GCP customers to specify flexibile routing
3054/// policies for Layer 4 traffic traversing through the connected service.
3055///
3056/// # Configuration
3057///
3058/// To configure `PolicyBasedRoutingService` use the `with_*` methods in the type returned
3059/// by [builder()][PolicyBasedRoutingService::builder]. The default configuration should
3060/// work for most applications. Common configuration changes include
3061///
3062/// * [with_endpoint()]: by default this client uses the global default endpoint
3063/// (`https://networkconnectivity.googleapis.com`). Applications using regional
3064/// endpoints or running in restricted networks (e.g. a network configured
3065/// with [Private Google Access with VPC Service Controls]) may want to
3066/// override this default.
3067/// * [with_credentials()]: by default this client uses
3068/// [Application Default Credentials]. Applications using custom
3069/// authentication may need to override this default.
3070///
3071/// [with_endpoint()]: super::builder::policy_based_routing_service::ClientBuilder::with_endpoint
3072/// [with_credentials()]: super::builder::policy_based_routing_service::ClientBuilder::with_credentials
3073/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
3074/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
3075///
3076/// # Pooling and Cloning
3077///
3078/// `PolicyBasedRoutingService` holds a connection pool internally, it is advised to
3079/// create one and reuse it. You do not need to wrap `PolicyBasedRoutingService` in
3080/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
3081/// already uses an `Arc` internally.
3082#[derive(Clone, Debug)]
3083pub struct PolicyBasedRoutingService {
3084 inner: std::sync::Arc<dyn super::stub::dynamic::PolicyBasedRoutingService>,
3085}
3086
3087impl PolicyBasedRoutingService {
3088 /// Returns a builder for [PolicyBasedRoutingService].
3089 ///
3090 /// ```
3091 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
3092 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3093 /// let client = PolicyBasedRoutingService::builder().build().await?;
3094 /// # Ok(()) }
3095 /// ```
3096 pub fn builder() -> super::builder::policy_based_routing_service::ClientBuilder {
3097 crate::new_client_builder(super::builder::policy_based_routing_service::client::Factory)
3098 }
3099
3100 /// Creates a new client from the provided stub.
3101 ///
3102 /// The most common case for calling this function is in tests mocking the
3103 /// client's behavior.
3104 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
3105 where
3106 T: super::stub::PolicyBasedRoutingService + 'static,
3107 {
3108 Self { inner: stub.into() }
3109 }
3110
3111 pub(crate) async fn new(
3112 config: gaxi::options::ClientConfig,
3113 ) -> crate::ClientBuilderResult<Self> {
3114 let inner = Self::build_inner(config).await?;
3115 Ok(Self { inner })
3116 }
3117
3118 async fn build_inner(
3119 conf: gaxi::options::ClientConfig,
3120 ) -> crate::ClientBuilderResult<
3121 std::sync::Arc<dyn super::stub::dynamic::PolicyBasedRoutingService>,
3122 > {
3123 if gaxi::options::tracing_enabled(&conf) {
3124 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
3125 }
3126 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
3127 }
3128
3129 async fn build_transport(
3130 conf: gaxi::options::ClientConfig,
3131 ) -> crate::ClientBuilderResult<impl super::stub::PolicyBasedRoutingService> {
3132 super::transport::PolicyBasedRoutingService::new(conf).await
3133 }
3134
3135 async fn build_with_tracing(
3136 conf: gaxi::options::ClientConfig,
3137 ) -> crate::ClientBuilderResult<impl super::stub::PolicyBasedRoutingService> {
3138 Self::build_transport(conf)
3139 .await
3140 .map(super::tracing::PolicyBasedRoutingService::new)
3141 }
3142
3143 /// Lists policy-based routes in a given project and location.
3144 ///
3145 /// # Example
3146 /// ```
3147 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3148 /// use google_cloud_gax::paginator::ItemPaginator as _;
3149 /// use google_cloud_networkconnectivity_v1::Result;
3150 /// async fn sample(
3151 /// client: &PolicyBasedRoutingService, parent: &str
3152 /// ) -> Result<()> {
3153 /// let mut list = client.list_policy_based_routes()
3154 /// .set_parent(parent)
3155 /// .by_item();
3156 /// while let Some(item) = list.next().await.transpose()? {
3157 /// println!("{:?}", item);
3158 /// }
3159 /// Ok(())
3160 /// }
3161 /// ```
3162 pub fn list_policy_based_routes(
3163 &self,
3164 ) -> super::builder::policy_based_routing_service::ListPolicyBasedRoutes {
3165 super::builder::policy_based_routing_service::ListPolicyBasedRoutes::new(self.inner.clone())
3166 }
3167
3168 /// Gets details of a single policy-based route.
3169 ///
3170 /// # Example
3171 /// ```
3172 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3173 /// use google_cloud_networkconnectivity_v1::Result;
3174 /// async fn sample(
3175 /// client: &PolicyBasedRoutingService, project_id: &str, policy_based_route_id: &str
3176 /// ) -> Result<()> {
3177 /// let response = client.get_policy_based_route()
3178 /// .set_name(format!("projects/{project_id}/locations/global/PolicyBasedRoutes/{policy_based_route_id}"))
3179 /// .send().await?;
3180 /// println!("response {:?}", response);
3181 /// Ok(())
3182 /// }
3183 /// ```
3184 pub fn get_policy_based_route(
3185 &self,
3186 ) -> super::builder::policy_based_routing_service::GetPolicyBasedRoute {
3187 super::builder::policy_based_routing_service::GetPolicyBasedRoute::new(self.inner.clone())
3188 }
3189
3190 /// Creates a new policy-based route in a given project and location.
3191 ///
3192 /// # Long running operations
3193 ///
3194 /// This method is used to start, and/or poll a [long-running Operation].
3195 /// The [Working with long-running operations] chapter in the [user guide]
3196 /// covers these operations in detail.
3197 ///
3198 /// [long-running operation]: https://google.aip.dev/151
3199 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3200 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3201 ///
3202 /// # Example
3203 /// ```
3204 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3205 /// use google_cloud_lro::Poller;
3206 /// use google_cloud_networkconnectivity_v1::model::PolicyBasedRoute;
3207 /// use google_cloud_networkconnectivity_v1::Result;
3208 /// async fn sample(
3209 /// client: &PolicyBasedRoutingService, parent: &str
3210 /// ) -> Result<()> {
3211 /// let response = client.create_policy_based_route()
3212 /// .set_parent(parent)
3213 /// .set_policy_based_route(
3214 /// PolicyBasedRoute::new()/* set fields */
3215 /// )
3216 /// .poller().until_done().await?;
3217 /// println!("response {:?}", response);
3218 /// Ok(())
3219 /// }
3220 /// ```
3221 pub fn create_policy_based_route(
3222 &self,
3223 ) -> super::builder::policy_based_routing_service::CreatePolicyBasedRoute {
3224 super::builder::policy_based_routing_service::CreatePolicyBasedRoute::new(
3225 self.inner.clone(),
3226 )
3227 }
3228
3229 /// Deletes a single policy-based route.
3230 ///
3231 /// # Long running operations
3232 ///
3233 /// This method is used to start, and/or poll a [long-running Operation].
3234 /// The [Working with long-running operations] chapter in the [user guide]
3235 /// covers these operations in detail.
3236 ///
3237 /// [long-running operation]: https://google.aip.dev/151
3238 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3239 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3240 ///
3241 /// # Example
3242 /// ```
3243 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3244 /// use google_cloud_lro::Poller;
3245 /// use google_cloud_networkconnectivity_v1::Result;
3246 /// async fn sample(
3247 /// client: &PolicyBasedRoutingService, project_id: &str, policy_based_route_id: &str
3248 /// ) -> Result<()> {
3249 /// client.delete_policy_based_route()
3250 /// .set_name(format!("projects/{project_id}/locations/global/PolicyBasedRoutes/{policy_based_route_id}"))
3251 /// .poller().until_done().await?;
3252 /// Ok(())
3253 /// }
3254 /// ```
3255 pub fn delete_policy_based_route(
3256 &self,
3257 ) -> super::builder::policy_based_routing_service::DeletePolicyBasedRoute {
3258 super::builder::policy_based_routing_service::DeletePolicyBasedRoute::new(
3259 self.inner.clone(),
3260 )
3261 }
3262
3263 /// Lists information about the supported locations for this service.
3264 ///
3265 /// # Example
3266 /// ```
3267 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3268 /// use google_cloud_gax::paginator::ItemPaginator as _;
3269 /// use google_cloud_networkconnectivity_v1::Result;
3270 /// async fn sample(
3271 /// client: &PolicyBasedRoutingService
3272 /// ) -> Result<()> {
3273 /// let mut list = client.list_locations()
3274 /// /* set fields */
3275 /// .by_item();
3276 /// while let Some(item) = list.next().await.transpose()? {
3277 /// println!("{:?}", item);
3278 /// }
3279 /// Ok(())
3280 /// }
3281 /// ```
3282 pub fn list_locations(&self) -> super::builder::policy_based_routing_service::ListLocations {
3283 super::builder::policy_based_routing_service::ListLocations::new(self.inner.clone())
3284 }
3285
3286 /// Gets information about a location.
3287 ///
3288 /// # Example
3289 /// ```
3290 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3291 /// use google_cloud_networkconnectivity_v1::Result;
3292 /// async fn sample(
3293 /// client: &PolicyBasedRoutingService
3294 /// ) -> Result<()> {
3295 /// let response = client.get_location()
3296 /// /* set fields */
3297 /// .send().await?;
3298 /// println!("response {:?}", response);
3299 /// Ok(())
3300 /// }
3301 /// ```
3302 pub fn get_location(&self) -> super::builder::policy_based_routing_service::GetLocation {
3303 super::builder::policy_based_routing_service::GetLocation::new(self.inner.clone())
3304 }
3305
3306 /// Sets the access control policy on the specified resource. Replaces
3307 /// any existing policy.
3308 ///
3309 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
3310 /// errors.
3311 ///
3312 /// # Example
3313 /// ```
3314 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3315 /// use google_cloud_networkconnectivity_v1::Result;
3316 /// async fn sample(
3317 /// client: &PolicyBasedRoutingService
3318 /// ) -> Result<()> {
3319 /// let response = client.set_iam_policy()
3320 /// /* set fields */
3321 /// .send().await?;
3322 /// println!("response {:?}", response);
3323 /// Ok(())
3324 /// }
3325 /// ```
3326 pub fn set_iam_policy(&self) -> super::builder::policy_based_routing_service::SetIamPolicy {
3327 super::builder::policy_based_routing_service::SetIamPolicy::new(self.inner.clone())
3328 }
3329
3330 /// Gets the access control policy for a resource. Returns an empty policy
3331 /// if the resource exists and does not have a policy set.
3332 ///
3333 /// # Example
3334 /// ```
3335 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3336 /// use google_cloud_networkconnectivity_v1::Result;
3337 /// async fn sample(
3338 /// client: &PolicyBasedRoutingService
3339 /// ) -> Result<()> {
3340 /// let response = client.get_iam_policy()
3341 /// /* set fields */
3342 /// .send().await?;
3343 /// println!("response {:?}", response);
3344 /// Ok(())
3345 /// }
3346 /// ```
3347 pub fn get_iam_policy(&self) -> super::builder::policy_based_routing_service::GetIamPolicy {
3348 super::builder::policy_based_routing_service::GetIamPolicy::new(self.inner.clone())
3349 }
3350
3351 /// Returns permissions that a caller has on the specified resource. If the
3352 /// resource does not exist, this will return an empty set of
3353 /// permissions, not a `NOT_FOUND` error.
3354 ///
3355 /// Note: This operation is designed to be used for building
3356 /// permission-aware UIs and command-line tools, not for authorization
3357 /// checking. This operation may "fail open" without warning.
3358 ///
3359 /// # Example
3360 /// ```
3361 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3362 /// use google_cloud_networkconnectivity_v1::Result;
3363 /// async fn sample(
3364 /// client: &PolicyBasedRoutingService
3365 /// ) -> Result<()> {
3366 /// let response = client.test_iam_permissions()
3367 /// /* set fields */
3368 /// .send().await?;
3369 /// println!("response {:?}", response);
3370 /// Ok(())
3371 /// }
3372 /// ```
3373 pub fn test_iam_permissions(
3374 &self,
3375 ) -> super::builder::policy_based_routing_service::TestIamPermissions {
3376 super::builder::policy_based_routing_service::TestIamPermissions::new(self.inner.clone())
3377 }
3378
3379 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3380 ///
3381 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3382 ///
3383 /// # Example
3384 /// ```
3385 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3386 /// use google_cloud_gax::paginator::ItemPaginator as _;
3387 /// use google_cloud_networkconnectivity_v1::Result;
3388 /// async fn sample(
3389 /// client: &PolicyBasedRoutingService
3390 /// ) -> Result<()> {
3391 /// let mut list = client.list_operations()
3392 /// /* set fields */
3393 /// .by_item();
3394 /// while let Some(item) = list.next().await.transpose()? {
3395 /// println!("{:?}", item);
3396 /// }
3397 /// Ok(())
3398 /// }
3399 /// ```
3400 pub fn list_operations(&self) -> super::builder::policy_based_routing_service::ListOperations {
3401 super::builder::policy_based_routing_service::ListOperations::new(self.inner.clone())
3402 }
3403
3404 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3405 ///
3406 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3407 ///
3408 /// # Example
3409 /// ```
3410 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3411 /// use google_cloud_networkconnectivity_v1::Result;
3412 /// async fn sample(
3413 /// client: &PolicyBasedRoutingService
3414 /// ) -> Result<()> {
3415 /// let response = client.get_operation()
3416 /// /* set fields */
3417 /// .send().await?;
3418 /// println!("response {:?}", response);
3419 /// Ok(())
3420 /// }
3421 /// ```
3422 pub fn get_operation(&self) -> super::builder::policy_based_routing_service::GetOperation {
3423 super::builder::policy_based_routing_service::GetOperation::new(self.inner.clone())
3424 }
3425
3426 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3427 ///
3428 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3429 ///
3430 /// # Example
3431 /// ```
3432 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3433 /// use google_cloud_networkconnectivity_v1::Result;
3434 /// async fn sample(
3435 /// client: &PolicyBasedRoutingService
3436 /// ) -> Result<()> {
3437 /// client.delete_operation()
3438 /// /* set fields */
3439 /// .send().await?;
3440 /// Ok(())
3441 /// }
3442 /// ```
3443 pub fn delete_operation(
3444 &self,
3445 ) -> super::builder::policy_based_routing_service::DeleteOperation {
3446 super::builder::policy_based_routing_service::DeleteOperation::new(self.inner.clone())
3447 }
3448
3449 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3450 ///
3451 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3452 ///
3453 /// # Example
3454 /// ```
3455 /// # use google_cloud_networkconnectivity_v1::client::PolicyBasedRoutingService;
3456 /// use google_cloud_networkconnectivity_v1::Result;
3457 /// async fn sample(
3458 /// client: &PolicyBasedRoutingService
3459 /// ) -> Result<()> {
3460 /// client.cancel_operation()
3461 /// /* set fields */
3462 /// .send().await?;
3463 /// Ok(())
3464 /// }
3465 /// ```
3466 pub fn cancel_operation(
3467 &self,
3468 ) -> super::builder::policy_based_routing_service::CancelOperation {
3469 super::builder::policy_based_routing_service::CancelOperation::new(self.inner.clone())
3470 }
3471}