google_cloud_monitoring_v3/
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 Monitoring API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_monitoring_v3::client::AlertPolicyService;
25/// let client = AlertPolicyService::builder().build().await?;
26/// // use `client` to make requests to the Cloud Monitoring API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// The AlertPolicyService API is used to manage (list, create, delete,
33/// edit) alert policies in Cloud Monitoring. An alerting policy is
34/// a description of the conditions under which some aspect of your
35/// system is considered to be "unhealthy" and the ways to notify
36/// people or services about this state. In addition to using this API, alert
37/// policies can also be managed through
38/// [Cloud Monitoring](https://cloud.google.com/monitoring/docs/),
39/// which can be reached by clicking the "Monitoring" tab in
40/// [Cloud console](https://console.cloud.google.com/).
41///
42/// # Configuration
43///
44/// To configure `AlertPolicyService` use the `with_*` methods in the type returned
45/// by [builder()][AlertPolicyService::builder]. The default configuration should
46/// work for most applications. Common configuration changes include
47///
48/// * [with_endpoint()]: by default this client uses the global default endpoint
49///   (`https://monitoring.googleapis.com`). Applications using regional
50///   endpoints or running in restricted networks (e.g. a network configured
51//    with [Private Google Access with VPC Service Controls]) may want to
52///   override this default.
53/// * [with_credentials()]: by default this client uses
54///   [Application Default Credentials]. Applications using custom
55///   authentication may need to override this default.
56///
57/// [with_endpoint()]: super::builder::alert_policy_service::ClientBuilder::with_endpoint
58/// [with_credentials()]: super::builder::alert_policy_service::ClientBuilder::credentials
59/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
60/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
61///
62/// # Pooling and Cloning
63///
64/// `AlertPolicyService` holds a connection pool internally, it is advised to
65/// create one and the reuse it.  You do not need to wrap `AlertPolicyService` in
66/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
67/// already uses an `Arc` internally.
68#[derive(Clone, Debug)]
69pub struct AlertPolicyService {
70    inner: std::sync::Arc<dyn super::stub::dynamic::AlertPolicyService>,
71}
72
73impl AlertPolicyService {
74    /// Returns a builder for [AlertPolicyService].
75    ///
76    /// ```
77    /// # tokio_test::block_on(async {
78    /// # use google_cloud_monitoring_v3::client::AlertPolicyService;
79    /// let client = AlertPolicyService::builder().build().await?;
80    /// # gax::client_builder::Result::<()>::Ok(()) });
81    /// ```
82    pub fn builder() -> super::builder::alert_policy_service::ClientBuilder {
83        gax::client_builder::internal::new_builder(
84            super::builder::alert_policy_service::client::Factory,
85        )
86    }
87
88    /// Creates a new client from the provided stub.
89    ///
90    /// The most common case for calling this function is in tests mocking the
91    /// client's behavior.
92    pub fn from_stub<T>(stub: T) -> Self
93    where
94        T: super::stub::AlertPolicyService + 'static,
95    {
96        Self {
97            inner: std::sync::Arc::new(stub),
98        }
99    }
100
101    pub(crate) async fn new(
102        config: gaxi::options::ClientConfig,
103    ) -> gax::client_builder::Result<Self> {
104        let inner = Self::build_inner(config).await?;
105        Ok(Self { inner })
106    }
107
108    async fn build_inner(
109        conf: gaxi::options::ClientConfig,
110    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::AlertPolicyService>>
111    {
112        if gaxi::options::tracing_enabled(&conf) {
113            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
114        }
115        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
116    }
117
118    async fn build_transport(
119        conf: gaxi::options::ClientConfig,
120    ) -> gax::client_builder::Result<impl super::stub::AlertPolicyService> {
121        super::transport::AlertPolicyService::new(conf).await
122    }
123
124    async fn build_with_tracing(
125        conf: gaxi::options::ClientConfig,
126    ) -> gax::client_builder::Result<impl super::stub::AlertPolicyService> {
127        Self::build_transport(conf)
128            .await
129            .map(super::tracing::AlertPolicyService::new)
130    }
131
132    /// Lists the existing alerting policies for the workspace.
133    pub fn list_alert_policies(&self) -> super::builder::alert_policy_service::ListAlertPolicies {
134        super::builder::alert_policy_service::ListAlertPolicies::new(self.inner.clone())
135    }
136
137    /// Gets a single alerting policy.
138    pub fn get_alert_policy(&self) -> super::builder::alert_policy_service::GetAlertPolicy {
139        super::builder::alert_policy_service::GetAlertPolicy::new(self.inner.clone())
140    }
141
142    /// Creates a new alerting policy.
143    ///
144    /// Design your application to single-thread API calls that modify the state of
145    /// alerting policies in a single project. This includes calls to
146    /// CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
147    pub fn create_alert_policy(&self) -> super::builder::alert_policy_service::CreateAlertPolicy {
148        super::builder::alert_policy_service::CreateAlertPolicy::new(self.inner.clone())
149    }
150
151    /// Deletes an alerting policy.
152    ///
153    /// Design your application to single-thread API calls that modify the state of
154    /// alerting policies in a single project. This includes calls to
155    /// CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
156    pub fn delete_alert_policy(&self) -> super::builder::alert_policy_service::DeleteAlertPolicy {
157        super::builder::alert_policy_service::DeleteAlertPolicy::new(self.inner.clone())
158    }
159
160    /// Updates an alerting policy. You can either replace the entire policy with
161    /// a new one or replace only certain fields in the current alerting policy by
162    /// specifying the fields to be updated via `updateMask`. Returns the
163    /// updated alerting policy.
164    ///
165    /// Design your application to single-thread API calls that modify the state of
166    /// alerting policies in a single project. This includes calls to
167    /// CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
168    pub fn update_alert_policy(&self) -> super::builder::alert_policy_service::UpdateAlertPolicy {
169        super::builder::alert_policy_service::UpdateAlertPolicy::new(self.inner.clone())
170    }
171}
172
173/// Implements a client for the Cloud Monitoring API.
174///
175/// # Example
176/// ```
177/// # tokio_test::block_on(async {
178/// # use google_cloud_monitoring_v3::client::GroupService;
179/// let client = GroupService::builder().build().await?;
180/// // use `client` to make requests to the Cloud Monitoring API.
181/// # gax::client_builder::Result::<()>::Ok(()) });
182/// ```
183///
184/// # Service Description
185///
186/// The Group API lets you inspect and manage your
187/// [groups](#google.monitoring.v3.Group).
188///
189/// A group is a named filter that is used to identify
190/// a collection of monitored resources. Groups are typically used to
191/// mirror the physical and/or logical topology of the environment.
192/// Because group membership is computed dynamically, monitored
193/// resources that are started in the future are automatically placed
194/// in matching groups. By using a group to name monitored resources in,
195/// for example, an alert policy, the target of that alert policy is
196/// updated automatically as monitored resources are added and removed
197/// from the infrastructure.
198///
199/// # Configuration
200///
201/// To configure `GroupService` use the `with_*` methods in the type returned
202/// by [builder()][GroupService::builder]. The default configuration should
203/// work for most applications. Common configuration changes include
204///
205/// * [with_endpoint()]: by default this client uses the global default endpoint
206///   (`https://monitoring.googleapis.com`). Applications using regional
207///   endpoints or running in restricted networks (e.g. a network configured
208//    with [Private Google Access with VPC Service Controls]) may want to
209///   override this default.
210/// * [with_credentials()]: by default this client uses
211///   [Application Default Credentials]. Applications using custom
212///   authentication may need to override this default.
213///
214/// [with_endpoint()]: super::builder::group_service::ClientBuilder::with_endpoint
215/// [with_credentials()]: super::builder::group_service::ClientBuilder::credentials
216/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
217/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
218///
219/// # Pooling and Cloning
220///
221/// `GroupService` holds a connection pool internally, it is advised to
222/// create one and the reuse it.  You do not need to wrap `GroupService` in
223/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
224/// already uses an `Arc` internally.
225#[derive(Clone, Debug)]
226pub struct GroupService {
227    inner: std::sync::Arc<dyn super::stub::dynamic::GroupService>,
228}
229
230impl GroupService {
231    /// Returns a builder for [GroupService].
232    ///
233    /// ```
234    /// # tokio_test::block_on(async {
235    /// # use google_cloud_monitoring_v3::client::GroupService;
236    /// let client = GroupService::builder().build().await?;
237    /// # gax::client_builder::Result::<()>::Ok(()) });
238    /// ```
239    pub fn builder() -> super::builder::group_service::ClientBuilder {
240        gax::client_builder::internal::new_builder(super::builder::group_service::client::Factory)
241    }
242
243    /// Creates a new client from the provided stub.
244    ///
245    /// The most common case for calling this function is in tests mocking the
246    /// client's behavior.
247    pub fn from_stub<T>(stub: T) -> Self
248    where
249        T: super::stub::GroupService + 'static,
250    {
251        Self {
252            inner: std::sync::Arc::new(stub),
253        }
254    }
255
256    pub(crate) async fn new(
257        config: gaxi::options::ClientConfig,
258    ) -> gax::client_builder::Result<Self> {
259        let inner = Self::build_inner(config).await?;
260        Ok(Self { inner })
261    }
262
263    async fn build_inner(
264        conf: gaxi::options::ClientConfig,
265    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::GroupService>> {
266        if gaxi::options::tracing_enabled(&conf) {
267            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
268        }
269        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
270    }
271
272    async fn build_transport(
273        conf: gaxi::options::ClientConfig,
274    ) -> gax::client_builder::Result<impl super::stub::GroupService> {
275        super::transport::GroupService::new(conf).await
276    }
277
278    async fn build_with_tracing(
279        conf: gaxi::options::ClientConfig,
280    ) -> gax::client_builder::Result<impl super::stub::GroupService> {
281        Self::build_transport(conf)
282            .await
283            .map(super::tracing::GroupService::new)
284    }
285
286    /// Lists the existing groups.
287    pub fn list_groups(&self) -> super::builder::group_service::ListGroups {
288        super::builder::group_service::ListGroups::new(self.inner.clone())
289    }
290
291    /// Gets a single group.
292    pub fn get_group(&self) -> super::builder::group_service::GetGroup {
293        super::builder::group_service::GetGroup::new(self.inner.clone())
294    }
295
296    /// Creates a new group.
297    pub fn create_group(&self) -> super::builder::group_service::CreateGroup {
298        super::builder::group_service::CreateGroup::new(self.inner.clone())
299    }
300
301    /// Updates an existing group.
302    /// You can change any group attributes except `name`.
303    pub fn update_group(&self) -> super::builder::group_service::UpdateGroup {
304        super::builder::group_service::UpdateGroup::new(self.inner.clone())
305    }
306
307    /// Deletes an existing group.
308    pub fn delete_group(&self) -> super::builder::group_service::DeleteGroup {
309        super::builder::group_service::DeleteGroup::new(self.inner.clone())
310    }
311
312    /// Lists the monitored resources that are members of a group.
313    pub fn list_group_members(&self) -> super::builder::group_service::ListGroupMembers {
314        super::builder::group_service::ListGroupMembers::new(self.inner.clone())
315    }
316}
317
318/// Implements a client for the Cloud Monitoring API.
319///
320/// # Example
321/// ```
322/// # tokio_test::block_on(async {
323/// # use google_cloud_monitoring_v3::client::MetricService;
324/// let client = MetricService::builder().build().await?;
325/// // use `client` to make requests to the Cloud Monitoring API.
326/// # gax::client_builder::Result::<()>::Ok(()) });
327/// ```
328///
329/// # Service Description
330///
331/// Manages metric descriptors, monitored resource descriptors, and
332/// time series data.
333///
334/// # Configuration
335///
336/// To configure `MetricService` use the `with_*` methods in the type returned
337/// by [builder()][MetricService::builder]. The default configuration should
338/// work for most applications. Common configuration changes include
339///
340/// * [with_endpoint()]: by default this client uses the global default endpoint
341///   (`https://monitoring.googleapis.com`). Applications using regional
342///   endpoints or running in restricted networks (e.g. a network configured
343//    with [Private Google Access with VPC Service Controls]) may want to
344///   override this default.
345/// * [with_credentials()]: by default this client uses
346///   [Application Default Credentials]. Applications using custom
347///   authentication may need to override this default.
348///
349/// [with_endpoint()]: super::builder::metric_service::ClientBuilder::with_endpoint
350/// [with_credentials()]: super::builder::metric_service::ClientBuilder::credentials
351/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
352/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
353///
354/// # Pooling and Cloning
355///
356/// `MetricService` holds a connection pool internally, it is advised to
357/// create one and the reuse it.  You do not need to wrap `MetricService` in
358/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
359/// already uses an `Arc` internally.
360#[derive(Clone, Debug)]
361pub struct MetricService {
362    inner: std::sync::Arc<dyn super::stub::dynamic::MetricService>,
363}
364
365impl MetricService {
366    /// Returns a builder for [MetricService].
367    ///
368    /// ```
369    /// # tokio_test::block_on(async {
370    /// # use google_cloud_monitoring_v3::client::MetricService;
371    /// let client = MetricService::builder().build().await?;
372    /// # gax::client_builder::Result::<()>::Ok(()) });
373    /// ```
374    pub fn builder() -> super::builder::metric_service::ClientBuilder {
375        gax::client_builder::internal::new_builder(super::builder::metric_service::client::Factory)
376    }
377
378    /// Creates a new client from the provided stub.
379    ///
380    /// The most common case for calling this function is in tests mocking the
381    /// client's behavior.
382    pub fn from_stub<T>(stub: T) -> Self
383    where
384        T: super::stub::MetricService + 'static,
385    {
386        Self {
387            inner: std::sync::Arc::new(stub),
388        }
389    }
390
391    pub(crate) async fn new(
392        config: gaxi::options::ClientConfig,
393    ) -> gax::client_builder::Result<Self> {
394        let inner = Self::build_inner(config).await?;
395        Ok(Self { inner })
396    }
397
398    async fn build_inner(
399        conf: gaxi::options::ClientConfig,
400    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::MetricService>> {
401        if gaxi::options::tracing_enabled(&conf) {
402            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
403        }
404        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
405    }
406
407    async fn build_transport(
408        conf: gaxi::options::ClientConfig,
409    ) -> gax::client_builder::Result<impl super::stub::MetricService> {
410        super::transport::MetricService::new(conf).await
411    }
412
413    async fn build_with_tracing(
414        conf: gaxi::options::ClientConfig,
415    ) -> gax::client_builder::Result<impl super::stub::MetricService> {
416        Self::build_transport(conf)
417            .await
418            .map(super::tracing::MetricService::new)
419    }
420
421    /// Lists monitored resource descriptors that match a filter.
422    pub fn list_monitored_resource_descriptors(
423        &self,
424    ) -> super::builder::metric_service::ListMonitoredResourceDescriptors {
425        super::builder::metric_service::ListMonitoredResourceDescriptors::new(self.inner.clone())
426    }
427
428    /// Gets a single monitored resource descriptor.
429    pub fn get_monitored_resource_descriptor(
430        &self,
431    ) -> super::builder::metric_service::GetMonitoredResourceDescriptor {
432        super::builder::metric_service::GetMonitoredResourceDescriptor::new(self.inner.clone())
433    }
434
435    /// Lists metric descriptors that match a filter.
436    pub fn list_metric_descriptors(&self) -> super::builder::metric_service::ListMetricDescriptors {
437        super::builder::metric_service::ListMetricDescriptors::new(self.inner.clone())
438    }
439
440    /// Gets a single metric descriptor.
441    pub fn get_metric_descriptor(&self) -> super::builder::metric_service::GetMetricDescriptor {
442        super::builder::metric_service::GetMetricDescriptor::new(self.inner.clone())
443    }
444
445    /// Creates a new metric descriptor.
446    /// The creation is executed asynchronously.
447    /// User-created metric descriptors define
448    /// [custom metrics](https://cloud.google.com/monitoring/custom-metrics).
449    /// The metric descriptor is updated if it already exists,
450    /// except that metric labels are never removed.
451    pub fn create_metric_descriptor(
452        &self,
453    ) -> super::builder::metric_service::CreateMetricDescriptor {
454        super::builder::metric_service::CreateMetricDescriptor::new(self.inner.clone())
455    }
456
457    /// Deletes a metric descriptor. Only user-created
458    /// [custom metrics](https://cloud.google.com/monitoring/custom-metrics) can be
459    /// deleted.
460    pub fn delete_metric_descriptor(
461        &self,
462    ) -> super::builder::metric_service::DeleteMetricDescriptor {
463        super::builder::metric_service::DeleteMetricDescriptor::new(self.inner.clone())
464    }
465
466    /// Lists time series that match a filter.
467    pub fn list_time_series(&self) -> super::builder::metric_service::ListTimeSeries {
468        super::builder::metric_service::ListTimeSeries::new(self.inner.clone())
469    }
470
471    /// Creates or adds data to one or more time series.
472    /// The response is empty if all time series in the request were written.
473    /// If any time series could not be written, a corresponding failure message is
474    /// included in the error response.
475    /// This method does not support
476    /// [resource locations constraint of an organization
477    /// policy](https://cloud.google.com/resource-manager/docs/organization-policy/defining-locations#setting_the_organization_policy).
478    pub fn create_time_series(&self) -> super::builder::metric_service::CreateTimeSeries {
479        super::builder::metric_service::CreateTimeSeries::new(self.inner.clone())
480    }
481
482    /// Creates or adds data to one or more service time series. A service time
483    /// series is a time series for a metric from a Google Cloud service. The
484    /// response is empty if all time series in the request were written. If any
485    /// time series could not be written, a corresponding failure message is
486    /// included in the error response. This endpoint rejects writes to
487    /// user-defined metrics.
488    /// This method is only for use by Google Cloud services. Use
489    /// [projects.timeSeries.create][google.monitoring.v3.MetricService.CreateTimeSeries]
490    /// instead.
491    ///
492    /// [google.monitoring.v3.MetricService.CreateTimeSeries]: crate::client::MetricService::create_time_series
493    pub fn create_service_time_series(
494        &self,
495    ) -> super::builder::metric_service::CreateServiceTimeSeries {
496        super::builder::metric_service::CreateServiceTimeSeries::new(self.inner.clone())
497    }
498}
499
500/// Implements a client for the Cloud Monitoring API.
501///
502/// # Example
503/// ```
504/// # tokio_test::block_on(async {
505/// # use google_cloud_monitoring_v3::client::NotificationChannelService;
506/// let client = NotificationChannelService::builder().build().await?;
507/// // use `client` to make requests to the Cloud Monitoring API.
508/// # gax::client_builder::Result::<()>::Ok(()) });
509/// ```
510///
511/// # Service Description
512///
513/// The Notification Channel API provides access to configuration that
514/// controls how messages related to incidents are sent.
515///
516/// # Configuration
517///
518/// To configure `NotificationChannelService` use the `with_*` methods in the type returned
519/// by [builder()][NotificationChannelService::builder]. The default configuration should
520/// work for most applications. Common configuration changes include
521///
522/// * [with_endpoint()]: by default this client uses the global default endpoint
523///   (`https://monitoring.googleapis.com`). Applications using regional
524///   endpoints or running in restricted networks (e.g. a network configured
525//    with [Private Google Access with VPC Service Controls]) may want to
526///   override this default.
527/// * [with_credentials()]: by default this client uses
528///   [Application Default Credentials]. Applications using custom
529///   authentication may need to override this default.
530///
531/// [with_endpoint()]: super::builder::notification_channel_service::ClientBuilder::with_endpoint
532/// [with_credentials()]: super::builder::notification_channel_service::ClientBuilder::credentials
533/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
534/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
535///
536/// # Pooling and Cloning
537///
538/// `NotificationChannelService` holds a connection pool internally, it is advised to
539/// create one and the reuse it.  You do not need to wrap `NotificationChannelService` in
540/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
541/// already uses an `Arc` internally.
542#[derive(Clone, Debug)]
543pub struct NotificationChannelService {
544    inner: std::sync::Arc<dyn super::stub::dynamic::NotificationChannelService>,
545}
546
547impl NotificationChannelService {
548    /// Returns a builder for [NotificationChannelService].
549    ///
550    /// ```
551    /// # tokio_test::block_on(async {
552    /// # use google_cloud_monitoring_v3::client::NotificationChannelService;
553    /// let client = NotificationChannelService::builder().build().await?;
554    /// # gax::client_builder::Result::<()>::Ok(()) });
555    /// ```
556    pub fn builder() -> super::builder::notification_channel_service::ClientBuilder {
557        gax::client_builder::internal::new_builder(
558            super::builder::notification_channel_service::client::Factory,
559        )
560    }
561
562    /// Creates a new client from the provided stub.
563    ///
564    /// The most common case for calling this function is in tests mocking the
565    /// client's behavior.
566    pub fn from_stub<T>(stub: T) -> Self
567    where
568        T: super::stub::NotificationChannelService + 'static,
569    {
570        Self {
571            inner: std::sync::Arc::new(stub),
572        }
573    }
574
575    pub(crate) async fn new(
576        config: gaxi::options::ClientConfig,
577    ) -> gax::client_builder::Result<Self> {
578        let inner = Self::build_inner(config).await?;
579        Ok(Self { inner })
580    }
581
582    async fn build_inner(
583        conf: gaxi::options::ClientConfig,
584    ) -> gax::client_builder::Result<
585        std::sync::Arc<dyn super::stub::dynamic::NotificationChannelService>,
586    > {
587        if gaxi::options::tracing_enabled(&conf) {
588            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
589        }
590        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
591    }
592
593    async fn build_transport(
594        conf: gaxi::options::ClientConfig,
595    ) -> gax::client_builder::Result<impl super::stub::NotificationChannelService> {
596        super::transport::NotificationChannelService::new(conf).await
597    }
598
599    async fn build_with_tracing(
600        conf: gaxi::options::ClientConfig,
601    ) -> gax::client_builder::Result<impl super::stub::NotificationChannelService> {
602        Self::build_transport(conf)
603            .await
604            .map(super::tracing::NotificationChannelService::new)
605    }
606
607    /// Lists the descriptors for supported channel types. The use of descriptors
608    /// makes it possible for new channel types to be dynamically added.
609    pub fn list_notification_channel_descriptors(
610        &self,
611    ) -> super::builder::notification_channel_service::ListNotificationChannelDescriptors {
612        super::builder::notification_channel_service::ListNotificationChannelDescriptors::new(
613            self.inner.clone(),
614        )
615    }
616
617    /// Gets a single channel descriptor. The descriptor indicates which fields
618    /// are expected / permitted for a notification channel of the given type.
619    pub fn get_notification_channel_descriptor(
620        &self,
621    ) -> super::builder::notification_channel_service::GetNotificationChannelDescriptor {
622        super::builder::notification_channel_service::GetNotificationChannelDescriptor::new(
623            self.inner.clone(),
624        )
625    }
626
627    /// Lists the notification channels that have been created for the project.
628    /// To list the types of notification channels that are supported, use
629    /// the `ListNotificationChannelDescriptors` method.
630    pub fn list_notification_channels(
631        &self,
632    ) -> super::builder::notification_channel_service::ListNotificationChannels {
633        super::builder::notification_channel_service::ListNotificationChannels::new(
634            self.inner.clone(),
635        )
636    }
637
638    /// Gets a single notification channel. The channel includes the relevant
639    /// configuration details with which the channel was created. However, the
640    /// response may truncate or omit passwords, API keys, or other private key
641    /// matter and thus the response may not be 100% identical to the information
642    /// that was supplied in the call to the create method.
643    pub fn get_notification_channel(
644        &self,
645    ) -> super::builder::notification_channel_service::GetNotificationChannel {
646        super::builder::notification_channel_service::GetNotificationChannel::new(
647            self.inner.clone(),
648        )
649    }
650
651    /// Creates a new notification channel, representing a single notification
652    /// endpoint such as an email address, SMS number, or PagerDuty service.
653    ///
654    /// Design your application to single-thread API calls that modify the state of
655    /// notification channels in a single project. This includes calls to
656    /// CreateNotificationChannel, DeleteNotificationChannel and
657    /// UpdateNotificationChannel.
658    pub fn create_notification_channel(
659        &self,
660    ) -> super::builder::notification_channel_service::CreateNotificationChannel {
661        super::builder::notification_channel_service::CreateNotificationChannel::new(
662            self.inner.clone(),
663        )
664    }
665
666    /// Updates a notification channel. Fields not specified in the field mask
667    /// remain unchanged.
668    ///
669    /// Design your application to single-thread API calls that modify the state of
670    /// notification channels in a single project. This includes calls to
671    /// CreateNotificationChannel, DeleteNotificationChannel and
672    /// UpdateNotificationChannel.
673    pub fn update_notification_channel(
674        &self,
675    ) -> super::builder::notification_channel_service::UpdateNotificationChannel {
676        super::builder::notification_channel_service::UpdateNotificationChannel::new(
677            self.inner.clone(),
678        )
679    }
680
681    /// Deletes a notification channel.
682    ///
683    /// Design your application to single-thread API calls that modify the state of
684    /// notification channels in a single project. This includes calls to
685    /// CreateNotificationChannel, DeleteNotificationChannel and
686    /// UpdateNotificationChannel.
687    pub fn delete_notification_channel(
688        &self,
689    ) -> super::builder::notification_channel_service::DeleteNotificationChannel {
690        super::builder::notification_channel_service::DeleteNotificationChannel::new(
691            self.inner.clone(),
692        )
693    }
694
695    /// Causes a verification code to be delivered to the channel. The code
696    /// can then be supplied in `VerifyNotificationChannel` to verify the channel.
697    pub fn send_notification_channel_verification_code(
698        &self,
699    ) -> super::builder::notification_channel_service::SendNotificationChannelVerificationCode {
700        super::builder::notification_channel_service::SendNotificationChannelVerificationCode::new(
701            self.inner.clone(),
702        )
703    }
704
705    /// Requests a verification code for an already verified channel that can then
706    /// be used in a call to VerifyNotificationChannel() on a different channel
707    /// with an equivalent identity in the same or in a different project. This
708    /// makes it possible to copy a channel between projects without requiring
709    /// manual reverification of the channel. If the channel is not in the
710    /// verified state, this method will fail (in other words, this may only be
711    /// used if the SendNotificationChannelVerificationCode and
712    /// VerifyNotificationChannel paths have already been used to put the given
713    /// channel into the verified state).
714    ///
715    /// There is no guarantee that the verification codes returned by this method
716    /// will be of a similar structure or form as the ones that are delivered
717    /// to the channel via SendNotificationChannelVerificationCode; while
718    /// VerifyNotificationChannel() will recognize both the codes delivered via
719    /// SendNotificationChannelVerificationCode() and returned from
720    /// GetNotificationChannelVerificationCode(), it is typically the case that
721    /// the verification codes delivered via
722    /// SendNotificationChannelVerificationCode() will be shorter and also
723    /// have a shorter expiration (e.g. codes such as "G-123456") whereas
724    /// GetVerificationCode() will typically return a much longer, websafe base
725    /// 64 encoded string that has a longer expiration time.
726    pub fn get_notification_channel_verification_code(
727        &self,
728    ) -> super::builder::notification_channel_service::GetNotificationChannelVerificationCode {
729        super::builder::notification_channel_service::GetNotificationChannelVerificationCode::new(
730            self.inner.clone(),
731        )
732    }
733
734    /// Verifies a `NotificationChannel` by proving receipt of the code
735    /// delivered to the channel as a result of calling
736    /// `SendNotificationChannelVerificationCode`.
737    pub fn verify_notification_channel(
738        &self,
739    ) -> super::builder::notification_channel_service::VerifyNotificationChannel {
740        super::builder::notification_channel_service::VerifyNotificationChannel::new(
741            self.inner.clone(),
742        )
743    }
744}
745
746/// Implements a client for the Cloud Monitoring API.
747///
748/// # Example
749/// ```
750/// # tokio_test::block_on(async {
751/// # use google_cloud_monitoring_v3::client::QueryService;
752/// let client = QueryService::builder().build().await?;
753/// // use `client` to make requests to the Cloud Monitoring API.
754/// # gax::client_builder::Result::<()>::Ok(()) });
755/// ```
756///
757/// # Service Description
758///
759/// The QueryService API is used to manage time series data in Cloud
760/// Monitoring. Time series data is a collection of data points that describes
761/// the time-varying values of a metric.
762///
763/// # Configuration
764///
765/// To configure `QueryService` use the `with_*` methods in the type returned
766/// by [builder()][QueryService::builder]. The default configuration should
767/// work for most applications. Common configuration changes include
768///
769/// * [with_endpoint()]: by default this client uses the global default endpoint
770///   (`https://monitoring.googleapis.com`). Applications using regional
771///   endpoints or running in restricted networks (e.g. a network configured
772//    with [Private Google Access with VPC Service Controls]) may want to
773///   override this default.
774/// * [with_credentials()]: by default this client uses
775///   [Application Default Credentials]. Applications using custom
776///   authentication may need to override this default.
777///
778/// [with_endpoint()]: super::builder::query_service::ClientBuilder::with_endpoint
779/// [with_credentials()]: super::builder::query_service::ClientBuilder::credentials
780/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
781/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
782///
783/// # Pooling and Cloning
784///
785/// `QueryService` holds a connection pool internally, it is advised to
786/// create one and the reuse it.  You do not need to wrap `QueryService` in
787/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
788/// already uses an `Arc` internally.
789#[derive(Clone, Debug)]
790pub struct QueryService {
791    inner: std::sync::Arc<dyn super::stub::dynamic::QueryService>,
792}
793
794impl QueryService {
795    /// Returns a builder for [QueryService].
796    ///
797    /// ```
798    /// # tokio_test::block_on(async {
799    /// # use google_cloud_monitoring_v3::client::QueryService;
800    /// let client = QueryService::builder().build().await?;
801    /// # gax::client_builder::Result::<()>::Ok(()) });
802    /// ```
803    pub fn builder() -> super::builder::query_service::ClientBuilder {
804        gax::client_builder::internal::new_builder(super::builder::query_service::client::Factory)
805    }
806
807    /// Creates a new client from the provided stub.
808    ///
809    /// The most common case for calling this function is in tests mocking the
810    /// client's behavior.
811    pub fn from_stub<T>(stub: T) -> Self
812    where
813        T: super::stub::QueryService + 'static,
814    {
815        Self {
816            inner: std::sync::Arc::new(stub),
817        }
818    }
819
820    pub(crate) async fn new(
821        config: gaxi::options::ClientConfig,
822    ) -> gax::client_builder::Result<Self> {
823        let inner = Self::build_inner(config).await?;
824        Ok(Self { inner })
825    }
826
827    async fn build_inner(
828        conf: gaxi::options::ClientConfig,
829    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::QueryService>> {
830        if gaxi::options::tracing_enabled(&conf) {
831            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
832        }
833        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
834    }
835
836    async fn build_transport(
837        conf: gaxi::options::ClientConfig,
838    ) -> gax::client_builder::Result<impl super::stub::QueryService> {
839        super::transport::QueryService::new(conf).await
840    }
841
842    async fn build_with_tracing(
843        conf: gaxi::options::ClientConfig,
844    ) -> gax::client_builder::Result<impl super::stub::QueryService> {
845        Self::build_transport(conf)
846            .await
847            .map(super::tracing::QueryService::new)
848    }
849
850    /// Queries time series by using Monitoring Query Language (MQL). We recommend
851    /// using PromQL instead of MQL. For more information about the status of MQL,
852    /// see the [MQL deprecation
853    /// notice](https://cloud.google.com/stackdriver/docs/deprecations/mql).
854    #[deprecated]
855    pub fn query_time_series(&self) -> super::builder::query_service::QueryTimeSeries {
856        super::builder::query_service::QueryTimeSeries::new(self.inner.clone())
857    }
858}
859
860/// Implements a client for the Cloud Monitoring API.
861///
862/// # Example
863/// ```
864/// # tokio_test::block_on(async {
865/// # use google_cloud_monitoring_v3::client::ServiceMonitoringService;
866/// let client = ServiceMonitoringService::builder().build().await?;
867/// // use `client` to make requests to the Cloud Monitoring API.
868/// # gax::client_builder::Result::<()>::Ok(()) });
869/// ```
870///
871/// # Service Description
872///
873/// The Cloud Monitoring Service-Oriented Monitoring API has endpoints for
874/// managing and querying aspects of a Metrics Scope's services. These include
875/// the `Service`'s monitored resources, its Service-Level Objectives, and a
876/// taxonomy of categorized Health Metrics.
877///
878/// # Configuration
879///
880/// To configure `ServiceMonitoringService` use the `with_*` methods in the type returned
881/// by [builder()][ServiceMonitoringService::builder]. The default configuration should
882/// work for most applications. Common configuration changes include
883///
884/// * [with_endpoint()]: by default this client uses the global default endpoint
885///   (`https://monitoring.googleapis.com`). Applications using regional
886///   endpoints or running in restricted networks (e.g. a network configured
887//    with [Private Google Access with VPC Service Controls]) may want to
888///   override this default.
889/// * [with_credentials()]: by default this client uses
890///   [Application Default Credentials]. Applications using custom
891///   authentication may need to override this default.
892///
893/// [with_endpoint()]: super::builder::service_monitoring_service::ClientBuilder::with_endpoint
894/// [with_credentials()]: super::builder::service_monitoring_service::ClientBuilder::credentials
895/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
896/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
897///
898/// # Pooling and Cloning
899///
900/// `ServiceMonitoringService` holds a connection pool internally, it is advised to
901/// create one and the reuse it.  You do not need to wrap `ServiceMonitoringService` in
902/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
903/// already uses an `Arc` internally.
904#[derive(Clone, Debug)]
905pub struct ServiceMonitoringService {
906    inner: std::sync::Arc<dyn super::stub::dynamic::ServiceMonitoringService>,
907}
908
909impl ServiceMonitoringService {
910    /// Returns a builder for [ServiceMonitoringService].
911    ///
912    /// ```
913    /// # tokio_test::block_on(async {
914    /// # use google_cloud_monitoring_v3::client::ServiceMonitoringService;
915    /// let client = ServiceMonitoringService::builder().build().await?;
916    /// # gax::client_builder::Result::<()>::Ok(()) });
917    /// ```
918    pub fn builder() -> super::builder::service_monitoring_service::ClientBuilder {
919        gax::client_builder::internal::new_builder(
920            super::builder::service_monitoring_service::client::Factory,
921        )
922    }
923
924    /// Creates a new client from the provided stub.
925    ///
926    /// The most common case for calling this function is in tests mocking the
927    /// client's behavior.
928    pub fn from_stub<T>(stub: T) -> Self
929    where
930        T: super::stub::ServiceMonitoringService + 'static,
931    {
932        Self {
933            inner: std::sync::Arc::new(stub),
934        }
935    }
936
937    pub(crate) async fn new(
938        config: gaxi::options::ClientConfig,
939    ) -> gax::client_builder::Result<Self> {
940        let inner = Self::build_inner(config).await?;
941        Ok(Self { inner })
942    }
943
944    async fn build_inner(
945        conf: gaxi::options::ClientConfig,
946    ) -> gax::client_builder::Result<
947        std::sync::Arc<dyn super::stub::dynamic::ServiceMonitoringService>,
948    > {
949        if gaxi::options::tracing_enabled(&conf) {
950            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
951        }
952        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
953    }
954
955    async fn build_transport(
956        conf: gaxi::options::ClientConfig,
957    ) -> gax::client_builder::Result<impl super::stub::ServiceMonitoringService> {
958        super::transport::ServiceMonitoringService::new(conf).await
959    }
960
961    async fn build_with_tracing(
962        conf: gaxi::options::ClientConfig,
963    ) -> gax::client_builder::Result<impl super::stub::ServiceMonitoringService> {
964        Self::build_transport(conf)
965            .await
966            .map(super::tracing::ServiceMonitoringService::new)
967    }
968
969    /// Create a `Service`.
970    pub fn create_service(&self) -> super::builder::service_monitoring_service::CreateService {
971        super::builder::service_monitoring_service::CreateService::new(self.inner.clone())
972    }
973
974    /// Get the named `Service`.
975    pub fn get_service(&self) -> super::builder::service_monitoring_service::GetService {
976        super::builder::service_monitoring_service::GetService::new(self.inner.clone())
977    }
978
979    /// List `Service`s for this Metrics Scope.
980    pub fn list_services(&self) -> super::builder::service_monitoring_service::ListServices {
981        super::builder::service_monitoring_service::ListServices::new(self.inner.clone())
982    }
983
984    /// Update this `Service`.
985    pub fn update_service(&self) -> super::builder::service_monitoring_service::UpdateService {
986        super::builder::service_monitoring_service::UpdateService::new(self.inner.clone())
987    }
988
989    /// Soft delete this `Service`.
990    pub fn delete_service(&self) -> super::builder::service_monitoring_service::DeleteService {
991        super::builder::service_monitoring_service::DeleteService::new(self.inner.clone())
992    }
993
994    /// Create a `ServiceLevelObjective` for the given `Service`.
995    pub fn create_service_level_objective(
996        &self,
997    ) -> super::builder::service_monitoring_service::CreateServiceLevelObjective {
998        super::builder::service_monitoring_service::CreateServiceLevelObjective::new(
999            self.inner.clone(),
1000        )
1001    }
1002
1003    /// Get a `ServiceLevelObjective` by name.
1004    pub fn get_service_level_objective(
1005        &self,
1006    ) -> super::builder::service_monitoring_service::GetServiceLevelObjective {
1007        super::builder::service_monitoring_service::GetServiceLevelObjective::new(
1008            self.inner.clone(),
1009        )
1010    }
1011
1012    /// List the `ServiceLevelObjective`s for the given `Service`.
1013    pub fn list_service_level_objectives(
1014        &self,
1015    ) -> super::builder::service_monitoring_service::ListServiceLevelObjectives {
1016        super::builder::service_monitoring_service::ListServiceLevelObjectives::new(
1017            self.inner.clone(),
1018        )
1019    }
1020
1021    /// Update the given `ServiceLevelObjective`.
1022    pub fn update_service_level_objective(
1023        &self,
1024    ) -> super::builder::service_monitoring_service::UpdateServiceLevelObjective {
1025        super::builder::service_monitoring_service::UpdateServiceLevelObjective::new(
1026            self.inner.clone(),
1027        )
1028    }
1029
1030    /// Delete the given `ServiceLevelObjective`.
1031    pub fn delete_service_level_objective(
1032        &self,
1033    ) -> super::builder::service_monitoring_service::DeleteServiceLevelObjective {
1034        super::builder::service_monitoring_service::DeleteServiceLevelObjective::new(
1035            self.inner.clone(),
1036        )
1037    }
1038}
1039
1040/// Implements a client for the Cloud Monitoring API.
1041///
1042/// # Example
1043/// ```
1044/// # tokio_test::block_on(async {
1045/// # use google_cloud_monitoring_v3::client::SnoozeService;
1046/// let client = SnoozeService::builder().build().await?;
1047/// // use `client` to make requests to the Cloud Monitoring API.
1048/// # gax::client_builder::Result::<()>::Ok(()) });
1049/// ```
1050///
1051/// # Service Description
1052///
1053/// The SnoozeService API is used to temporarily prevent an alert policy from
1054/// generating alerts. A Snooze is a description of the criteria under which one
1055/// or more alert policies should not fire alerts for the specified duration.
1056///
1057/// # Configuration
1058///
1059/// To configure `SnoozeService` use the `with_*` methods in the type returned
1060/// by [builder()][SnoozeService::builder]. The default configuration should
1061/// work for most applications. Common configuration changes include
1062///
1063/// * [with_endpoint()]: by default this client uses the global default endpoint
1064///   (`https://monitoring.googleapis.com`). Applications using regional
1065///   endpoints or running in restricted networks (e.g. a network configured
1066//    with [Private Google Access with VPC Service Controls]) may want to
1067///   override this default.
1068/// * [with_credentials()]: by default this client uses
1069///   [Application Default Credentials]. Applications using custom
1070///   authentication may need to override this default.
1071///
1072/// [with_endpoint()]: super::builder::snooze_service::ClientBuilder::with_endpoint
1073/// [with_credentials()]: super::builder::snooze_service::ClientBuilder::credentials
1074/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1075/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1076///
1077/// # Pooling and Cloning
1078///
1079/// `SnoozeService` holds a connection pool internally, it is advised to
1080/// create one and the reuse it.  You do not need to wrap `SnoozeService` in
1081/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1082/// already uses an `Arc` internally.
1083#[derive(Clone, Debug)]
1084pub struct SnoozeService {
1085    inner: std::sync::Arc<dyn super::stub::dynamic::SnoozeService>,
1086}
1087
1088impl SnoozeService {
1089    /// Returns a builder for [SnoozeService].
1090    ///
1091    /// ```
1092    /// # tokio_test::block_on(async {
1093    /// # use google_cloud_monitoring_v3::client::SnoozeService;
1094    /// let client = SnoozeService::builder().build().await?;
1095    /// # gax::client_builder::Result::<()>::Ok(()) });
1096    /// ```
1097    pub fn builder() -> super::builder::snooze_service::ClientBuilder {
1098        gax::client_builder::internal::new_builder(super::builder::snooze_service::client::Factory)
1099    }
1100
1101    /// Creates a new client from the provided stub.
1102    ///
1103    /// The most common case for calling this function is in tests mocking the
1104    /// client's behavior.
1105    pub fn from_stub<T>(stub: T) -> Self
1106    where
1107        T: super::stub::SnoozeService + 'static,
1108    {
1109        Self {
1110            inner: std::sync::Arc::new(stub),
1111        }
1112    }
1113
1114    pub(crate) async fn new(
1115        config: gaxi::options::ClientConfig,
1116    ) -> gax::client_builder::Result<Self> {
1117        let inner = Self::build_inner(config).await?;
1118        Ok(Self { inner })
1119    }
1120
1121    async fn build_inner(
1122        conf: gaxi::options::ClientConfig,
1123    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SnoozeService>> {
1124        if gaxi::options::tracing_enabled(&conf) {
1125            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1126        }
1127        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1128    }
1129
1130    async fn build_transport(
1131        conf: gaxi::options::ClientConfig,
1132    ) -> gax::client_builder::Result<impl super::stub::SnoozeService> {
1133        super::transport::SnoozeService::new(conf).await
1134    }
1135
1136    async fn build_with_tracing(
1137        conf: gaxi::options::ClientConfig,
1138    ) -> gax::client_builder::Result<impl super::stub::SnoozeService> {
1139        Self::build_transport(conf)
1140            .await
1141            .map(super::tracing::SnoozeService::new)
1142    }
1143
1144    /// Creates a `Snooze` that will prevent alerts, which match the provided
1145    /// criteria, from being opened. The `Snooze` applies for a specific time
1146    /// interval.
1147    pub fn create_snooze(&self) -> super::builder::snooze_service::CreateSnooze {
1148        super::builder::snooze_service::CreateSnooze::new(self.inner.clone())
1149    }
1150
1151    /// Lists the `Snooze`s associated with a project. Can optionally pass in
1152    /// `filter`, which specifies predicates to match `Snooze`s.
1153    pub fn list_snoozes(&self) -> super::builder::snooze_service::ListSnoozes {
1154        super::builder::snooze_service::ListSnoozes::new(self.inner.clone())
1155    }
1156
1157    /// Retrieves a `Snooze` by `name`.
1158    pub fn get_snooze(&self) -> super::builder::snooze_service::GetSnooze {
1159        super::builder::snooze_service::GetSnooze::new(self.inner.clone())
1160    }
1161
1162    /// Updates a `Snooze`, identified by its `name`, with the parameters in the
1163    /// given `Snooze` object.
1164    pub fn update_snooze(&self) -> super::builder::snooze_service::UpdateSnooze {
1165        super::builder::snooze_service::UpdateSnooze::new(self.inner.clone())
1166    }
1167}
1168
1169/// Implements a client for the Cloud Monitoring API.
1170///
1171/// # Example
1172/// ```
1173/// # tokio_test::block_on(async {
1174/// # use google_cloud_monitoring_v3::client::UptimeCheckService;
1175/// let client = UptimeCheckService::builder().build().await?;
1176/// // use `client` to make requests to the Cloud Monitoring API.
1177/// # gax::client_builder::Result::<()>::Ok(()) });
1178/// ```
1179///
1180/// # Service Description
1181///
1182/// The UptimeCheckService API is used to manage (list, create, delete, edit)
1183/// Uptime check configurations in the Cloud Monitoring product. An Uptime
1184/// check is a piece of configuration that determines which resources and
1185/// services to monitor for availability. These configurations can also be
1186/// configured interactively by navigating to the [Cloud console]
1187/// (<https://console.cloud.google.com>), selecting the appropriate project,
1188/// clicking on "Monitoring" on the left-hand side to navigate to Cloud
1189/// Monitoring, and then clicking on "Uptime".
1190///
1191/// # Configuration
1192///
1193/// To configure `UptimeCheckService` use the `with_*` methods in the type returned
1194/// by [builder()][UptimeCheckService::builder]. The default configuration should
1195/// work for most applications. Common configuration changes include
1196///
1197/// * [with_endpoint()]: by default this client uses the global default endpoint
1198///   (`https://monitoring.googleapis.com`). Applications using regional
1199///   endpoints or running in restricted networks (e.g. a network configured
1200//    with [Private Google Access with VPC Service Controls]) may want to
1201///   override this default.
1202/// * [with_credentials()]: by default this client uses
1203///   [Application Default Credentials]. Applications using custom
1204///   authentication may need to override this default.
1205///
1206/// [with_endpoint()]: super::builder::uptime_check_service::ClientBuilder::with_endpoint
1207/// [with_credentials()]: super::builder::uptime_check_service::ClientBuilder::credentials
1208/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1209/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1210///
1211/// # Pooling and Cloning
1212///
1213/// `UptimeCheckService` holds a connection pool internally, it is advised to
1214/// create one and the reuse it.  You do not need to wrap `UptimeCheckService` in
1215/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1216/// already uses an `Arc` internally.
1217#[derive(Clone, Debug)]
1218pub struct UptimeCheckService {
1219    inner: std::sync::Arc<dyn super::stub::dynamic::UptimeCheckService>,
1220}
1221
1222impl UptimeCheckService {
1223    /// Returns a builder for [UptimeCheckService].
1224    ///
1225    /// ```
1226    /// # tokio_test::block_on(async {
1227    /// # use google_cloud_monitoring_v3::client::UptimeCheckService;
1228    /// let client = UptimeCheckService::builder().build().await?;
1229    /// # gax::client_builder::Result::<()>::Ok(()) });
1230    /// ```
1231    pub fn builder() -> super::builder::uptime_check_service::ClientBuilder {
1232        gax::client_builder::internal::new_builder(
1233            super::builder::uptime_check_service::client::Factory,
1234        )
1235    }
1236
1237    /// Creates a new client from the provided stub.
1238    ///
1239    /// The most common case for calling this function is in tests mocking the
1240    /// client's behavior.
1241    pub fn from_stub<T>(stub: T) -> Self
1242    where
1243        T: super::stub::UptimeCheckService + 'static,
1244    {
1245        Self {
1246            inner: std::sync::Arc::new(stub),
1247        }
1248    }
1249
1250    pub(crate) async fn new(
1251        config: gaxi::options::ClientConfig,
1252    ) -> gax::client_builder::Result<Self> {
1253        let inner = Self::build_inner(config).await?;
1254        Ok(Self { inner })
1255    }
1256
1257    async fn build_inner(
1258        conf: gaxi::options::ClientConfig,
1259    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::UptimeCheckService>>
1260    {
1261        if gaxi::options::tracing_enabled(&conf) {
1262            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1263        }
1264        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1265    }
1266
1267    async fn build_transport(
1268        conf: gaxi::options::ClientConfig,
1269    ) -> gax::client_builder::Result<impl super::stub::UptimeCheckService> {
1270        super::transport::UptimeCheckService::new(conf).await
1271    }
1272
1273    async fn build_with_tracing(
1274        conf: gaxi::options::ClientConfig,
1275    ) -> gax::client_builder::Result<impl super::stub::UptimeCheckService> {
1276        Self::build_transport(conf)
1277            .await
1278            .map(super::tracing::UptimeCheckService::new)
1279    }
1280
1281    /// Lists the existing valid Uptime check configurations for the project
1282    /// (leaving out any invalid configurations).
1283    pub fn list_uptime_check_configs(
1284        &self,
1285    ) -> super::builder::uptime_check_service::ListUptimeCheckConfigs {
1286        super::builder::uptime_check_service::ListUptimeCheckConfigs::new(self.inner.clone())
1287    }
1288
1289    /// Gets a single Uptime check configuration.
1290    pub fn get_uptime_check_config(
1291        &self,
1292    ) -> super::builder::uptime_check_service::GetUptimeCheckConfig {
1293        super::builder::uptime_check_service::GetUptimeCheckConfig::new(self.inner.clone())
1294    }
1295
1296    /// Creates a new Uptime check configuration.
1297    pub fn create_uptime_check_config(
1298        &self,
1299    ) -> super::builder::uptime_check_service::CreateUptimeCheckConfig {
1300        super::builder::uptime_check_service::CreateUptimeCheckConfig::new(self.inner.clone())
1301    }
1302
1303    /// Updates an Uptime check configuration. You can either replace the entire
1304    /// configuration with a new one or replace only certain fields in the current
1305    /// configuration by specifying the fields to be updated via `updateMask`.
1306    /// Returns the updated configuration.
1307    pub fn update_uptime_check_config(
1308        &self,
1309    ) -> super::builder::uptime_check_service::UpdateUptimeCheckConfig {
1310        super::builder::uptime_check_service::UpdateUptimeCheckConfig::new(self.inner.clone())
1311    }
1312
1313    /// Deletes an Uptime check configuration. Note that this method will fail
1314    /// if the Uptime check configuration is referenced by an alert policy or
1315    /// other dependent configs that would be rendered invalid by the deletion.
1316    pub fn delete_uptime_check_config(
1317        &self,
1318    ) -> super::builder::uptime_check_service::DeleteUptimeCheckConfig {
1319        super::builder::uptime_check_service::DeleteUptimeCheckConfig::new(self.inner.clone())
1320    }
1321
1322    /// Returns the list of IP addresses that checkers run from.
1323    pub fn list_uptime_check_ips(
1324        &self,
1325    ) -> super::builder::uptime_check_service::ListUptimeCheckIps {
1326        super::builder::uptime_check_service::ListUptimeCheckIps::new(self.inner.clone())
1327    }
1328}