google-cloud-logging-v2 1.8.0

Google Cloud Client Libraries for Rust - Cloud Logging API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Cloud Logging API.
///
/// # Example
/// ```
/// # use google_cloud_logging_v2::client::LoggingServiceV2;
/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
///     let client = LoggingServiceV2::builder().build().await?;
///     // use `client` to make requests to the Cloud Logging API.
/// # Ok(()) }
/// ```
///
/// # Service Description
///
/// Service for ingesting and querying logs.
///
/// # Configuration
///
/// To configure `LoggingServiceV2` use the `with_*` methods in the type returned
/// by [builder()][LoggingServiceV2::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://logging.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::logging_service_v_2::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::logging_service_v_2::ClientBuilder::with_credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `LoggingServiceV2` holds a connection pool internally, it is advised to
/// create one and reuse it. You do not need to wrap `LoggingServiceV2` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct LoggingServiceV2 {
    inner: std::sync::Arc<dyn super::stub::dynamic::LoggingServiceV2>,
}

impl LoggingServiceV2 {
    /// Returns a builder for [LoggingServiceV2].
    ///
    /// ```
    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
    /// # use google_cloud_logging_v2::client::LoggingServiceV2;
    /// let client = LoggingServiceV2::builder().build().await?;
    /// # Ok(()) }
    /// ```
    pub fn builder() -> super::builder::logging_service_v_2::ClientBuilder {
        crate::new_client_builder(super::builder::logging_service_v_2::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::LoggingServiceV2 + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::LoggingServiceV2>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::LoggingServiceV2> {
        super::transport::LoggingServiceV2::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::LoggingServiceV2> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::LoggingServiceV2::new)
    }

    /// Deletes all the log entries in a log for the _Default Log Bucket. The log
    /// reappears if it receives new entries. Log entries written shortly before
    /// the delete operation might not be deleted. Entries received after the
    /// delete operation with a timestamp before the operation will be deleted.
    pub fn delete_log(&self) -> super::builder::logging_service_v_2::DeleteLog {
        super::builder::logging_service_v_2::DeleteLog::new(self.inner.clone())
    }

    /// Writes log entries to Logging. This API method is the
    /// only way to send log entries to Logging. This method
    /// is used, directly or indirectly, by the Logging agent
    /// (fluentd) and all logging libraries configured to use Logging.
    /// A single request may contain log entries for a maximum of 1000
    /// different resources (projects, organizations, billing accounts or
    /// folders)
    pub fn write_log_entries(&self) -> super::builder::logging_service_v_2::WriteLogEntries {
        super::builder::logging_service_v_2::WriteLogEntries::new(self.inner.clone())
    }

    /// Lists log entries.  Use this method to retrieve log entries that originated
    /// from a project/folder/organization/billing account.  For ways to export log
    /// entries, see [Exporting
    /// Logs](https://cloud.google.com/logging/docs/export).
    pub fn list_log_entries(&self) -> super::builder::logging_service_v_2::ListLogEntries {
        super::builder::logging_service_v_2::ListLogEntries::new(self.inner.clone())
    }

    /// Lists the descriptors for monitored resource types used by Logging.
    pub fn list_monitored_resource_descriptors(
        &self,
    ) -> super::builder::logging_service_v_2::ListMonitoredResourceDescriptors {
        super::builder::logging_service_v_2::ListMonitoredResourceDescriptors::new(
            self.inner.clone(),
        )
    }

    /// Lists the logs in projects, organizations, folders, or billing accounts.
    /// Only logs that have entries are listed.
    pub fn list_logs(&self) -> super::builder::logging_service_v_2::ListLogs {
        super::builder::logging_service_v_2::ListLogs::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::logging_service_v_2::ListOperations {
        super::builder::logging_service_v_2::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::logging_service_v_2::GetOperation {
        super::builder::logging_service_v_2::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::logging_service_v_2::CancelOperation {
        super::builder::logging_service_v_2::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud Logging API.
///
/// # Example
/// ```
/// # use google_cloud_logging_v2::client::ConfigServiceV2;
/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
///     let client = ConfigServiceV2::builder().build().await?;
///     // use `client` to make requests to the Cloud Logging API.
/// # Ok(()) }
/// ```
///
/// # Service Description
///
/// Service for configuring sinks used to route log entries.
///
/// # Configuration
///
/// To configure `ConfigServiceV2` use the `with_*` methods in the type returned
/// by [builder()][ConfigServiceV2::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://logging.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::config_service_v_2::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::config_service_v_2::ClientBuilder::with_credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `ConfigServiceV2` holds a connection pool internally, it is advised to
/// create one and reuse it. You do not need to wrap `ConfigServiceV2` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct ConfigServiceV2 {
    inner: std::sync::Arc<dyn super::stub::dynamic::ConfigServiceV2>,
}

impl ConfigServiceV2 {
    /// Returns a builder for [ConfigServiceV2].
    ///
    /// ```
    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
    /// # use google_cloud_logging_v2::client::ConfigServiceV2;
    /// let client = ConfigServiceV2::builder().build().await?;
    /// # Ok(()) }
    /// ```
    pub fn builder() -> super::builder::config_service_v_2::ClientBuilder {
        crate::new_client_builder(super::builder::config_service_v_2::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::ConfigServiceV2 + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ConfigServiceV2>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::ConfigServiceV2> {
        super::transport::ConfigServiceV2::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::ConfigServiceV2> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::ConfigServiceV2::new)
    }

    /// Lists log buckets.
    pub fn list_buckets(&self) -> super::builder::config_service_v_2::ListBuckets {
        super::builder::config_service_v_2::ListBuckets::new(self.inner.clone())
    }

    /// Gets a log bucket.
    pub fn get_bucket(&self) -> super::builder::config_service_v_2::GetBucket {
        super::builder::config_service_v_2::GetBucket::new(self.inner.clone())
    }

    /// Creates a log bucket asynchronously that can be used to store log entries.
    ///
    /// After a bucket has been created, the bucket's location cannot be changed.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_bucket_async(&self) -> super::builder::config_service_v_2::CreateBucketAsync {
        super::builder::config_service_v_2::CreateBucketAsync::new(self.inner.clone())
    }

    /// Updates a log bucket asynchronously.
    ///
    /// If the bucket has a `lifecycle_state` of `DELETE_REQUESTED`, then
    /// `FAILED_PRECONDITION` will be returned.
    ///
    /// After a bucket has been created, the bucket's location cannot be changed.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_bucket_async(&self) -> super::builder::config_service_v_2::UpdateBucketAsync {
        super::builder::config_service_v_2::UpdateBucketAsync::new(self.inner.clone())
    }

    /// Creates a log bucket that can be used to store log entries. After a bucket
    /// has been created, the bucket's location cannot be changed.
    pub fn create_bucket(&self) -> super::builder::config_service_v_2::CreateBucket {
        super::builder::config_service_v_2::CreateBucket::new(self.inner.clone())
    }

    /// Updates a log bucket.
    ///
    /// If the bucket has a `lifecycle_state` of `DELETE_REQUESTED`, then
    /// `FAILED_PRECONDITION` will be returned.
    ///
    /// After a bucket has been created, the bucket's location cannot be changed.
    pub fn update_bucket(&self) -> super::builder::config_service_v_2::UpdateBucket {
        super::builder::config_service_v_2::UpdateBucket::new(self.inner.clone())
    }

    /// Deletes a log bucket.
    ///
    /// Changes the bucket's `lifecycle_state` to the `DELETE_REQUESTED` state.
    /// After 7 days, the bucket will be purged and all log entries in the bucket
    /// will be permanently deleted.
    pub fn delete_bucket(&self) -> super::builder::config_service_v_2::DeleteBucket {
        super::builder::config_service_v_2::DeleteBucket::new(self.inner.clone())
    }

    /// Undeletes a log bucket. A bucket that has been deleted can be undeleted
    /// within the grace period of 7 days.
    pub fn undelete_bucket(&self) -> super::builder::config_service_v_2::UndeleteBucket {
        super::builder::config_service_v_2::UndeleteBucket::new(self.inner.clone())
    }

    /// Lists views on a log bucket.
    pub fn list_views(&self) -> super::builder::config_service_v_2::ListViews {
        super::builder::config_service_v_2::ListViews::new(self.inner.clone())
    }

    /// Gets a view on a log bucket..
    pub fn get_view(&self) -> super::builder::config_service_v_2::GetView {
        super::builder::config_service_v_2::GetView::new(self.inner.clone())
    }

    /// Creates a view over log entries in a log bucket. A bucket may contain a
    /// maximum of 30 views.
    pub fn create_view(&self) -> super::builder::config_service_v_2::CreateView {
        super::builder::config_service_v_2::CreateView::new(self.inner.clone())
    }

    /// Updates a view on a log bucket. This method replaces the following fields
    /// in the existing view with values from the new view: `filter`.
    /// If an `UNAVAILABLE` error is returned, this indicates that system is not in
    /// a state where it can update the view. If this occurs, please try again in a
    /// few minutes.
    pub fn update_view(&self) -> super::builder::config_service_v_2::UpdateView {
        super::builder::config_service_v_2::UpdateView::new(self.inner.clone())
    }

    /// Deletes a view on a log bucket.
    /// If an `UNAVAILABLE` error is returned, this indicates that system is not in
    /// a state where it can delete the view. If this occurs, please try again in a
    /// few minutes.
    pub fn delete_view(&self) -> super::builder::config_service_v_2::DeleteView {
        super::builder::config_service_v_2::DeleteView::new(self.inner.clone())
    }

    /// Lists sinks.
    pub fn list_sinks(&self) -> super::builder::config_service_v_2::ListSinks {
        super::builder::config_service_v_2::ListSinks::new(self.inner.clone())
    }

    /// Gets a sink.
    pub fn get_sink(&self) -> super::builder::config_service_v_2::GetSink {
        super::builder::config_service_v_2::GetSink::new(self.inner.clone())
    }

    /// Creates a sink that exports specified log entries to a destination. The
    /// export of newly-ingested log entries begins immediately, unless the sink's
    /// `writer_identity` is not permitted to write to the destination. A sink can
    /// export log entries only from the resource owning the sink.
    pub fn create_sink(&self) -> super::builder::config_service_v_2::CreateSink {
        super::builder::config_service_v_2::CreateSink::new(self.inner.clone())
    }

    /// Updates a sink. This method replaces the following fields in the existing
    /// sink with values from the new sink: `destination`, and `filter`.
    ///
    /// The updated sink might also have a new `writer_identity`; see the
    /// `unique_writer_identity` field.
    pub fn update_sink(&self) -> super::builder::config_service_v_2::UpdateSink {
        super::builder::config_service_v_2::UpdateSink::new(self.inner.clone())
    }

    /// Deletes a sink. If the sink has a unique `writer_identity`, then that
    /// service account is also deleted.
    pub fn delete_sink(&self) -> super::builder::config_service_v_2::DeleteSink {
        super::builder::config_service_v_2::DeleteSink::new(self.inner.clone())
    }

    /// Asynchronously creates a linked dataset in BigQuery which makes it possible
    /// to use BigQuery to read the logs stored in the log bucket. A log bucket may
    /// currently only contain one link.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_link(&self) -> super::builder::config_service_v_2::CreateLink {
        super::builder::config_service_v_2::CreateLink::new(self.inner.clone())
    }

    /// Deletes a link. This will also delete the corresponding BigQuery linked
    /// dataset.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_link(&self) -> super::builder::config_service_v_2::DeleteLink {
        super::builder::config_service_v_2::DeleteLink::new(self.inner.clone())
    }

    /// Lists links.
    pub fn list_links(&self) -> super::builder::config_service_v_2::ListLinks {
        super::builder::config_service_v_2::ListLinks::new(self.inner.clone())
    }

    /// Gets a link.
    pub fn get_link(&self) -> super::builder::config_service_v_2::GetLink {
        super::builder::config_service_v_2::GetLink::new(self.inner.clone())
    }

    /// Lists all the exclusions on the _Default sink in a parent resource.
    pub fn list_exclusions(&self) -> super::builder::config_service_v_2::ListExclusions {
        super::builder::config_service_v_2::ListExclusions::new(self.inner.clone())
    }

    /// Gets the description of an exclusion in the _Default sink.
    pub fn get_exclusion(&self) -> super::builder::config_service_v_2::GetExclusion {
        super::builder::config_service_v_2::GetExclusion::new(self.inner.clone())
    }

    /// Creates a new exclusion in the _Default sink in a specified parent
    /// resource. Only log entries belonging to that resource can be excluded. You
    /// can have up to 10 exclusions in a resource.
    pub fn create_exclusion(&self) -> super::builder::config_service_v_2::CreateExclusion {
        super::builder::config_service_v_2::CreateExclusion::new(self.inner.clone())
    }

    /// Changes one or more properties of an existing exclusion in the _Default
    /// sink.
    pub fn update_exclusion(&self) -> super::builder::config_service_v_2::UpdateExclusion {
        super::builder::config_service_v_2::UpdateExclusion::new(self.inner.clone())
    }

    /// Deletes an exclusion in the _Default sink.
    pub fn delete_exclusion(&self) -> super::builder::config_service_v_2::DeleteExclusion {
        super::builder::config_service_v_2::DeleteExclusion::new(self.inner.clone())
    }

    /// Gets the Logging CMEK settings for the given resource.
    ///
    /// Note: CMEK for the Log Router can be configured for Google Cloud projects,
    /// folders, organizations and billing accounts. Once configured for an
    /// organization, it applies to all projects and folders in the Google Cloud
    /// organization.
    ///
    /// See [Enabling CMEK for Log
    /// Router](https://cloud.google.com/logging/docs/routing/managed-encryption)
    /// for more information.
    pub fn get_cmek_settings(&self) -> super::builder::config_service_v_2::GetCmekSettings {
        super::builder::config_service_v_2::GetCmekSettings::new(self.inner.clone())
    }

    /// Updates the Log Router CMEK settings for the given resource.
    ///
    /// Note: CMEK for the Log Router can currently only be configured for Google
    /// Cloud organizations. Once configured, it applies to all projects and
    /// folders in the Google Cloud organization.
    ///
    /// [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings]
    /// will fail if 1) `kms_key_name` is invalid, or 2) the associated service
    /// account does not have the required
    /// `roles/cloudkms.cryptoKeyEncrypterDecrypter` role assigned for the key, or
    /// 3) access to the key is disabled.
    ///
    /// See [Enabling CMEK for Log
    /// Router](https://cloud.google.com/logging/docs/routing/managed-encryption)
    /// for more information.
    ///
    /// [google.logging.v2.ConfigServiceV2.UpdateCmekSettings]: crate::client::ConfigServiceV2::update_cmek_settings
    pub fn update_cmek_settings(&self) -> super::builder::config_service_v_2::UpdateCmekSettings {
        super::builder::config_service_v_2::UpdateCmekSettings::new(self.inner.clone())
    }

    /// Gets the Log Router settings for the given resource.
    ///
    /// Note: Settings for the Log Router can be get for Google Cloud projects,
    /// folders, organizations and billing accounts. Currently it can only be
    /// configured for organizations. Once configured for an organization, it
    /// applies to all projects and folders in the Google Cloud organization.
    ///
    /// See [Enabling CMEK for Log
    /// Router](https://cloud.google.com/logging/docs/routing/managed-encryption)
    /// for more information.
    pub fn get_settings(&self) -> super::builder::config_service_v_2::GetSettings {
        super::builder::config_service_v_2::GetSettings::new(self.inner.clone())
    }

    /// Updates the Log Router settings for the given resource.
    ///
    /// Note: Settings for the Log Router can currently only be configured for
    /// Google Cloud organizations. Once configured, it applies to all projects and
    /// folders in the Google Cloud organization.
    ///
    /// [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings]
    /// will fail if 1) `kms_key_name` is invalid, or 2) the associated service
    /// account does not have the required
    /// `roles/cloudkms.cryptoKeyEncrypterDecrypter` role assigned for the key, or
    /// 3) access to the key is disabled. 4) `location_id` is not supported by
    /// Logging. 5) `location_id` violate OrgPolicy.
    ///
    /// See [Enabling CMEK for Log
    /// Router](https://cloud.google.com/logging/docs/routing/managed-encryption)
    /// for more information.
    ///
    /// [google.logging.v2.ConfigServiceV2.UpdateSettings]: crate::client::ConfigServiceV2::update_settings
    pub fn update_settings(&self) -> super::builder::config_service_v_2::UpdateSettings {
        super::builder::config_service_v_2::UpdateSettings::new(self.inner.clone())
    }

    /// Copies a set of log entries from a log bucket to a Cloud Storage bucket.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn copy_log_entries(&self) -> super::builder::config_service_v_2::CopyLogEntries {
        super::builder::config_service_v_2::CopyLogEntries::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::config_service_v_2::ListOperations {
        super::builder::config_service_v_2::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::config_service_v_2::GetOperation {
        super::builder::config_service_v_2::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::config_service_v_2::CancelOperation {
        super::builder::config_service_v_2::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud Logging API.
///
/// # Example
/// ```
/// # use google_cloud_logging_v2::client::MetricsServiceV2;
/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
///     let client = MetricsServiceV2::builder().build().await?;
///     // use `client` to make requests to the Cloud Logging API.
/// # Ok(()) }
/// ```
///
/// # Service Description
///
/// Service for configuring logs-based metrics.
///
/// # Configuration
///
/// To configure `MetricsServiceV2` use the `with_*` methods in the type returned
/// by [builder()][MetricsServiceV2::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://logging.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::metrics_service_v_2::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::metrics_service_v_2::ClientBuilder::with_credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `MetricsServiceV2` holds a connection pool internally, it is advised to
/// create one and reuse it. You do not need to wrap `MetricsServiceV2` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct MetricsServiceV2 {
    inner: std::sync::Arc<dyn super::stub::dynamic::MetricsServiceV2>,
}

impl MetricsServiceV2 {
    /// Returns a builder for [MetricsServiceV2].
    ///
    /// ```
    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
    /// # use google_cloud_logging_v2::client::MetricsServiceV2;
    /// let client = MetricsServiceV2::builder().build().await?;
    /// # Ok(()) }
    /// ```
    pub fn builder() -> super::builder::metrics_service_v_2::ClientBuilder {
        crate::new_client_builder(super::builder::metrics_service_v_2::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::MetricsServiceV2 + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::MetricsServiceV2>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::MetricsServiceV2> {
        super::transport::MetricsServiceV2::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::MetricsServiceV2> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::MetricsServiceV2::new)
    }

    /// Lists logs-based metrics.
    pub fn list_log_metrics(&self) -> super::builder::metrics_service_v_2::ListLogMetrics {
        super::builder::metrics_service_v_2::ListLogMetrics::new(self.inner.clone())
    }

    /// Gets a logs-based metric.
    pub fn get_log_metric(&self) -> super::builder::metrics_service_v_2::GetLogMetric {
        super::builder::metrics_service_v_2::GetLogMetric::new(self.inner.clone())
    }

    /// Creates a logs-based metric.
    pub fn create_log_metric(&self) -> super::builder::metrics_service_v_2::CreateLogMetric {
        super::builder::metrics_service_v_2::CreateLogMetric::new(self.inner.clone())
    }

    /// Creates or updates a logs-based metric.
    pub fn update_log_metric(&self) -> super::builder::metrics_service_v_2::UpdateLogMetric {
        super::builder::metrics_service_v_2::UpdateLogMetric::new(self.inner.clone())
    }

    /// Deletes a logs-based metric.
    pub fn delete_log_metric(&self) -> super::builder::metrics_service_v_2::DeleteLogMetric {
        super::builder::metrics_service_v_2::DeleteLogMetric::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::metrics_service_v_2::ListOperations {
        super::builder::metrics_service_v_2::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::metrics_service_v_2::GetOperation {
        super::builder::metrics_service_v_2::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::metrics_service_v_2::CancelOperation {
        super::builder::metrics_service_v_2::CancelOperation::new(self.inner.clone())
    }
}