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