google_cloud_networkmanagement_v1/client.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Network Management API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// async fn sample(
26/// parent: &str,
27/// ) -> anyhow::Result<()> {
28/// let client = ReachabilityService::builder().build().await?;
29/// let mut list = client.list_connectivity_tests()
30/// .set_parent(parent)
31/// .by_item();
32/// while let Some(item) = list.next().await.transpose()? {
33/// println!("{:?}", item);
34/// }
35/// Ok(())
36/// }
37/// ```
38///
39/// # Service Description
40///
41/// The Reachability service in the Google Cloud Network Management API provides
42/// services that analyze the reachability within a single Google Virtual Private
43/// Cloud (VPC) network, between peered VPC networks, between VPC and on-premises
44/// networks, or between VPC networks and internet hosts. A reachability analysis
45/// is based on Google Cloud network configurations.
46///
47/// You can use the analysis results to verify these configurations and
48/// to troubleshoot connectivity issues.
49///
50/// # Configuration
51///
52/// To configure `ReachabilityService` use the `with_*` methods in the type returned
53/// by [builder()][ReachabilityService::builder]. The default configuration should
54/// work for most applications. Common configuration changes include
55///
56/// * [with_endpoint()]: by default this client uses the global default endpoint
57/// (`https://networkmanagement.googleapis.com`). Applications using regional
58/// endpoints or running in restricted networks (e.g. a network configured
59// with [Private Google Access with VPC Service Controls]) may want to
60/// override this default.
61/// * [with_credentials()]: by default this client uses
62/// [Application Default Credentials]. Applications using custom
63/// authentication may need to override this default.
64///
65/// [with_endpoint()]: super::builder::reachability_service::ClientBuilder::with_endpoint
66/// [with_credentials()]: super::builder::reachability_service::ClientBuilder::with_credentials
67/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
68/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
69///
70/// # Pooling and Cloning
71///
72/// `ReachabilityService` holds a connection pool internally, it is advised to
73/// create one and reuse it. You do not need to wrap `ReachabilityService` in
74/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
75/// already uses an `Arc` internally.
76#[derive(Clone, Debug)]
77pub struct ReachabilityService {
78 inner: std::sync::Arc<dyn super::stub::dynamic::ReachabilityService>,
79}
80
81impl ReachabilityService {
82 /// Returns a builder for [ReachabilityService].
83 ///
84 /// ```
85 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
86 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
87 /// let client = ReachabilityService::builder().build().await?;
88 /// # Ok(()) }
89 /// ```
90 pub fn builder() -> super::builder::reachability_service::ClientBuilder {
91 crate::new_client_builder(super::builder::reachability_service::client::Factory)
92 }
93
94 /// Creates a new client from the provided stub.
95 ///
96 /// The most common case for calling this function is in tests mocking the
97 /// client's behavior.
98 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
99 where
100 T: super::stub::ReachabilityService + 'static,
101 {
102 Self { inner: stub.into() }
103 }
104
105 pub(crate) async fn new(
106 config: gaxi::options::ClientConfig,
107 ) -> crate::ClientBuilderResult<Self> {
108 let inner = Self::build_inner(config).await?;
109 Ok(Self { inner })
110 }
111
112 async fn build_inner(
113 conf: gaxi::options::ClientConfig,
114 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ReachabilityService>>
115 {
116 if gaxi::options::tracing_enabled(&conf) {
117 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
118 }
119 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
120 }
121
122 async fn build_transport(
123 conf: gaxi::options::ClientConfig,
124 ) -> crate::ClientBuilderResult<impl super::stub::ReachabilityService> {
125 super::transport::ReachabilityService::new(conf).await
126 }
127
128 async fn build_with_tracing(
129 conf: gaxi::options::ClientConfig,
130 ) -> crate::ClientBuilderResult<impl super::stub::ReachabilityService> {
131 Self::build_transport(conf)
132 .await
133 .map(super::tracing::ReachabilityService::new)
134 }
135
136 /// Lists all Connectivity Tests owned by a project.
137 ///
138 /// # Example
139 /// ```
140 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
141 /// use google_cloud_gax::paginator::ItemPaginator as _;
142 /// use google_cloud_networkmanagement_v1::Result;
143 /// async fn sample(
144 /// client: &ReachabilityService, parent: &str
145 /// ) -> Result<()> {
146 /// let mut list = client.list_connectivity_tests()
147 /// .set_parent(parent)
148 /// .by_item();
149 /// while let Some(item) = list.next().await.transpose()? {
150 /// println!("{:?}", item);
151 /// }
152 /// Ok(())
153 /// }
154 /// ```
155 pub fn list_connectivity_tests(
156 &self,
157 ) -> super::builder::reachability_service::ListConnectivityTests {
158 super::builder::reachability_service::ListConnectivityTests::new(self.inner.clone())
159 }
160
161 /// Gets the details of a specific Connectivity Test.
162 ///
163 /// # Example
164 /// ```
165 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
166 /// use google_cloud_networkmanagement_v1::Result;
167 /// async fn sample(
168 /// client: &ReachabilityService, project_id: &str, test_id: &str
169 /// ) -> Result<()> {
170 /// let response = client.get_connectivity_test()
171 /// .set_name(format!("projects/{project_id}/locations/global/connectivityTests/{test_id}"))
172 /// .send().await?;
173 /// println!("response {:?}", response);
174 /// Ok(())
175 /// }
176 /// ```
177 pub fn get_connectivity_test(
178 &self,
179 ) -> super::builder::reachability_service::GetConnectivityTest {
180 super::builder::reachability_service::GetConnectivityTest::new(self.inner.clone())
181 }
182
183 /// Creates a new Connectivity Test.
184 /// After you create a test, the reachability analysis is performed as part
185 /// of the long running operation, which completes when the analysis completes.
186 ///
187 /// If the endpoint specifications in `ConnectivityTest` are invalid
188 /// (for example, containing non-existent resources in the network, or you
189 /// don't have read permissions to the network configurations of listed
190 /// projects), then the reachability result returns a value of `UNKNOWN`.
191 ///
192 /// If the endpoint specifications in `ConnectivityTest` are
193 /// incomplete, the reachability result returns a value of
194 /// \<code\>AMBIGUOUS\</code\>. For more information,
195 /// see the Connectivity Test documentation.
196 ///
197 /// # Long running operations
198 ///
199 /// This method is used to start, and/or poll a [long-running Operation].
200 /// The [Working with long-running operations] chapter in the [user guide]
201 /// covers these operations in detail.
202 ///
203 /// [long-running operation]: https://google.aip.dev/151
204 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
205 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
206 ///
207 /// # Example
208 /// ```
209 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
210 /// use google_cloud_lro::Poller;
211 /// use google_cloud_networkmanagement_v1::model::ConnectivityTest;
212 /// use google_cloud_networkmanagement_v1::Result;
213 /// async fn sample(
214 /// client: &ReachabilityService, parent: &str
215 /// ) -> Result<()> {
216 /// let response = client.create_connectivity_test()
217 /// .set_parent(parent)
218 /// .set_resource(
219 /// ConnectivityTest::new()/* set fields */
220 /// )
221 /// .poller().until_done().await?;
222 /// println!("response {:?}", response);
223 /// Ok(())
224 /// }
225 /// ```
226 pub fn create_connectivity_test(
227 &self,
228 ) -> super::builder::reachability_service::CreateConnectivityTest {
229 super::builder::reachability_service::CreateConnectivityTest::new(self.inner.clone())
230 }
231
232 /// Updates the configuration of an existing `ConnectivityTest`.
233 /// After you update a test, the reachability analysis is performed as part
234 /// of the long running operation, which completes when the analysis completes.
235 /// The Reachability state in the test resource is updated with the new result.
236 ///
237 /// If the endpoint specifications in `ConnectivityTest` are invalid
238 /// (for example, they contain non-existent resources in the network, or the
239 /// user does not have read permissions to the network configurations of
240 /// listed projects), then the reachability result returns a value of
241 /// \<code\>UNKNOWN\</code\>.
242 ///
243 /// If the endpoint specifications in `ConnectivityTest` are incomplete, the
244 /// reachability result returns a value of `AMBIGUOUS`. See the documentation
245 /// in `ConnectivityTest` for more details.
246 ///
247 /// # Long running operations
248 ///
249 /// This method is used to start, and/or poll a [long-running Operation].
250 /// The [Working with long-running operations] chapter in the [user guide]
251 /// covers these operations in detail.
252 ///
253 /// [long-running operation]: https://google.aip.dev/151
254 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
255 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
256 ///
257 /// # Example
258 /// ```
259 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
260 /// use google_cloud_lro::Poller;
261 /// # extern crate wkt as google_cloud_wkt;
262 /// use google_cloud_wkt::FieldMask;
263 /// use google_cloud_networkmanagement_v1::model::ConnectivityTest;
264 /// use google_cloud_networkmanagement_v1::Result;
265 /// async fn sample(
266 /// client: &ReachabilityService, project_id: &str, test_id: &str
267 /// ) -> Result<()> {
268 /// let response = client.update_connectivity_test()
269 /// .set_resource(
270 /// ConnectivityTest::new().set_name(format!("projects/{project_id}/locations/global/connectivityTests/{test_id}"))/* set fields */
271 /// )
272 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
273 /// .poller().until_done().await?;
274 /// println!("response {:?}", response);
275 /// Ok(())
276 /// }
277 /// ```
278 pub fn update_connectivity_test(
279 &self,
280 ) -> super::builder::reachability_service::UpdateConnectivityTest {
281 super::builder::reachability_service::UpdateConnectivityTest::new(self.inner.clone())
282 }
283
284 /// Rerun an existing `ConnectivityTest`.
285 /// After the user triggers the rerun, the reachability analysis is performed
286 /// as part of the long running operation, which completes when the analysis
287 /// completes.
288 ///
289 /// Even though the test configuration remains the same, the reachability
290 /// result may change due to underlying network configuration changes.
291 ///
292 /// If the endpoint specifications in `ConnectivityTest` become invalid (for
293 /// example, specified resources are deleted in the network, or you lost
294 /// read permissions to the network configurations of listed projects), then
295 /// the reachability result returns a value of `UNKNOWN`.
296 ///
297 /// # Long running operations
298 ///
299 /// This method is used to start, and/or poll a [long-running Operation].
300 /// The [Working with long-running operations] chapter in the [user guide]
301 /// covers these operations in detail.
302 ///
303 /// [long-running operation]: https://google.aip.dev/151
304 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
305 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
306 ///
307 /// # Example
308 /// ```
309 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
310 /// use google_cloud_lro::Poller;
311 /// use google_cloud_networkmanagement_v1::Result;
312 /// async fn sample(
313 /// client: &ReachabilityService
314 /// ) -> Result<()> {
315 /// let response = client.rerun_connectivity_test()
316 /// /* set fields */
317 /// .poller().until_done().await?;
318 /// println!("response {:?}", response);
319 /// Ok(())
320 /// }
321 /// ```
322 pub fn rerun_connectivity_test(
323 &self,
324 ) -> super::builder::reachability_service::RerunConnectivityTest {
325 super::builder::reachability_service::RerunConnectivityTest::new(self.inner.clone())
326 }
327
328 /// Deletes a specific `ConnectivityTest`.
329 ///
330 /// # Long running operations
331 ///
332 /// This method is used to start, and/or poll a [long-running Operation].
333 /// The [Working with long-running operations] chapter in the [user guide]
334 /// covers these operations in detail.
335 ///
336 /// [long-running operation]: https://google.aip.dev/151
337 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
338 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
339 ///
340 /// # Example
341 /// ```
342 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
343 /// use google_cloud_lro::Poller;
344 /// use google_cloud_networkmanagement_v1::Result;
345 /// async fn sample(
346 /// client: &ReachabilityService, project_id: &str, test_id: &str
347 /// ) -> Result<()> {
348 /// client.delete_connectivity_test()
349 /// .set_name(format!("projects/{project_id}/locations/global/connectivityTests/{test_id}"))
350 /// .poller().until_done().await?;
351 /// Ok(())
352 /// }
353 /// ```
354 pub fn delete_connectivity_test(
355 &self,
356 ) -> super::builder::reachability_service::DeleteConnectivityTest {
357 super::builder::reachability_service::DeleteConnectivityTest::new(self.inner.clone())
358 }
359
360 /// Lists information about the supported locations for this service.
361 /// This method can be called in two ways:
362 ///
363 /// * **List all public locations:** Use the path `GET /v1/locations`.
364 /// * **List project-visible locations:** Use the path
365 /// `GET /v1/projects/{project_id}/locations`. This may include public
366 /// locations as well as private or other locations specifically visible
367 /// to the project.
368 ///
369 /// # Example
370 /// ```
371 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
372 /// use google_cloud_gax::paginator::ItemPaginator as _;
373 /// use google_cloud_networkmanagement_v1::Result;
374 /// async fn sample(
375 /// client: &ReachabilityService
376 /// ) -> Result<()> {
377 /// let mut list = client.list_locations()
378 /// /* set fields */
379 /// .by_item();
380 /// while let Some(item) = list.next().await.transpose()? {
381 /// println!("{:?}", item);
382 /// }
383 /// Ok(())
384 /// }
385 /// ```
386 pub fn list_locations(&self) -> super::builder::reachability_service::ListLocations {
387 super::builder::reachability_service::ListLocations::new(self.inner.clone())
388 }
389
390 /// Gets information about a location.
391 ///
392 /// # Example
393 /// ```
394 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
395 /// use google_cloud_networkmanagement_v1::Result;
396 /// async fn sample(
397 /// client: &ReachabilityService
398 /// ) -> Result<()> {
399 /// let response = client.get_location()
400 /// /* set fields */
401 /// .send().await?;
402 /// println!("response {:?}", response);
403 /// Ok(())
404 /// }
405 /// ```
406 pub fn get_location(&self) -> super::builder::reachability_service::GetLocation {
407 super::builder::reachability_service::GetLocation::new(self.inner.clone())
408 }
409
410 /// Sets the access control policy on the specified resource. Replaces
411 /// any existing policy.
412 ///
413 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
414 /// errors.
415 ///
416 /// # Example
417 /// ```
418 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
419 /// use google_cloud_networkmanagement_v1::Result;
420 /// async fn sample(
421 /// client: &ReachabilityService
422 /// ) -> Result<()> {
423 /// let response = client.set_iam_policy()
424 /// /* set fields */
425 /// .send().await?;
426 /// println!("response {:?}", response);
427 /// Ok(())
428 /// }
429 /// ```
430 pub fn set_iam_policy(&self) -> super::builder::reachability_service::SetIamPolicy {
431 super::builder::reachability_service::SetIamPolicy::new(self.inner.clone())
432 }
433
434 /// Gets the access control policy for a resource. Returns an empty policy
435 /// if the resource exists and does not have a policy set.
436 ///
437 /// # Example
438 /// ```
439 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
440 /// use google_cloud_networkmanagement_v1::Result;
441 /// async fn sample(
442 /// client: &ReachabilityService
443 /// ) -> Result<()> {
444 /// let response = client.get_iam_policy()
445 /// /* set fields */
446 /// .send().await?;
447 /// println!("response {:?}", response);
448 /// Ok(())
449 /// }
450 /// ```
451 pub fn get_iam_policy(&self) -> super::builder::reachability_service::GetIamPolicy {
452 super::builder::reachability_service::GetIamPolicy::new(self.inner.clone())
453 }
454
455 /// Returns permissions that a caller has on the specified resource. If the
456 /// resource does not exist, this will return an empty set of
457 /// permissions, not a `NOT_FOUND` error.
458 ///
459 /// Note: This operation is designed to be used for building
460 /// permission-aware UIs and command-line tools, not for authorization
461 /// checking. This operation may "fail open" without warning.
462 ///
463 /// # Example
464 /// ```
465 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
466 /// use google_cloud_networkmanagement_v1::Result;
467 /// async fn sample(
468 /// client: &ReachabilityService
469 /// ) -> Result<()> {
470 /// let response = client.test_iam_permissions()
471 /// /* set fields */
472 /// .send().await?;
473 /// println!("response {:?}", response);
474 /// Ok(())
475 /// }
476 /// ```
477 pub fn test_iam_permissions(&self) -> super::builder::reachability_service::TestIamPermissions {
478 super::builder::reachability_service::TestIamPermissions::new(self.inner.clone())
479 }
480
481 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
482 ///
483 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
484 ///
485 /// # Example
486 /// ```
487 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
488 /// use google_cloud_gax::paginator::ItemPaginator as _;
489 /// use google_cloud_networkmanagement_v1::Result;
490 /// async fn sample(
491 /// client: &ReachabilityService
492 /// ) -> Result<()> {
493 /// let mut list = client.list_operations()
494 /// /* set fields */
495 /// .by_item();
496 /// while let Some(item) = list.next().await.transpose()? {
497 /// println!("{:?}", item);
498 /// }
499 /// Ok(())
500 /// }
501 /// ```
502 pub fn list_operations(&self) -> super::builder::reachability_service::ListOperations {
503 super::builder::reachability_service::ListOperations::new(self.inner.clone())
504 }
505
506 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
507 ///
508 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
509 ///
510 /// # Example
511 /// ```
512 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
513 /// use google_cloud_networkmanagement_v1::Result;
514 /// async fn sample(
515 /// client: &ReachabilityService
516 /// ) -> Result<()> {
517 /// let response = client.get_operation()
518 /// /* set fields */
519 /// .send().await?;
520 /// println!("response {:?}", response);
521 /// Ok(())
522 /// }
523 /// ```
524 pub fn get_operation(&self) -> super::builder::reachability_service::GetOperation {
525 super::builder::reachability_service::GetOperation::new(self.inner.clone())
526 }
527
528 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
529 ///
530 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
531 ///
532 /// # Example
533 /// ```
534 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
535 /// use google_cloud_networkmanagement_v1::Result;
536 /// async fn sample(
537 /// client: &ReachabilityService
538 /// ) -> Result<()> {
539 /// client.delete_operation()
540 /// /* set fields */
541 /// .send().await?;
542 /// Ok(())
543 /// }
544 /// ```
545 pub fn delete_operation(&self) -> super::builder::reachability_service::DeleteOperation {
546 super::builder::reachability_service::DeleteOperation::new(self.inner.clone())
547 }
548
549 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
550 ///
551 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
552 ///
553 /// # Example
554 /// ```
555 /// # use google_cloud_networkmanagement_v1::client::ReachabilityService;
556 /// use google_cloud_networkmanagement_v1::Result;
557 /// async fn sample(
558 /// client: &ReachabilityService
559 /// ) -> Result<()> {
560 /// client.cancel_operation()
561 /// /* set fields */
562 /// .send().await?;
563 /// Ok(())
564 /// }
565 /// ```
566 pub fn cancel_operation(&self) -> super::builder::reachability_service::CancelOperation {
567 super::builder::reachability_service::CancelOperation::new(self.inner.clone())
568 }
569}
570
571/// Implements a client for the Network Management API.
572///
573/// # Example
574/// ```
575/// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
576/// use google_cloud_gax::paginator::ItemPaginator as _;
577/// async fn sample(
578/// project_id: &str,
579/// location_id: &str,
580/// ) -> anyhow::Result<()> {
581/// let client = VpcFlowLogsService::builder().build().await?;
582/// let mut list = client.list_vpc_flow_logs_configs()
583/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
584/// .by_item();
585/// while let Some(item) = list.next().await.transpose()? {
586/// println!("{:?}", item);
587/// }
588/// Ok(())
589/// }
590/// ```
591///
592/// # Service Description
593///
594/// The VPC Flow Logs service in the Google Cloud Network Management API provides
595/// configurations that generate Flow Logs. The service and the configuration
596/// resources created using this service are global.
597///
598/// # Configuration
599///
600/// To configure `VpcFlowLogsService` use the `with_*` methods in the type returned
601/// by [builder()][VpcFlowLogsService::builder]. The default configuration should
602/// work for most applications. Common configuration changes include
603///
604/// * [with_endpoint()]: by default this client uses the global default endpoint
605/// (`https://networkmanagement.googleapis.com`). Applications using regional
606/// endpoints or running in restricted networks (e.g. a network configured
607// with [Private Google Access with VPC Service Controls]) may want to
608/// override this default.
609/// * [with_credentials()]: by default this client uses
610/// [Application Default Credentials]. Applications using custom
611/// authentication may need to override this default.
612///
613/// [with_endpoint()]: super::builder::vpc_flow_logs_service::ClientBuilder::with_endpoint
614/// [with_credentials()]: super::builder::vpc_flow_logs_service::ClientBuilder::with_credentials
615/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
616/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
617///
618/// # Pooling and Cloning
619///
620/// `VpcFlowLogsService` holds a connection pool internally, it is advised to
621/// create one and reuse it. You do not need to wrap `VpcFlowLogsService` in
622/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
623/// already uses an `Arc` internally.
624#[derive(Clone, Debug)]
625pub struct VpcFlowLogsService {
626 inner: std::sync::Arc<dyn super::stub::dynamic::VpcFlowLogsService>,
627}
628
629impl VpcFlowLogsService {
630 /// Returns a builder for [VpcFlowLogsService].
631 ///
632 /// ```
633 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
634 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
635 /// let client = VpcFlowLogsService::builder().build().await?;
636 /// # Ok(()) }
637 /// ```
638 pub fn builder() -> super::builder::vpc_flow_logs_service::ClientBuilder {
639 crate::new_client_builder(super::builder::vpc_flow_logs_service::client::Factory)
640 }
641
642 /// Creates a new client from the provided stub.
643 ///
644 /// The most common case for calling this function is in tests mocking the
645 /// client's behavior.
646 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
647 where
648 T: super::stub::VpcFlowLogsService + 'static,
649 {
650 Self { inner: stub.into() }
651 }
652
653 pub(crate) async fn new(
654 config: gaxi::options::ClientConfig,
655 ) -> crate::ClientBuilderResult<Self> {
656 let inner = Self::build_inner(config).await?;
657 Ok(Self { inner })
658 }
659
660 async fn build_inner(
661 conf: gaxi::options::ClientConfig,
662 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::VpcFlowLogsService>>
663 {
664 if gaxi::options::tracing_enabled(&conf) {
665 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
666 }
667 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
668 }
669
670 async fn build_transport(
671 conf: gaxi::options::ClientConfig,
672 ) -> crate::ClientBuilderResult<impl super::stub::VpcFlowLogsService> {
673 super::transport::VpcFlowLogsService::new(conf).await
674 }
675
676 async fn build_with_tracing(
677 conf: gaxi::options::ClientConfig,
678 ) -> crate::ClientBuilderResult<impl super::stub::VpcFlowLogsService> {
679 Self::build_transport(conf)
680 .await
681 .map(super::tracing::VpcFlowLogsService::new)
682 }
683
684 /// Lists all `VpcFlowLogsConfigs` in a given project.
685 ///
686 /// # Example
687 /// ```
688 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
689 /// use google_cloud_gax::paginator::ItemPaginator as _;
690 /// use google_cloud_networkmanagement_v1::Result;
691 /// async fn sample(
692 /// client: &VpcFlowLogsService, project_id: &str, location_id: &str
693 /// ) -> Result<()> {
694 /// let mut list = client.list_vpc_flow_logs_configs()
695 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
696 /// .by_item();
697 /// while let Some(item) = list.next().await.transpose()? {
698 /// println!("{:?}", item);
699 /// }
700 /// Ok(())
701 /// }
702 /// ```
703 pub fn list_vpc_flow_logs_configs(
704 &self,
705 ) -> super::builder::vpc_flow_logs_service::ListVpcFlowLogsConfigs {
706 super::builder::vpc_flow_logs_service::ListVpcFlowLogsConfigs::new(self.inner.clone())
707 }
708
709 /// Gets the details of a specific `VpcFlowLogsConfig`.
710 ///
711 /// # Example
712 /// ```
713 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
714 /// use google_cloud_networkmanagement_v1::Result;
715 /// async fn sample(
716 /// client: &VpcFlowLogsService, project_id: &str, location_id: &str, vpc_flow_logs_config_id: &str
717 /// ) -> Result<()> {
718 /// let response = client.get_vpc_flow_logs_config()
719 /// .set_name(format!("projects/{project_id}/locations/{location_id}/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}"))
720 /// .send().await?;
721 /// println!("response {:?}", response);
722 /// Ok(())
723 /// }
724 /// ```
725 pub fn get_vpc_flow_logs_config(
726 &self,
727 ) -> super::builder::vpc_flow_logs_service::GetVpcFlowLogsConfig {
728 super::builder::vpc_flow_logs_service::GetVpcFlowLogsConfig::new(self.inner.clone())
729 }
730
731 /// Creates a new `VpcFlowLogsConfig`.
732 /// If a configuration with the exact same settings already exists (even if the
733 /// ID is different), the creation fails.
734 /// Notes:
735 ///
736 /// 1. Creating a configuration with `state=DISABLED` will fail
737 /// 1. The following fields are not considered as settings for the purpose
738 /// of the check mentioned above, therefore - creating another configuration
739 /// with the same fields but different values for the following fields will
740 /// fail as well:
741 /// * name
742 /// * create_time
743 /// * update_time
744 /// * labels
745 /// * description
746 ///
747 /// # Long running operations
748 ///
749 /// This method is used to start, and/or poll a [long-running Operation].
750 /// The [Working with long-running operations] chapter in the [user guide]
751 /// covers these operations in detail.
752 ///
753 /// [long-running operation]: https://google.aip.dev/151
754 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
755 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
756 ///
757 /// # Example
758 /// ```
759 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
760 /// use google_cloud_lro::Poller;
761 /// use google_cloud_networkmanagement_v1::model::VpcFlowLogsConfig;
762 /// use google_cloud_networkmanagement_v1::Result;
763 /// async fn sample(
764 /// client: &VpcFlowLogsService, project_id: &str, location_id: &str
765 /// ) -> Result<()> {
766 /// let response = client.create_vpc_flow_logs_config()
767 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
768 /// .set_vpc_flow_logs_config(
769 /// VpcFlowLogsConfig::new()/* set fields */
770 /// )
771 /// .poller().until_done().await?;
772 /// println!("response {:?}", response);
773 /// Ok(())
774 /// }
775 /// ```
776 pub fn create_vpc_flow_logs_config(
777 &self,
778 ) -> super::builder::vpc_flow_logs_service::CreateVpcFlowLogsConfig {
779 super::builder::vpc_flow_logs_service::CreateVpcFlowLogsConfig::new(self.inner.clone())
780 }
781
782 /// Updates an existing `VpcFlowLogsConfig`.
783 /// If a configuration with the exact same settings already exists (even if the
784 /// ID is different), the creation fails.
785 /// Notes:
786 ///
787 /// 1. Updating a configuration with `state=DISABLED` will fail.
788 /// 1. The following fields are not considered as settings for the purpose
789 /// of the check mentioned above, therefore - updating another configuration
790 /// with the same fields but different values for the following fields will
791 /// fail as well:
792 /// * name
793 /// * create_time
794 /// * update_time
795 /// * labels
796 /// * description
797 ///
798 /// # Long running operations
799 ///
800 /// This method is used to start, and/or poll a [long-running Operation].
801 /// The [Working with long-running operations] chapter in the [user guide]
802 /// covers these operations in detail.
803 ///
804 /// [long-running operation]: https://google.aip.dev/151
805 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
806 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
807 ///
808 /// # Example
809 /// ```
810 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
811 /// use google_cloud_lro::Poller;
812 /// # extern crate wkt as google_cloud_wkt;
813 /// use google_cloud_wkt::FieldMask;
814 /// use google_cloud_networkmanagement_v1::model::VpcFlowLogsConfig;
815 /// use google_cloud_networkmanagement_v1::Result;
816 /// async fn sample(
817 /// client: &VpcFlowLogsService, project_id: &str, location_id: &str, vpc_flow_logs_config_id: &str
818 /// ) -> Result<()> {
819 /// let response = client.update_vpc_flow_logs_config()
820 /// .set_vpc_flow_logs_config(
821 /// VpcFlowLogsConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}"))/* set fields */
822 /// )
823 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
824 /// .poller().until_done().await?;
825 /// println!("response {:?}", response);
826 /// Ok(())
827 /// }
828 /// ```
829 pub fn update_vpc_flow_logs_config(
830 &self,
831 ) -> super::builder::vpc_flow_logs_service::UpdateVpcFlowLogsConfig {
832 super::builder::vpc_flow_logs_service::UpdateVpcFlowLogsConfig::new(self.inner.clone())
833 }
834
835 /// Deletes a specific `VpcFlowLogsConfig`.
836 ///
837 /// # Long running operations
838 ///
839 /// This method is used to start, and/or poll a [long-running Operation].
840 /// The [Working with long-running operations] chapter in the [user guide]
841 /// covers these operations in detail.
842 ///
843 /// [long-running operation]: https://google.aip.dev/151
844 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
845 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
846 ///
847 /// # Example
848 /// ```
849 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
850 /// use google_cloud_lro::Poller;
851 /// use google_cloud_networkmanagement_v1::Result;
852 /// async fn sample(
853 /// client: &VpcFlowLogsService, project_id: &str, location_id: &str, vpc_flow_logs_config_id: &str
854 /// ) -> Result<()> {
855 /// client.delete_vpc_flow_logs_config()
856 /// .set_name(format!("projects/{project_id}/locations/{location_id}/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}"))
857 /// .poller().until_done().await?;
858 /// Ok(())
859 /// }
860 /// ```
861 pub fn delete_vpc_flow_logs_config(
862 &self,
863 ) -> super::builder::vpc_flow_logs_service::DeleteVpcFlowLogsConfig {
864 super::builder::vpc_flow_logs_service::DeleteVpcFlowLogsConfig::new(self.inner.clone())
865 }
866
867 /// QueryOrgVpcFlowLogsConfigs returns a list of all organization-level VPC
868 /// Flow Logs configurations applicable to the specified project.
869 ///
870 /// # Example
871 /// ```
872 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
873 /// use google_cloud_gax::paginator::ItemPaginator as _;
874 /// use google_cloud_networkmanagement_v1::Result;
875 /// async fn sample(
876 /// client: &VpcFlowLogsService
877 /// ) -> Result<()> {
878 /// let mut list = client.query_org_vpc_flow_logs_configs()
879 /// /* set fields */
880 /// .by_item();
881 /// while let Some(item) = list.next().await.transpose()? {
882 /// println!("{:?}", item);
883 /// }
884 /// Ok(())
885 /// }
886 /// ```
887 pub fn query_org_vpc_flow_logs_configs(
888 &self,
889 ) -> super::builder::vpc_flow_logs_service::QueryOrgVpcFlowLogsConfigs {
890 super::builder::vpc_flow_logs_service::QueryOrgVpcFlowLogsConfigs::new(self.inner.clone())
891 }
892
893 /// ShowEffectiveFlowLogsConfigs returns a list of all VPC Flow Logs
894 /// configurations applicable to a specified resource.
895 ///
896 /// # Example
897 /// ```
898 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
899 /// use google_cloud_gax::paginator::ItemPaginator as _;
900 /// use google_cloud_networkmanagement_v1::Result;
901 /// async fn sample(
902 /// client: &VpcFlowLogsService
903 /// ) -> Result<()> {
904 /// let mut list = client.show_effective_flow_logs_configs()
905 /// /* set fields */
906 /// .by_item();
907 /// while let Some(item) = list.next().await.transpose()? {
908 /// println!("{:?}", item);
909 /// }
910 /// Ok(())
911 /// }
912 /// ```
913 pub fn show_effective_flow_logs_configs(
914 &self,
915 ) -> super::builder::vpc_flow_logs_service::ShowEffectiveFlowLogsConfigs {
916 super::builder::vpc_flow_logs_service::ShowEffectiveFlowLogsConfigs::new(self.inner.clone())
917 }
918
919 /// Lists information about the supported locations for this service.
920 /// This method can be called in two ways:
921 ///
922 /// * **List all public locations:** Use the path `GET /v1/locations`.
923 /// * **List project-visible locations:** Use the path
924 /// `GET /v1/projects/{project_id}/locations`. This may include public
925 /// locations as well as private or other locations specifically visible
926 /// to the project.
927 ///
928 /// # Example
929 /// ```
930 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
931 /// use google_cloud_gax::paginator::ItemPaginator as _;
932 /// use google_cloud_networkmanagement_v1::Result;
933 /// async fn sample(
934 /// client: &VpcFlowLogsService
935 /// ) -> Result<()> {
936 /// let mut list = client.list_locations()
937 /// /* set fields */
938 /// .by_item();
939 /// while let Some(item) = list.next().await.transpose()? {
940 /// println!("{:?}", item);
941 /// }
942 /// Ok(())
943 /// }
944 /// ```
945 pub fn list_locations(&self) -> super::builder::vpc_flow_logs_service::ListLocations {
946 super::builder::vpc_flow_logs_service::ListLocations::new(self.inner.clone())
947 }
948
949 /// Gets information about a location.
950 ///
951 /// # Example
952 /// ```
953 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
954 /// use google_cloud_networkmanagement_v1::Result;
955 /// async fn sample(
956 /// client: &VpcFlowLogsService
957 /// ) -> Result<()> {
958 /// let response = client.get_location()
959 /// /* set fields */
960 /// .send().await?;
961 /// println!("response {:?}", response);
962 /// Ok(())
963 /// }
964 /// ```
965 pub fn get_location(&self) -> super::builder::vpc_flow_logs_service::GetLocation {
966 super::builder::vpc_flow_logs_service::GetLocation::new(self.inner.clone())
967 }
968
969 /// Sets the access control policy on the specified resource. Replaces
970 /// any existing policy.
971 ///
972 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
973 /// errors.
974 ///
975 /// # Example
976 /// ```
977 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
978 /// use google_cloud_networkmanagement_v1::Result;
979 /// async fn sample(
980 /// client: &VpcFlowLogsService
981 /// ) -> Result<()> {
982 /// let response = client.set_iam_policy()
983 /// /* set fields */
984 /// .send().await?;
985 /// println!("response {:?}", response);
986 /// Ok(())
987 /// }
988 /// ```
989 pub fn set_iam_policy(&self) -> super::builder::vpc_flow_logs_service::SetIamPolicy {
990 super::builder::vpc_flow_logs_service::SetIamPolicy::new(self.inner.clone())
991 }
992
993 /// Gets the access control policy for a resource. Returns an empty policy
994 /// if the resource exists and does not have a policy set.
995 ///
996 /// # Example
997 /// ```
998 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
999 /// use google_cloud_networkmanagement_v1::Result;
1000 /// async fn sample(
1001 /// client: &VpcFlowLogsService
1002 /// ) -> Result<()> {
1003 /// let response = client.get_iam_policy()
1004 /// /* set fields */
1005 /// .send().await?;
1006 /// println!("response {:?}", response);
1007 /// Ok(())
1008 /// }
1009 /// ```
1010 pub fn get_iam_policy(&self) -> super::builder::vpc_flow_logs_service::GetIamPolicy {
1011 super::builder::vpc_flow_logs_service::GetIamPolicy::new(self.inner.clone())
1012 }
1013
1014 /// Returns permissions that a caller has on the specified resource. If the
1015 /// resource does not exist, this will return an empty set of
1016 /// permissions, not a `NOT_FOUND` error.
1017 ///
1018 /// Note: This operation is designed to be used for building
1019 /// permission-aware UIs and command-line tools, not for authorization
1020 /// checking. This operation may "fail open" without warning.
1021 ///
1022 /// # Example
1023 /// ```
1024 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
1025 /// use google_cloud_networkmanagement_v1::Result;
1026 /// async fn sample(
1027 /// client: &VpcFlowLogsService
1028 /// ) -> Result<()> {
1029 /// let response = client.test_iam_permissions()
1030 /// /* set fields */
1031 /// .send().await?;
1032 /// println!("response {:?}", response);
1033 /// Ok(())
1034 /// }
1035 /// ```
1036 pub fn test_iam_permissions(
1037 &self,
1038 ) -> super::builder::vpc_flow_logs_service::TestIamPermissions {
1039 super::builder::vpc_flow_logs_service::TestIamPermissions::new(self.inner.clone())
1040 }
1041
1042 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1043 ///
1044 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1045 ///
1046 /// # Example
1047 /// ```
1048 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
1049 /// use google_cloud_gax::paginator::ItemPaginator as _;
1050 /// use google_cloud_networkmanagement_v1::Result;
1051 /// async fn sample(
1052 /// client: &VpcFlowLogsService
1053 /// ) -> Result<()> {
1054 /// let mut list = client.list_operations()
1055 /// /* set fields */
1056 /// .by_item();
1057 /// while let Some(item) = list.next().await.transpose()? {
1058 /// println!("{:?}", item);
1059 /// }
1060 /// Ok(())
1061 /// }
1062 /// ```
1063 pub fn list_operations(&self) -> super::builder::vpc_flow_logs_service::ListOperations {
1064 super::builder::vpc_flow_logs_service::ListOperations::new(self.inner.clone())
1065 }
1066
1067 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1068 ///
1069 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1070 ///
1071 /// # Example
1072 /// ```
1073 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
1074 /// use google_cloud_networkmanagement_v1::Result;
1075 /// async fn sample(
1076 /// client: &VpcFlowLogsService
1077 /// ) -> Result<()> {
1078 /// let response = client.get_operation()
1079 /// /* set fields */
1080 /// .send().await?;
1081 /// println!("response {:?}", response);
1082 /// Ok(())
1083 /// }
1084 /// ```
1085 pub fn get_operation(&self) -> super::builder::vpc_flow_logs_service::GetOperation {
1086 super::builder::vpc_flow_logs_service::GetOperation::new(self.inner.clone())
1087 }
1088
1089 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1090 ///
1091 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1092 ///
1093 /// # Example
1094 /// ```
1095 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
1096 /// use google_cloud_networkmanagement_v1::Result;
1097 /// async fn sample(
1098 /// client: &VpcFlowLogsService
1099 /// ) -> Result<()> {
1100 /// client.delete_operation()
1101 /// /* set fields */
1102 /// .send().await?;
1103 /// Ok(())
1104 /// }
1105 /// ```
1106 pub fn delete_operation(&self) -> super::builder::vpc_flow_logs_service::DeleteOperation {
1107 super::builder::vpc_flow_logs_service::DeleteOperation::new(self.inner.clone())
1108 }
1109
1110 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1111 ///
1112 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1113 ///
1114 /// # Example
1115 /// ```
1116 /// # use google_cloud_networkmanagement_v1::client::VpcFlowLogsService;
1117 /// use google_cloud_networkmanagement_v1::Result;
1118 /// async fn sample(
1119 /// client: &VpcFlowLogsService
1120 /// ) -> Result<()> {
1121 /// client.cancel_operation()
1122 /// /* set fields */
1123 /// .send().await?;
1124 /// Ok(())
1125 /// }
1126 /// ```
1127 pub fn cancel_operation(&self) -> super::builder::vpc_flow_logs_service::CancelOperation {
1128 super::builder::vpc_flow_logs_service::CancelOperation::new(self.inner.clone())
1129 }
1130}
1131
1132/// Implements a client for the Network Management API.
1133///
1134/// # Example
1135/// ```
1136/// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1137/// use google_cloud_gax::paginator::ItemPaginator as _;
1138/// async fn sample(
1139/// project_id: &str,
1140/// location_id: &str,
1141/// ) -> anyhow::Result<()> {
1142/// let client = OrganizationVpcFlowLogsService::builder().build().await?;
1143/// let mut list = client.list_vpc_flow_logs_configs()
1144/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
1145/// .by_item();
1146/// while let Some(item) = list.next().await.transpose()? {
1147/// println!("{:?}", item);
1148/// }
1149/// Ok(())
1150/// }
1151/// ```
1152///
1153/// # Service Description
1154///
1155/// The VPC Flow Logs organization service in the Google Cloud Network Management
1156/// API provides organization level configurations that generate Flow Logs. The
1157/// service and the configuration resources created using this service are
1158/// global.
1159///
1160/// # Configuration
1161///
1162/// To configure `OrganizationVpcFlowLogsService` use the `with_*` methods in the type returned
1163/// by [builder()][OrganizationVpcFlowLogsService::builder]. The default configuration should
1164/// work for most applications. Common configuration changes include
1165///
1166/// * [with_endpoint()]: by default this client uses the global default endpoint
1167/// (`https://networkmanagement.googleapis.com`). Applications using regional
1168/// endpoints or running in restricted networks (e.g. a network configured
1169// with [Private Google Access with VPC Service Controls]) may want to
1170/// override this default.
1171/// * [with_credentials()]: by default this client uses
1172/// [Application Default Credentials]. Applications using custom
1173/// authentication may need to override this default.
1174///
1175/// [with_endpoint()]: super::builder::organization_vpc_flow_logs_service::ClientBuilder::with_endpoint
1176/// [with_credentials()]: super::builder::organization_vpc_flow_logs_service::ClientBuilder::with_credentials
1177/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1178/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1179///
1180/// # Pooling and Cloning
1181///
1182/// `OrganizationVpcFlowLogsService` holds a connection pool internally, it is advised to
1183/// create one and reuse it. You do not need to wrap `OrganizationVpcFlowLogsService` in
1184/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1185/// already uses an `Arc` internally.
1186#[derive(Clone, Debug)]
1187pub struct OrganizationVpcFlowLogsService {
1188 inner: std::sync::Arc<dyn super::stub::dynamic::OrganizationVpcFlowLogsService>,
1189}
1190
1191impl OrganizationVpcFlowLogsService {
1192 /// Returns a builder for [OrganizationVpcFlowLogsService].
1193 ///
1194 /// ```
1195 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1196 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1197 /// let client = OrganizationVpcFlowLogsService::builder().build().await?;
1198 /// # Ok(()) }
1199 /// ```
1200 pub fn builder() -> super::builder::organization_vpc_flow_logs_service::ClientBuilder {
1201 crate::new_client_builder(
1202 super::builder::organization_vpc_flow_logs_service::client::Factory,
1203 )
1204 }
1205
1206 /// Creates a new client from the provided stub.
1207 ///
1208 /// The most common case for calling this function is in tests mocking the
1209 /// client's behavior.
1210 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1211 where
1212 T: super::stub::OrganizationVpcFlowLogsService + 'static,
1213 {
1214 Self { inner: stub.into() }
1215 }
1216
1217 pub(crate) async fn new(
1218 config: gaxi::options::ClientConfig,
1219 ) -> crate::ClientBuilderResult<Self> {
1220 let inner = Self::build_inner(config).await?;
1221 Ok(Self { inner })
1222 }
1223
1224 async fn build_inner(
1225 conf: gaxi::options::ClientConfig,
1226 ) -> crate::ClientBuilderResult<
1227 std::sync::Arc<dyn super::stub::dynamic::OrganizationVpcFlowLogsService>,
1228 > {
1229 if gaxi::options::tracing_enabled(&conf) {
1230 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1231 }
1232 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1233 }
1234
1235 async fn build_transport(
1236 conf: gaxi::options::ClientConfig,
1237 ) -> crate::ClientBuilderResult<impl super::stub::OrganizationVpcFlowLogsService> {
1238 super::transport::OrganizationVpcFlowLogsService::new(conf).await
1239 }
1240
1241 async fn build_with_tracing(
1242 conf: gaxi::options::ClientConfig,
1243 ) -> crate::ClientBuilderResult<impl super::stub::OrganizationVpcFlowLogsService> {
1244 Self::build_transport(conf)
1245 .await
1246 .map(super::tracing::OrganizationVpcFlowLogsService::new)
1247 }
1248
1249 /// Lists all `VpcFlowLogsConfigs` in a given organization.
1250 ///
1251 /// # Example
1252 /// ```
1253 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1254 /// use google_cloud_gax::paginator::ItemPaginator as _;
1255 /// use google_cloud_networkmanagement_v1::Result;
1256 /// async fn sample(
1257 /// client: &OrganizationVpcFlowLogsService, project_id: &str, location_id: &str
1258 /// ) -> Result<()> {
1259 /// let mut list = client.list_vpc_flow_logs_configs()
1260 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
1261 /// .by_item();
1262 /// while let Some(item) = list.next().await.transpose()? {
1263 /// println!("{:?}", item);
1264 /// }
1265 /// Ok(())
1266 /// }
1267 /// ```
1268 pub fn list_vpc_flow_logs_configs(
1269 &self,
1270 ) -> super::builder::organization_vpc_flow_logs_service::ListVpcFlowLogsConfigs {
1271 super::builder::organization_vpc_flow_logs_service::ListVpcFlowLogsConfigs::new(
1272 self.inner.clone(),
1273 )
1274 }
1275
1276 /// Gets the details of a specific `VpcFlowLogsConfig`.
1277 ///
1278 /// # Example
1279 /// ```
1280 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1281 /// use google_cloud_networkmanagement_v1::Result;
1282 /// async fn sample(
1283 /// client: &OrganizationVpcFlowLogsService, project_id: &str, location_id: &str, vpc_flow_logs_config_id: &str
1284 /// ) -> Result<()> {
1285 /// let response = client.get_vpc_flow_logs_config()
1286 /// .set_name(format!("projects/{project_id}/locations/{location_id}/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}"))
1287 /// .send().await?;
1288 /// println!("response {:?}", response);
1289 /// Ok(())
1290 /// }
1291 /// ```
1292 pub fn get_vpc_flow_logs_config(
1293 &self,
1294 ) -> super::builder::organization_vpc_flow_logs_service::GetVpcFlowLogsConfig {
1295 super::builder::organization_vpc_flow_logs_service::GetVpcFlowLogsConfig::new(
1296 self.inner.clone(),
1297 )
1298 }
1299
1300 /// Creates a new `VpcFlowLogsConfig`.
1301 /// If a configuration with the exact same settings already exists (even if the
1302 /// ID is different), the creation fails.
1303 /// Notes:
1304 ///
1305 /// 1. Creating a configuration with `state=DISABLED` will fail
1306 /// 1. The following fields are not considered as settings for the purpose
1307 /// of the check mentioned above, therefore - creating another configuration
1308 /// with the same fields but different values for the following fields will
1309 /// fail as well:
1310 /// * name
1311 /// * create_time
1312 /// * update_time
1313 /// * labels
1314 /// * description
1315 ///
1316 /// # Long running operations
1317 ///
1318 /// This method is used to start, and/or poll a [long-running Operation].
1319 /// The [Working with long-running operations] chapter in the [user guide]
1320 /// covers these operations in detail.
1321 ///
1322 /// [long-running operation]: https://google.aip.dev/151
1323 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1324 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1325 ///
1326 /// # Example
1327 /// ```
1328 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1329 /// use google_cloud_lro::Poller;
1330 /// use google_cloud_networkmanagement_v1::model::VpcFlowLogsConfig;
1331 /// use google_cloud_networkmanagement_v1::Result;
1332 /// async fn sample(
1333 /// client: &OrganizationVpcFlowLogsService, project_id: &str, location_id: &str
1334 /// ) -> Result<()> {
1335 /// let response = client.create_vpc_flow_logs_config()
1336 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
1337 /// .set_vpc_flow_logs_config(
1338 /// VpcFlowLogsConfig::new()/* set fields */
1339 /// )
1340 /// .poller().until_done().await?;
1341 /// println!("response {:?}", response);
1342 /// Ok(())
1343 /// }
1344 /// ```
1345 pub fn create_vpc_flow_logs_config(
1346 &self,
1347 ) -> super::builder::organization_vpc_flow_logs_service::CreateVpcFlowLogsConfig {
1348 super::builder::organization_vpc_flow_logs_service::CreateVpcFlowLogsConfig::new(
1349 self.inner.clone(),
1350 )
1351 }
1352
1353 /// Updates an existing `VpcFlowLogsConfig`.
1354 /// If a configuration with the exact same settings already exists (even if the
1355 /// ID is different), the creation fails.
1356 /// Notes:
1357 ///
1358 /// 1. Updating a configuration with `state=DISABLED` will fail
1359 /// 1. The following fields are not considered as settings for the purpose
1360 /// of the check mentioned above, therefore - updating another configuration
1361 /// with the same fields but different values for the following fields will
1362 /// fail as well:
1363 /// * name
1364 /// * create_time
1365 /// * update_time
1366 /// * labels
1367 /// * description
1368 ///
1369 /// # Long running operations
1370 ///
1371 /// This method is used to start, and/or poll a [long-running Operation].
1372 /// The [Working with long-running operations] chapter in the [user guide]
1373 /// covers these operations in detail.
1374 ///
1375 /// [long-running operation]: https://google.aip.dev/151
1376 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1377 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1378 ///
1379 /// # Example
1380 /// ```
1381 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1382 /// use google_cloud_lro::Poller;
1383 /// # extern crate wkt as google_cloud_wkt;
1384 /// use google_cloud_wkt::FieldMask;
1385 /// use google_cloud_networkmanagement_v1::model::VpcFlowLogsConfig;
1386 /// use google_cloud_networkmanagement_v1::Result;
1387 /// async fn sample(
1388 /// client: &OrganizationVpcFlowLogsService, project_id: &str, location_id: &str, vpc_flow_logs_config_id: &str
1389 /// ) -> Result<()> {
1390 /// let response = client.update_vpc_flow_logs_config()
1391 /// .set_vpc_flow_logs_config(
1392 /// VpcFlowLogsConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}"))/* set fields */
1393 /// )
1394 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1395 /// .poller().until_done().await?;
1396 /// println!("response {:?}", response);
1397 /// Ok(())
1398 /// }
1399 /// ```
1400 pub fn update_vpc_flow_logs_config(
1401 &self,
1402 ) -> super::builder::organization_vpc_flow_logs_service::UpdateVpcFlowLogsConfig {
1403 super::builder::organization_vpc_flow_logs_service::UpdateVpcFlowLogsConfig::new(
1404 self.inner.clone(),
1405 )
1406 }
1407
1408 /// Deletes a specific `VpcFlowLogsConfig`.
1409 ///
1410 /// # Long running operations
1411 ///
1412 /// This method is used to start, and/or poll a [long-running Operation].
1413 /// The [Working with long-running operations] chapter in the [user guide]
1414 /// covers these operations in detail.
1415 ///
1416 /// [long-running operation]: https://google.aip.dev/151
1417 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1418 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1419 ///
1420 /// # Example
1421 /// ```
1422 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1423 /// use google_cloud_lro::Poller;
1424 /// use google_cloud_networkmanagement_v1::Result;
1425 /// async fn sample(
1426 /// client: &OrganizationVpcFlowLogsService, project_id: &str, location_id: &str, vpc_flow_logs_config_id: &str
1427 /// ) -> Result<()> {
1428 /// client.delete_vpc_flow_logs_config()
1429 /// .set_name(format!("projects/{project_id}/locations/{location_id}/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}"))
1430 /// .poller().until_done().await?;
1431 /// Ok(())
1432 /// }
1433 /// ```
1434 pub fn delete_vpc_flow_logs_config(
1435 &self,
1436 ) -> super::builder::organization_vpc_flow_logs_service::DeleteVpcFlowLogsConfig {
1437 super::builder::organization_vpc_flow_logs_service::DeleteVpcFlowLogsConfig::new(
1438 self.inner.clone(),
1439 )
1440 }
1441
1442 /// Lists information about the supported locations for this service.
1443 /// This method can be called in two ways:
1444 ///
1445 /// * **List all public locations:** Use the path `GET /v1/locations`.
1446 /// * **List project-visible locations:** Use the path
1447 /// `GET /v1/projects/{project_id}/locations`. This may include public
1448 /// locations as well as private or other locations specifically visible
1449 /// to the project.
1450 ///
1451 /// # Example
1452 /// ```
1453 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1454 /// use google_cloud_gax::paginator::ItemPaginator as _;
1455 /// use google_cloud_networkmanagement_v1::Result;
1456 /// async fn sample(
1457 /// client: &OrganizationVpcFlowLogsService
1458 /// ) -> Result<()> {
1459 /// let mut list = client.list_locations()
1460 /// /* set fields */
1461 /// .by_item();
1462 /// while let Some(item) = list.next().await.transpose()? {
1463 /// println!("{:?}", item);
1464 /// }
1465 /// Ok(())
1466 /// }
1467 /// ```
1468 pub fn list_locations(
1469 &self,
1470 ) -> super::builder::organization_vpc_flow_logs_service::ListLocations {
1471 super::builder::organization_vpc_flow_logs_service::ListLocations::new(self.inner.clone())
1472 }
1473
1474 /// Gets information about a location.
1475 ///
1476 /// # Example
1477 /// ```
1478 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1479 /// use google_cloud_networkmanagement_v1::Result;
1480 /// async fn sample(
1481 /// client: &OrganizationVpcFlowLogsService
1482 /// ) -> Result<()> {
1483 /// let response = client.get_location()
1484 /// /* set fields */
1485 /// .send().await?;
1486 /// println!("response {:?}", response);
1487 /// Ok(())
1488 /// }
1489 /// ```
1490 pub fn get_location(&self) -> super::builder::organization_vpc_flow_logs_service::GetLocation {
1491 super::builder::organization_vpc_flow_logs_service::GetLocation::new(self.inner.clone())
1492 }
1493
1494 /// Sets the access control policy on the specified resource. Replaces
1495 /// any existing policy.
1496 ///
1497 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
1498 /// errors.
1499 ///
1500 /// # Example
1501 /// ```
1502 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1503 /// use google_cloud_networkmanagement_v1::Result;
1504 /// async fn sample(
1505 /// client: &OrganizationVpcFlowLogsService
1506 /// ) -> Result<()> {
1507 /// let response = client.set_iam_policy()
1508 /// /* set fields */
1509 /// .send().await?;
1510 /// println!("response {:?}", response);
1511 /// Ok(())
1512 /// }
1513 /// ```
1514 pub fn set_iam_policy(
1515 &self,
1516 ) -> super::builder::organization_vpc_flow_logs_service::SetIamPolicy {
1517 super::builder::organization_vpc_flow_logs_service::SetIamPolicy::new(self.inner.clone())
1518 }
1519
1520 /// Gets the access control policy for a resource. Returns an empty policy
1521 /// if the resource exists and does not have a policy set.
1522 ///
1523 /// # Example
1524 /// ```
1525 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1526 /// use google_cloud_networkmanagement_v1::Result;
1527 /// async fn sample(
1528 /// client: &OrganizationVpcFlowLogsService
1529 /// ) -> Result<()> {
1530 /// let response = client.get_iam_policy()
1531 /// /* set fields */
1532 /// .send().await?;
1533 /// println!("response {:?}", response);
1534 /// Ok(())
1535 /// }
1536 /// ```
1537 pub fn get_iam_policy(
1538 &self,
1539 ) -> super::builder::organization_vpc_flow_logs_service::GetIamPolicy {
1540 super::builder::organization_vpc_flow_logs_service::GetIamPolicy::new(self.inner.clone())
1541 }
1542
1543 /// Returns permissions that a caller has on the specified resource. If the
1544 /// resource does not exist, this will return an empty set of
1545 /// permissions, not a `NOT_FOUND` error.
1546 ///
1547 /// Note: This operation is designed to be used for building
1548 /// permission-aware UIs and command-line tools, not for authorization
1549 /// checking. This operation may "fail open" without warning.
1550 ///
1551 /// # Example
1552 /// ```
1553 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1554 /// use google_cloud_networkmanagement_v1::Result;
1555 /// async fn sample(
1556 /// client: &OrganizationVpcFlowLogsService
1557 /// ) -> Result<()> {
1558 /// let response = client.test_iam_permissions()
1559 /// /* set fields */
1560 /// .send().await?;
1561 /// println!("response {:?}", response);
1562 /// Ok(())
1563 /// }
1564 /// ```
1565 pub fn test_iam_permissions(
1566 &self,
1567 ) -> super::builder::organization_vpc_flow_logs_service::TestIamPermissions {
1568 super::builder::organization_vpc_flow_logs_service::TestIamPermissions::new(
1569 self.inner.clone(),
1570 )
1571 }
1572
1573 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1574 ///
1575 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1576 ///
1577 /// # Example
1578 /// ```
1579 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1580 /// use google_cloud_gax::paginator::ItemPaginator as _;
1581 /// use google_cloud_networkmanagement_v1::Result;
1582 /// async fn sample(
1583 /// client: &OrganizationVpcFlowLogsService
1584 /// ) -> Result<()> {
1585 /// let mut list = client.list_operations()
1586 /// /* set fields */
1587 /// .by_item();
1588 /// while let Some(item) = list.next().await.transpose()? {
1589 /// println!("{:?}", item);
1590 /// }
1591 /// Ok(())
1592 /// }
1593 /// ```
1594 pub fn list_operations(
1595 &self,
1596 ) -> super::builder::organization_vpc_flow_logs_service::ListOperations {
1597 super::builder::organization_vpc_flow_logs_service::ListOperations::new(self.inner.clone())
1598 }
1599
1600 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1601 ///
1602 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1603 ///
1604 /// # Example
1605 /// ```
1606 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1607 /// use google_cloud_networkmanagement_v1::Result;
1608 /// async fn sample(
1609 /// client: &OrganizationVpcFlowLogsService
1610 /// ) -> Result<()> {
1611 /// let response = client.get_operation()
1612 /// /* set fields */
1613 /// .send().await?;
1614 /// println!("response {:?}", response);
1615 /// Ok(())
1616 /// }
1617 /// ```
1618 pub fn get_operation(
1619 &self,
1620 ) -> super::builder::organization_vpc_flow_logs_service::GetOperation {
1621 super::builder::organization_vpc_flow_logs_service::GetOperation::new(self.inner.clone())
1622 }
1623
1624 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1625 ///
1626 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1627 ///
1628 /// # Example
1629 /// ```
1630 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1631 /// use google_cloud_networkmanagement_v1::Result;
1632 /// async fn sample(
1633 /// client: &OrganizationVpcFlowLogsService
1634 /// ) -> Result<()> {
1635 /// client.delete_operation()
1636 /// /* set fields */
1637 /// .send().await?;
1638 /// Ok(())
1639 /// }
1640 /// ```
1641 pub fn delete_operation(
1642 &self,
1643 ) -> super::builder::organization_vpc_flow_logs_service::DeleteOperation {
1644 super::builder::organization_vpc_flow_logs_service::DeleteOperation::new(self.inner.clone())
1645 }
1646
1647 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1648 ///
1649 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1650 ///
1651 /// # Example
1652 /// ```
1653 /// # use google_cloud_networkmanagement_v1::client::OrganizationVpcFlowLogsService;
1654 /// use google_cloud_networkmanagement_v1::Result;
1655 /// async fn sample(
1656 /// client: &OrganizationVpcFlowLogsService
1657 /// ) -> Result<()> {
1658 /// client.cancel_operation()
1659 /// /* set fields */
1660 /// .send().await?;
1661 /// Ok(())
1662 /// }
1663 /// ```
1664 pub fn cancel_operation(
1665 &self,
1666 ) -> super::builder::organization_vpc_flow_logs_service::CancelOperation {
1667 super::builder::organization_vpc_flow_logs_service::CancelOperation::new(self.inner.clone())
1668 }
1669}