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