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