Skip to main content

google_cloud_logging_v2/
client.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::bare_urls)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::redundant_explicit_links)]
20
21/// Implements a client for the Cloud Logging API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_logging_v2::client::LoggingServiceV2;
26/// async fn sample(
27/// ) -> anyhow::Result<()> {
28///     let client = LoggingServiceV2::builder().build().await?;
29///     // use `client` to make requests to the Cloud Logging API.
30///     Ok(())
31/// }
32/// ```
33///
34/// # Service Description
35///
36/// Service for ingesting and querying logs.
37///
38/// # Configuration
39///
40/// To configure `LoggingServiceV2` use the `with_*` methods in the type returned
41/// by [builder()][LoggingServiceV2::builder]. The default configuration should
42/// work for most applications. Common configuration changes include
43///
44/// * [with_endpoint()]: by default this client uses the global default endpoint
45///   (`https://logging.googleapis.com`). Applications using regional
46///   endpoints or running in restricted networks (e.g. a network configured
47///   with [Private Google Access with VPC Service Controls]) may want to
48///   override this default.
49/// * [with_credentials()]: by default this client uses
50///   [Application Default Credentials]. Applications using custom
51///   authentication may need to override this default.
52///
53/// [with_endpoint()]: super::builder::logging_service_v_2::ClientBuilder::with_endpoint
54/// [with_credentials()]: super::builder::logging_service_v_2::ClientBuilder::with_credentials
55/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
56/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
57///
58/// # Pooling and Cloning
59///
60/// `LoggingServiceV2` holds a connection pool internally, it is advised to
61/// create one and reuse it. You do not need to wrap `LoggingServiceV2` in
62/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
63/// already uses an `Arc` internally.
64#[derive(Clone, Debug)]
65pub struct LoggingServiceV2 {
66    inner: std::sync::Arc<dyn super::stub::dynamic::LoggingServiceV2>,
67}
68
69impl LoggingServiceV2 {
70    /// Returns a builder for [LoggingServiceV2].
71    ///
72    /// ```
73    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
74    /// # use google_cloud_logging_v2::client::LoggingServiceV2;
75    /// let client = LoggingServiceV2::builder().build().await?;
76    /// # Ok(()) }
77    /// ```
78    pub fn builder() -> super::builder::logging_service_v_2::ClientBuilder {
79        crate::new_client_builder(super::builder::logging_service_v_2::client::Factory)
80    }
81
82    /// Creates a new client from the provided stub.
83    ///
84    /// The most common case for calling this function is in tests mocking the
85    /// client's behavior.
86    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
87    where
88        T: super::stub::LoggingServiceV2 + 'static,
89    {
90        Self { inner: stub.into() }
91    }
92
93    pub(crate) async fn new(
94        config: gaxi::options::ClientConfig,
95    ) -> crate::ClientBuilderResult<Self> {
96        let inner = Self::build_inner(config).await?;
97        Ok(Self { inner })
98    }
99
100    async fn build_inner(
101        conf: gaxi::options::ClientConfig,
102    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::LoggingServiceV2>>
103    {
104        if gaxi::options::tracing_enabled(&conf) {
105            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
106        }
107        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
108    }
109
110    async fn build_transport(
111        conf: gaxi::options::ClientConfig,
112    ) -> crate::ClientBuilderResult<impl super::stub::LoggingServiceV2> {
113        super::transport::LoggingServiceV2::new(conf).await
114    }
115
116    async fn build_with_tracing(
117        conf: gaxi::options::ClientConfig,
118    ) -> crate::ClientBuilderResult<impl super::stub::LoggingServiceV2> {
119        Self::build_transport(conf)
120            .await
121            .map(super::tracing::LoggingServiceV2::new)
122    }
123
124    /// Deletes all the log entries in a log for the _Default Log Bucket. The log
125    /// reappears if it receives new entries. Log entries written shortly before
126    /// the delete operation might not be deleted. Entries received after the
127    /// delete operation with a timestamp before the operation will be deleted.
128    pub fn delete_log(&self) -> super::builder::logging_service_v_2::DeleteLog {
129        super::builder::logging_service_v_2::DeleteLog::new(self.inner.clone())
130    }
131
132    /// Writes log entries to Logging. This API method is the
133    /// only way to send log entries to Logging. This method
134    /// is used, directly or indirectly, by the Logging agent
135    /// (fluentd) and all logging libraries configured to use Logging.
136    /// A single request may contain log entries for a maximum of 1000
137    /// different resources (projects, organizations, billing accounts or
138    /// folders)
139    pub fn write_log_entries(&self) -> super::builder::logging_service_v_2::WriteLogEntries {
140        super::builder::logging_service_v_2::WriteLogEntries::new(self.inner.clone())
141    }
142
143    /// Lists log entries.  Use this method to retrieve log entries that originated
144    /// from a project/folder/organization/billing account.  For ways to export log
145    /// entries, see [Exporting
146    /// Logs](https://cloud.google.com/logging/docs/export).
147    pub fn list_log_entries(&self) -> super::builder::logging_service_v_2::ListLogEntries {
148        super::builder::logging_service_v_2::ListLogEntries::new(self.inner.clone())
149    }
150
151    /// Lists the descriptors for monitored resource types used by Logging.
152    pub fn list_monitored_resource_descriptors(
153        &self,
154    ) -> super::builder::logging_service_v_2::ListMonitoredResourceDescriptors {
155        super::builder::logging_service_v_2::ListMonitoredResourceDescriptors::new(
156            self.inner.clone(),
157        )
158    }
159
160    /// Lists the logs in projects, organizations, folders, or billing accounts.
161    /// Only logs that have entries are listed.
162    pub fn list_logs(&self) -> super::builder::logging_service_v_2::ListLogs {
163        super::builder::logging_service_v_2::ListLogs::new(self.inner.clone())
164    }
165
166    /// Streaming read of log entries as they are ingested. Until the stream is
167    /// terminated, it will continue reading logs.
168    pub fn tail_log_entries(&self) -> super::builder::logging_service_v_2::TailLogEntries {
169        super::builder::logging_service_v_2::TailLogEntries::new(self.inner.clone())
170    }
171
172    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
173    ///
174    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
175    pub fn list_operations(&self) -> super::builder::logging_service_v_2::ListOperations {
176        super::builder::logging_service_v_2::ListOperations::new(self.inner.clone())
177    }
178
179    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
180    ///
181    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
182    pub fn get_operation(&self) -> super::builder::logging_service_v_2::GetOperation {
183        super::builder::logging_service_v_2::GetOperation::new(self.inner.clone())
184    }
185
186    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
187    ///
188    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
189    pub fn cancel_operation(&self) -> super::builder::logging_service_v_2::CancelOperation {
190        super::builder::logging_service_v_2::CancelOperation::new(self.inner.clone())
191    }
192}
193
194/// Implements a client for the Cloud Logging API.
195///
196/// # Example
197/// ```
198/// # use google_cloud_logging_v2::client::ConfigServiceV2;
199/// async fn sample(
200/// ) -> anyhow::Result<()> {
201///     let client = ConfigServiceV2::builder().build().await?;
202///     // use `client` to make requests to the Cloud Logging API.
203///     Ok(())
204/// }
205/// ```
206///
207/// # Service Description
208///
209/// Service for configuring sinks used to route log entries.
210///
211/// # Configuration
212///
213/// To configure `ConfigServiceV2` use the `with_*` methods in the type returned
214/// by [builder()][ConfigServiceV2::builder]. The default configuration should
215/// work for most applications. Common configuration changes include
216///
217/// * [with_endpoint()]: by default this client uses the global default endpoint
218///   (`https://logging.googleapis.com`). Applications using regional
219///   endpoints or running in restricted networks (e.g. a network configured
220///   with [Private Google Access with VPC Service Controls]) may want to
221///   override this default.
222/// * [with_credentials()]: by default this client uses
223///   [Application Default Credentials]. Applications using custom
224///   authentication may need to override this default.
225///
226/// [with_endpoint()]: super::builder::config_service_v_2::ClientBuilder::with_endpoint
227/// [with_credentials()]: super::builder::config_service_v_2::ClientBuilder::with_credentials
228/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
229/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
230///
231/// # Pooling and Cloning
232///
233/// `ConfigServiceV2` holds a connection pool internally, it is advised to
234/// create one and reuse it. You do not need to wrap `ConfigServiceV2` in
235/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
236/// already uses an `Arc` internally.
237#[derive(Clone, Debug)]
238pub struct ConfigServiceV2 {
239    inner: std::sync::Arc<dyn super::stub::dynamic::ConfigServiceV2>,
240}
241
242impl ConfigServiceV2 {
243    /// Returns a builder for [ConfigServiceV2].
244    ///
245    /// ```
246    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
247    /// # use google_cloud_logging_v2::client::ConfigServiceV2;
248    /// let client = ConfigServiceV2::builder().build().await?;
249    /// # Ok(()) }
250    /// ```
251    pub fn builder() -> super::builder::config_service_v_2::ClientBuilder {
252        crate::new_client_builder(super::builder::config_service_v_2::client::Factory)
253    }
254
255    /// Creates a new client from the provided stub.
256    ///
257    /// The most common case for calling this function is in tests mocking the
258    /// client's behavior.
259    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
260    where
261        T: super::stub::ConfigServiceV2 + 'static,
262    {
263        Self { inner: stub.into() }
264    }
265
266    pub(crate) async fn new(
267        config: gaxi::options::ClientConfig,
268    ) -> crate::ClientBuilderResult<Self> {
269        let inner = Self::build_inner(config).await?;
270        Ok(Self { inner })
271    }
272
273    async fn build_inner(
274        conf: gaxi::options::ClientConfig,
275    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ConfigServiceV2>> {
276        if gaxi::options::tracing_enabled(&conf) {
277            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
278        }
279        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
280    }
281
282    async fn build_transport(
283        conf: gaxi::options::ClientConfig,
284    ) -> crate::ClientBuilderResult<impl super::stub::ConfigServiceV2> {
285        super::transport::ConfigServiceV2::new(conf).await
286    }
287
288    async fn build_with_tracing(
289        conf: gaxi::options::ClientConfig,
290    ) -> crate::ClientBuilderResult<impl super::stub::ConfigServiceV2> {
291        Self::build_transport(conf)
292            .await
293            .map(super::tracing::ConfigServiceV2::new)
294    }
295
296    /// Lists log buckets.
297    pub fn list_buckets(&self) -> super::builder::config_service_v_2::ListBuckets {
298        super::builder::config_service_v_2::ListBuckets::new(self.inner.clone())
299    }
300
301    /// Gets a log bucket.
302    pub fn get_bucket(&self) -> super::builder::config_service_v_2::GetBucket {
303        super::builder::config_service_v_2::GetBucket::new(self.inner.clone())
304    }
305
306    /// Creates a log bucket asynchronously that can be used to store log entries.
307    ///
308    /// After a bucket has been created, the bucket's location cannot be changed.
309    ///
310    /// # Long running operations
311    ///
312    /// This method is used to start, and/or poll a [long-running Operation].
313    /// The [Working with long-running operations] chapter in the [user guide]
314    /// covers these operations in detail.
315    ///
316    /// [long-running operation]: https://google.aip.dev/151
317    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
318    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
319    pub fn create_bucket_async(&self) -> super::builder::config_service_v_2::CreateBucketAsync {
320        super::builder::config_service_v_2::CreateBucketAsync::new(self.inner.clone())
321    }
322
323    /// Updates a log bucket asynchronously.
324    ///
325    /// If the bucket has a `lifecycle_state` of `DELETE_REQUESTED`, then
326    /// `FAILED_PRECONDITION` will be returned.
327    ///
328    /// After a bucket has been created, the bucket's location cannot be changed.
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    pub fn update_bucket_async(&self) -> super::builder::config_service_v_2::UpdateBucketAsync {
340        super::builder::config_service_v_2::UpdateBucketAsync::new(self.inner.clone())
341    }
342
343    /// Creates a log bucket that can be used to store log entries. After a bucket
344    /// has been created, the bucket's location cannot be changed.
345    pub fn create_bucket(&self) -> super::builder::config_service_v_2::CreateBucket {
346        super::builder::config_service_v_2::CreateBucket::new(self.inner.clone())
347    }
348
349    /// Updates a log bucket.
350    ///
351    /// If the bucket has a `lifecycle_state` of `DELETE_REQUESTED`, then
352    /// `FAILED_PRECONDITION` will be returned.
353    ///
354    /// After a bucket has been created, the bucket's location cannot be changed.
355    pub fn update_bucket(&self) -> super::builder::config_service_v_2::UpdateBucket {
356        super::builder::config_service_v_2::UpdateBucket::new(self.inner.clone())
357    }
358
359    /// Deletes a log bucket.
360    ///
361    /// Changes the bucket's `lifecycle_state` to the `DELETE_REQUESTED` state.
362    /// After 7 days, the bucket will be purged and all log entries in the bucket
363    /// will be permanently deleted.
364    pub fn delete_bucket(&self) -> super::builder::config_service_v_2::DeleteBucket {
365        super::builder::config_service_v_2::DeleteBucket::new(self.inner.clone())
366    }
367
368    /// Undeletes a log bucket. A bucket that has been deleted can be undeleted
369    /// within the grace period of 7 days.
370    pub fn undelete_bucket(&self) -> super::builder::config_service_v_2::UndeleteBucket {
371        super::builder::config_service_v_2::UndeleteBucket::new(self.inner.clone())
372    }
373
374    /// Lists views on a log bucket.
375    pub fn list_views(&self) -> super::builder::config_service_v_2::ListViews {
376        super::builder::config_service_v_2::ListViews::new(self.inner.clone())
377    }
378
379    /// Gets a view on a log bucket..
380    pub fn get_view(&self) -> super::builder::config_service_v_2::GetView {
381        super::builder::config_service_v_2::GetView::new(self.inner.clone())
382    }
383
384    /// Creates a view over log entries in a log bucket. A bucket may contain a
385    /// maximum of 30 views.
386    pub fn create_view(&self) -> super::builder::config_service_v_2::CreateView {
387        super::builder::config_service_v_2::CreateView::new(self.inner.clone())
388    }
389
390    /// Updates a view on a log bucket. This method replaces the following fields
391    /// in the existing view with values from the new view: `filter`.
392    /// If an `UNAVAILABLE` error is returned, this indicates that system is not in
393    /// a state where it can update the view. If this occurs, please try again in a
394    /// few minutes.
395    pub fn update_view(&self) -> super::builder::config_service_v_2::UpdateView {
396        super::builder::config_service_v_2::UpdateView::new(self.inner.clone())
397    }
398
399    /// Deletes a view on a log bucket.
400    /// If an `UNAVAILABLE` error is returned, this indicates that system is not in
401    /// a state where it can delete the view. If this occurs, please try again in a
402    /// few minutes.
403    pub fn delete_view(&self) -> super::builder::config_service_v_2::DeleteView {
404        super::builder::config_service_v_2::DeleteView::new(self.inner.clone())
405    }
406
407    /// Lists sinks.
408    pub fn list_sinks(&self) -> super::builder::config_service_v_2::ListSinks {
409        super::builder::config_service_v_2::ListSinks::new(self.inner.clone())
410    }
411
412    /// Gets a sink.
413    pub fn get_sink(&self) -> super::builder::config_service_v_2::GetSink {
414        super::builder::config_service_v_2::GetSink::new(self.inner.clone())
415    }
416
417    /// Creates a sink that exports specified log entries to a destination. The
418    /// export of newly-ingested log entries begins immediately, unless the sink's
419    /// `writer_identity` is not permitted to write to the destination. A sink can
420    /// export log entries only from the resource owning the sink.
421    pub fn create_sink(&self) -> super::builder::config_service_v_2::CreateSink {
422        super::builder::config_service_v_2::CreateSink::new(self.inner.clone())
423    }
424
425    /// Updates a sink. This method replaces the following fields in the existing
426    /// sink with values from the new sink: `destination`, and `filter`.
427    ///
428    /// The updated sink might also have a new `writer_identity`; see the
429    /// `unique_writer_identity` field.
430    pub fn update_sink(&self) -> super::builder::config_service_v_2::UpdateSink {
431        super::builder::config_service_v_2::UpdateSink::new(self.inner.clone())
432    }
433
434    /// Deletes a sink. If the sink has a unique `writer_identity`, then that
435    /// service account is also deleted.
436    pub fn delete_sink(&self) -> super::builder::config_service_v_2::DeleteSink {
437        super::builder::config_service_v_2::DeleteSink::new(self.inner.clone())
438    }
439
440    /// Asynchronously creates a linked dataset in BigQuery which makes it possible
441    /// to use BigQuery to read the logs stored in the log bucket. A log bucket may
442    /// currently only contain one link.
443    ///
444    /// # Long running operations
445    ///
446    /// This method is used to start, and/or poll a [long-running Operation].
447    /// The [Working with long-running operations] chapter in the [user guide]
448    /// covers these operations in detail.
449    ///
450    /// [long-running operation]: https://google.aip.dev/151
451    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
452    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
453    pub fn create_link(&self) -> super::builder::config_service_v_2::CreateLink {
454        super::builder::config_service_v_2::CreateLink::new(self.inner.clone())
455    }
456
457    /// Deletes a link. This will also delete the corresponding BigQuery linked
458    /// dataset.
459    ///
460    /// # Long running operations
461    ///
462    /// This method is used to start, and/or poll a [long-running Operation].
463    /// The [Working with long-running operations] chapter in the [user guide]
464    /// covers these operations in detail.
465    ///
466    /// [long-running operation]: https://google.aip.dev/151
467    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
468    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
469    pub fn delete_link(&self) -> super::builder::config_service_v_2::DeleteLink {
470        super::builder::config_service_v_2::DeleteLink::new(self.inner.clone())
471    }
472
473    /// Lists links.
474    pub fn list_links(&self) -> super::builder::config_service_v_2::ListLinks {
475        super::builder::config_service_v_2::ListLinks::new(self.inner.clone())
476    }
477
478    /// Gets a link.
479    pub fn get_link(&self) -> super::builder::config_service_v_2::GetLink {
480        super::builder::config_service_v_2::GetLink::new(self.inner.clone())
481    }
482
483    /// Lists all the exclusions on the _Default sink in a parent resource.
484    pub fn list_exclusions(&self) -> super::builder::config_service_v_2::ListExclusions {
485        super::builder::config_service_v_2::ListExclusions::new(self.inner.clone())
486    }
487
488    /// Gets the description of an exclusion in the _Default sink.
489    pub fn get_exclusion(&self) -> super::builder::config_service_v_2::GetExclusion {
490        super::builder::config_service_v_2::GetExclusion::new(self.inner.clone())
491    }
492
493    /// Creates a new exclusion in the _Default sink in a specified parent
494    /// resource. Only log entries belonging to that resource can be excluded. You
495    /// can have up to 10 exclusions in a resource.
496    pub fn create_exclusion(&self) -> super::builder::config_service_v_2::CreateExclusion {
497        super::builder::config_service_v_2::CreateExclusion::new(self.inner.clone())
498    }
499
500    /// Changes one or more properties of an existing exclusion in the _Default
501    /// sink.
502    pub fn update_exclusion(&self) -> super::builder::config_service_v_2::UpdateExclusion {
503        super::builder::config_service_v_2::UpdateExclusion::new(self.inner.clone())
504    }
505
506    /// Deletes an exclusion in the _Default sink.
507    pub fn delete_exclusion(&self) -> super::builder::config_service_v_2::DeleteExclusion {
508        super::builder::config_service_v_2::DeleteExclusion::new(self.inner.clone())
509    }
510
511    /// Gets the Logging CMEK settings for the given resource.
512    ///
513    /// Note: CMEK for the Log Router can be configured for Google Cloud projects,
514    /// folders, organizations and billing accounts. Once configured for an
515    /// organization, it applies to all projects and folders in the Google Cloud
516    /// organization.
517    ///
518    /// See [Enabling CMEK for Log
519    /// Router](https://cloud.google.com/logging/docs/routing/managed-encryption)
520    /// for more information.
521    pub fn get_cmek_settings(&self) -> super::builder::config_service_v_2::GetCmekSettings {
522        super::builder::config_service_v_2::GetCmekSettings::new(self.inner.clone())
523    }
524
525    /// Updates the Log Router CMEK settings for the given resource.
526    ///
527    /// Note: CMEK for the Log Router can currently only be configured for Google
528    /// Cloud organizations. Once configured, it applies to all projects and
529    /// folders in the Google Cloud organization.
530    ///
531    /// [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings]
532    /// will fail if 1) `kms_key_name` is invalid, or 2) the associated service
533    /// account does not have the required
534    /// `roles/cloudkms.cryptoKeyEncrypterDecrypter` role assigned for the key, or
535    /// 3) access to the key is disabled.
536    ///
537    /// See [Enabling CMEK for Log
538    /// Router](https://cloud.google.com/logging/docs/routing/managed-encryption)
539    /// for more information.
540    ///
541    /// [google.logging.v2.ConfigServiceV2.UpdateCmekSettings]: crate::client::ConfigServiceV2::update_cmek_settings
542    pub fn update_cmek_settings(&self) -> super::builder::config_service_v_2::UpdateCmekSettings {
543        super::builder::config_service_v_2::UpdateCmekSettings::new(self.inner.clone())
544    }
545
546    /// Gets the Log Router settings for the given resource.
547    ///
548    /// Note: Settings for the Log Router can be get for Google Cloud projects,
549    /// folders, organizations and billing accounts. Currently it can only be
550    /// configured for organizations. Once configured for an organization, it
551    /// applies to all projects and folders in the Google Cloud organization.
552    ///
553    /// See [Enabling CMEK for Log
554    /// Router](https://cloud.google.com/logging/docs/routing/managed-encryption)
555    /// for more information.
556    pub fn get_settings(&self) -> super::builder::config_service_v_2::GetSettings {
557        super::builder::config_service_v_2::GetSettings::new(self.inner.clone())
558    }
559
560    /// Updates the Log Router settings for the given resource.
561    ///
562    /// Note: Settings for the Log Router can currently only be configured for
563    /// Google Cloud organizations. Once configured, it applies to all projects and
564    /// folders in the Google Cloud organization.
565    ///
566    /// [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings]
567    /// will fail if 1) `kms_key_name` is invalid, or 2) the associated service
568    /// account does not have the required
569    /// `roles/cloudkms.cryptoKeyEncrypterDecrypter` role assigned for the key, or
570    /// 3) access to the key is disabled. 4) `location_id` is not supported by
571    /// Logging. 5) `location_id` violate OrgPolicy.
572    ///
573    /// See [Enabling CMEK for Log
574    /// Router](https://cloud.google.com/logging/docs/routing/managed-encryption)
575    /// for more information.
576    ///
577    /// [google.logging.v2.ConfigServiceV2.UpdateSettings]: crate::client::ConfigServiceV2::update_settings
578    pub fn update_settings(&self) -> super::builder::config_service_v_2::UpdateSettings {
579        super::builder::config_service_v_2::UpdateSettings::new(self.inner.clone())
580    }
581
582    /// Copies a set of log entries from a log bucket to a Cloud Storage bucket.
583    ///
584    /// # Long running operations
585    ///
586    /// This method is used to start, and/or poll a [long-running Operation].
587    /// The [Working with long-running operations] chapter in the [user guide]
588    /// covers these operations in detail.
589    ///
590    /// [long-running operation]: https://google.aip.dev/151
591    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
592    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
593    pub fn copy_log_entries(&self) -> super::builder::config_service_v_2::CopyLogEntries {
594        super::builder::config_service_v_2::CopyLogEntries::new(self.inner.clone())
595    }
596
597    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
598    ///
599    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
600    pub fn list_operations(&self) -> super::builder::config_service_v_2::ListOperations {
601        super::builder::config_service_v_2::ListOperations::new(self.inner.clone())
602    }
603
604    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
605    ///
606    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
607    pub fn get_operation(&self) -> super::builder::config_service_v_2::GetOperation {
608        super::builder::config_service_v_2::GetOperation::new(self.inner.clone())
609    }
610
611    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
612    ///
613    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
614    pub fn cancel_operation(&self) -> super::builder::config_service_v_2::CancelOperation {
615        super::builder::config_service_v_2::CancelOperation::new(self.inner.clone())
616    }
617}
618
619/// Implements a client for the Cloud Logging API.
620///
621/// # Example
622/// ```
623/// # use google_cloud_logging_v2::client::MetricsServiceV2;
624/// async fn sample(
625/// ) -> anyhow::Result<()> {
626///     let client = MetricsServiceV2::builder().build().await?;
627///     // use `client` to make requests to the Cloud Logging API.
628///     Ok(())
629/// }
630/// ```
631///
632/// # Service Description
633///
634/// Service for configuring logs-based metrics.
635///
636/// # Configuration
637///
638/// To configure `MetricsServiceV2` use the `with_*` methods in the type returned
639/// by [builder()][MetricsServiceV2::builder]. The default configuration should
640/// work for most applications. Common configuration changes include
641///
642/// * [with_endpoint()]: by default this client uses the global default endpoint
643///   (`https://logging.googleapis.com`). Applications using regional
644///   endpoints or running in restricted networks (e.g. a network configured
645///   with [Private Google Access with VPC Service Controls]) may want to
646///   override this default.
647/// * [with_credentials()]: by default this client uses
648///   [Application Default Credentials]. Applications using custom
649///   authentication may need to override this default.
650///
651/// [with_endpoint()]: super::builder::metrics_service_v_2::ClientBuilder::with_endpoint
652/// [with_credentials()]: super::builder::metrics_service_v_2::ClientBuilder::with_credentials
653/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
654/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
655///
656/// # Pooling and Cloning
657///
658/// `MetricsServiceV2` holds a connection pool internally, it is advised to
659/// create one and reuse it. You do not need to wrap `MetricsServiceV2` in
660/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
661/// already uses an `Arc` internally.
662#[derive(Clone, Debug)]
663pub struct MetricsServiceV2 {
664    inner: std::sync::Arc<dyn super::stub::dynamic::MetricsServiceV2>,
665}
666
667impl MetricsServiceV2 {
668    /// Returns a builder for [MetricsServiceV2].
669    ///
670    /// ```
671    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
672    /// # use google_cloud_logging_v2::client::MetricsServiceV2;
673    /// let client = MetricsServiceV2::builder().build().await?;
674    /// # Ok(()) }
675    /// ```
676    pub fn builder() -> super::builder::metrics_service_v_2::ClientBuilder {
677        crate::new_client_builder(super::builder::metrics_service_v_2::client::Factory)
678    }
679
680    /// Creates a new client from the provided stub.
681    ///
682    /// The most common case for calling this function is in tests mocking the
683    /// client's behavior.
684    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
685    where
686        T: super::stub::MetricsServiceV2 + 'static,
687    {
688        Self { inner: stub.into() }
689    }
690
691    pub(crate) async fn new(
692        config: gaxi::options::ClientConfig,
693    ) -> crate::ClientBuilderResult<Self> {
694        let inner = Self::build_inner(config).await?;
695        Ok(Self { inner })
696    }
697
698    async fn build_inner(
699        conf: gaxi::options::ClientConfig,
700    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::MetricsServiceV2>>
701    {
702        if gaxi::options::tracing_enabled(&conf) {
703            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
704        }
705        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
706    }
707
708    async fn build_transport(
709        conf: gaxi::options::ClientConfig,
710    ) -> crate::ClientBuilderResult<impl super::stub::MetricsServiceV2> {
711        super::transport::MetricsServiceV2::new(conf).await
712    }
713
714    async fn build_with_tracing(
715        conf: gaxi::options::ClientConfig,
716    ) -> crate::ClientBuilderResult<impl super::stub::MetricsServiceV2> {
717        Self::build_transport(conf)
718            .await
719            .map(super::tracing::MetricsServiceV2::new)
720    }
721
722    /// Lists logs-based metrics.
723    pub fn list_log_metrics(&self) -> super::builder::metrics_service_v_2::ListLogMetrics {
724        super::builder::metrics_service_v_2::ListLogMetrics::new(self.inner.clone())
725    }
726
727    /// Gets a logs-based metric.
728    pub fn get_log_metric(&self) -> super::builder::metrics_service_v_2::GetLogMetric {
729        super::builder::metrics_service_v_2::GetLogMetric::new(self.inner.clone())
730    }
731
732    /// Creates a logs-based metric.
733    pub fn create_log_metric(&self) -> super::builder::metrics_service_v_2::CreateLogMetric {
734        super::builder::metrics_service_v_2::CreateLogMetric::new(self.inner.clone())
735    }
736
737    /// Creates or updates a logs-based metric.
738    pub fn update_log_metric(&self) -> super::builder::metrics_service_v_2::UpdateLogMetric {
739        super::builder::metrics_service_v_2::UpdateLogMetric::new(self.inner.clone())
740    }
741
742    /// Deletes a logs-based metric.
743    pub fn delete_log_metric(&self) -> super::builder::metrics_service_v_2::DeleteLogMetric {
744        super::builder::metrics_service_v_2::DeleteLogMetric::new(self.inner.clone())
745    }
746
747    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
748    ///
749    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
750    pub fn list_operations(&self) -> super::builder::metrics_service_v_2::ListOperations {
751        super::builder::metrics_service_v_2::ListOperations::new(self.inner.clone())
752    }
753
754    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
755    ///
756    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
757    pub fn get_operation(&self) -> super::builder::metrics_service_v_2::GetOperation {
758        super::builder::metrics_service_v_2::GetOperation::new(self.inner.clone())
759    }
760
761    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
762    ///
763    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
764    pub fn cancel_operation(&self) -> super::builder::metrics_service_v_2::CancelOperation {
765        super::builder::metrics_service_v_2::CancelOperation::new(self.inner.clone())
766    }
767}