Skip to main content

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