google_monitoring3/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17 CloudPlatform,
18
19 /// View and write monitoring data for all of your Google and third-party Cloud and API projects
20 Full,
21
22 /// View monitoring data for all of your Google Cloud and third-party projects
23 Read,
24
25 /// Publish metric data to your Google Cloud projects
26 Write,
27}
28
29impl AsRef<str> for Scope {
30 fn as_ref(&self) -> &str {
31 match *self {
32 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
33 Scope::Full => "https://www.googleapis.com/auth/monitoring",
34 Scope::Read => "https://www.googleapis.com/auth/monitoring.read",
35 Scope::Write => "https://www.googleapis.com/auth/monitoring.write",
36 }
37 }
38}
39
40#[allow(clippy::derivable_impls)]
41impl Default for Scope {
42 fn default() -> Scope {
43 Scope::Full
44 }
45}
46
47// ########
48// HUB ###
49// ######
50
51/// Central instance to access all Monitoring related resource activities
52///
53/// # Examples
54///
55/// Instantiate a new hub
56///
57/// ```test_harness,no_run
58/// extern crate hyper;
59/// extern crate hyper_rustls;
60/// extern crate google_monitoring3 as monitoring3;
61/// use monitoring3::{Result, Error};
62/// # async fn dox() {
63/// use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
64///
65/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
66/// // `client_secret`, among other things.
67/// let secret: yup_oauth2::ApplicationSecret = Default::default();
68/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
69/// // unless you replace `None` with the desired Flow.
70/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
71/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
72/// // retrieve them from storage.
73/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
74/// secret,
75/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http1()
87/// .build()
88/// );
89/// let mut hub = Monitoring::new(client, auth);
90/// // You can configure optional parameters by calling the respective setters at will, and
91/// // execute the final call using `doit()`.
92/// // Values shown here are possibly random and not representative !
93/// let result = hub.services().service_level_objectives_list("parent")
94/// .view("duo")
95/// .page_token("ipsum")
96/// .page_size(-62)
97/// .filter("Lorem")
98/// .doit().await;
99///
100/// match result {
101/// Err(e) => match e {
102/// // The Error enum provides details about what exactly happened.
103/// // You can also just use its `Debug`, `Display` or `Error` traits
104/// Error::HttpError(_)
105/// |Error::Io(_)
106/// |Error::MissingAPIKey
107/// |Error::MissingToken(_)
108/// |Error::Cancelled
109/// |Error::UploadSizeLimitExceeded(_, _)
110/// |Error::Failure(_)
111/// |Error::BadRequest(_)
112/// |Error::FieldClash(_)
113/// |Error::JsonDecodeError(_, _) => println!("{}", e),
114/// },
115/// Ok(res) => println!("Success: {:?}", res),
116/// }
117/// # }
118/// ```
119#[derive(Clone)]
120pub struct Monitoring<C> {
121 pub client: common::Client<C>,
122 pub auth: Box<dyn common::GetToken>,
123 _user_agent: String,
124 _base_url: String,
125 _root_url: String,
126}
127
128impl<C> common::Hub for Monitoring<C> {}
129
130impl<'a, C> Monitoring<C> {
131 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Monitoring<C> {
132 Monitoring {
133 client,
134 auth: Box::new(auth),
135 _user_agent: "google-api-rust-client/6.0.0".to_string(),
136 _base_url: "https://monitoring.googleapis.com/".to_string(),
137 _root_url: "https://monitoring.googleapis.com/".to_string(),
138 }
139 }
140
141 pub fn folders(&'a self) -> FolderMethods<'a, C> {
142 FolderMethods { hub: self }
143 }
144 pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
145 OrganizationMethods { hub: self }
146 }
147 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
148 ProjectMethods { hub: self }
149 }
150 pub fn services(&'a self) -> ServiceMethods<'a, C> {
151 ServiceMethods { hub: self }
152 }
153 pub fn uptime_check_ips(&'a self) -> UptimeCheckIpMethods<'a, C> {
154 UptimeCheckIpMethods { hub: self }
155 }
156
157 /// Set the user-agent header field to use in all requests to the server.
158 /// It defaults to `google-api-rust-client/6.0.0`.
159 ///
160 /// Returns the previously set user-agent.
161 pub fn user_agent(&mut self, agent_name: String) -> String {
162 std::mem::replace(&mut self._user_agent, agent_name)
163 }
164
165 /// Set the base url to use in all requests to the server.
166 /// It defaults to `https://monitoring.googleapis.com/`.
167 ///
168 /// Returns the previously set base url.
169 pub fn base_url(&mut self, new_base_url: String) -> String {
170 std::mem::replace(&mut self._base_url, new_base_url)
171 }
172
173 /// Set the root url to use in all requests to the server.
174 /// It defaults to `https://monitoring.googleapis.com/`.
175 ///
176 /// Returns the previously set root url.
177 pub fn root_url(&mut self, new_root_url: String) -> String {
178 std::mem::replace(&mut self._root_url, new_root_url)
179 }
180}
181
182// ############
183// SCHEMAS ###
184// ##########
185/// Describes how to combine multiple time series to provide a different view of the data. Aggregation of time series is done in two steps. First, each time series in the set is aligned to the same time interval boundaries, then the set of time series is optionally reduced in number.Alignment consists of applying the per_series_aligner operation to each time series after its data has been divided into regular alignment_period time intervals. This process takes all of the data points in an alignment period, applies a mathematical transformation such as averaging, minimum, maximum, delta, etc., and converts them into a single data point per period.Reduction is when the aligned and transformed time series can optionally be combined, reducing the number of time series through similar mathematical transformations. Reduction involves applying a cross_series_reducer to all the time series, optionally sorting the time series into subsets with group_by_fields, and applying the reducer to each subset.The raw time series data can contain a huge amount of information from multiple sources. Alignment and reduction transforms this mass of data into a more manageable and representative collection of data, for example "the 95% latency across the average of all tasks in a cluster". This representative data can be more easily graphed and comprehended, and the individual time series data is still available for later drilldown. For more details, see Filtering and aggregation (https://cloud.google.com/monitoring/api/v3/aggregation).
186///
187/// This type is not used in any activity, and only used as *part* of another schema.
188///
189#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
190#[serde_with::serde_as]
191#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
192pub struct Aggregation {
193 /// The alignment_period specifies a time interval, in seconds, that is used to divide the data in all the time series into consistent blocks of time. This will be done before the per-series aligner can be applied to the data.The value must be at least 60 seconds. If a per-series aligner other than ALIGN_NONE is specified, this field is required or an error is returned. If no per-series aligner is specified, or the aligner ALIGN_NONE is specified, then this field is ignored.The maximum value of the alignment_period is 104 weeks (2 years) for charts, and 90,000 seconds (25 hours) for alerting policies.
194 #[serde(rename = "alignmentPeriod")]
195 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
196 pub alignment_period: Option<chrono::Duration>,
197 /// The reduction operation to be used to combine time series into a single time series, where the value of each data point in the resulting series is a function of all the already aligned values in the input time series.Not all reducer operations can be applied to all time series. The valid choices depend on the metric_kind and the value_type of the original time series. Reduction can yield a time series with a different metric_kind or value_type than the input time series.Time series data must first be aligned (see per_series_aligner) in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified, and must not be ALIGN_NONE. An alignment_period must also be specified; otherwise, an error is returned.
198 #[serde(rename = "crossSeriesReducer")]
199 pub cross_series_reducer: Option<String>,
200 /// The set of fields to preserve when cross_series_reducer is specified. The group_by_fields determine how the time series are partitioned into subsets prior to applying the aggregation operation. Each subset contains time series that have the same value for each of the grouping fields. Each individual time series is a member of exactly one subset. The cross_series_reducer is applied to each subset of time series. It is not possible to reduce across different resource types, so this field implicitly contains resource.type. Fields not specified in group_by_fields are aggregated away. If group_by_fields is not specified and all the time series have the same resource type, then the time series are aggregated into a single output time series. If cross_series_reducer is not defined, this field is ignored.
201 #[serde(rename = "groupByFields")]
202 pub group_by_fields: Option<Vec<String>>,
203 /// An Aligner describes how to bring the data points in a single time series into temporal alignment. Except for ALIGN_NONE, all alignments cause all the data points in an alignment_period to be mathematically grouped together, resulting in a single data point for each alignment_period with end timestamp at the end of the period.Not all alignment operations may be applied to all time series. The valid choices depend on the metric_kind and value_type of the original time series. Alignment can change the metric_kind or the value_type of the time series.Time series data must be aligned in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified and not equal to ALIGN_NONE and alignment_period must be specified; otherwise, an error is returned.
204 #[serde(rename = "perSeriesAligner")]
205 pub per_series_aligner: Option<String>,
206}
207
208impl common::Part for Aggregation {}
209
210/// A description of the conditions under which some aspect of your system is considered to be “unhealthy” and the ways to notify people or services about this state. For an overview of alert policies, see Introduction to Alerting (https://cloud.google.com/monitoring/alerts/).
211///
212/// # Activities
213///
214/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
215/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
216///
217/// * [alert policies create projects](ProjectAlertPolicyCreateCall) (request|response)
218/// * [alert policies get projects](ProjectAlertPolicyGetCall) (response)
219/// * [alert policies patch projects](ProjectAlertPolicyPatchCall) (request|response)
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct AlertPolicy {
224 /// Control over how this alert policy's notification channels are notified.
225 #[serde(rename = "alertStrategy")]
226 pub alert_strategy: Option<AlertStrategy>,
227 /// How to combine the results of multiple conditions to determine if an incident should be opened. If condition_time_series_query_language is present, this must be COMBINE_UNSPECIFIED.
228 pub combiner: Option<String>,
229 /// A list of conditions for the policy. The conditions are combined by AND or OR according to the combiner field. If the combined conditions evaluate to true, then an incident is created. A policy can have from one to six conditions. If condition_time_series_query_language is present, it must be the only condition. If condition_monitoring_query_language is present, it must be the only condition.
230 pub conditions: Option<Vec<Condition>>,
231 /// A read-only record of the creation of the alerting policy. If provided in a call to create or update, this field will be ignored.
232 #[serde(rename = "creationRecord")]
233 pub creation_record: Option<MutationRecord>,
234 /// A short name or phrase used to identify the policy in dashboards, notifications, and incidents. To avoid confusion, don't use the same display name for multiple policies in the same project. The name is limited to 512 Unicode characters.The convention for the display_name of a PrometheusQueryLanguageCondition is "{rule group name}/{alert name}", where the {rule group name} and {alert name} should be taken from the corresponding Prometheus configuration file. This convention is not enforced. In any case the display_name is not a unique key of the AlertPolicy.
235 #[serde(rename = "displayName")]
236 pub display_name: Option<String>,
237 /// Documentation that is included with notifications and incidents related to this policy. Best practice is for the documentation to include information to help responders understand, mitigate, escalate, and correct the underlying problems detected by the alerting policy. Notification channels that have limited capacity might not show this documentation.
238 pub documentation: Option<Documentation>,
239 /// Whether or not the policy is enabled. On write, the default interpretation if unset is that the policy is enabled. On read, clients should not make any assumption about the state if it has not been populated. The field should always be populated on List and Get operations, unless a field projection has been specified that strips it out.
240 pub enabled: Option<bool>,
241 /// A read-only record of the most recent change to the alerting policy. If provided in a call to create or update, this field will be ignored.
242 #[serde(rename = "mutationRecord")]
243 pub mutation_record: Option<MutationRecord>,
244 /// Required if the policy exists. The resource name for this policy. The format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] [ALERT_POLICY_ID] is assigned by Cloud Monitoring when the policy is created. When calling the alertPolicies.create method, do not include the name field in the alerting policy passed as part of the request.
245 pub name: Option<String>,
246 /// Identifies the notification channels to which notifications should be sent when incidents are opened or closed or when new violations occur on an already opened incident. Each element of this array corresponds to the name field in each of the NotificationChannel objects that are returned from the ListNotificationChannels method. The format of the entries in this field is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
247 #[serde(rename = "notificationChannels")]
248 pub notification_channels: Option<Vec<String>>,
249 /// Optional. The severity of an alert policy indicates how important incidents generated by that policy are. The severity level will be displayed on the Incident detail page and in notifications.
250 pub severity: Option<String>,
251 /// User-supplied key/value data to be used for organizing and identifying the AlertPolicy objects.The field can contain up to 64 entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter.Note that Prometheus {alert name} is a valid Prometheus label names (https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels), whereas Prometheus {rule group} is an unrestricted UTF-8 string. This means that they cannot be stored as-is in user labels, because they may contain characters that are not allowed in user-label values.
252 #[serde(rename = "userLabels")]
253 pub user_labels: Option<HashMap<String, String>>,
254 /// Read-only description of how the alert policy is invalid. This field is only set when the alert policy is invalid. An invalid alert policy will not generate incidents.
255 pub validity: Option<Status>,
256}
257
258impl common::RequestValue for AlertPolicy {}
259impl common::ResponseResult for AlertPolicy {}
260
261/// Control over how the notification channels in notification_channels are notified when this alert fires.
262///
263/// This type is not used in any activity, and only used as *part* of another schema.
264///
265#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
266#[serde_with::serde_as]
267#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
268pub struct AlertStrategy {
269 /// If an alert policy that was active has no data for this long, any open incidents will close
270 #[serde(rename = "autoClose")]
271 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
272 pub auto_close: Option<chrono::Duration>,
273 /// Control how notifications will be sent out, on a per-channel basis.
274 #[serde(rename = "notificationChannelStrategy")]
275 pub notification_channel_strategy: Option<Vec<NotificationChannelStrategy>>,
276 /// Required for alert policies with a LogMatch condition.This limit is not implemented for alert policies that are not log-based.
277 #[serde(rename = "notificationRateLimit")]
278 pub notification_rate_limit: Option<NotificationRateLimit>,
279}
280
281impl common::Part for AlertStrategy {}
282
283/// App Engine service. Learn more at https://cloud.google.com/appengine.
284///
285/// This type is not used in any activity, and only used as *part* of another schema.
286///
287#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
288#[serde_with::serde_as]
289#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
290pub struct AppEngine {
291 /// The ID of the App Engine module underlying this service. Corresponds to the module_id resource label in the gae_app monitored resource (https://cloud.google.com/monitoring/api/resources#tag_gae_app).
292 #[serde(rename = "moduleId")]
293 pub module_id: Option<String>,
294}
295
296impl common::Part for AppEngine {}
297
298/// Future parameters for the availability SLI.
299///
300/// This type is not used in any activity, and only used as *part* of another schema.
301///
302#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
303#[serde_with::serde_as]
304#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
305pub struct AvailabilityCriteria {
306 _never_set: Option<bool>,
307}
308
309impl common::Part for AvailabilityCriteria {}
310
311/// The authentication parameters to provide to the specified resource or URL that requires a username and password. Currently, only Basic HTTP authentication (https://tools.ietf.org/html/rfc7617) is supported in Uptime checks.
312///
313/// This type is not used in any activity, and only used as *part* of another schema.
314///
315#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
316#[serde_with::serde_as]
317#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
318pub struct BasicAuthentication {
319 /// The password to use when authenticating with the HTTP server.
320 pub password: Option<String>,
321 /// The username to use when authenticating with the HTTP server.
322 pub username: Option<String>,
323}
324
325impl common::Part for BasicAuthentication {}
326
327/// A well-known service type, defined by its service type and service labels. Documentation and examples here (https://cloud.google.com/stackdriver/docs/solutions/slo-monitoring/api/api-structures#basic-svc-w-basic-sli).
328///
329/// This type is not used in any activity, and only used as *part* of another schema.
330///
331#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
332#[serde_with::serde_as]
333#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
334pub struct BasicService {
335 /// Labels that specify the resource that emits the monitoring data which is used for SLO reporting of this Service. Documentation and valid values for given service types here (https://cloud.google.com/stackdriver/docs/solutions/slo-monitoring/api/api-structures#basic-svc-w-basic-sli).
336 #[serde(rename = "serviceLabels")]
337 pub service_labels: Option<HashMap<String, String>>,
338 /// The type of service that this basic service defines, e.g. APP_ENGINE service type. Documentation and valid values here (https://cloud.google.com/stackdriver/docs/solutions/slo-monitoring/api/api-structures#basic-svc-w-basic-sli).
339 #[serde(rename = "serviceType")]
340 pub service_type: Option<String>,
341}
342
343impl common::Part for BasicService {}
344
345/// An SLI measuring performance on a well-known service type. Performance will be computed on the basis of pre-defined metrics. The type of the service_resource determines the metrics to use and the service_resource.labels and metric_labels are used to construct a monitoring filter to filter that metric down to just the data relevant to this service.
346///
347/// This type is not used in any activity, and only used as *part* of another schema.
348///
349#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
350#[serde_with::serde_as]
351#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
352pub struct BasicSli {
353 /// Good service is defined to be the count of requests made to this service that return successfully.
354 pub availability: Option<AvailabilityCriteria>,
355 /// Good service is defined to be the count of requests made to this service that are fast enough with respect to latency.threshold.
356 pub latency: Option<LatencyCriteria>,
357 /// OPTIONAL: The set of locations to which this SLI is relevant. Telemetry from other locations will not be used to calculate performance for this SLI. If omitted, this SLI applies to all locations in which the Service has activity. For service types that don't support breaking down by location, setting this field will result in an error.
358 pub location: Option<Vec<String>>,
359 /// OPTIONAL: The set of RPCs to which this SLI is relevant. Telemetry from other methods will not be used to calculate performance for this SLI. If omitted, this SLI applies to all the Service's methods. For service types that don't support breaking down by method, setting this field will result in an error.
360 pub method: Option<Vec<String>>,
361 /// OPTIONAL: The set of API versions to which this SLI is relevant. Telemetry from other API versions will not be used to calculate performance for this SLI. If omitted, this SLI applies to all API versions. For service types that don't support breaking down by version, setting this field will result in an error.
362 pub version: Option<Vec<String>>,
363}
364
365impl common::Part for BasicSli {}
366
367/// BucketOptions describes the bucket boundaries used to create a histogram for the distribution. The buckets can be in a linear sequence, an exponential sequence, or each bucket can be specified explicitly. BucketOptions does not include the number of values in each bucket.A bucket has an inclusive lower bound and exclusive upper bound for the values that are counted for that bucket. The upper bound of a bucket must be strictly greater than the lower bound. The sequence of N buckets for a distribution consists of an underflow bucket (number 0), zero or more finite buckets (number 1 through N - 2) and an overflow bucket (number N - 1). The buckets are contiguous: the lower bound of bucket i (i > 0) is the same as the upper bound of bucket i - 1. The buckets span the whole range of finite values: lower bound of the underflow bucket is -infinity and the upper bound of the overflow bucket is +infinity. The finite buckets are so-called because both bounds are finite.
368///
369/// This type is not used in any activity, and only used as *part* of another schema.
370///
371#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
372#[serde_with::serde_as]
373#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
374pub struct BucketOptions {
375 /// The explicit buckets.
376 #[serde(rename = "explicitBuckets")]
377 pub explicit_buckets: Option<Explicit>,
378 /// The exponential buckets.
379 #[serde(rename = "exponentialBuckets")]
380 pub exponential_buckets: Option<Exponential>,
381 /// The linear bucket.
382 #[serde(rename = "linearBuckets")]
383 pub linear_buckets: Option<Linear>,
384}
385
386impl common::Part for BucketOptions {}
387
388/// Cloud Endpoints service. Learn more at https://cloud.google.com/endpoints.
389///
390/// This type is not used in any activity, and only used as *part* of another schema.
391///
392#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
393#[serde_with::serde_as]
394#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
395pub struct CloudEndpoints {
396 /// The name of the Cloud Endpoints service underlying this service. Corresponds to the service resource label in the api monitored resource (https://cloud.google.com/monitoring/api/resources#tag_api).
397 pub service: Option<String>,
398}
399
400impl common::Part for CloudEndpoints {}
401
402/// A Synthetic Monitor deployed to a Cloud Functions V2 instance.
403///
404/// This type is not used in any activity, and only used as *part* of another schema.
405///
406#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
407#[serde_with::serde_as]
408#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
409pub struct CloudFunctionV2Target {
410 /// Output only. The cloud_run_revision Monitored Resource associated with the GCFv2. The Synthetic Monitor execution results (metrics, logs, and spans) are reported against this Monitored Resource. This field is output only.
411 #[serde(rename = "cloudRunRevision")]
412 pub cloud_run_revision: Option<MonitoredResource>,
413 /// Required. Fully qualified GCFv2 resource name i.e. projects/{project}/locations/{location}/functions/{function} Required.
414 pub name: Option<String>,
415}
416
417impl common::Part for CloudFunctionV2Target {}
418
419/// Cloud Run service. Learn more at https://cloud.google.com/run.
420///
421/// This type is not used in any activity, and only used as *part* of another schema.
422///
423#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
424#[serde_with::serde_as]
425#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
426pub struct CloudRun {
427 /// The location the service is run. Corresponds to the location resource label in the cloud_run_revision monitored resource (https://cloud.google.com/monitoring/api/resources#tag_cloud_run_revision).
428 pub location: Option<String>,
429 /// The name of the Cloud Run service. Corresponds to the service_name resource label in the cloud_run_revision monitored resource (https://cloud.google.com/monitoring/api/resources#tag_cloud_run_revision).
430 #[serde(rename = "serviceName")]
431 pub service_name: Option<String>,
432}
433
434impl common::Part for CloudRun {}
435
436/// Istio service scoped to a single Kubernetes cluster. Learn more at https://istio.io. Clusters running OSS Istio will have their services ingested as this type.
437///
438/// This type is not used in any activity, and only used as *part* of another schema.
439///
440#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
441#[serde_with::serde_as]
442#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
443pub struct ClusterIstio {
444 /// The name of the Kubernetes cluster in which this Istio service is defined. Corresponds to the cluster_name resource label in k8s_cluster resources.
445 #[serde(rename = "clusterName")]
446 pub cluster_name: Option<String>,
447 /// The location of the Kubernetes cluster in which this Istio service is defined. Corresponds to the location resource label in k8s_cluster resources.
448 pub location: Option<String>,
449 /// The name of the Istio service underlying this service. Corresponds to the destination_service_name metric label in Istio metrics.
450 #[serde(rename = "serviceName")]
451 pub service_name: Option<String>,
452 /// The namespace of the Istio service underlying this service. Corresponds to the destination_service_namespace metric label in Istio metrics.
453 #[serde(rename = "serviceNamespace")]
454 pub service_namespace: Option<String>,
455}
456
457impl common::Part for ClusterIstio {}
458
459/// A collection of data points sent from a collectd-based plugin. See the collectd documentation for more information.
460///
461/// This type is not used in any activity, and only used as *part* of another schema.
462///
463#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
464#[serde_with::serde_as]
465#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
466pub struct CollectdPayload {
467 /// The end time of the interval.
468 #[serde(rename = "endTime")]
469 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
470 /// The measurement metadata. Example: "process_id" -> 12345
471 pub metadata: Option<HashMap<String, TypedValue>>,
472 /// The name of the plugin. Example: "disk".
473 pub plugin: Option<String>,
474 /// The instance name of the plugin Example: "hdcl".
475 #[serde(rename = "pluginInstance")]
476 pub plugin_instance: Option<String>,
477 /// The start time of the interval.
478 #[serde(rename = "startTime")]
479 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
480 /// The measurement type. Example: "memory".
481 #[serde(rename = "type")]
482 pub type_: Option<String>,
483 /// The measurement type instance. Example: "used".
484 #[serde(rename = "typeInstance")]
485 pub type_instance: Option<String>,
486 /// The measured values during this time interval. Each value must have a different data_source_name.
487 pub values: Option<Vec<CollectdValue>>,
488}
489
490impl common::Part for CollectdPayload {}
491
492/// Describes the error status for payloads that were not written.
493///
494/// This type is not used in any activity, and only used as *part* of another schema.
495///
496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
497#[serde_with::serde_as]
498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
499pub struct CollectdPayloadError {
500 /// Records the error status for the payload. If this field is present, the partial errors for nested values won't be populated.
501 pub error: Option<Status>,
502 /// The zero-based index in CreateCollectdTimeSeriesRequest.collectd_payloads.
503 pub index: Option<i32>,
504 /// Records the error status for values that were not written due to an error.Failed payloads for which nothing is written will not include partial value errors.
505 #[serde(rename = "valueErrors")]
506 pub value_errors: Option<Vec<CollectdValueError>>,
507}
508
509impl common::Part for CollectdPayloadError {}
510
511/// A single data point from a collectd-based plugin.
512///
513/// This type is not used in any activity, and only used as *part* of another schema.
514///
515#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
516#[serde_with::serde_as]
517#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
518pub struct CollectdValue {
519 /// The data source for the collectd value. For example, there are two data sources for network measurements: "rx" and "tx".
520 #[serde(rename = "dataSourceName")]
521 pub data_source_name: Option<String>,
522 /// The type of measurement.
523 #[serde(rename = "dataSourceType")]
524 pub data_source_type: Option<String>,
525 /// The measurement value.
526 pub value: Option<TypedValue>,
527}
528
529impl common::Part for CollectdValue {}
530
531/// Describes the error status for values that were not written.
532///
533/// This type is not used in any activity, and only used as *part* of another schema.
534///
535#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
536#[serde_with::serde_as]
537#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
538pub struct CollectdValueError {
539 /// Records the error status for the value.
540 pub error: Option<Status>,
541 /// The zero-based index in CollectdPayload.values within the parent CreateCollectdTimeSeriesRequest.collectd_payloads.
542 pub index: Option<i32>,
543}
544
545impl common::Part for CollectdValueError {}
546
547/// A condition is a true/false test that determines when an alerting policy should open an incident. If a condition evaluates to true, it signifies that something is wrong.
548///
549/// This type is not used in any activity, and only used as *part* of another schema.
550///
551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
552#[serde_with::serde_as]
553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
554pub struct Condition {
555 /// A condition that checks that a time series continues to receive new data points.
556 #[serde(rename = "conditionAbsent")]
557 pub condition_absent: Option<MetricAbsence>,
558 /// A condition that checks for log messages matching given constraints. If set, no other conditions can be present.
559 #[serde(rename = "conditionMatchedLog")]
560 pub condition_matched_log: Option<LogMatch>,
561 /// A condition that uses the Monitoring Query Language to define alerts.
562 #[serde(rename = "conditionMonitoringQueryLanguage")]
563 pub condition_monitoring_query_language: Option<MonitoringQueryLanguageCondition>,
564 /// A condition that uses the Prometheus query language to define alerts.
565 #[serde(rename = "conditionPrometheusQueryLanguage")]
566 pub condition_prometheus_query_language: Option<PrometheusQueryLanguageCondition>,
567 /// A condition that compares a time series against a threshold.
568 #[serde(rename = "conditionThreshold")]
569 pub condition_threshold: Option<MetricThreshold>,
570 /// A short name or phrase used to identify the condition in dashboards, notifications, and incidents. To avoid confusion, don't use the same display name for multiple conditions in the same policy.
571 #[serde(rename = "displayName")]
572 pub display_name: Option<String>,
573 /// Required if the condition exists. The unique resource name for this condition. Its format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[POLICY_ID]/conditions/[CONDITION_ID] [CONDITION_ID] is assigned by Cloud Monitoring when the condition is created as part of a new or updated alerting policy.When calling the alertPolicies.create method, do not include the name field in the conditions of the requested alerting policy. Cloud Monitoring creates the condition identifiers and includes them in the new policy.When calling the alertPolicies.update method to update a policy, including a condition name causes the existing condition to be updated. Conditions without names are added to the updated policy. Existing conditions are deleted if they are not updated.Best practice is to preserve [CONDITION_ID] if you make only small changes, such as those to condition thresholds, durations, or trigger values. Otherwise, treat the change as a new condition and let the existing condition be deleted.
574 pub name: Option<String>,
575}
576
577impl common::Part for Condition {}
578
579/// Optional. Used to perform content matching. This allows matching based on substrings and regular expressions, together with their negations. Only the first 4 MB of an HTTP or HTTPS check's response (and the first 1 MB of a TCP check's response) are examined for purposes of content matching.
580///
581/// This type is not used in any activity, and only used as *part* of another schema.
582///
583#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
584#[serde_with::serde_as]
585#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
586pub struct ContentMatcher {
587 /// String, regex or JSON content to match. Maximum 1024 bytes. An empty content string indicates no content matching is to be performed.
588 pub content: Option<String>,
589 /// Matcher information for MATCHES_JSON_PATH and NOT_MATCHES_JSON_PATH
590 #[serde(rename = "jsonPathMatcher")]
591 pub json_path_matcher: Option<JsonPathMatcher>,
592 /// The type of content matcher that will be applied to the server output, compared to the content string when the check is run.
593 pub matcher: Option<String>,
594}
595
596impl common::Part for ContentMatcher {}
597
598/// The CreateCollectdTimeSeries request.
599///
600/// # Activities
601///
602/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
603/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
604///
605/// * [collectd time series create projects](ProjectCollectdTimeSeryCreateCall) (request)
606#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
607#[serde_with::serde_as]
608#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
609pub struct CreateCollectdTimeSeriesRequest {
610 /// The collectd payloads representing the time series data. You must not include more than a single point for each time series, so no two payloads can have the same values for all of the fields plugin, plugin_instance, type, and type_instance.
611 #[serde(rename = "collectdPayloads")]
612 pub collectd_payloads: Option<Vec<CollectdPayload>>,
613 /// The version of collectd that collected the data. Example: "5.3.0-192.el6".
614 #[serde(rename = "collectdVersion")]
615 pub collectd_version: Option<String>,
616 /// The monitored resource associated with the time series.
617 pub resource: Option<MonitoredResource>,
618}
619
620impl common::RequestValue for CreateCollectdTimeSeriesRequest {}
621
622/// The CreateCollectdTimeSeries response.
623///
624/// # Activities
625///
626/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
627/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
628///
629/// * [collectd time series create projects](ProjectCollectdTimeSeryCreateCall) (response)
630#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
631#[serde_with::serde_as]
632#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
633pub struct CreateCollectdTimeSeriesResponse {
634 /// Records the error status for points that were not written due to an error in the request.Failed requests for which nothing is written will return an error response instead. Requests where data points were rejected by the backend will set summary instead.
635 #[serde(rename = "payloadErrors")]
636 pub payload_errors: Option<Vec<CollectdPayloadError>>,
637 /// Aggregate statistics from writing the payloads. This field is omitted if all points were successfully written, so that the response is empty. This is for backwards compatibility with clients that log errors on any non-empty response.
638 pub summary: Option<CreateTimeSeriesSummary>,
639}
640
641impl common::ResponseResult for CreateCollectdTimeSeriesResponse {}
642
643/// The CreateTimeSeries request.
644///
645/// # Activities
646///
647/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
648/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
649///
650/// * [time series create projects](ProjectTimeSeryCreateCall) (request)
651/// * [time series create service projects](ProjectTimeSeryCreateServiceCall) (request)
652#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
653#[serde_with::serde_as]
654#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
655pub struct CreateTimeSeriesRequest {
656 /// Required. The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than any other point in its time series. Each TimeSeries value must fully specify a unique time series by supplying all label values for the metric and the monitored resource.The maximum number of TimeSeries objects per Create request is 200.
657 #[serde(rename = "timeSeries")]
658 pub time_series: Option<Vec<TimeSeries>>,
659}
660
661impl common::RequestValue for CreateTimeSeriesRequest {}
662
663/// Summary of the result of a failed request to write data to a time series.
664///
665/// This type is not used in any activity, and only used as *part* of another schema.
666///
667#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
668#[serde_with::serde_as]
669#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
670pub struct CreateTimeSeriesSummary {
671 /// The number of points that failed to be written. Order is not guaranteed.
672 pub errors: Option<Vec<Error>>,
673 /// The number of points that were successfully written.
674 #[serde(rename = "successPointCount")]
675 pub success_point_count: Option<i32>,
676 /// The number of points in the request.
677 #[serde(rename = "totalPointCount")]
678 pub total_point_count: Option<i32>,
679}
680
681impl common::Part for CreateTimeSeriesSummary {}
682
683/// Criteria specific to the AlertPolicys that this Snooze applies to. The Snooze will suppress alerts that come from one of the AlertPolicys whose names are supplied.
684///
685/// This type is not used in any activity, and only used as *part* of another schema.
686///
687#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
688#[serde_with::serde_as]
689#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
690pub struct Criteria {
691 /// The specific AlertPolicy names for the alert that should be snoozed. The format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[POLICY_ID] There is a limit of 16 policies per snooze. This limit is checked during snooze creation.
692 pub policies: Option<Vec<String>>,
693}
694
695impl common::Part for Criteria {}
696
697/// Use a custom service to designate a service that you want to monitor when none of the other service types (like App Engine, Cloud Run, or a GKE type) matches your intended service.
698///
699/// This type is not used in any activity, and only used as *part* of another schema.
700///
701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
702#[serde_with::serde_as]
703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
704pub struct Custom {
705 _never_set: Option<bool>,
706}
707
708impl common::Part for Custom {}
709
710/// Distribution contains summary statistics for a population of values. It optionally contains a histogram representing the distribution of those values across a set of buckets.The summary statistics are the count, mean, sum of the squared deviation from the mean, the minimum, and the maximum of the set of population of values. The histogram is based on a sequence of buckets and gives a count of values that fall into each bucket. The boundaries of the buckets are given either explicitly or by formulas for buckets of fixed or exponentially increasing widths.Although it is not forbidden, it is generally a bad idea to include non-finite values (infinities or NaNs) in the population of values, as this will render the mean and sum_of_squared_deviation fields meaningless.
711///
712/// This type is not used in any activity, and only used as *part* of another schema.
713///
714#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
715#[serde_with::serde_as]
716#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
717pub struct Distribution {
718 /// Required in the Cloud Monitoring API v3. The values for each bucket specified in bucket_options. The sum of the values in bucketCounts must equal the value in the count field of the Distribution object. The order of the bucket counts follows the numbering schemes described for the three bucket types. The underflow bucket has number 0; the finite buckets, if any, have numbers 1 through N-2; and the overflow bucket has number N-1. The size of bucket_counts must not be greater than N. If the size is less than N, then the remaining buckets are assigned values of zero.
719 #[serde(rename = "bucketCounts")]
720 #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
721 pub bucket_counts: Option<Vec<i64>>,
722 /// Required in the Cloud Monitoring API v3. Defines the histogram bucket boundaries.
723 #[serde(rename = "bucketOptions")]
724 pub bucket_options: Option<BucketOptions>,
725 /// The number of values in the population. Must be non-negative. This value must equal the sum of the values in bucket_counts if a histogram is provided.
726 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
727 pub count: Option<i64>,
728 /// Must be in increasing order of value field.
729 pub exemplars: Option<Vec<Exemplar>>,
730 /// The arithmetic mean of the values in the population. If count is zero then this field must be zero.
731 pub mean: Option<f64>,
732 /// If specified, contains the range of the population values. The field must not be present if the count is zero. This field is presently ignored by the Cloud Monitoring API v3.
733 pub range: Option<Range>,
734 /// The sum of squared deviations from the mean of the values in the population. For values x_i this is: Sum\[i=1..n\]((x_i - mean)^2) Knuth, “The Art of Computer Programming”, Vol. 2, page 232, 3rd edition describes Welford’s method for accumulating this sum in one pass.If count is zero then this field must be zero.
735 #[serde(rename = "sumOfSquaredDeviation")]
736 pub sum_of_squared_deviation: Option<f64>,
737}
738
739impl common::Part for Distribution {}
740
741/// A DistributionCut defines a TimeSeries and thresholds used for measuring good service and total service. The TimeSeries must have ValueType = DISTRIBUTION and MetricKind = DELTA or MetricKind = CUMULATIVE. The computed good_service will be the estimated count of values in the Distribution that fall within the specified min and max.
742///
743/// This type is not used in any activity, and only used as *part* of another schema.
744///
745#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
746#[serde_with::serde_as]
747#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
748pub struct DistributionCut {
749 /// A monitoring filter (https://cloud.google.com/monitoring/api/v3/filters) specifying a TimeSeries aggregating values. Must have ValueType = DISTRIBUTION and MetricKind = DELTA or MetricKind = CUMULATIVE.
750 #[serde(rename = "distributionFilter")]
751 pub distribution_filter: Option<String>,
752 /// Range of values considered "good." For a one-sided range, set one bound to an infinite value.
753 pub range: Option<GoogleMonitoringV3Range>,
754}
755
756impl common::Part for DistributionCut {}
757
758/// Documentation that is included in the notifications and incidents pertaining to this policy.
759///
760/// This type is not used in any activity, and only used as *part* of another schema.
761///
762#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
763#[serde_with::serde_as]
764#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
765pub struct Documentation {
766 /// The body of the documentation, interpreted according to mime_type. The content may not exceed 8,192 Unicode characters and may not exceed more than 10,240 bytes when encoded in UTF-8 format, whichever is smaller. This text can be templatized by using variables (https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars).
767 pub content: Option<String>,
768 /// Optional. Links to content such as playbooks, repositories, and other resources. This field can contain up to 3 entries.
769 pub links: Option<Vec<Link>>,
770 /// The format of the content field. Presently, only the value "text/markdown" is supported. See Markdown (https://en.wikipedia.org/wiki/Markdown) for more information.
771 #[serde(rename = "mimeType")]
772 pub mime_type: Option<String>,
773 /// Optional. The subject line of the notification. The subject line may not exceed 10,240 bytes. In notifications generated by this policy, the contents of the subject line after variable expansion will be truncated to 255 bytes or shorter at the latest UTF-8 character boundary. The 255-byte limit is recommended by this thread (https://stackoverflow.com/questions/1592291/what-is-the-email-subject-length-limit). It is both the limit imposed by some third-party ticketing products and it is common to define textual fields in databases as VARCHAR(255).The contents of the subject line can be templatized by using variables (https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars). If this field is missing or empty, a default subject line will be generated.
774 pub subject: Option<String>,
775}
776
777impl common::Part for Documentation {}
778
779/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
780///
781/// # Activities
782///
783/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
784/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
785///
786/// * [alert policies delete projects](ProjectAlertPolicyDeleteCall) (response)
787/// * [groups delete projects](ProjectGroupDeleteCall) (response)
788/// * [metric descriptors delete projects](ProjectMetricDescriptorDeleteCall) (response)
789/// * [notification channels delete projects](ProjectNotificationChannelDeleteCall) (response)
790/// * [notification channels send verification code projects](ProjectNotificationChannelSendVerificationCodeCall) (response)
791/// * [time series create projects](ProjectTimeSeryCreateCall) (response)
792/// * [time series create service projects](ProjectTimeSeryCreateServiceCall) (response)
793/// * [uptime check configs delete projects](ProjectUptimeCheckConfigDeleteCall) (response)
794/// * [service level objectives delete services](ServiceServiceLevelObjectiveDeleteCall) (response)
795/// * [delete services](ServiceDeleteCall) (response)
796#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
797#[serde_with::serde_as]
798#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
799pub struct Empty {
800 _never_set: Option<bool>,
801}
802
803impl common::ResponseResult for Empty {}
804
805/// Detailed information about an error category.
806///
807/// This type is not used in any activity, and only used as *part* of another schema.
808///
809#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
810#[serde_with::serde_as]
811#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
812pub struct Error {
813 /// The number of points that couldn't be written because of status.
814 #[serde(rename = "pointCount")]
815 pub point_count: Option<i32>,
816 /// The status of the requested write operation.
817 pub status: Option<Status>,
818}
819
820impl common::Part for Error {}
821
822/// Exemplars are example points that may be used to annotate aggregated distribution values. They are metadata that gives information about a particular value added to a Distribution bucket, such as a trace ID that was active when a value was added. They may contain further information, such as a example values and timestamps, origin, etc.
823///
824/// This type is not used in any activity, and only used as *part* of another schema.
825///
826#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
827#[serde_with::serde_as]
828#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
829pub struct Exemplar {
830 /// Contextual information about the example value. Examples are:Trace: type.googleapis.com/google.monitoring.v3.SpanContextLiteral string: type.googleapis.com/google.protobuf.StringValueLabels dropped during aggregation: type.googleapis.com/google.monitoring.v3.DroppedLabelsThere may be only a single attachment of any given message type in a single exemplar, and this is enforced by the system.
831 pub attachments: Option<Vec<HashMap<String, serde_json::Value>>>,
832 /// The observation (sampling) time of the above value.
833 pub timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
834 /// Value of the exemplar point. This value determines to which bucket the exemplar belongs.
835 pub value: Option<f64>,
836}
837
838impl common::Part for Exemplar {}
839
840/// Specifies a set of buckets with arbitrary widths.There are size(bounds) + 1 (= N) buckets. Bucket i has the following boundaries:Upper bound (0 <= i < N-1): boundsi Lower bound (1 <= i < N); boundsi - 1The bounds field must contain at least one element. If bounds has only one element, then there are no finite buckets, and that single element is the common boundary of the overflow and underflow buckets.
841///
842/// This type is not used in any activity, and only used as *part* of another schema.
843///
844#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
845#[serde_with::serde_as]
846#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
847pub struct Explicit {
848 /// The values must be monotonically increasing.
849 pub bounds: Option<Vec<f64>>,
850}
851
852impl common::Part for Explicit {}
853
854/// Specifies an exponential sequence of buckets that have a width that is proportional to the value of the lower bound. Each bucket represents a constant relative uncertainty on a specific value in the bucket.There are num_finite_buckets + 2 (= N) buckets. Bucket i has the following boundaries:Upper bound (0 <= i < N-1): scale * (growth_factor ^ i).Lower bound (1 <= i < N): scale * (growth_factor ^ (i - 1)).
855///
856/// This type is not used in any activity, and only used as *part* of another schema.
857///
858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
859#[serde_with::serde_as]
860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
861pub struct Exponential {
862 /// Must be greater than 1.
863 #[serde(rename = "growthFactor")]
864 pub growth_factor: Option<f64>,
865 /// Must be greater than 0.
866 #[serde(rename = "numFiniteBuckets")]
867 pub num_finite_buckets: Option<i32>,
868 /// Must be greater than 0.
869 pub scale: Option<f64>,
870}
871
872impl common::Part for Exponential {}
873
874/// Options used when forecasting the time series and testing the predicted value against the threshold.
875///
876/// This type is not used in any activity, and only used as *part* of another schema.
877///
878#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
879#[serde_with::serde_as]
880#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
881pub struct ForecastOptions {
882 /// Required. The length of time into the future to forecast whether a time series will violate the threshold. If the predicted value is found to violate the threshold, and the violation is observed in all forecasts made for the configured duration, then the time series is considered to be failing. The forecast horizon can range from 1 hour to 60 hours.
883 #[serde(rename = "forecastHorizon")]
884 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
885 pub forecast_horizon: Option<chrono::Duration>,
886}
887
888impl common::Part for ForecastOptions {}
889
890/// The GetNotificationChannelVerificationCode request.
891///
892/// # Activities
893///
894/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
895/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
896///
897/// * [notification channels get verification code projects](ProjectNotificationChannelGetVerificationCodeCall) (request)
898#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
899#[serde_with::serde_as]
900#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
901pub struct GetNotificationChannelVerificationCodeRequest {
902 /// The desired expiration time. If specified, the API will guarantee that the returned code will not be valid after the specified timestamp; however, the API cannot guarantee that the returned code will be valid for at least as long as the requested time (the API puts an upper bound on the amount of time for which a code may be valid). If omitted, a default expiration will be used, which may be less than the max permissible expiration (so specifying an expiration may extend the code's lifetime over omitting an expiration, even though the API does impose an upper limit on the maximum expiration that is permitted).
903 #[serde(rename = "expireTime")]
904 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
905}
906
907impl common::RequestValue for GetNotificationChannelVerificationCodeRequest {}
908
909/// The GetNotificationChannelVerificationCode request.
910///
911/// # Activities
912///
913/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
914/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
915///
916/// * [notification channels get verification code projects](ProjectNotificationChannelGetVerificationCodeCall) (response)
917#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
918#[serde_with::serde_as]
919#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
920pub struct GetNotificationChannelVerificationCodeResponse {
921 /// The verification code, which may be used to verify other channels that have an equivalent identity (i.e. other channels of the same type with the same fingerprint such as other email channels with the same email address or other sms channels with the same number).
922 pub code: Option<String>,
923 /// The expiration time associated with the code that was returned. If an expiration was provided in the request, this is the minimum of the requested expiration in the request and the max permitted expiration.
924 #[serde(rename = "expireTime")]
925 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
926}
927
928impl common::ResponseResult for GetNotificationChannelVerificationCodeResponse {}
929
930/// GKE Namespace. The field names correspond to the resource metadata labels on monitored resources that fall under a namespace (for example, k8s_container or k8s_pod).
931///
932/// This type is not used in any activity, and only used as *part* of another schema.
933///
934#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
935#[serde_with::serde_as]
936#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
937pub struct GkeNamespace {
938 /// The name of the parent cluster.
939 #[serde(rename = "clusterName")]
940 pub cluster_name: Option<String>,
941 /// The location of the parent cluster. This may be a zone or region.
942 pub location: Option<String>,
943 /// The name of this namespace.
944 #[serde(rename = "namespaceName")]
945 pub namespace_name: Option<String>,
946 /// Output only. The project this resource lives in. For legacy services migrated from the Custom type, this may be a distinct project from the one parenting the service itself.
947 #[serde(rename = "projectId")]
948 pub project_id: Option<String>,
949}
950
951impl common::Part for GkeNamespace {}
952
953/// GKE Service. The "service" here represents a Kubernetes service object (https://kubernetes.io/docs/concepts/services-networking/service). The field names correspond to the resource labels on k8s_service monitored resources (https://cloud.google.com/monitoring/api/resources#tag_k8s_service).
954///
955/// This type is not used in any activity, and only used as *part* of another schema.
956///
957#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
958#[serde_with::serde_as]
959#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
960pub struct GkeService {
961 /// The name of the parent cluster.
962 #[serde(rename = "clusterName")]
963 pub cluster_name: Option<String>,
964 /// The location of the parent cluster. This may be a zone or region.
965 pub location: Option<String>,
966 /// The name of the parent namespace.
967 #[serde(rename = "namespaceName")]
968 pub namespace_name: Option<String>,
969 /// Output only. The project this resource lives in. For legacy services migrated from the Custom type, this may be a distinct project from the one parenting the service itself.
970 #[serde(rename = "projectId")]
971 pub project_id: Option<String>,
972 /// The name of this service.
973 #[serde(rename = "serviceName")]
974 pub service_name: Option<String>,
975}
976
977impl common::Part for GkeService {}
978
979/// A GKE Workload (Deployment, StatefulSet, etc). The field names correspond to the metadata labels on monitored resources that fall under a workload (for example, k8s_container or k8s_pod).
980///
981/// This type is not used in any activity, and only used as *part* of another schema.
982///
983#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
984#[serde_with::serde_as]
985#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
986pub struct GkeWorkload {
987 /// The name of the parent cluster.
988 #[serde(rename = "clusterName")]
989 pub cluster_name: Option<String>,
990 /// The location of the parent cluster. This may be a zone or region.
991 pub location: Option<String>,
992 /// The name of the parent namespace.
993 #[serde(rename = "namespaceName")]
994 pub namespace_name: Option<String>,
995 /// Output only. The project this resource lives in. For legacy services migrated from the Custom type, this may be a distinct project from the one parenting the service itself.
996 #[serde(rename = "projectId")]
997 pub project_id: Option<String>,
998 /// The name of this workload.
999 #[serde(rename = "topLevelControllerName")]
1000 pub top_level_controller_name: Option<String>,
1001 /// The type of this workload (for example, "Deployment" or "DaemonSet")
1002 #[serde(rename = "topLevelControllerType")]
1003 pub top_level_controller_type: Option<String>,
1004}
1005
1006impl common::Part for GkeWorkload {}
1007
1008/// Range of numerical values within min and max.
1009///
1010/// This type is not used in any activity, and only used as *part* of another schema.
1011///
1012#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1013#[serde_with::serde_as]
1014#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1015pub struct GoogleMonitoringV3Range {
1016 /// Range maximum.
1017 pub max: Option<f64>,
1018 /// Range minimum.
1019 pub min: Option<f64>,
1020}
1021
1022impl common::Part for GoogleMonitoringV3Range {}
1023
1024/// The description of a dynamic collection of monitored resources. Each group has a filter that is matched against monitored resources and their associated metadata. If a group’s filter matches an available monitored resource, then that resource is a member of that group. Groups can contain any number of monitored resources, and each monitored resource can be a member of any number of groups.Groups can be nested in parent-child hierarchies. The parentName field identifies an optional parent for each group. If a group has a parent, then the only monitored resources available to be matched by the group’s filter are the resources contained in the parent group. In other words, a group contains the monitored resources that match its filter and the filters of all the group’s ancestors. A group without a parent can contain any monitored resource.For example, consider an infrastructure running a set of instances with two user-defined tags: “environment” and “role”. A parent group has a filter, environment=“production”. A child of that parent group has a filter, role=“transcoder”. The parent group contains all instances in the production environment, regardless of their roles. The child group contains instances that have the transcoder role and are in the production environment.The monitored resources contained in a group can change at any moment, depending on what resources exist and what filters are associated with the group and its ancestors.
1025///
1026/// # Activities
1027///
1028/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1029/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1030///
1031/// * [groups create projects](ProjectGroupCreateCall) (request|response)
1032/// * [groups get projects](ProjectGroupGetCall) (response)
1033/// * [groups update projects](ProjectGroupUpdateCall) (request|response)
1034#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1035#[serde_with::serde_as]
1036#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1037pub struct Group {
1038 /// A user-assigned name for this group, used only for display purposes.
1039 #[serde(rename = "displayName")]
1040 pub display_name: Option<String>,
1041 /// The filter used to determine which monitored resources belong to this group.
1042 pub filter: Option<String>,
1043 /// If true, the members of this group are considered to be a cluster. The system can perform additional analysis on groups that are clusters.
1044 #[serde(rename = "isCluster")]
1045 pub is_cluster: Option<bool>,
1046 /// Output only. The name of this group. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] When creating a group, this field is ignored and a new name is created consisting of the project specified in the call to CreateGroup and a unique [GROUP_ID] that is generated automatically.
1047 pub name: Option<String>,
1048 /// The name of the group's parent, if it has one. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] For groups with no parent, parent_name is the empty string, "".
1049 #[serde(rename = "parentName")]
1050 pub parent_name: Option<String>,
1051}
1052
1053impl common::RequestValue for Group {}
1054impl common::ResponseResult for Group {}
1055
1056/// Information involved in an HTTP/HTTPS Uptime check request.
1057///
1058/// This type is not used in any activity, and only used as *part* of another schema.
1059///
1060#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1061#[serde_with::serde_as]
1062#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1063pub struct HttpCheck {
1064 /// If present, the check will only pass if the HTTP response status code is in this set of status codes. If empty, the HTTP status code will only pass if the HTTP status code is 200-299.
1065 #[serde(rename = "acceptedResponseStatusCodes")]
1066 pub accepted_response_status_codes: Option<Vec<ResponseStatusCode>>,
1067 /// The authentication information. Optional when creating an HTTP check; defaults to empty. Do not set both auth_method and auth_info.
1068 #[serde(rename = "authInfo")]
1069 pub auth_info: Option<BasicAuthentication>,
1070 /// The request body associated with the HTTP POST request. If content_type is URL_ENCODED, the body passed in must be URL-encoded. Users can provide a Content-Length header via the headers field or the API will do so. If the request_method is GET and body is not empty, the API will return an error. The maximum byte size is 1 megabyte.Note: If client libraries aren't used (which performs the conversion automatically) base64 encode your body data since the field is of bytes type.
1071 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1072 pub body: Option<Vec<u8>>,
1073 /// The content type header to use for the check. The following configurations result in errors: 1. Content type is specified in both the headers field and the content_type field. 2. Request method is GET and content_type is not TYPE_UNSPECIFIED 3. Request method is POST and content_type is TYPE_UNSPECIFIED. 4. Request method is POST and a "Content-Type" header is provided via headers field. The content_type field should be used instead.
1074 #[serde(rename = "contentType")]
1075 pub content_type: Option<String>,
1076 /// A user provided content type header to use for the check. The invalid configurations outlined in the content_type field apply to custom_content_type, as well as the following: 1. content_type is URL_ENCODED and custom_content_type is set. 2. content_type is USER_PROVIDED and custom_content_type is not set.
1077 #[serde(rename = "customContentType")]
1078 pub custom_content_type: Option<String>,
1079 /// The list of headers to send as part of the Uptime check request. If two headers have the same key and different values, they should be entered as a single header, with the value being a comma-separated list of all the desired values as described at https://www.w3.org/Protocols/rfc2616/rfc2616.txt (page 31). Entering two separate headers with the same key in a Create call will cause the first to be overwritten by the second. The maximum number of headers allowed is 100.
1080 pub headers: Option<HashMap<String, String>>,
1081 /// Boolean specifying whether to encrypt the header information. Encryption should be specified for any headers related to authentication that you do not wish to be seen when retrieving the configuration. The server will be responsible for encrypting the headers. On Get/List calls, if mask_headers is set to true then the headers will be obscured with ******.
1082 #[serde(rename = "maskHeaders")]
1083 pub mask_headers: Option<bool>,
1084 /// Optional (defaults to "/"). The path to the page against which to run the check. Will be combined with the host (specified within the monitored_resource) and port to construct the full URL. If the provided path does not begin with "/", a "/" will be prepended automatically.
1085 pub path: Option<String>,
1086 /// Contains information needed to add pings to an HTTP check.
1087 #[serde(rename = "pingConfig")]
1088 pub ping_config: Option<PingConfig>,
1089 /// Optional (defaults to 80 when use_ssl is false, and 443 when use_ssl is true). The TCP port on the HTTP server against which to run the check. Will be combined with host (specified within the monitored_resource) and path to construct the full URL.
1090 pub port: Option<i32>,
1091 /// The HTTP request method to use for the check. If set to METHOD_UNSPECIFIED then request_method defaults to GET.
1092 #[serde(rename = "requestMethod")]
1093 pub request_method: Option<String>,
1094 /// If specified, Uptime will generate and attach an OIDC JWT token for the Monitoring service agent service account as an Authorization header in the HTTP request when probing.
1095 #[serde(rename = "serviceAgentAuthentication")]
1096 pub service_agent_authentication: Option<ServiceAgentAuthentication>,
1097 /// If true, use HTTPS instead of HTTP to run the check.
1098 #[serde(rename = "useSsl")]
1099 pub use_ssl: Option<bool>,
1100 /// Boolean specifying whether to include SSL certificate validation as a part of the Uptime check. Only applies to checks where monitored_resource is set to uptime_url. If use_ssl is false, setting validate_ssl to true has no effect.
1101 #[serde(rename = "validateSsl")]
1102 pub validate_ssl: Option<bool>,
1103}
1104
1105impl common::Part for HttpCheck {}
1106
1107/// An internal checker allows Uptime checks to run on private/internal GCP resources.
1108///
1109/// This type is not used in any activity, and only used as *part* of another schema.
1110///
1111#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1112#[serde_with::serde_as]
1113#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1114pub struct InternalChecker {
1115 /// The checker's human-readable name. The display name should be unique within a Cloud Monitoring Metrics Scope in order to make it easier to identify; however, uniqueness is not enforced.
1116 #[serde(rename = "displayName")]
1117 pub display_name: Option<String>,
1118 /// The GCP zone the Uptime check should egress from. Only respected for internal Uptime checks, where internal_network is specified.
1119 #[serde(rename = "gcpZone")]
1120 pub gcp_zone: Option<String>,
1121 /// A unique resource name for this InternalChecker. The format is: projects/[PROJECT_ID_OR_NUMBER]/internalCheckers/[INTERNAL_CHECKER_ID] [PROJECT_ID_OR_NUMBER] is the Cloud Monitoring Metrics Scope project for the Uptime check config associated with the internal checker.
1122 pub name: Option<String>,
1123 /// The GCP VPC network (https://cloud.google.com/vpc/docs/vpc) where the internal resource lives (ex: "default").
1124 pub network: Option<String>,
1125 /// The GCP project ID where the internal checker lives. Not necessary the same as the Metrics Scope project.
1126 #[serde(rename = "peerProjectId")]
1127 pub peer_project_id: Option<String>,
1128 /// The current operational state of the internal checker.
1129 pub state: Option<String>,
1130}
1131
1132impl common::Part for InternalChecker {}
1133
1134/// Canonical service scoped to an Istio mesh. Anthos clusters running ASM >= 1.6.8 will have their services ingested as this type.
1135///
1136/// This type is not used in any activity, and only used as *part* of another schema.
1137///
1138#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1139#[serde_with::serde_as]
1140#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1141pub struct IstioCanonicalService {
1142 /// The name of the canonical service underlying this service. Corresponds to the destination_canonical_service_name metric label in label in Istio metrics (https://cloud.google.com/monitoring/api/metrics_istio).
1143 #[serde(rename = "canonicalService")]
1144 pub canonical_service: Option<String>,
1145 /// The namespace of the canonical service underlying this service. Corresponds to the destination_canonical_service_namespace metric label in Istio metrics (https://cloud.google.com/monitoring/api/metrics_istio).
1146 #[serde(rename = "canonicalServiceNamespace")]
1147 pub canonical_service_namespace: Option<String>,
1148 /// Identifier for the Istio mesh in which this canonical service is defined. Corresponds to the mesh_uid metric label in Istio metrics (https://cloud.google.com/monitoring/api/metrics_istio).
1149 #[serde(rename = "meshUid")]
1150 pub mesh_uid: Option<String>,
1151}
1152
1153impl common::Part for IstioCanonicalService {}
1154
1155/// Information needed to perform a JSONPath content match. Used for ContentMatcherOption::MATCHES_JSON_PATH and ContentMatcherOption::NOT_MATCHES_JSON_PATH.
1156///
1157/// This type is not used in any activity, and only used as *part* of another schema.
1158///
1159#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1160#[serde_with::serde_as]
1161#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1162pub struct JsonPathMatcher {
1163 /// The type of JSONPath match that will be applied to the JSON output (ContentMatcher.content)
1164 #[serde(rename = "jsonMatcher")]
1165 pub json_matcher: Option<String>,
1166 /// JSONPath within the response output pointing to the expected ContentMatcher::content to match against.
1167 #[serde(rename = "jsonPath")]
1168 pub json_path: Option<String>,
1169}
1170
1171impl common::Part for JsonPathMatcher {}
1172
1173/// A description of a label.
1174///
1175/// This type is not used in any activity, and only used as *part* of another schema.
1176///
1177#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1178#[serde_with::serde_as]
1179#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1180pub struct LabelDescriptor {
1181 /// A human-readable description for the label.
1182 pub description: Option<String>,
1183 /// The key for this label. The key must meet the following criteria: Does not exceed 100 characters. Matches the following regular expression: [a-zA-Z][a-zA-Z0-9_]* The first character must be an upper- or lower-case letter. The remaining characters must be letters, digits, or underscores.
1184 pub key: Option<String>,
1185 /// The type of data that can be assigned to the label.
1186 #[serde(rename = "valueType")]
1187 pub value_type: Option<String>,
1188}
1189
1190impl common::Part for LabelDescriptor {}
1191
1192/// A label value.
1193///
1194/// This type is not used in any activity, and only used as *part* of another schema.
1195///
1196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1197#[serde_with::serde_as]
1198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1199pub struct LabelValue {
1200 /// A bool label value.
1201 #[serde(rename = "boolValue")]
1202 pub bool_value: Option<bool>,
1203 /// An int64 label value.
1204 #[serde(rename = "int64Value")]
1205 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1206 pub int64_value: Option<i64>,
1207 /// A string label value.
1208 #[serde(rename = "stringValue")]
1209 pub string_value: Option<String>,
1210}
1211
1212impl common::Part for LabelValue {}
1213
1214/// Parameters for a latency threshold SLI.
1215///
1216/// This type is not used in any activity, and only used as *part* of another schema.
1217///
1218#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1219#[serde_with::serde_as]
1220#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1221pub struct LatencyCriteria {
1222 /// Good service is defined to be the count of requests made to this service that return in no more than threshold.
1223 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1224 pub threshold: Option<chrono::Duration>,
1225}
1226
1227impl common::Part for LatencyCriteria {}
1228
1229/// Specifies a linear sequence of buckets that all have the same width (except overflow and underflow). Each bucket represents a constant absolute uncertainty on the specific value in the bucket.There are num_finite_buckets + 2 (= N) buckets. Bucket i has the following boundaries:Upper bound (0 <= i < N-1): offset + (width * i).Lower bound (1 <= i < N): offset + (width * (i - 1)).
1230///
1231/// This type is not used in any activity, and only used as *part* of another schema.
1232///
1233#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1234#[serde_with::serde_as]
1235#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1236pub struct Linear {
1237 /// Must be greater than 0.
1238 #[serde(rename = "numFiniteBuckets")]
1239 pub num_finite_buckets: Option<i32>,
1240 /// Lower bound of the first bucket.
1241 pub offset: Option<f64>,
1242 /// Must be greater than 0.
1243 pub width: Option<f64>,
1244}
1245
1246impl common::Part for Linear {}
1247
1248/// Links to content such as playbooks, repositories, and other resources.
1249///
1250/// This type is not used in any activity, and only used as *part* of another schema.
1251///
1252#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1253#[serde_with::serde_as]
1254#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1255pub struct Link {
1256 /// A short display name for the link. The display name must not be empty or exceed 63 characters. Example: "playbook".
1257 #[serde(rename = "displayName")]
1258 pub display_name: Option<String>,
1259 /// The url of a webpage. A url can be templatized by using variables in the path or the query parameters. The total length of a URL should not exceed 2083 characters before and after variable expansion. Example: "https://my_domain.com/playbook?name=${resource.name}"
1260 pub url: Option<String>,
1261}
1262
1263impl common::Part for Link {}
1264
1265/// The protocol for the ListAlertPolicies response.
1266///
1267/// # Activities
1268///
1269/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1270/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1271///
1272/// * [alert policies list projects](ProjectAlertPolicyListCall) (response)
1273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1274#[serde_with::serde_as]
1275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1276pub struct ListAlertPoliciesResponse {
1277 /// The returned alert policies.
1278 #[serde(rename = "alertPolicies")]
1279 pub alert_policies: Option<Vec<AlertPolicy>>,
1280 /// If there might be more results than were returned, then this field is set to a non-empty value. To see the additional results, use that value as page_token in the next call to this method.
1281 #[serde(rename = "nextPageToken")]
1282 pub next_page_token: Option<String>,
1283 /// The total number of alert policies in all pages. This number is only an estimate, and may change in subsequent pages. https://aip.dev/158
1284 #[serde(rename = "totalSize")]
1285 pub total_size: Option<i32>,
1286}
1287
1288impl common::ResponseResult for ListAlertPoliciesResponse {}
1289
1290/// The ListGroupMembers response.
1291///
1292/// # Activities
1293///
1294/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1295/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1296///
1297/// * [groups members list projects](ProjectGroupMemberListCall) (response)
1298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1299#[serde_with::serde_as]
1300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1301pub struct ListGroupMembersResponse {
1302 /// A set of monitored resources in the group.
1303 pub members: Option<Vec<MonitoredResource>>,
1304 /// If there are more results than have been returned, then this field is set to a non-empty value. To see the additional results, use that value as page_token in the next call to this method.
1305 #[serde(rename = "nextPageToken")]
1306 pub next_page_token: Option<String>,
1307 /// The total number of elements matching this request.
1308 #[serde(rename = "totalSize")]
1309 pub total_size: Option<i32>,
1310}
1311
1312impl common::ResponseResult for ListGroupMembersResponse {}
1313
1314/// The ListGroups response.
1315///
1316/// # Activities
1317///
1318/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1319/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1320///
1321/// * [groups list projects](ProjectGroupListCall) (response)
1322#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1323#[serde_with::serde_as]
1324#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1325pub struct ListGroupsResponse {
1326 /// The groups that match the specified filters.
1327 pub group: Option<Vec<Group>>,
1328 /// If there are more results than have been returned, then this field is set to a non-empty value. To see the additional results, use that value as page_token in the next call to this method.
1329 #[serde(rename = "nextPageToken")]
1330 pub next_page_token: Option<String>,
1331}
1332
1333impl common::ResponseResult for ListGroupsResponse {}
1334
1335/// The ListMetricDescriptors response.
1336///
1337/// # Activities
1338///
1339/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1340/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1341///
1342/// * [metric descriptors list projects](ProjectMetricDescriptorListCall) (response)
1343#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1344#[serde_with::serde_as]
1345#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1346pub struct ListMetricDescriptorsResponse {
1347 /// The metric descriptors that are available to the project and that match the value of filter, if present.
1348 #[serde(rename = "metricDescriptors")]
1349 pub metric_descriptors: Option<Vec<MetricDescriptor>>,
1350 /// If there are more results than have been returned, then this field is set to a non-empty value. To see the additional results, use that value as page_token in the next call to this method.
1351 #[serde(rename = "nextPageToken")]
1352 pub next_page_token: Option<String>,
1353}
1354
1355impl common::ResponseResult for ListMetricDescriptorsResponse {}
1356
1357/// The ListMonitoredResourceDescriptors response.
1358///
1359/// # Activities
1360///
1361/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1362/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1363///
1364/// * [monitored resource descriptors list projects](ProjectMonitoredResourceDescriptorListCall) (response)
1365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1366#[serde_with::serde_as]
1367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1368pub struct ListMonitoredResourceDescriptorsResponse {
1369 /// If there are more results than have been returned, then this field is set to a non-empty value. To see the additional results, use that value as page_token in the next call to this method.
1370 #[serde(rename = "nextPageToken")]
1371 pub next_page_token: Option<String>,
1372 /// The monitored resource descriptors that are available to this project and that match filter, if present.
1373 #[serde(rename = "resourceDescriptors")]
1374 pub resource_descriptors: Option<Vec<MonitoredResourceDescriptor>>,
1375}
1376
1377impl common::ResponseResult for ListMonitoredResourceDescriptorsResponse {}
1378
1379/// The ListNotificationChannelDescriptors response.
1380///
1381/// # Activities
1382///
1383/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1384/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1385///
1386/// * [notification channel descriptors list projects](ProjectNotificationChannelDescriptorListCall) (response)
1387#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1388#[serde_with::serde_as]
1389#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1390pub struct ListNotificationChannelDescriptorsResponse {
1391 /// The monitored resource descriptors supported for the specified project, optionally filtered.
1392 #[serde(rename = "channelDescriptors")]
1393 pub channel_descriptors: Option<Vec<NotificationChannelDescriptor>>,
1394 /// If not empty, indicates that there may be more results that match the request. Use the value in the page_token field in a subsequent request to fetch the next set of results. If empty, all results have been returned.
1395 #[serde(rename = "nextPageToken")]
1396 pub next_page_token: Option<String>,
1397}
1398
1399impl common::ResponseResult for ListNotificationChannelDescriptorsResponse {}
1400
1401/// The ListNotificationChannels response.
1402///
1403/// # Activities
1404///
1405/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1406/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1407///
1408/// * [notification channels list projects](ProjectNotificationChannelListCall) (response)
1409#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1410#[serde_with::serde_as]
1411#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1412pub struct ListNotificationChannelsResponse {
1413 /// If not empty, indicates that there may be more results that match the request. Use the value in the page_token field in a subsequent request to fetch the next set of results. If empty, all results have been returned.
1414 #[serde(rename = "nextPageToken")]
1415 pub next_page_token: Option<String>,
1416 /// The notification channels defined for the specified project.
1417 #[serde(rename = "notificationChannels")]
1418 pub notification_channels: Option<Vec<NotificationChannel>>,
1419 /// The total number of notification channels in all pages. This number is only an estimate, and may change in subsequent pages. https://aip.dev/158
1420 #[serde(rename = "totalSize")]
1421 pub total_size: Option<i32>,
1422}
1423
1424impl common::ResponseResult for ListNotificationChannelsResponse {}
1425
1426/// The ListServiceLevelObjectives response.
1427///
1428/// # Activities
1429///
1430/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1431/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1432///
1433/// * [service level objectives list services](ServiceServiceLevelObjectiveListCall) (response)
1434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1435#[serde_with::serde_as]
1436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1437pub struct ListServiceLevelObjectivesResponse {
1438 /// If there are more results than have been returned, then this field is set to a non-empty value. To see the additional results, use that value as page_token in the next call to this method.
1439 #[serde(rename = "nextPageToken")]
1440 pub next_page_token: Option<String>,
1441 /// The ServiceLevelObjectives matching the specified filter.
1442 #[serde(rename = "serviceLevelObjectives")]
1443 pub service_level_objectives: Option<Vec<ServiceLevelObjective>>,
1444}
1445
1446impl common::ResponseResult for ListServiceLevelObjectivesResponse {}
1447
1448/// The ListServices response.
1449///
1450/// # Activities
1451///
1452/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1453/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1454///
1455/// * [list services](ServiceListCall) (response)
1456#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1457#[serde_with::serde_as]
1458#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1459pub struct ListServicesResponse {
1460 /// If there are more results than have been returned, then this field is set to a non-empty value. To see the additional results, use that value as page_token in the next call to this method.
1461 #[serde(rename = "nextPageToken")]
1462 pub next_page_token: Option<String>,
1463 /// The Services matching the specified filter.
1464 pub services: Option<Vec<Service>>,
1465}
1466
1467impl common::ResponseResult for ListServicesResponse {}
1468
1469/// The results of a successful ListSnoozes call, containing the matching Snoozes.
1470///
1471/// # Activities
1472///
1473/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1474/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1475///
1476/// * [snoozes list projects](ProjectSnoozeListCall) (response)
1477#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1478#[serde_with::serde_as]
1479#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1480pub struct ListSnoozesResponse {
1481 /// Page token for repeated calls to ListSnoozes, to fetch additional pages of results. If this is empty or missing, there are no more pages.
1482 #[serde(rename = "nextPageToken")]
1483 pub next_page_token: Option<String>,
1484 /// Snoozes matching this list call.
1485 pub snoozes: Option<Vec<Snooze>>,
1486}
1487
1488impl common::ResponseResult for ListSnoozesResponse {}
1489
1490/// The ListTimeSeries response.
1491///
1492/// # Activities
1493///
1494/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1495/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1496///
1497/// * [time series list folders](FolderTimeSeryListCall) (response)
1498/// * [time series list organizations](OrganizationTimeSeryListCall) (response)
1499/// * [time series list projects](ProjectTimeSeryListCall) (response)
1500#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1501#[serde_with::serde_as]
1502#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1503pub struct ListTimeSeriesResponse {
1504 /// Query execution errors that may have caused the time series data returned to be incomplete.
1505 #[serde(rename = "executionErrors")]
1506 pub execution_errors: Option<Vec<Status>>,
1507 /// If there are more results than have been returned, then this field is set to a non-empty value. To see the additional results, use that value as page_token in the next call to this method.
1508 #[serde(rename = "nextPageToken")]
1509 pub next_page_token: Option<String>,
1510 /// One or more time series that match the filter included in the request.
1511 #[serde(rename = "timeSeries")]
1512 pub time_series: Option<Vec<TimeSeries>>,
1513 /// The unit in which all time_series point values are reported. unit follows the UCUM format for units as seen in https://unitsofmeasure.org/ucum.html. If different time_series have different units (for example, because they come from different metric types, or a unit is absent), then unit will be "{not_a_unit}".
1514 pub unit: Option<String>,
1515}
1516
1517impl common::ResponseResult for ListTimeSeriesResponse {}
1518
1519/// The protocol for the ListUptimeCheckConfigs response.
1520///
1521/// # Activities
1522///
1523/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1524/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1525///
1526/// * [uptime check configs list projects](ProjectUptimeCheckConfigListCall) (response)
1527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1528#[serde_with::serde_as]
1529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1530pub struct ListUptimeCheckConfigsResponse {
1531 /// This field represents the pagination token to retrieve the next page of results. If the value is empty, it means no further results for the request. To retrieve the next page of results, the value of the next_page_token is passed to the subsequent List method call (in the request message's page_token field).
1532 #[serde(rename = "nextPageToken")]
1533 pub next_page_token: Option<String>,
1534 /// The total number of Uptime check configurations for the project, irrespective of any pagination.
1535 #[serde(rename = "totalSize")]
1536 pub total_size: Option<i32>,
1537 /// The returned Uptime check configurations.
1538 #[serde(rename = "uptimeCheckConfigs")]
1539 pub uptime_check_configs: Option<Vec<UptimeCheckConfig>>,
1540}
1541
1542impl common::ResponseResult for ListUptimeCheckConfigsResponse {}
1543
1544/// The protocol for the ListUptimeCheckIps response.
1545///
1546/// # Activities
1547///
1548/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1549/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1550///
1551/// * [list uptime check ips](UptimeCheckIpListCall) (response)
1552#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1553#[serde_with::serde_as]
1554#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1555pub struct ListUptimeCheckIpsResponse {
1556 /// This field represents the pagination token to retrieve the next page of results. If the value is empty, it means no further results for the request. To retrieve the next page of results, the value of the next_page_token is passed to the subsequent List method call (in the request message's page_token field). NOTE: this field is not yet implemented
1557 #[serde(rename = "nextPageToken")]
1558 pub next_page_token: Option<String>,
1559 /// The returned list of IP addresses (including region and location) that the checkers run from.
1560 #[serde(rename = "uptimeCheckIps")]
1561 pub uptime_check_ips: Option<Vec<UptimeCheckIp>>,
1562}
1563
1564impl common::ResponseResult for ListUptimeCheckIpsResponse {}
1565
1566/// A condition type that checks whether a log message in the scoping project (https://cloud.google.com/monitoring/api/v3#project_name) satisfies the given filter. Logs from other projects in the metrics scope are not evaluated.
1567///
1568/// This type is not used in any activity, and only used as *part* of another schema.
1569///
1570#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1571#[serde_with::serde_as]
1572#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1573pub struct LogMatch {
1574 /// Required. A logs-based filter. See Advanced Logs Queries (https://cloud.google.com/logging/docs/view/advanced-queries) for how this filter should be constructed.
1575 pub filter: Option<String>,
1576 /// Optional. A map from a label key to an extractor expression, which is used to extract the value for this label key. Each entry in this map is a specification for how data should be extracted from log entries that match filter. Each combination of extracted values is treated as a separate rule for the purposes of triggering notifications. Label keys and corresponding values can be used in notifications generated by this condition.Please see the documentation on logs-based metric valueExtractors (https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics#LogMetric.FIELDS.value_extractor) for syntax and examples.
1577 #[serde(rename = "labelExtractors")]
1578 pub label_extractors: Option<HashMap<String, String>>,
1579}
1580
1581impl common::Part for LogMatch {}
1582
1583/// Istio service scoped to an Istio mesh. Anthos clusters running ASM < 1.6.8 will have their services ingested as this type.
1584///
1585/// This type is not used in any activity, and only used as *part* of another schema.
1586///
1587#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1588#[serde_with::serde_as]
1589#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1590pub struct MeshIstio {
1591 /// Identifier for the mesh in which this Istio service is defined. Corresponds to the mesh_uid metric label in Istio metrics.
1592 #[serde(rename = "meshUid")]
1593 pub mesh_uid: Option<String>,
1594 /// The name of the Istio service underlying this service. Corresponds to the destination_service_name metric label in Istio metrics.
1595 #[serde(rename = "serviceName")]
1596 pub service_name: Option<String>,
1597 /// The namespace of the Istio service underlying this service. Corresponds to the destination_service_namespace metric label in Istio metrics.
1598 #[serde(rename = "serviceNamespace")]
1599 pub service_namespace: Option<String>,
1600}
1601
1602impl common::Part for MeshIstio {}
1603
1604/// A specific metric, identified by specifying values for all of the labels of a MetricDescriptor.
1605///
1606/// This type is not used in any activity, and only used as *part* of another schema.
1607///
1608#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1609#[serde_with::serde_as]
1610#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1611pub struct Metric {
1612 /// The set of label values that uniquely identify this metric. All labels listed in the MetricDescriptor must be assigned values.
1613 pub labels: Option<HashMap<String, String>>,
1614 /// An existing metric type, see google.api.MetricDescriptor. For example, custom.googleapis.com/invoice/paid/amount.
1615 #[serde(rename = "type")]
1616 pub type_: Option<String>,
1617}
1618
1619impl common::Part for Metric {}
1620
1621/// A condition type that checks that monitored resources are reporting data. The configuration defines a metric and a set of monitored resources. The predicate is considered in violation when a time series for the specified metric of a monitored resource does not include any data in the specified duration.
1622///
1623/// This type is not used in any activity, and only used as *part* of another schema.
1624///
1625#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1626#[serde_with::serde_as]
1627#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1628pub struct MetricAbsence {
1629 /// Specifies the alignment of data points in individual time series as well as how to combine the retrieved time series together (such as when aggregating multiple streams on each resource to a single stream for each resource or when aggregating streams across all members of a group of resources). Multiple aggregations are applied in the order specified.This field is similar to the one in the ListTimeSeries request (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). It is advisable to use the ListTimeSeries method when debugging this field.
1630 pub aggregations: Option<Vec<Aggregation>>,
1631 /// The amount of time that a time series must fail to report new data to be considered failing. The minimum value of this field is 120 seconds. Larger values that are a multiple of a minute--for example, 240 or 300 seconds--are supported. If an invalid value is given, an error will be returned. The Duration.nanos field is ignored.
1632 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1633 pub duration: Option<chrono::Duration>,
1634 /// Required. A filter (https://cloud.google.com/monitoring/api/v3/filters) that identifies which time series should be compared with the threshold.The filter is similar to the one that is specified in the ListTimeSeries request (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) (that call is useful to verify the time series that will be retrieved / processed). The filter must specify the metric type and the resource type. Optionally, it can specify resource labels and metric labels. This field must not exceed 2048 Unicode characters in length.
1635 pub filter: Option<String>,
1636 /// The number/percent of time series for which the comparison must hold in order for the condition to trigger. If unspecified, then the condition will trigger if the comparison is true for any of the time series that have been identified by filter and aggregations.
1637 pub trigger: Option<Trigger>,
1638}
1639
1640impl common::Part for MetricAbsence {}
1641
1642/// Defines a metric type and its schema. Once a metric descriptor is created, deleting or altering it stops data collection and makes the metric type’s existing data unusable.
1643///
1644/// # Activities
1645///
1646/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1647/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1648///
1649/// * [metric descriptors create projects](ProjectMetricDescriptorCreateCall) (request|response)
1650/// * [metric descriptors get projects](ProjectMetricDescriptorGetCall) (response)
1651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1652#[serde_with::serde_as]
1653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1654pub struct MetricDescriptor {
1655 /// A detailed description of the metric, which can be used in documentation.
1656 pub description: Option<String>,
1657 /// A concise name for the metric, which can be displayed in user interfaces. Use sentence case without an ending period, for example "Request count". This field is optional but it is recommended to be set for any metrics associated with user-visible concepts, such as Quota.
1658 #[serde(rename = "displayName")]
1659 pub display_name: Option<String>,
1660 /// The set of labels that can be used to describe a specific instance of this metric type. For example, the appengine.googleapis.com/http/server/response_latencies metric type has a label for the HTTP response code, response_code, so you can look at latencies for successful responses or just for responses that failed.
1661 pub labels: Option<Vec<LabelDescriptor>>,
1662 /// Optional. The launch stage of the metric definition.
1663 #[serde(rename = "launchStage")]
1664 pub launch_stage: Option<String>,
1665 /// Optional. Metadata which can be used to guide usage of the metric.
1666 pub metadata: Option<MetricDescriptorMetadata>,
1667 /// Whether the metric records instantaneous values, changes to a value, etc. Some combinations of metric_kind and value_type might not be supported.
1668 #[serde(rename = "metricKind")]
1669 pub metric_kind: Option<String>,
1670 /// Read-only. If present, then a time series, which is identified partially by a metric type and a MonitoredResourceDescriptor, that is associated with this metric type can only be associated with one of the monitored resource types listed here.
1671 #[serde(rename = "monitoredResourceTypes")]
1672 pub monitored_resource_types: Option<Vec<String>>,
1673 /// The resource name of the metric descriptor.
1674 pub name: Option<String>,
1675 /// The metric type, including its DNS name prefix. The type is not URL-encoded. All user-defined metric types have the DNS name custom.googleapis.com or external.googleapis.com. Metric types should use a natural hierarchical grouping. For example: "custom.googleapis.com/invoice/paid/amount" "external.googleapis.com/prometheus/up" "appengine.googleapis.com/http/server/response_latencies"
1676 #[serde(rename = "type")]
1677 pub type_: Option<String>,
1678 /// The units in which the metric value is reported. It is only applicable if the value_type is INT64, DOUBLE, or DISTRIBUTION. The unit defines the representation of the stored metric values.Different systems might scale the values to be more easily displayed (so a value of 0.02kBy might be displayed as 20By, and a value of 3523kBy might be displayed as 3.5MBy). However, if the unit is kBy, then the value of the metric is always in thousands of bytes, no matter how it might be displayed.If you want a custom metric to record the exact number of CPU-seconds used by a job, you can create an INT64 CUMULATIVE metric whose unit is s{CPU} (or equivalently 1s{CPU} or just s). If the job uses 12,005 CPU-seconds, then the value is written as 12005.Alternatively, if you want a custom metric to record data in a more granular way, you can create a DOUBLE CUMULATIVE metric whose unit is ks{CPU}, and then write the value 12.005 (which is 12005/1000), or use Kis{CPU} and write 11.723 (which is 12005/1024).The supported units are a subset of The Unified Code for Units of Measure (https://unitsofmeasure.org/ucum.html) standard:Basic units (UNIT) bit bit By byte s second min minute h hour d day 1 dimensionlessPrefixes (PREFIX) k kilo (10^3) M mega (10^6) G giga (10^9) T tera (10^12) P peta (10^15) E exa (10^18) Z zetta (10^21) Y yotta (10^24) m milli (10^-3) u micro (10^-6) n nano (10^-9) p pico (10^-12) f femto (10^-15) a atto (10^-18) z zepto (10^-21) y yocto (10^-24) Ki kibi (2^10) Mi mebi (2^20) Gi gibi (2^30) Ti tebi (2^40) Pi pebi (2^50)GrammarThe grammar also includes these connectors: / division or ratio (as an infix operator). For examples, kBy/{email} or MiBy/10ms (although you should almost never have /s in a metric unit; rates should always be computed at query time from the underlying cumulative or delta value). . multiplication or composition (as an infix operator). For examples, GBy.d or k{watt}.h.The grammar for a unit is as follows: Expression = Component { "." Component } { "/" Component } ; Component = ( [ PREFIX ] UNIT | "%" ) [ Annotation ] | Annotation | "1" ; Annotation = "{" NAME "}" ; Notes: Annotation is just a comment if it follows a UNIT. If the annotation is used alone, then the unit is equivalent to 1. For examples, {request}/s == 1/s, By{transmitted}/s == By/s. NAME is a sequence of non-blank printable ASCII characters not containing { or }. 1 represents a unitary dimensionless unit (https://en.wikipedia.org/wiki/Dimensionless_quantity) of 1, such as in 1/s. It is typically used when none of the basic units are appropriate. For example, "new users per day" can be represented as 1/d or {new-users}/d (and a metric value 5 would mean "5 new users). Alternatively, "thousands of page views per day" would be represented as 1000/d or k1/d or k{page_views}/d (and a metric value of 5.3 would mean "5300 page views per day"). % represents dimensionless value of 1/100, and annotates values giving a percentage (so the metric values are typically in the range of 0..100, and a metric value 3 means "3 percent"). 10^2.% indicates a metric contains a ratio, typically in the range 0..1, that will be multiplied by 100 and displayed as a percentage (so a metric value 0.03 means "3 percent").
1679 pub unit: Option<String>,
1680 /// Whether the measurement is an integer, a floating-point number, etc. Some combinations of metric_kind and value_type might not be supported.
1681 #[serde(rename = "valueType")]
1682 pub value_type: Option<String>,
1683}
1684
1685impl common::RequestValue for MetricDescriptor {}
1686impl common::ResponseResult for MetricDescriptor {}
1687
1688/// Additional annotations that can be used to guide the usage of a metric.
1689///
1690/// This type is not used in any activity, and only used as *part* of another schema.
1691///
1692#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1693#[serde_with::serde_as]
1694#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1695pub struct MetricDescriptorMetadata {
1696 /// The delay of data points caused by ingestion. Data points older than this age are guaranteed to be ingested and available to be read, excluding data loss due to errors.
1697 #[serde(rename = "ingestDelay")]
1698 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1699 pub ingest_delay: Option<chrono::Duration>,
1700 /// Deprecated. Must use the MetricDescriptor.launch_stage instead.
1701 #[serde(rename = "launchStage")]
1702 pub launch_stage: Option<String>,
1703 /// The sampling period of metric data points. For metrics which are written periodically, consecutive data points are stored at this time interval, excluding data loss due to errors. Metrics with a higher granularity have a smaller sampling period.
1704 #[serde(rename = "samplePeriod")]
1705 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1706 pub sample_period: Option<chrono::Duration>,
1707}
1708
1709impl common::Part for MetricDescriptorMetadata {}
1710
1711/// A MetricRange is used when each window is good when the value x of a single TimeSeries satisfies range.min <= x <= range.max. The provided TimeSeries must have ValueType = INT64 or ValueType = DOUBLE and MetricKind = GAUGE.
1712///
1713/// This type is not used in any activity, and only used as *part* of another schema.
1714///
1715#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1716#[serde_with::serde_as]
1717#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1718pub struct MetricRange {
1719 /// Range of values considered "good." For a one-sided range, set one bound to an infinite value.
1720 pub range: Option<GoogleMonitoringV3Range>,
1721 /// A monitoring filter (https://cloud.google.com/monitoring/api/v3/filters) specifying the TimeSeries to use for evaluating window quality.
1722 #[serde(rename = "timeSeries")]
1723 pub time_series: Option<String>,
1724}
1725
1726impl common::Part for MetricRange {}
1727
1728/// A condition type that compares a collection of time series against a threshold.
1729///
1730/// This type is not used in any activity, and only used as *part* of another schema.
1731///
1732#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1733#[serde_with::serde_as]
1734#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1735pub struct MetricThreshold {
1736 /// Specifies the alignment of data points in individual time series as well as how to combine the retrieved time series together (such as when aggregating multiple streams on each resource to a single stream for each resource or when aggregating streams across all members of a group of resources). Multiple aggregations are applied in the order specified.This field is similar to the one in the ListTimeSeries request (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). It is advisable to use the ListTimeSeries method when debugging this field.
1737 pub aggregations: Option<Vec<Aggregation>>,
1738 /// The comparison to apply between the time series (indicated by filter and aggregation) and the threshold (indicated by threshold_value). The comparison is applied on each time series, with the time series on the left-hand side and the threshold on the right-hand side.Only COMPARISON_LT and COMPARISON_GT are supported currently.
1739 pub comparison: Option<String>,
1740 /// Specifies the alignment of data points in individual time series selected by denominatorFilter as well as how to combine the retrieved time series together (such as when aggregating multiple streams on each resource to a single stream for each resource or when aggregating streams across all members of a group of resources).When computing ratios, the aggregations and denominator_aggregations fields must use the same alignment period and produce time series that have the same periodicity and labels.
1741 #[serde(rename = "denominatorAggregations")]
1742 pub denominator_aggregations: Option<Vec<Aggregation>>,
1743 /// A filter (https://cloud.google.com/monitoring/api/v3/filters) that identifies a time series that should be used as the denominator of a ratio that will be compared with the threshold. If a denominator_filter is specified, the time series specified by the filter field will be used as the numerator.The filter must specify the metric type and optionally may contain restrictions on resource type, resource labels, and metric labels. This field may not exceed 2048 Unicode characters in length.
1744 #[serde(rename = "denominatorFilter")]
1745 pub denominator_filter: Option<String>,
1746 /// The amount of time that a time series must violate the threshold to be considered failing. Currently, only values that are a multiple of a minute--e.g., 0, 60, 120, or 300 seconds--are supported. If an invalid value is given, an error will be returned. When choosing a duration, it is useful to keep in mind the frequency of the underlying time series data (which may also be affected by any alignments specified in the aggregations field); a good duration is long enough so that a single outlier does not generate spurious alerts, but short enough that unhealthy states are detected and alerted on quickly.
1747 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1748 pub duration: Option<chrono::Duration>,
1749 /// A condition control that determines how metric-threshold conditions are evaluated when data stops arriving. To use this control, the value of the duration field must be greater than or equal to 60 seconds.
1750 #[serde(rename = "evaluationMissingData")]
1751 pub evaluation_missing_data: Option<String>,
1752 /// Required. A filter (https://cloud.google.com/monitoring/api/v3/filters) that identifies which time series should be compared with the threshold.The filter is similar to the one that is specified in the ListTimeSeries request (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) (that call is useful to verify the time series that will be retrieved / processed). The filter must specify the metric type and the resource type. Optionally, it can specify resource labels and metric labels. This field must not exceed 2048 Unicode characters in length.
1753 pub filter: Option<String>,
1754 /// When this field is present, the MetricThreshold condition forecasts whether the time series is predicted to violate the threshold within the forecast_horizon. When this field is not set, the MetricThreshold tests the current value of the timeseries against the threshold.
1755 #[serde(rename = "forecastOptions")]
1756 pub forecast_options: Option<ForecastOptions>,
1757 /// A value against which to compare the time series.
1758 #[serde(rename = "thresholdValue")]
1759 pub threshold_value: Option<f64>,
1760 /// The number/percent of time series for which the comparison must hold in order for the condition to trigger. If unspecified, then the condition will trigger if the comparison is true for any of the time series that have been identified by filter and aggregations, or by the ratio, if denominator_filter and denominator_aggregations are specified.
1761 pub trigger: Option<Trigger>,
1762}
1763
1764impl common::Part for MetricThreshold {}
1765
1766/// An object representing a resource that can be used for monitoring, logging, billing, or other purposes. Examples include virtual machine instances, databases, and storage devices such as disks. The type field identifies a MonitoredResourceDescriptor object that describes the resource's schema. Information in the labels field identifies the actual resource and its attributes according to the schema. For example, a particular Compute Engine VM instance could be represented by the following object, because the MonitoredResourceDescriptor for "gce_instance" has labels "project_id", "instance_id" and "zone": { "type": "gce_instance", "labels": { "project_id": "my-project", "instance_id": "12345678901234", "zone": "us-central1-a" }}
1767///
1768/// This type is not used in any activity, and only used as *part* of another schema.
1769///
1770#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1771#[serde_with::serde_as]
1772#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1773pub struct MonitoredResource {
1774 /// Required. Values for all of the labels listed in the associated monitored resource descriptor. For example, Compute Engine VM instances use the labels "project_id", "instance_id", and "zone".
1775 pub labels: Option<HashMap<String, String>>,
1776 /// Required. The monitored resource type. This field must match the type field of a MonitoredResourceDescriptor object. For example, the type of a Compute Engine VM instance is gce_instance. For a list of types, see Monitoring resource types (https://cloud.google.com/monitoring/api/resources) and Logging resource types (https://cloud.google.com/logging/docs/api/v2/resource-list).
1777 #[serde(rename = "type")]
1778 pub type_: Option<String>,
1779}
1780
1781impl common::Part for MonitoredResource {}
1782
1783/// An object that describes the schema of a MonitoredResource object using a type name and a set of labels. For example, the monitored resource descriptor for Google Compute Engine VM instances has a type of “gce_instance” and specifies the use of the labels “instance_id” and “zone” to identify particular VM instances.Different APIs can support different monitored resource types. APIs generally provide a list method that returns the monitored resource descriptors used by the API.
1784///
1785/// # Activities
1786///
1787/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1788/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1789///
1790/// * [monitored resource descriptors get projects](ProjectMonitoredResourceDescriptorGetCall) (response)
1791#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1792#[serde_with::serde_as]
1793#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1794pub struct MonitoredResourceDescriptor {
1795 /// Optional. A detailed description of the monitored resource type that might be used in documentation.
1796 pub description: Option<String>,
1797 /// Optional. A concise name for the monitored resource type that might be displayed in user interfaces. It should be a Title Cased Noun Phrase, without any article or other determiners. For example, "Google Cloud SQL Database".
1798 #[serde(rename = "displayName")]
1799 pub display_name: Option<String>,
1800 /// Required. A set of labels used to describe instances of this monitored resource type. For example, an individual Google Cloud SQL database is identified by values for the labels "database_id" and "zone".
1801 pub labels: Option<Vec<LabelDescriptor>>,
1802 /// Optional. The launch stage of the monitored resource definition.
1803 #[serde(rename = "launchStage")]
1804 pub launch_stage: Option<String>,
1805 /// Optional. The resource name of the monitored resource descriptor: "projects/{project_id}/monitoredResourceDescriptors/{type}" where {type} is the value of the type field in this object and {project_id} is a project ID that provides API-specific context for accessing the type. APIs that do not use project information can use the resource name format "monitoredResourceDescriptors/{type}".
1806 pub name: Option<String>,
1807 /// Required. The monitored resource type. For example, the type "cloudsql_database" represents databases in Google Cloud SQL. For a list of types, see Monitored resource types (https://cloud.google.com/monitoring/api/resources) and Logging resource types (https://cloud.google.com/logging/docs/api/v2/resource-list).
1808 #[serde(rename = "type")]
1809 pub type_: Option<String>,
1810}
1811
1812impl common::ResponseResult for MonitoredResourceDescriptor {}
1813
1814/// Auxiliary metadata for a MonitoredResource object. MonitoredResource objects contain the minimum set of information to uniquely identify a monitored resource instance. There is some other useful auxiliary metadata. Monitoring and Logging use an ingestion pipeline to extract metadata for cloud resources of all types, and store the metadata in this message.
1815///
1816/// This type is not used in any activity, and only used as *part* of another schema.
1817///
1818#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1819#[serde_with::serde_as]
1820#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1821pub struct MonitoredResourceMetadata {
1822 /// Output only. Values for predefined system metadata labels. System labels are a kind of metadata extracted by Google, including "machine_image", "vpc", "subnet_id", "security_group", "name", etc. System label values can be only strings, Boolean values, or a list of strings. For example: { "name": "my-test-instance", "security_group": ["a", "b", "c"], "spot_instance": false }
1823 #[serde(rename = "systemLabels")]
1824 pub system_labels: Option<HashMap<String, serde_json::Value>>,
1825 /// Output only. A map of user-defined metadata labels.
1826 #[serde(rename = "userLabels")]
1827 pub user_labels: Option<HashMap<String, String>>,
1828}
1829
1830impl common::Part for MonitoredResourceMetadata {}
1831
1832/// A condition type that allows alert policies to be defined using Monitoring Query Language (https://cloud.google.com/monitoring/mql).
1833///
1834/// This type is not used in any activity, and only used as *part* of another schema.
1835///
1836#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1837#[serde_with::serde_as]
1838#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1839pub struct MonitoringQueryLanguageCondition {
1840 /// The amount of time that a time series must violate the threshold to be considered failing. Currently, only values that are a multiple of a minute--e.g., 0, 60, 120, or 300 seconds--are supported. If an invalid value is given, an error will be returned. When choosing a duration, it is useful to keep in mind the frequency of the underlying time series data (which may also be affected by any alignments specified in the aggregations field); a good duration is long enough so that a single outlier does not generate spurious alerts, but short enough that unhealthy states are detected and alerted on quickly.
1841 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1842 pub duration: Option<chrono::Duration>,
1843 /// A condition control that determines how metric-threshold conditions are evaluated when data stops arriving.
1844 #[serde(rename = "evaluationMissingData")]
1845 pub evaluation_missing_data: Option<String>,
1846 /// Monitoring Query Language (https://cloud.google.com/monitoring/mql) query that outputs a boolean stream.
1847 pub query: Option<String>,
1848 /// The number/percent of time series for which the comparison must hold in order for the condition to trigger. If unspecified, then the condition will trigger if the comparison is true for any of the time series that have been identified by filter and aggregations, or by the ratio, if denominator_filter and denominator_aggregations are specified.
1849 pub trigger: Option<Trigger>,
1850}
1851
1852impl common::Part for MonitoringQueryLanguageCondition {}
1853
1854/// Describes a change made to a configuration.
1855///
1856/// This type is not used in any activity, and only used as *part* of another schema.
1857///
1858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1859#[serde_with::serde_as]
1860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1861pub struct MutationRecord {
1862 /// When the change occurred.
1863 #[serde(rename = "mutateTime")]
1864 pub mutate_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1865 /// The email address of the user making the change.
1866 #[serde(rename = "mutatedBy")]
1867 pub mutated_by: Option<String>,
1868}
1869
1870impl common::Part for MutationRecord {}
1871
1872/// A NotificationChannel is a medium through which an alert is delivered when a policy violation is detected. Examples of channels include email, SMS, and third-party messaging applications. Fields containing sensitive information like authentication tokens or contact info are only partially populated on retrieval.
1873///
1874/// # Activities
1875///
1876/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1877/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1878///
1879/// * [notification channels create projects](ProjectNotificationChannelCreateCall) (request|response)
1880/// * [notification channels get projects](ProjectNotificationChannelGetCall) (response)
1881/// * [notification channels patch projects](ProjectNotificationChannelPatchCall) (request|response)
1882/// * [notification channels verify projects](ProjectNotificationChannelVerifyCall) (response)
1883#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1884#[serde_with::serde_as]
1885#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1886pub struct NotificationChannel {
1887 /// Record of the creation of this channel.
1888 #[serde(rename = "creationRecord")]
1889 pub creation_record: Option<MutationRecord>,
1890 /// An optional human-readable description of this notification channel. This description may provide additional details, beyond the display name, for the channel. This may not exceed 1024 Unicode characters.
1891 pub description: Option<String>,
1892 /// An optional human-readable name for this notification channel. It is recommended that you specify a non-empty and unique name in order to make it easier to identify the channels in your project, though this is not enforced. The display name is limited to 512 Unicode characters.
1893 #[serde(rename = "displayName")]
1894 pub display_name: Option<String>,
1895 /// Whether notifications are forwarded to the described channel. This makes it possible to disable delivery of notifications to a particular channel without removing the channel from all alerting policies that reference the channel. This is a more convenient approach when the change is temporary and you want to receive notifications from the same set of alerting policies on the channel at some point in the future.
1896 pub enabled: Option<bool>,
1897 /// Configuration fields that define the channel and its behavior. The permissible and required labels are specified in the NotificationChannelDescriptor.labels of the NotificationChannelDescriptor corresponding to the type field.
1898 pub labels: Option<HashMap<String, String>>,
1899 /// Records of the modification of this channel.
1900 #[serde(rename = "mutationRecords")]
1901 pub mutation_records: Option<Vec<MutationRecord>>,
1902 /// The full REST resource name for this channel. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] The [CHANNEL_ID] is automatically assigned by the server on creation.
1903 pub name: Option<String>,
1904 /// The type of the notification channel. This field matches the value of the NotificationChannelDescriptor.type field.
1905 #[serde(rename = "type")]
1906 pub type_: Option<String>,
1907 /// User-supplied key/value data that does not need to conform to the corresponding NotificationChannelDescriptor's schema, unlike the labels field. This field is intended to be used for organizing and identifying the NotificationChannel objects.The field can contain up to 64 entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter.
1908 #[serde(rename = "userLabels")]
1909 pub user_labels: Option<HashMap<String, String>>,
1910 /// Indicates whether this channel has been verified or not. On a ListNotificationChannels or GetNotificationChannel operation, this field is expected to be populated.If the value is UNVERIFIED, then it indicates that the channel is non-functioning (it both requires verification and lacks verification); otherwise, it is assumed that the channel works.If the channel is neither VERIFIED nor UNVERIFIED, it implies that the channel is of a type that does not require verification or that this specific channel has been exempted from verification because it was created prior to verification being required for channels of this type.This field cannot be modified using a standard UpdateNotificationChannel operation. To change the value of this field, you must call VerifyNotificationChannel.
1911 #[serde(rename = "verificationStatus")]
1912 pub verification_status: Option<String>,
1913}
1914
1915impl common::RequestValue for NotificationChannel {}
1916impl common::ResponseResult for NotificationChannel {}
1917
1918/// A description of a notification channel. The descriptor includes the properties of the channel and the set of labels or fields that must be specified to configure channels of a given type.
1919///
1920/// # Activities
1921///
1922/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1923/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1924///
1925/// * [notification channel descriptors get projects](ProjectNotificationChannelDescriptorGetCall) (response)
1926#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1927#[serde_with::serde_as]
1928#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1929pub struct NotificationChannelDescriptor {
1930 /// A human-readable description of the notification channel type. The description may include a description of the properties of the channel and pointers to external documentation.
1931 pub description: Option<String>,
1932 /// A human-readable name for the notification channel type. This form of the name is suitable for a user interface.
1933 #[serde(rename = "displayName")]
1934 pub display_name: Option<String>,
1935 /// The set of labels that must be defined to identify a particular channel of the corresponding type. Each label includes a description for how that field should be populated.
1936 pub labels: Option<Vec<LabelDescriptor>>,
1937 /// The product launch stage for channels of this type.
1938 #[serde(rename = "launchStage")]
1939 pub launch_stage: Option<String>,
1940 /// The full REST resource name for this descriptor. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannelDescriptors/[TYPE] In the above, [TYPE] is the value of the type field.
1941 pub name: Option<String>,
1942 /// The tiers that support this notification channel; the project service tier must be one of the supported_tiers.
1943 #[serde(rename = "supportedTiers")]
1944 pub supported_tiers: Option<Vec<String>>,
1945 /// The type of notification channel, such as "email" and "sms". To view the full list of channels, see Channel descriptors (https://cloud.google.com/monitoring/alerts/using-channels-api#ncd). Notification channel types are globally unique.
1946 #[serde(rename = "type")]
1947 pub type_: Option<String>,
1948}
1949
1950impl common::ResponseResult for NotificationChannelDescriptor {}
1951
1952/// Control over how the notification channels in notification_channels are notified when this alert fires, on a per-channel basis.
1953///
1954/// This type is not used in any activity, and only used as *part* of another schema.
1955///
1956#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1957#[serde_with::serde_as]
1958#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1959pub struct NotificationChannelStrategy {
1960 /// The full REST resource name for the notification channels that these settings apply to. Each of these correspond to the name field in one of the NotificationChannel objects referenced in the notification_channels field of this AlertPolicy. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
1961 #[serde(rename = "notificationChannelNames")]
1962 pub notification_channel_names: Option<Vec<String>>,
1963 /// The frequency at which to send reminder notifications for open incidents.
1964 #[serde(rename = "renotifyInterval")]
1965 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1966 pub renotify_interval: Option<chrono::Duration>,
1967}
1968
1969impl common::Part for NotificationChannelStrategy {}
1970
1971/// Control over the rate of notifications sent to this alert policy's notification channels.
1972///
1973/// This type is not used in any activity, and only used as *part* of another schema.
1974///
1975#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1976#[serde_with::serde_as]
1977#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1978pub struct NotificationRateLimit {
1979 /// Not more than one notification per period.
1980 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1981 pub period: Option<chrono::Duration>,
1982}
1983
1984impl common::Part for NotificationRateLimit {}
1985
1986/// A PerformanceThreshold is used when each window is good when that window has a sufficiently high performance.
1987///
1988/// This type is not used in any activity, and only used as *part* of another schema.
1989///
1990#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1991#[serde_with::serde_as]
1992#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1993pub struct PerformanceThreshold {
1994 /// BasicSli to evaluate to judge window quality.
1995 #[serde(rename = "basicSliPerformance")]
1996 pub basic_sli_performance: Option<BasicSli>,
1997 /// RequestBasedSli to evaluate to judge window quality.
1998 pub performance: Option<RequestBasedSli>,
1999 /// If window performance >= threshold, the window is counted as good.
2000 pub threshold: Option<f64>,
2001}
2002
2003impl common::Part for PerformanceThreshold {}
2004
2005/// Information involved in sending ICMP pings alongside public HTTP/TCP checks. For HTTP, the pings are performed for each part of the redirect chain.
2006///
2007/// This type is not used in any activity, and only used as *part* of another schema.
2008///
2009#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2010#[serde_with::serde_as]
2011#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2012pub struct PingConfig {
2013 /// Number of ICMP pings. A maximum of 3 ICMP pings is currently supported.
2014 #[serde(rename = "pingsCount")]
2015 pub pings_count: Option<i32>,
2016}
2017
2018impl common::Part for PingConfig {}
2019
2020/// A single data point in a time series.
2021///
2022/// This type is not used in any activity, and only used as *part* of another schema.
2023///
2024#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2025#[serde_with::serde_as]
2026#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2027pub struct Point {
2028 /// The time interval to which the data point applies. For GAUGE metrics, the start time is optional, but if it is supplied, it must equal the end time. For DELTA metrics, the start and end time should specify a non-zero interval, with subsequent points specifying contiguous and non-overlapping intervals. For CUMULATIVE metrics, the start and end time should specify a non-zero interval, with subsequent points specifying the same start time and increasing end times, until an event resets the cumulative value to zero and sets a new start time for the following points.
2029 pub interval: Option<TimeInterval>,
2030 /// The value of the data point.
2031 pub value: Option<TypedValue>,
2032}
2033
2034impl common::Part for Point {}
2035
2036/// A point's value columns and time interval. Each point has one or more point values corresponding to the entries in point_descriptors field in the TimeSeriesDescriptor associated with this object.
2037///
2038/// This type is not used in any activity, and only used as *part* of another schema.
2039///
2040#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2041#[serde_with::serde_as]
2042#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2043pub struct PointData {
2044 /// The time interval associated with the point.
2045 #[serde(rename = "timeInterval")]
2046 pub time_interval: Option<TimeInterval>,
2047 /// The values that make up the point.
2048 pub values: Option<Vec<TypedValue>>,
2049}
2050
2051impl common::Part for PointData {}
2052
2053/// A condition type that allows alert policies to be defined using Prometheus Query Language (PromQL) (https://prometheus.io/docs/prometheus/latest/querying/basics/).The PrometheusQueryLanguageCondition message contains information from a Prometheus alerting rule and its associated rule group.A Prometheus alerting rule is described here (https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/). The semantics of a Prometheus alerting rule is described here (https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#rule).A Prometheus rule group is described here (https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/). The semantics of a Prometheus rule group is described here (https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#rule_group).Because Cloud Alerting has no representation of a Prometheus rule group resource, we must embed the information of the parent rule group inside each of the conditions that refer to it. We must also update the contents of all Prometheus alerts in case the information of their rule group changes.The PrometheusQueryLanguageCondition protocol buffer combines the information of the corresponding rule group and alerting rule. The structure of the PrometheusQueryLanguageCondition protocol buffer does NOT mimic the structure of the Prometheus rule group and alerting rule YAML declarations. The PrometheusQueryLanguageCondition protocol buffer may change in the future to support future rule group and/or alerting rule features. There are no new such features at the present time (2023-06-26).
2054///
2055/// This type is not used in any activity, and only used as *part* of another schema.
2056///
2057#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2058#[serde_with::serde_as]
2059#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2060pub struct PrometheusQueryLanguageCondition {
2061 /// Optional. The alerting rule name of this alert in the corresponding Prometheus configuration file.Some external tools may require this field to be populated correctly in order to refer to the original Prometheus configuration file. The rule group name and the alert name are necessary to update the relevant AlertPolicies in case the definition of the rule group changes in the future.This field is optional. If this field is not empty, then it must be a valid Prometheus label name (https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). This field may not exceed 2048 Unicode characters in length.
2062 #[serde(rename = "alertRule")]
2063 pub alert_rule: Option<String>,
2064 /// Optional. Alerts are considered firing once their PromQL expression was evaluated to be "true" for this long. Alerts whose PromQL expression was not evaluated to be "true" for long enough are considered pending. Must be a non-negative duration or missing. This field is optional. Its default value is zero.
2065 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2066 pub duration: Option<chrono::Duration>,
2067 /// Optional. How often this rule should be evaluated. Must be a positive multiple of 30 seconds or missing. This field is optional. Its default value is 30 seconds. If this PrometheusQueryLanguageCondition was generated from a Prometheus alerting rule, then this value should be taken from the enclosing rule group.
2068 #[serde(rename = "evaluationInterval")]
2069 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2070 pub evaluation_interval: Option<chrono::Duration>,
2071 /// Optional. Labels to add to or overwrite in the PromQL query result. Label names must be valid (https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). Label values can be templatized by using variables (https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars). The only available variable names are the names of the labels in the PromQL result, including "__name__" and "value". "labels" may be empty.
2072 pub labels: Option<HashMap<String, String>>,
2073 /// Required. The PromQL expression to evaluate. Every evaluation cycle this expression is evaluated at the current time, and all resultant time series become pending/firing alerts. This field must not be empty.
2074 pub query: Option<String>,
2075 /// Optional. The rule group name of this alert in the corresponding Prometheus configuration file.Some external tools may require this field to be populated correctly in order to refer to the original Prometheus configuration file. The rule group name and the alert name are necessary to update the relevant AlertPolicies in case the definition of the rule group changes in the future.This field is optional. If this field is not empty, then it must contain a valid UTF-8 string. This field may not exceed 2048 Unicode characters in length.
2076 #[serde(rename = "ruleGroup")]
2077 pub rule_group: Option<String>,
2078}
2079
2080impl common::Part for PrometheusQueryLanguageCondition {}
2081
2082/// The QueryTimeSeries request.
2083///
2084/// # Activities
2085///
2086/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2087/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2088///
2089/// * [time series query projects](ProjectTimeSeryQueryCall) (request)
2090#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2091#[serde_with::serde_as]
2092#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2093pub struct QueryTimeSeriesRequest {
2094 /// A positive number that is the maximum number of time_series_data to return.
2095 #[serde(rename = "pageSize")]
2096 pub page_size: Option<i32>,
2097 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
2098 #[serde(rename = "pageToken")]
2099 pub page_token: Option<String>,
2100 /// Required. The query in the Monitoring Query Language (https://cloud.google.com/monitoring/mql/reference) format. The default time zone is in UTC.
2101 pub query: Option<String>,
2102}
2103
2104impl common::RequestValue for QueryTimeSeriesRequest {}
2105
2106/// The QueryTimeSeries response.
2107///
2108/// # Activities
2109///
2110/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2111/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2112///
2113/// * [time series query projects](ProjectTimeSeryQueryCall) (response)
2114#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2115#[serde_with::serde_as]
2116#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2117pub struct QueryTimeSeriesResponse {
2118 /// If there are more results than have been returned, then this field is set to a non-empty value. To see the additional results, use that value as page_token in the next call to this method.
2119 #[serde(rename = "nextPageToken")]
2120 pub next_page_token: Option<String>,
2121 /// Query execution errors that may have caused the time series data returned to be incomplete. The available data will be available in the response.
2122 #[serde(rename = "partialErrors")]
2123 pub partial_errors: Option<Vec<Status>>,
2124 /// The time series data.
2125 #[serde(rename = "timeSeriesData")]
2126 pub time_series_data: Option<Vec<TimeSeriesData>>,
2127 /// The descriptor for the time series data.
2128 #[serde(rename = "timeSeriesDescriptor")]
2129 pub time_series_descriptor: Option<TimeSeriesDescriptor>,
2130}
2131
2132impl common::ResponseResult for QueryTimeSeriesResponse {}
2133
2134/// The range of the population values.
2135///
2136/// This type is not used in any activity, and only used as *part* of another schema.
2137///
2138#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2139#[serde_with::serde_as]
2140#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2141pub struct Range {
2142 /// The maximum of the population values.
2143 pub max: Option<f64>,
2144 /// The minimum of the population values.
2145 pub min: Option<f64>,
2146}
2147
2148impl common::Part for Range {}
2149
2150/// Service Level Indicators for which atomic units of service are counted directly.
2151///
2152/// This type is not used in any activity, and only used as *part* of another schema.
2153///
2154#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2155#[serde_with::serde_as]
2156#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2157pub struct RequestBasedSli {
2158 /// distribution_cut is used when good_service is a count of values aggregated in a Distribution that fall into a good range. The total_service is the total count of all values aggregated in the Distribution.
2159 #[serde(rename = "distributionCut")]
2160 pub distribution_cut: Option<DistributionCut>,
2161 /// good_total_ratio is used when the ratio of good_service to total_service is computed from two TimeSeries.
2162 #[serde(rename = "goodTotalRatio")]
2163 pub good_total_ratio: Option<TimeSeriesRatio>,
2164}
2165
2166impl common::Part for RequestBasedSli {}
2167
2168/// The resource submessage for group checks. It can be used instead of a monitored resource, when multiple resources are being monitored.
2169///
2170/// This type is not used in any activity, and only used as *part* of another schema.
2171///
2172#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2173#[serde_with::serde_as]
2174#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2175pub struct ResourceGroup {
2176 /// The group of resources being monitored. Should be only the [GROUP_ID], and not the full-path projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID].
2177 #[serde(rename = "groupId")]
2178 pub group_id: Option<String>,
2179 /// The resource type of the group members.
2180 #[serde(rename = "resourceType")]
2181 pub resource_type: Option<String>,
2182}
2183
2184impl common::Part for ResourceGroup {}
2185
2186/// A status to accept. Either a status code class like "2xx", or an integer status code like "200".
2187///
2188/// This type is not used in any activity, and only used as *part* of another schema.
2189///
2190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2191#[serde_with::serde_as]
2192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2193pub struct ResponseStatusCode {
2194 /// A class of status codes to accept.
2195 #[serde(rename = "statusClass")]
2196 pub status_class: Option<String>,
2197 /// A status code to accept.
2198 #[serde(rename = "statusValue")]
2199 pub status_value: Option<i32>,
2200}
2201
2202impl common::Part for ResponseStatusCode {}
2203
2204/// The SendNotificationChannelVerificationCode request.
2205///
2206/// # Activities
2207///
2208/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2209/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2210///
2211/// * [notification channels send verification code projects](ProjectNotificationChannelSendVerificationCodeCall) (request)
2212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2213#[serde_with::serde_as]
2214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2215pub struct SendNotificationChannelVerificationCodeRequest {
2216 _never_set: Option<bool>,
2217}
2218
2219impl common::RequestValue for SendNotificationChannelVerificationCodeRequest {}
2220
2221/// A Service is a discrete, autonomous, and network-accessible unit, designed to solve an individual concern (Wikipedia (https://en.wikipedia.org/wiki/Service-orientation)). In Cloud Monitoring, a Service acts as the root resource under which operational aspects of the service are accessible.
2222///
2223/// # Activities
2224///
2225/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2226/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2227///
2228/// * [service level objectives create services](ServiceServiceLevelObjectiveCreateCall) (none)
2229/// * [service level objectives delete services](ServiceServiceLevelObjectiveDeleteCall) (none)
2230/// * [service level objectives get services](ServiceServiceLevelObjectiveGetCall) (none)
2231/// * [service level objectives list services](ServiceServiceLevelObjectiveListCall) (none)
2232/// * [service level objectives patch services](ServiceServiceLevelObjectivePatchCall) (none)
2233/// * [create services](ServiceCreateCall) (request|response)
2234/// * [delete services](ServiceDeleteCall) (none)
2235/// * [get services](ServiceGetCall) (response)
2236/// * [list services](ServiceListCall) (none)
2237/// * [patch services](ServicePatchCall) (request|response)
2238#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2239#[serde_with::serde_as]
2240#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2241pub struct Service {
2242 /// Type used for App Engine services.
2243 #[serde(rename = "appEngine")]
2244 pub app_engine: Option<AppEngine>,
2245 /// Message that contains the service type and service labels of this service if it is a basic service. Documentation and examples here (https://cloud.google.com/stackdriver/docs/solutions/slo-monitoring/api/api-structures#basic-svc-w-basic-sli).
2246 #[serde(rename = "basicService")]
2247 pub basic_service: Option<BasicService>,
2248 /// Type used for Cloud Endpoints services.
2249 #[serde(rename = "cloudEndpoints")]
2250 pub cloud_endpoints: Option<CloudEndpoints>,
2251 /// Type used for Cloud Run services.
2252 #[serde(rename = "cloudRun")]
2253 pub cloud_run: Option<CloudRun>,
2254 /// Type used for Istio services that live in a Kubernetes cluster.
2255 #[serde(rename = "clusterIstio")]
2256 pub cluster_istio: Option<ClusterIstio>,
2257 /// Custom service type.
2258 pub custom: Option<Custom>,
2259 /// Name used for UI elements listing this Service.
2260 #[serde(rename = "displayName")]
2261 pub display_name: Option<String>,
2262 /// Type used for GKE Namespaces.
2263 #[serde(rename = "gkeNamespace")]
2264 pub gke_namespace: Option<GkeNamespace>,
2265 /// Type used for GKE Services (the Kubernetes concept of a service).
2266 #[serde(rename = "gkeService")]
2267 pub gke_service: Option<GkeService>,
2268 /// Type used for GKE Workloads.
2269 #[serde(rename = "gkeWorkload")]
2270 pub gke_workload: Option<GkeWorkload>,
2271 /// Type used for canonical services scoped to an Istio mesh. Metrics for Istio are documented here (https://istio.io/latest/docs/reference/config/metrics/)
2272 #[serde(rename = "istioCanonicalService")]
2273 pub istio_canonical_service: Option<IstioCanonicalService>,
2274 /// Type used for Istio services scoped to an Istio mesh.
2275 #[serde(rename = "meshIstio")]
2276 pub mesh_istio: Option<MeshIstio>,
2277 /// Identifier. Resource name for this Service. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
2278 pub name: Option<String>,
2279 /// Configuration for how to query telemetry on a Service.
2280 pub telemetry: Option<Telemetry>,
2281 /// Labels which have been used to annotate the service. Label keys must start with a letter. Label keys and values may contain lowercase letters, numbers, underscores, and dashes. Label keys and values have a maximum length of 63 characters, and must be less than 128 bytes in size. Up to 64 label entries may be stored. For labels which do not have a semantic value, the empty string may be supplied for the label value.
2282 #[serde(rename = "userLabels")]
2283 pub user_labels: Option<HashMap<String, String>>,
2284}
2285
2286impl common::RequestValue for Service {}
2287impl common::Resource for Service {}
2288impl common::ResponseResult for Service {}
2289
2290/// Contains information needed for generating either an OpenID Connect token (https://developers.google.com/identity/protocols/OpenIDConnect) or OAuth token (https://developers.google.com/identity/protocols/oauth2). The token will be generated for the Monitoring service agent service account.
2291///
2292/// This type is not used in any activity, and only used as *part* of another schema.
2293///
2294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2295#[serde_with::serde_as]
2296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2297pub struct ServiceAgentAuthentication {
2298 /// Type of authentication.
2299 #[serde(rename = "type")]
2300 pub type_: Option<String>,
2301}
2302
2303impl common::Part for ServiceAgentAuthentication {}
2304
2305/// A Service-Level Indicator (SLI) describes the "performance" of a service. For some services, the SLI is well-defined. In such cases, the SLI can be described easily by referencing the well-known SLI and providing the needed parameters. Alternatively, a "custom" SLI can be defined with a query to the underlying metric store. An SLI is defined to be good_service / total_service over any queried time interval. The value of performance always falls into the range 0 <= performance <= 1. A custom SLI describes how to compute this ratio, whether this is by dividing values from a pair of time series, cutting a Distribution into good and bad counts, or counting time windows in which the service complies with a criterion. For separation of concerns, a single Service-Level Indicator measures performance for only one aspect of service quality, such as fraction of successful queries or fast-enough queries.
2306///
2307/// This type is not used in any activity, and only used as *part* of another schema.
2308///
2309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2310#[serde_with::serde_as]
2311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2312pub struct ServiceLevelIndicator {
2313 /// Basic SLI on a well-known service type.
2314 #[serde(rename = "basicSli")]
2315 pub basic_sli: Option<BasicSli>,
2316 /// Request-based SLIs
2317 #[serde(rename = "requestBased")]
2318 pub request_based: Option<RequestBasedSli>,
2319 /// Windows-based SLIs
2320 #[serde(rename = "windowsBased")]
2321 pub windows_based: Option<WindowsBasedSli>,
2322}
2323
2324impl common::Part for ServiceLevelIndicator {}
2325
2326/// A Service-Level Objective (SLO) describes a level of desired good service. It consists of a service-level indicator (SLI), a performance goal, and a period over which the objective is to be evaluated against that goal. The SLO can use SLIs defined in a number of different manners. Typical SLOs might include “99% of requests in each rolling week have latency below 200 milliseconds” or “99.5% of requests in each calendar month return successfully.”
2327///
2328/// # Activities
2329///
2330/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2331/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2332///
2333/// * [service level objectives create services](ServiceServiceLevelObjectiveCreateCall) (request|response)
2334/// * [service level objectives get services](ServiceServiceLevelObjectiveGetCall) (response)
2335/// * [service level objectives patch services](ServiceServiceLevelObjectivePatchCall) (request|response)
2336#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2337#[serde_with::serde_as]
2338#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2339pub struct ServiceLevelObjective {
2340 /// A calendar period, semantically "since the start of the current ". At this time, only DAY, WEEK, FORTNIGHT, and MONTH are supported.
2341 #[serde(rename = "calendarPeriod")]
2342 pub calendar_period: Option<String>,
2343 /// Name used for UI elements listing this SLO.
2344 #[serde(rename = "displayName")]
2345 pub display_name: Option<String>,
2346 /// The fraction of service that must be good in order for this objective to be met. 0 < goal <= 0.9999.
2347 pub goal: Option<f64>,
2348 /// Identifier. Resource name for this ServiceLevelObjective. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
2349 pub name: Option<String>,
2350 /// A rolling time period, semantically "in the past ". Must be an integer multiple of 1 day no larger than 30 days.
2351 #[serde(rename = "rollingPeriod")]
2352 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2353 pub rolling_period: Option<chrono::Duration>,
2354 /// The definition of good service, used to measure and calculate the quality of the Service's performance with respect to a single aspect of service quality.
2355 #[serde(rename = "serviceLevelIndicator")]
2356 pub service_level_indicator: Option<ServiceLevelIndicator>,
2357 /// Labels which have been used to annotate the service-level objective. Label keys must start with a letter. Label keys and values may contain lowercase letters, numbers, underscores, and dashes. Label keys and values have a maximum length of 63 characters, and must be less than 128 bytes in size. Up to 64 label entries may be stored. For labels which do not have a semantic value, the empty string may be supplied for the label value.
2358 #[serde(rename = "userLabels")]
2359 pub user_labels: Option<HashMap<String, String>>,
2360}
2361
2362impl common::RequestValue for ServiceLevelObjective {}
2363impl common::ResponseResult for ServiceLevelObjective {}
2364
2365/// A Snooze will prevent any alerts from being opened, and close any that are already open. The Snooze will work on alerts that match the criteria defined in the Snooze. The Snooze will be active from interval.start_time through interval.end_time.
2366///
2367/// # Activities
2368///
2369/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2370/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2371///
2372/// * [snoozes create projects](ProjectSnoozeCreateCall) (request|response)
2373/// * [snoozes get projects](ProjectSnoozeGetCall) (response)
2374/// * [snoozes patch projects](ProjectSnoozePatchCall) (request|response)
2375#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2376#[serde_with::serde_as]
2377#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2378pub struct Snooze {
2379 /// Required. This defines the criteria for applying the Snooze. See Criteria for more information.
2380 pub criteria: Option<Criteria>,
2381 /// Required. A display name for the Snooze. This can be, at most, 512 unicode characters.
2382 #[serde(rename = "displayName")]
2383 pub display_name: Option<String>,
2384 /// Required. The Snooze will be active from interval.start_time through interval.end_time. interval.start_time cannot be in the past. There is a 15 second clock skew to account for the time it takes for a request to reach the API from the UI.
2385 pub interval: Option<TimeInterval>,
2386 /// Required. Identifier. The name of the Snooze. The format is: projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID] The ID of the Snooze will be generated by the system.
2387 pub name: Option<String>,
2388}
2389
2390impl common::RequestValue for Snooze {}
2391impl common::ResponseResult for Snooze {}
2392
2393/// The Status type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by gRPC (https://github.com/grpc). Each Status message contains three pieces of data: error code, error message, and error details.You can find out more about this error model and how to work with it in the API Design Guide (https://cloud.google.com/apis/design/errors).
2394///
2395/// This type is not used in any activity, and only used as *part* of another schema.
2396///
2397#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2398#[serde_with::serde_as]
2399#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2400pub struct Status {
2401 /// The status code, which should be an enum value of google.rpc.Code.
2402 pub code: Option<i32>,
2403 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2404 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2405 /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
2406 pub message: Option<String>,
2407}
2408
2409impl common::Part for Status {}
2410
2411/// Describes a Synthetic Monitor to be invoked by Uptime.
2412///
2413/// This type is not used in any activity, and only used as *part* of another schema.
2414///
2415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2416#[serde_with::serde_as]
2417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2418pub struct SyntheticMonitorTarget {
2419 /// Target a Synthetic Monitor GCFv2 instance.
2420 #[serde(rename = "cloudFunctionV2")]
2421 pub cloud_function_v2: Option<CloudFunctionV2Target>,
2422}
2423
2424impl common::Part for SyntheticMonitorTarget {}
2425
2426/// Information required for a TCP Uptime check request.
2427///
2428/// This type is not used in any activity, and only used as *part* of another schema.
2429///
2430#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2431#[serde_with::serde_as]
2432#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2433pub struct TcpCheck {
2434 /// Contains information needed to add pings to a TCP check.
2435 #[serde(rename = "pingConfig")]
2436 pub ping_config: Option<PingConfig>,
2437 /// The TCP port on the server against which to run the check. Will be combined with host (specified within the monitored_resource) to construct the full URL. Required.
2438 pub port: Option<i32>,
2439}
2440
2441impl common::Part for TcpCheck {}
2442
2443/// Configuration for how to query telemetry on a Service.
2444///
2445/// This type is not used in any activity, and only used as *part* of another schema.
2446///
2447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2448#[serde_with::serde_as]
2449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2450pub struct Telemetry {
2451 /// The full name of the resource that defines this service. Formatted as described in https://cloud.google.com/apis/design/resource_names.
2452 #[serde(rename = "resourceName")]
2453 pub resource_name: Option<String>,
2454}
2455
2456impl common::Part for Telemetry {}
2457
2458/// Describes a time interval: Reads: A half-open time interval. It includes the end time but excludes the start time: (startTime, endTime]. The start time must be specified, must be earlier than the end time, and should be no older than the data retention period for the metric. Writes: A closed time interval. It extends from the start time to the end time, and includes both: [startTime, endTime]. Valid time intervals depend on the MetricKind (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors#MetricKind) of the metric value. The end time must not be earlier than the start time, and the end time must not be more than 25 hours in the past or more than five minutes in the future. For GAUGE metrics, the startTime value is technically optional; if no value is specified, the start time defaults to the value of the end time, and the interval represents a single point in time. If both start and end times are specified, they must be identical. Such an interval is valid only for GAUGE metrics, which are point-in-time measurements. The end time of a new interval must be at least a millisecond after the end time of the previous interval. For DELTA metrics, the start time and end time must specify a non-zero interval, with subsequent points specifying contiguous and non-overlapping intervals. For DELTA metrics, the start time of the next interval must be at least a millisecond after the end time of the previous interval. For CUMULATIVE metrics, the start time and end time must specify a non-zero interval, with subsequent points specifying the same start time and increasing end times, until an event resets the cumulative value to zero and sets a new start time for the following points. The new start time must be at least a millisecond after the end time of the previous interval. The start time of a new interval must be at least a millisecond after the end time of the previous interval because intervals are closed. If the start time of a new interval is the same as the end time of the previous interval, then data written at the new start time could overwrite data written at the previous end time.
2459///
2460/// This type is not used in any activity, and only used as *part* of another schema.
2461///
2462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2463#[serde_with::serde_as]
2464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2465pub struct TimeInterval {
2466 /// Required. The end of the time interval.
2467 #[serde(rename = "endTime")]
2468 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2469 /// Optional. The beginning of the time interval. The default value for the start time is the end time. The start time must not be later than the end time.
2470 #[serde(rename = "startTime")]
2471 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2472}
2473
2474impl common::Part for TimeInterval {}
2475
2476/// A collection of data points that describes the time-varying values of a metric. A time series is identified by a combination of a fully-specified monitored resource and a fully-specified metric. This type is used for both listing and creating time series.
2477///
2478/// This type is not used in any activity, and only used as *part* of another schema.
2479///
2480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2481#[serde_with::serde_as]
2482#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2483pub struct TimeSeries {
2484 /// Output only. The associated monitored resource metadata. When reading a time series, this field will include metadata labels that are explicitly named in the reduction. When creating a time series, this field is ignored.
2485 pub metadata: Option<MonitoredResourceMetadata>,
2486 /// The associated metric. A fully-specified metric used to identify the time series.
2487 pub metric: Option<Metric>,
2488 /// The metric kind of the time series. When listing time series, this metric kind might be different from the metric kind of the associated metric if this time series is an alignment or reduction of other time series.When creating a time series, this field is optional. If present, it must be the same as the metric kind of the associated metric. If the associated metric's descriptor must be auto-created, then this field specifies the metric kind of the new descriptor and must be either GAUGE (the default) or CUMULATIVE.
2489 #[serde(rename = "metricKind")]
2490 pub metric_kind: Option<String>,
2491 /// The data points of this time series. When listing time series, points are returned in reverse time order.When creating a time series, this field must contain exactly one point and the point's type must be the same as the value type of the associated metric. If the associated metric's descriptor must be auto-created, then the value type of the descriptor is determined by the point's type, which must be BOOL, INT64, DOUBLE, or DISTRIBUTION.
2492 pub points: Option<Vec<Point>>,
2493 /// The associated monitored resource. Custom metrics can use only certain monitored resource types in their time series data. For more information, see Monitored resources for custom metrics (https://cloud.google.com/monitoring/custom-metrics/creating-metrics#custom-metric-resources).
2494 pub resource: Option<MonitoredResource>,
2495 /// The units in which the metric value is reported. It is only applicable if the value_type is INT64, DOUBLE, or DISTRIBUTION. The unit defines the representation of the stored metric values.
2496 pub unit: Option<String>,
2497 /// The value type of the time series. When listing time series, this value type might be different from the value type of the associated metric if this time series is an alignment or reduction of other time series.When creating a time series, this field is optional. If present, it must be the same as the type of the data in the points field.
2498 #[serde(rename = "valueType")]
2499 pub value_type: Option<String>,
2500}
2501
2502impl common::Part for TimeSeries {}
2503
2504/// Represents the values of a time series associated with a TimeSeriesDescriptor.
2505///
2506/// This type is not used in any activity, and only used as *part* of another schema.
2507///
2508#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2509#[serde_with::serde_as]
2510#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2511pub struct TimeSeriesData {
2512 /// The values of the labels in the time series identifier, given in the same order as the label_descriptors field of the TimeSeriesDescriptor associated with this object. Each value must have a value of the type given in the corresponding entry of label_descriptors.
2513 #[serde(rename = "labelValues")]
2514 pub label_values: Option<Vec<LabelValue>>,
2515 /// The points in the time series.
2516 #[serde(rename = "pointData")]
2517 pub point_data: Option<Vec<PointData>>,
2518}
2519
2520impl common::Part for TimeSeriesData {}
2521
2522/// A descriptor for the labels and points in a time series.
2523///
2524/// This type is not used in any activity, and only used as *part* of another schema.
2525///
2526#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2527#[serde_with::serde_as]
2528#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2529pub struct TimeSeriesDescriptor {
2530 /// Descriptors for the labels.
2531 #[serde(rename = "labelDescriptors")]
2532 pub label_descriptors: Option<Vec<LabelDescriptor>>,
2533 /// Descriptors for the point data value columns.
2534 #[serde(rename = "pointDescriptors")]
2535 pub point_descriptors: Option<Vec<ValueDescriptor>>,
2536}
2537
2538impl common::Part for TimeSeriesDescriptor {}
2539
2540/// A TimeSeriesRatio specifies two TimeSeries to use for computing the good_service / total_service ratio. The specified TimeSeries must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE. The TimeSeriesRatio must specify exactly two of good, bad, and total, and the relationship good_service + bad_service = total_service will be assumed.
2541///
2542/// This type is not used in any activity, and only used as *part* of another schema.
2543///
2544#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2545#[serde_with::serde_as]
2546#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2547pub struct TimeSeriesRatio {
2548 /// A monitoring filter (https://cloud.google.com/monitoring/api/v3/filters) specifying a TimeSeries quantifying bad service, either demanded service that was not provided or demanded service that was of inadequate quality. Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE.
2549 #[serde(rename = "badServiceFilter")]
2550 pub bad_service_filter: Option<String>,
2551 /// A monitoring filter (https://cloud.google.com/monitoring/api/v3/filters) specifying a TimeSeries quantifying good service provided. Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE.
2552 #[serde(rename = "goodServiceFilter")]
2553 pub good_service_filter: Option<String>,
2554 /// A monitoring filter (https://cloud.google.com/monitoring/api/v3/filters) specifying a TimeSeries quantifying total demanded service. Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE.
2555 #[serde(rename = "totalServiceFilter")]
2556 pub total_service_filter: Option<String>,
2557}
2558
2559impl common::Part for TimeSeriesRatio {}
2560
2561/// Specifies how many time series must fail a predicate to trigger a condition. If not specified, then a {count: 1} trigger is used.
2562///
2563/// This type is not used in any activity, and only used as *part* of another schema.
2564///
2565#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2566#[serde_with::serde_as]
2567#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2568pub struct Trigger {
2569 /// The absolute number of time series that must fail the predicate for the condition to be triggered.
2570 pub count: Option<i32>,
2571 /// The percentage of time series that must fail the predicate for the condition to be triggered.
2572 pub percent: Option<f64>,
2573}
2574
2575impl common::Part for Trigger {}
2576
2577/// A single strongly-typed value.
2578///
2579/// This type is not used in any activity, and only used as *part* of another schema.
2580///
2581#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2582#[serde_with::serde_as]
2583#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2584pub struct TypedValue {
2585 /// A Boolean value: true or false.
2586 #[serde(rename = "boolValue")]
2587 pub bool_value: Option<bool>,
2588 /// A distribution value.
2589 #[serde(rename = "distributionValue")]
2590 pub distribution_value: Option<Distribution>,
2591 /// A 64-bit double-precision floating-point number. Its magnitude is approximately ±10±300 and it has 16 significant digits of precision.
2592 #[serde(rename = "doubleValue")]
2593 pub double_value: Option<f64>,
2594 /// A 64-bit integer. Its range is approximately ±9.2x1018.
2595 #[serde(rename = "int64Value")]
2596 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2597 pub int64_value: Option<i64>,
2598 /// A variable-length string value.
2599 #[serde(rename = "stringValue")]
2600 pub string_value: Option<String>,
2601}
2602
2603impl common::Part for TypedValue {}
2604
2605/// This message configures which resources and services to monitor for availability.
2606///
2607/// # Activities
2608///
2609/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2610/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2611///
2612/// * [uptime check configs create projects](ProjectUptimeCheckConfigCreateCall) (request|response)
2613/// * [uptime check configs get projects](ProjectUptimeCheckConfigGetCall) (response)
2614/// * [uptime check configs patch projects](ProjectUptimeCheckConfigPatchCall) (request|response)
2615#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2616#[serde_with::serde_as]
2617#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2618pub struct UptimeCheckConfig {
2619 /// The type of checkers to use to execute the Uptime check.
2620 #[serde(rename = "checkerType")]
2621 pub checker_type: Option<String>,
2622 /// The content that is expected to appear in the data returned by the target server against which the check is run. Currently, only the first entry in the content_matchers list is supported, and additional entries will be ignored. This field is optional and should only be specified if a content match is required as part of the/ Uptime check.
2623 #[serde(rename = "contentMatchers")]
2624 pub content_matchers: Option<Vec<ContentMatcher>>,
2625 /// A human-friendly name for the Uptime check configuration. The display name should be unique within a Cloud Monitoring Workspace in order to make it easier to identify; however, uniqueness is not enforced. Required.
2626 #[serde(rename = "displayName")]
2627 pub display_name: Option<String>,
2628 /// Contains information needed to make an HTTP or HTTPS check.
2629 #[serde(rename = "httpCheck")]
2630 pub http_check: Option<HttpCheck>,
2631 /// The internal checkers that this check will egress from. If is_internal is true and this list is empty, the check will egress from all the InternalCheckers configured for the project that owns this UptimeCheckConfig.
2632 #[serde(rename = "internalCheckers")]
2633 pub internal_checkers: Option<Vec<InternalChecker>>,
2634 /// If this is true, then checks are made only from the 'internal_checkers'. If it is false, then checks are made only from the 'selected_regions'. It is an error to provide 'selected_regions' when is_internal is true, or to provide 'internal_checkers' when is_internal is false.
2635 #[serde(rename = "isInternal")]
2636 pub is_internal: Option<bool>,
2637 /// The monitored resource (https://cloud.google.com/monitoring/api/resources) associated with the configuration. The following monitored resource types are valid for this field: uptime_url, gce_instance, gae_app, aws_ec2_instance, aws_elb_load_balancer k8s_service servicedirectory_service cloud_run_revision
2638 #[serde(rename = "monitoredResource")]
2639 pub monitored_resource: Option<MonitoredResource>,
2640 /// Identifier. A unique resource name for this Uptime check configuration. The format is: projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] [PROJECT_ID_OR_NUMBER] is the Workspace host project associated with the Uptime check.This field should be omitted when creating the Uptime check configuration; on create, the resource name is assigned by the server and included in the response.
2641 pub name: Option<String>,
2642 /// How often, in seconds, the Uptime check is performed. Currently, the only supported values are 60s (1 minute), 300s (5 minutes), 600s (10 minutes), and 900s (15 minutes). Optional, defaults to 60s.
2643 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2644 pub period: Option<chrono::Duration>,
2645 /// The group resource associated with the configuration.
2646 #[serde(rename = "resourceGroup")]
2647 pub resource_group: Option<ResourceGroup>,
2648 /// The list of regions from which the check will be run. Some regions contain one location, and others contain more than one. If this field is specified, enough regions must be provided to include a minimum of 3 locations. Not specifying this field will result in Uptime checks running from all available regions.
2649 #[serde(rename = "selectedRegions")]
2650 pub selected_regions: Option<Vec<String>>,
2651 /// Specifies a Synthetic Monitor to invoke.
2652 #[serde(rename = "syntheticMonitor")]
2653 pub synthetic_monitor: Option<SyntheticMonitorTarget>,
2654 /// Contains information needed to make a TCP check.
2655 #[serde(rename = "tcpCheck")]
2656 pub tcp_check: Option<TcpCheck>,
2657 /// The maximum amount of time to wait for the request to complete (must be between 1 and 60 seconds). Required.
2658 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2659 pub timeout: Option<chrono::Duration>,
2660 /// User-supplied key/value data to be used for organizing and identifying the UptimeCheckConfig objects.The field can contain up to 64 entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter.
2661 #[serde(rename = "userLabels")]
2662 pub user_labels: Option<HashMap<String, String>>,
2663}
2664
2665impl common::RequestValue for UptimeCheckConfig {}
2666impl common::ResponseResult for UptimeCheckConfig {}
2667
2668/// Contains the region, location, and list of IP addresses where checkers in the location run from.
2669///
2670/// # Activities
2671///
2672/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2673/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2674///
2675/// * [list uptime check ips](UptimeCheckIpListCall) (none)
2676#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2677#[serde_with::serde_as]
2678#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2679pub struct UptimeCheckIp {
2680 /// The IP address from which the Uptime check originates. This is a fully specified IP address (not an IP address range). Most IP addresses, as of this publication, are in IPv4 format; however, one should not rely on the IP addresses being in IPv4 format indefinitely, and should support interpreting this field in either IPv4 or IPv6 format.
2681 #[serde(rename = "ipAddress")]
2682 pub ip_address: Option<String>,
2683 /// A more specific location within the region that typically encodes a particular city/town/metro (and its containing state/province or country) within the broader umbrella region category.
2684 pub location: Option<String>,
2685 /// A broad region category in which the IP address is located.
2686 pub region: Option<String>,
2687}
2688
2689impl common::Resource for UptimeCheckIp {}
2690
2691/// A descriptor for the value columns in a data point.
2692///
2693/// This type is not used in any activity, and only used as *part* of another schema.
2694///
2695#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2696#[serde_with::serde_as]
2697#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2698pub struct ValueDescriptor {
2699 /// The value key.
2700 pub key: Option<String>,
2701 /// The value stream kind.
2702 #[serde(rename = "metricKind")]
2703 pub metric_kind: Option<String>,
2704 /// The unit in which time_series point values are reported. unit follows the UCUM format for units as seen in https://unitsofmeasure.org/ucum.html. unit is only valid if value_type is INTEGER, DOUBLE, DISTRIBUTION.
2705 pub unit: Option<String>,
2706 /// The value type.
2707 #[serde(rename = "valueType")]
2708 pub value_type: Option<String>,
2709}
2710
2711impl common::Part for ValueDescriptor {}
2712
2713/// The VerifyNotificationChannel request.
2714///
2715/// # Activities
2716///
2717/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2718/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2719///
2720/// * [notification channels verify projects](ProjectNotificationChannelVerifyCall) (request)
2721#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2722#[serde_with::serde_as]
2723#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2724pub struct VerifyNotificationChannelRequest {
2725 /// Required. The verification code that was delivered to the channel as a result of invoking the SendNotificationChannelVerificationCode API method or that was retrieved from a verified channel via GetNotificationChannelVerificationCode. For example, one might have "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in general, one is only guaranteed that the code is valid UTF-8; one should not make any assumptions regarding the structure or format of the code).
2726 pub code: Option<String>,
2727}
2728
2729impl common::RequestValue for VerifyNotificationChannelRequest {}
2730
2731/// A WindowsBasedSli defines good_service as the count of time windows for which the provided service was of good quality. Criteria for determining if service was good are embedded in the window_criterion.
2732///
2733/// This type is not used in any activity, and only used as *part* of another schema.
2734///
2735#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2736#[serde_with::serde_as]
2737#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2738pub struct WindowsBasedSli {
2739 /// A monitoring filter (https://cloud.google.com/monitoring/api/v3/filters) specifying a TimeSeries with ValueType = BOOL. The window is good if any true values appear in the window.
2740 #[serde(rename = "goodBadMetricFilter")]
2741 pub good_bad_metric_filter: Option<String>,
2742 /// A window is good if its performance is high enough.
2743 #[serde(rename = "goodTotalRatioThreshold")]
2744 pub good_total_ratio_threshold: Option<PerformanceThreshold>,
2745 /// A window is good if the metric's value is in a good range, averaged across returned streams.
2746 #[serde(rename = "metricMeanInRange")]
2747 pub metric_mean_in_range: Option<MetricRange>,
2748 /// A window is good if the metric's value is in a good range, summed across returned streams.
2749 #[serde(rename = "metricSumInRange")]
2750 pub metric_sum_in_range: Option<MetricRange>,
2751 /// Duration over which window quality is evaluated. Must be an integer fraction of a day and at least 60s.
2752 #[serde(rename = "windowPeriod")]
2753 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2754 pub window_period: Option<chrono::Duration>,
2755}
2756
2757impl common::Part for WindowsBasedSli {}
2758
2759// ###################
2760// MethodBuilders ###
2761// #################
2762
2763/// A builder providing access to all methods supported on *folder* resources.
2764/// It is not used directly, but through the [`Monitoring`] hub.
2765///
2766/// # Example
2767///
2768/// Instantiate a resource builder
2769///
2770/// ```test_harness,no_run
2771/// extern crate hyper;
2772/// extern crate hyper_rustls;
2773/// extern crate google_monitoring3 as monitoring3;
2774///
2775/// # async fn dox() {
2776/// use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2777///
2778/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2779/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2780/// secret,
2781/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2782/// ).build().await.unwrap();
2783///
2784/// let client = hyper_util::client::legacy::Client::builder(
2785/// hyper_util::rt::TokioExecutor::new()
2786/// )
2787/// .build(
2788/// hyper_rustls::HttpsConnectorBuilder::new()
2789/// .with_native_roots()
2790/// .unwrap()
2791/// .https_or_http()
2792/// .enable_http1()
2793/// .build()
2794/// );
2795/// let mut hub = Monitoring::new(client, auth);
2796/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2797/// // like `time_series_list(...)`
2798/// // to build up your call.
2799/// let rb = hub.folders();
2800/// # }
2801/// ```
2802pub struct FolderMethods<'a, C>
2803where
2804 C: 'a,
2805{
2806 hub: &'a Monitoring<C>,
2807}
2808
2809impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
2810
2811impl<'a, C> FolderMethods<'a, C> {
2812 /// Create a builder to help you perform the following task:
2813 ///
2814 /// Lists time series that match a filter.
2815 ///
2816 /// # Arguments
2817 ///
2818 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name), organization or folder on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]
2819 pub fn time_series_list(&self, name: &str) -> FolderTimeSeryListCall<'a, C> {
2820 FolderTimeSeryListCall {
2821 hub: self.hub,
2822 _name: name.to_string(),
2823 _view: Default::default(),
2824 _secondary_aggregation_per_series_aligner: Default::default(),
2825 _secondary_aggregation_group_by_fields: Default::default(),
2826 _secondary_aggregation_cross_series_reducer: Default::default(),
2827 _secondary_aggregation_alignment_period: Default::default(),
2828 _page_token: Default::default(),
2829 _page_size: Default::default(),
2830 _order_by: Default::default(),
2831 _interval_start_time: Default::default(),
2832 _interval_end_time: Default::default(),
2833 _filter: Default::default(),
2834 _aggregation_per_series_aligner: Default::default(),
2835 _aggregation_group_by_fields: Default::default(),
2836 _aggregation_cross_series_reducer: Default::default(),
2837 _aggregation_alignment_period: Default::default(),
2838 _delegate: Default::default(),
2839 _additional_params: Default::default(),
2840 _scopes: Default::default(),
2841 }
2842 }
2843}
2844
2845/// A builder providing access to all methods supported on *organization* resources.
2846/// It is not used directly, but through the [`Monitoring`] hub.
2847///
2848/// # Example
2849///
2850/// Instantiate a resource builder
2851///
2852/// ```test_harness,no_run
2853/// extern crate hyper;
2854/// extern crate hyper_rustls;
2855/// extern crate google_monitoring3 as monitoring3;
2856///
2857/// # async fn dox() {
2858/// use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2859///
2860/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2861/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2862/// secret,
2863/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2864/// ).build().await.unwrap();
2865///
2866/// let client = hyper_util::client::legacy::Client::builder(
2867/// hyper_util::rt::TokioExecutor::new()
2868/// )
2869/// .build(
2870/// hyper_rustls::HttpsConnectorBuilder::new()
2871/// .with_native_roots()
2872/// .unwrap()
2873/// .https_or_http()
2874/// .enable_http1()
2875/// .build()
2876/// );
2877/// let mut hub = Monitoring::new(client, auth);
2878/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2879/// // like `time_series_list(...)`
2880/// // to build up your call.
2881/// let rb = hub.organizations();
2882/// # }
2883/// ```
2884pub struct OrganizationMethods<'a, C>
2885where
2886 C: 'a,
2887{
2888 hub: &'a Monitoring<C>,
2889}
2890
2891impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
2892
2893impl<'a, C> OrganizationMethods<'a, C> {
2894 /// Create a builder to help you perform the following task:
2895 ///
2896 /// Lists time series that match a filter.
2897 ///
2898 /// # Arguments
2899 ///
2900 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name), organization or folder on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]
2901 pub fn time_series_list(&self, name: &str) -> OrganizationTimeSeryListCall<'a, C> {
2902 OrganizationTimeSeryListCall {
2903 hub: self.hub,
2904 _name: name.to_string(),
2905 _view: Default::default(),
2906 _secondary_aggregation_per_series_aligner: Default::default(),
2907 _secondary_aggregation_group_by_fields: Default::default(),
2908 _secondary_aggregation_cross_series_reducer: Default::default(),
2909 _secondary_aggregation_alignment_period: Default::default(),
2910 _page_token: Default::default(),
2911 _page_size: Default::default(),
2912 _order_by: Default::default(),
2913 _interval_start_time: Default::default(),
2914 _interval_end_time: Default::default(),
2915 _filter: Default::default(),
2916 _aggregation_per_series_aligner: Default::default(),
2917 _aggregation_group_by_fields: Default::default(),
2918 _aggregation_cross_series_reducer: Default::default(),
2919 _aggregation_alignment_period: Default::default(),
2920 _delegate: Default::default(),
2921 _additional_params: Default::default(),
2922 _scopes: Default::default(),
2923 }
2924 }
2925}
2926
2927/// A builder providing access to all methods supported on *project* resources.
2928/// It is not used directly, but through the [`Monitoring`] hub.
2929///
2930/// # Example
2931///
2932/// Instantiate a resource builder
2933///
2934/// ```test_harness,no_run
2935/// extern crate hyper;
2936/// extern crate hyper_rustls;
2937/// extern crate google_monitoring3 as monitoring3;
2938///
2939/// # async fn dox() {
2940/// use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2941///
2942/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2943/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2944/// secret,
2945/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2946/// ).build().await.unwrap();
2947///
2948/// let client = hyper_util::client::legacy::Client::builder(
2949/// hyper_util::rt::TokioExecutor::new()
2950/// )
2951/// .build(
2952/// hyper_rustls::HttpsConnectorBuilder::new()
2953/// .with_native_roots()
2954/// .unwrap()
2955/// .https_or_http()
2956/// .enable_http1()
2957/// .build()
2958/// );
2959/// let mut hub = Monitoring::new(client, auth);
2960/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2961/// // like `alert_policies_create(...)`, `alert_policies_delete(...)`, `alert_policies_get(...)`, `alert_policies_list(...)`, `alert_policies_patch(...)`, `collectd_time_series_create(...)`, `groups_create(...)`, `groups_delete(...)`, `groups_get(...)`, `groups_list(...)`, `groups_members_list(...)`, `groups_update(...)`, `metric_descriptors_create(...)`, `metric_descriptors_delete(...)`, `metric_descriptors_get(...)`, `metric_descriptors_list(...)`, `monitored_resource_descriptors_get(...)`, `monitored_resource_descriptors_list(...)`, `notification_channel_descriptors_get(...)`, `notification_channel_descriptors_list(...)`, `notification_channels_create(...)`, `notification_channels_delete(...)`, `notification_channels_get(...)`, `notification_channels_get_verification_code(...)`, `notification_channels_list(...)`, `notification_channels_patch(...)`, `notification_channels_send_verification_code(...)`, `notification_channels_verify(...)`, `snoozes_create(...)`, `snoozes_get(...)`, `snoozes_list(...)`, `snoozes_patch(...)`, `time_series_create(...)`, `time_series_create_service(...)`, `time_series_list(...)`, `time_series_query(...)`, `uptime_check_configs_create(...)`, `uptime_check_configs_delete(...)`, `uptime_check_configs_get(...)`, `uptime_check_configs_list(...)` and `uptime_check_configs_patch(...)`
2962/// // to build up your call.
2963/// let rb = hub.projects();
2964/// # }
2965/// ```
2966pub struct ProjectMethods<'a, C>
2967where
2968 C: 'a,
2969{
2970 hub: &'a Monitoring<C>,
2971}
2972
2973impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2974
2975impl<'a, C> ProjectMethods<'a, C> {
2976 /// Create a builder to help you perform the following task:
2977 ///
2978 /// Creates a new alerting policy.Design your application to single-thread API calls that modify the state of alerting policies in a single project. This includes calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
2979 ///
2980 /// # Arguments
2981 ///
2982 /// * `request` - No description provided.
2983 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) in which to create the alerting policy. The format is: projects/[PROJECT_ID_OR_NUMBER] Note that this field names the parent container in which the alerting policy will be written, not the name of the created policy. |name| must be a host project of a Metrics Scope, otherwise INVALID_ARGUMENT error will return. The alerting policy that is returned will have a name that contains a normalized representation of this name as a prefix but adds a suffix of the form /alertPolicies/[ALERT_POLICY_ID], identifying the policy in the container.
2984 pub fn alert_policies_create(
2985 &self,
2986 request: AlertPolicy,
2987 name: &str,
2988 ) -> ProjectAlertPolicyCreateCall<'a, C> {
2989 ProjectAlertPolicyCreateCall {
2990 hub: self.hub,
2991 _request: request,
2992 _name: name.to_string(),
2993 _delegate: Default::default(),
2994 _additional_params: Default::default(),
2995 _scopes: Default::default(),
2996 }
2997 }
2998
2999 /// Create a builder to help you perform the following task:
3000 ///
3001 /// Deletes an alerting policy.Design your application to single-thread API calls that modify the state of alerting policies in a single project. This includes calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
3002 ///
3003 /// # Arguments
3004 ///
3005 /// * `name` - Required. The alerting policy to delete. The format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] For more information, see AlertPolicy.
3006 pub fn alert_policies_delete(&self, name: &str) -> ProjectAlertPolicyDeleteCall<'a, C> {
3007 ProjectAlertPolicyDeleteCall {
3008 hub: self.hub,
3009 _name: name.to_string(),
3010 _delegate: Default::default(),
3011 _additional_params: Default::default(),
3012 _scopes: Default::default(),
3013 }
3014 }
3015
3016 /// Create a builder to help you perform the following task:
3017 ///
3018 /// Gets a single alerting policy.
3019 ///
3020 /// # Arguments
3021 ///
3022 /// * `name` - Required. The alerting policy to retrieve. The format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
3023 pub fn alert_policies_get(&self, name: &str) -> ProjectAlertPolicyGetCall<'a, C> {
3024 ProjectAlertPolicyGetCall {
3025 hub: self.hub,
3026 _name: name.to_string(),
3027 _delegate: Default::default(),
3028 _additional_params: Default::default(),
3029 _scopes: Default::default(),
3030 }
3031 }
3032
3033 /// Create a builder to help you perform the following task:
3034 ///
3035 /// Lists the existing alerting policies for the workspace.
3036 ///
3037 /// # Arguments
3038 ///
3039 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) whose alert policies are to be listed. The format is: projects/[PROJECT_ID_OR_NUMBER] Note that this field names the parent container in which the alerting policies to be listed are stored. To retrieve a single alerting policy by name, use the GetAlertPolicy operation, instead.
3040 pub fn alert_policies_list(&self, name: &str) -> ProjectAlertPolicyListCall<'a, C> {
3041 ProjectAlertPolicyListCall {
3042 hub: self.hub,
3043 _name: name.to_string(),
3044 _page_token: Default::default(),
3045 _page_size: Default::default(),
3046 _order_by: Default::default(),
3047 _filter: Default::default(),
3048 _delegate: Default::default(),
3049 _additional_params: Default::default(),
3050 _scopes: Default::default(),
3051 }
3052 }
3053
3054 /// Create a builder to help you perform the following task:
3055 ///
3056 /// Updates an alerting policy. You can either replace the entire policy with a new one or replace only certain fields in the current alerting policy by specifying the fields to be updated via updateMask. Returns the updated alerting policy.Design your application to single-thread API calls that modify the state of alerting policies in a single project. This includes calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
3057 ///
3058 /// # Arguments
3059 ///
3060 /// * `request` - No description provided.
3061 /// * `name` - Required if the policy exists. The resource name for this policy. The format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] [ALERT_POLICY_ID] is assigned by Cloud Monitoring when the policy is created. When calling the alertPolicies.create method, do not include the name field in the alerting policy passed as part of the request.
3062 pub fn alert_policies_patch(
3063 &self,
3064 request: AlertPolicy,
3065 name: &str,
3066 ) -> ProjectAlertPolicyPatchCall<'a, C> {
3067 ProjectAlertPolicyPatchCall {
3068 hub: self.hub,
3069 _request: request,
3070 _name: name.to_string(),
3071 _update_mask: Default::default(),
3072 _delegate: Default::default(),
3073 _additional_params: Default::default(),
3074 _scopes: Default::default(),
3075 }
3076 }
3077
3078 /// Create a builder to help you perform the following task:
3079 ///
3080 /// Cloud Monitoring Agent only: Creates a new time series.This method is only for use by the Cloud Monitoring Agent. Use projects.timeSeries.create instead.
3081 ///
3082 /// # Arguments
3083 ///
3084 /// * `request` - No description provided.
3085 /// * `name` - The project (https://cloud.google.com/monitoring/api/v3#project_name) in which to create the time series. The format is: projects/[PROJECT_ID_OR_NUMBER]
3086 pub fn collectd_time_series_create(
3087 &self,
3088 request: CreateCollectdTimeSeriesRequest,
3089 name: &str,
3090 ) -> ProjectCollectdTimeSeryCreateCall<'a, C> {
3091 ProjectCollectdTimeSeryCreateCall {
3092 hub: self.hub,
3093 _request: request,
3094 _name: name.to_string(),
3095 _delegate: Default::default(),
3096 _additional_params: Default::default(),
3097 _scopes: Default::default(),
3098 }
3099 }
3100
3101 /// Create a builder to help you perform the following task:
3102 ///
3103 /// Lists the monitored resources that are members of a group.
3104 ///
3105 /// # Arguments
3106 ///
3107 /// * `name` - Required. The group whose members are listed. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
3108 pub fn groups_members_list(&self, name: &str) -> ProjectGroupMemberListCall<'a, C> {
3109 ProjectGroupMemberListCall {
3110 hub: self.hub,
3111 _name: name.to_string(),
3112 _page_token: Default::default(),
3113 _page_size: Default::default(),
3114 _interval_start_time: Default::default(),
3115 _interval_end_time: Default::default(),
3116 _filter: Default::default(),
3117 _delegate: Default::default(),
3118 _additional_params: Default::default(),
3119 _scopes: Default::default(),
3120 }
3121 }
3122
3123 /// Create a builder to help you perform the following task:
3124 ///
3125 /// Creates a new group.
3126 ///
3127 /// # Arguments
3128 ///
3129 /// * `request` - No description provided.
3130 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) in which to create the group. The format is: projects/[PROJECT_ID_OR_NUMBER]
3131 pub fn groups_create(&self, request: Group, name: &str) -> ProjectGroupCreateCall<'a, C> {
3132 ProjectGroupCreateCall {
3133 hub: self.hub,
3134 _request: request,
3135 _name: name.to_string(),
3136 _validate_only: Default::default(),
3137 _delegate: Default::default(),
3138 _additional_params: Default::default(),
3139 _scopes: Default::default(),
3140 }
3141 }
3142
3143 /// Create a builder to help you perform the following task:
3144 ///
3145 /// Deletes an existing group.
3146 ///
3147 /// # Arguments
3148 ///
3149 /// * `name` - Required. The group to delete. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
3150 pub fn groups_delete(&self, name: &str) -> ProjectGroupDeleteCall<'a, C> {
3151 ProjectGroupDeleteCall {
3152 hub: self.hub,
3153 _name: name.to_string(),
3154 _recursive: Default::default(),
3155 _delegate: Default::default(),
3156 _additional_params: Default::default(),
3157 _scopes: Default::default(),
3158 }
3159 }
3160
3161 /// Create a builder to help you perform the following task:
3162 ///
3163 /// Gets a single group.
3164 ///
3165 /// # Arguments
3166 ///
3167 /// * `name` - Required. The group to retrieve. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
3168 pub fn groups_get(&self, name: &str) -> ProjectGroupGetCall<'a, C> {
3169 ProjectGroupGetCall {
3170 hub: self.hub,
3171 _name: name.to_string(),
3172 _delegate: Default::default(),
3173 _additional_params: Default::default(),
3174 _scopes: Default::default(),
3175 }
3176 }
3177
3178 /// Create a builder to help you perform the following task:
3179 ///
3180 /// Lists the existing groups.
3181 ///
3182 /// # Arguments
3183 ///
3184 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) whose groups are to be listed. The format is: projects/[PROJECT_ID_OR_NUMBER]
3185 pub fn groups_list(&self, name: &str) -> ProjectGroupListCall<'a, C> {
3186 ProjectGroupListCall {
3187 hub: self.hub,
3188 _name: name.to_string(),
3189 _page_token: Default::default(),
3190 _page_size: Default::default(),
3191 _descendants_of_group: Default::default(),
3192 _children_of_group: Default::default(),
3193 _ancestors_of_group: Default::default(),
3194 _delegate: Default::default(),
3195 _additional_params: Default::default(),
3196 _scopes: Default::default(),
3197 }
3198 }
3199
3200 /// Create a builder to help you perform the following task:
3201 ///
3202 /// Updates an existing group. You can change any group attributes except name.
3203 ///
3204 /// # Arguments
3205 ///
3206 /// * `request` - No description provided.
3207 /// * `name` - Output only. The name of this group. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] When creating a group, this field is ignored and a new name is created consisting of the project specified in the call to CreateGroup and a unique [GROUP_ID] that is generated automatically.
3208 pub fn groups_update(&self, request: Group, name: &str) -> ProjectGroupUpdateCall<'a, C> {
3209 ProjectGroupUpdateCall {
3210 hub: self.hub,
3211 _request: request,
3212 _name: name.to_string(),
3213 _validate_only: Default::default(),
3214 _delegate: Default::default(),
3215 _additional_params: Default::default(),
3216 _scopes: Default::default(),
3217 }
3218 }
3219
3220 /// Create a builder to help you perform the following task:
3221 ///
3222 /// Creates a new metric descriptor. The creation is executed asynchronously. User-created metric descriptors define custom metrics (https://cloud.google.com/monitoring/custom-metrics). The metric descriptor is updated if it already exists, except that metric labels are never removed.
3223 ///
3224 /// # Arguments
3225 ///
3226 /// * `request` - No description provided.
3227 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: 4 projects/PROJECT_ID_OR_NUMBER
3228 pub fn metric_descriptors_create(
3229 &self,
3230 request: MetricDescriptor,
3231 name: &str,
3232 ) -> ProjectMetricDescriptorCreateCall<'a, C> {
3233 ProjectMetricDescriptorCreateCall {
3234 hub: self.hub,
3235 _request: request,
3236 _name: name.to_string(),
3237 _delegate: Default::default(),
3238 _additional_params: Default::default(),
3239 _scopes: Default::default(),
3240 }
3241 }
3242
3243 /// Create a builder to help you perform the following task:
3244 ///
3245 /// Deletes a metric descriptor. Only user-created custom metrics (https://cloud.google.com/monitoring/custom-metrics) can be deleted.
3246 ///
3247 /// # Arguments
3248 ///
3249 /// * `name` - Required. The metric descriptor on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID] An example of [METRIC_ID] is: "custom.googleapis.com/my_test_metric".
3250 pub fn metric_descriptors_delete(
3251 &self,
3252 name: &str,
3253 ) -> ProjectMetricDescriptorDeleteCall<'a, C> {
3254 ProjectMetricDescriptorDeleteCall {
3255 hub: self.hub,
3256 _name: name.to_string(),
3257 _delegate: Default::default(),
3258 _additional_params: Default::default(),
3259 _scopes: Default::default(),
3260 }
3261 }
3262
3263 /// Create a builder to help you perform the following task:
3264 ///
3265 /// Gets a single metric descriptor.
3266 ///
3267 /// # Arguments
3268 ///
3269 /// * `name` - Required. The metric descriptor on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID] An example value of [METRIC_ID] is "compute.googleapis.com/instance/disk/read_bytes_count".
3270 pub fn metric_descriptors_get(&self, name: &str) -> ProjectMetricDescriptorGetCall<'a, C> {
3271 ProjectMetricDescriptorGetCall {
3272 hub: self.hub,
3273 _name: name.to_string(),
3274 _delegate: Default::default(),
3275 _additional_params: Default::default(),
3276 _scopes: Default::default(),
3277 }
3278 }
3279
3280 /// Create a builder to help you perform the following task:
3281 ///
3282 /// Lists metric descriptors that match a filter.
3283 ///
3284 /// # Arguments
3285 ///
3286 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
3287 pub fn metric_descriptors_list(&self, name: &str) -> ProjectMetricDescriptorListCall<'a, C> {
3288 ProjectMetricDescriptorListCall {
3289 hub: self.hub,
3290 _name: name.to_string(),
3291 _page_token: Default::default(),
3292 _page_size: Default::default(),
3293 _filter: Default::default(),
3294 _delegate: Default::default(),
3295 _additional_params: Default::default(),
3296 _scopes: Default::default(),
3297 }
3298 }
3299
3300 /// Create a builder to help you perform the following task:
3301 ///
3302 /// Gets a single monitored resource descriptor.
3303 ///
3304 /// # Arguments
3305 ///
3306 /// * `name` - Required. The monitored resource descriptor to get. The format is: projects/[PROJECT_ID_OR_NUMBER]/monitoredResourceDescriptors/[RESOURCE_TYPE] The [RESOURCE_TYPE] is a predefined type, such as cloudsql_database.
3307 pub fn monitored_resource_descriptors_get(
3308 &self,
3309 name: &str,
3310 ) -> ProjectMonitoredResourceDescriptorGetCall<'a, C> {
3311 ProjectMonitoredResourceDescriptorGetCall {
3312 hub: self.hub,
3313 _name: name.to_string(),
3314 _delegate: Default::default(),
3315 _additional_params: Default::default(),
3316 _scopes: Default::default(),
3317 }
3318 }
3319
3320 /// Create a builder to help you perform the following task:
3321 ///
3322 /// Lists monitored resource descriptors that match a filter.
3323 ///
3324 /// # Arguments
3325 ///
3326 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
3327 pub fn monitored_resource_descriptors_list(
3328 &self,
3329 name: &str,
3330 ) -> ProjectMonitoredResourceDescriptorListCall<'a, C> {
3331 ProjectMonitoredResourceDescriptorListCall {
3332 hub: self.hub,
3333 _name: name.to_string(),
3334 _page_token: Default::default(),
3335 _page_size: Default::default(),
3336 _filter: Default::default(),
3337 _delegate: Default::default(),
3338 _additional_params: Default::default(),
3339 _scopes: Default::default(),
3340 }
3341 }
3342
3343 /// Create a builder to help you perform the following task:
3344 ///
3345 /// Gets a single channel descriptor. The descriptor indicates which fields are expected / permitted for a notification channel of the given type.
3346 ///
3347 /// # Arguments
3348 ///
3349 /// * `name` - Required. The channel type for which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannelDescriptors/[CHANNEL_TYPE]
3350 pub fn notification_channel_descriptors_get(
3351 &self,
3352 name: &str,
3353 ) -> ProjectNotificationChannelDescriptorGetCall<'a, C> {
3354 ProjectNotificationChannelDescriptorGetCall {
3355 hub: self.hub,
3356 _name: name.to_string(),
3357 _delegate: Default::default(),
3358 _additional_params: Default::default(),
3359 _scopes: Default::default(),
3360 }
3361 }
3362
3363 /// Create a builder to help you perform the following task:
3364 ///
3365 /// Lists the descriptors for supported channel types. The use of descriptors makes it possible for new channel types to be dynamically added.
3366 ///
3367 /// # Arguments
3368 ///
3369 /// * `name` - Required. The REST resource name of the parent from which to retrieve the notification channel descriptors. The expected syntax is: projects/[PROJECT_ID_OR_NUMBER] Note that this names (https://cloud.google.com/monitoring/api/v3#project_name) the parent container in which to look for the descriptors; to retrieve a single descriptor by name, use the GetNotificationChannelDescriptor operation, instead.
3370 pub fn notification_channel_descriptors_list(
3371 &self,
3372 name: &str,
3373 ) -> ProjectNotificationChannelDescriptorListCall<'a, C> {
3374 ProjectNotificationChannelDescriptorListCall {
3375 hub: self.hub,
3376 _name: name.to_string(),
3377 _page_token: Default::default(),
3378 _page_size: Default::default(),
3379 _delegate: Default::default(),
3380 _additional_params: Default::default(),
3381 _scopes: Default::default(),
3382 }
3383 }
3384
3385 /// Create a builder to help you perform the following task:
3386 ///
3387 /// Creates a new notification channel, representing a single notification endpoint such as an email address, SMS number, or PagerDuty service.Design your application to single-thread API calls that modify the state of notification channels in a single project. This includes calls to CreateNotificationChannel, DeleteNotificationChannel and UpdateNotificationChannel.
3388 ///
3389 /// # Arguments
3390 ///
3391 /// * `request` - No description provided.
3392 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER] This names the container into which the channel will be written, this does not name the newly created channel. The resulting channel's name will have a normalized version of this field as a prefix, but will add /notificationChannels/[CHANNEL_ID] to identify the channel.
3393 pub fn notification_channels_create(
3394 &self,
3395 request: NotificationChannel,
3396 name: &str,
3397 ) -> ProjectNotificationChannelCreateCall<'a, C> {
3398 ProjectNotificationChannelCreateCall {
3399 hub: self.hub,
3400 _request: request,
3401 _name: name.to_string(),
3402 _delegate: Default::default(),
3403 _additional_params: Default::default(),
3404 _scopes: Default::default(),
3405 }
3406 }
3407
3408 /// Create a builder to help you perform the following task:
3409 ///
3410 /// Deletes a notification channel.Design your application to single-thread API calls that modify the state of notification channels in a single project. This includes calls to CreateNotificationChannel, DeleteNotificationChannel and UpdateNotificationChannel.
3411 ///
3412 /// # Arguments
3413 ///
3414 /// * `name` - Required. The channel for which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
3415 pub fn notification_channels_delete(
3416 &self,
3417 name: &str,
3418 ) -> ProjectNotificationChannelDeleteCall<'a, C> {
3419 ProjectNotificationChannelDeleteCall {
3420 hub: self.hub,
3421 _name: name.to_string(),
3422 _force: Default::default(),
3423 _delegate: Default::default(),
3424 _additional_params: Default::default(),
3425 _scopes: Default::default(),
3426 }
3427 }
3428
3429 /// Create a builder to help you perform the following task:
3430 ///
3431 /// Gets a single notification channel. The channel includes the relevant configuration details with which the channel was created. However, the response may truncate or omit passwords, API keys, or other private key matter and thus the response may not be 100% identical to the information that was supplied in the call to the create method.
3432 ///
3433 /// # Arguments
3434 ///
3435 /// * `name` - Required. The channel for which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
3436 pub fn notification_channels_get(
3437 &self,
3438 name: &str,
3439 ) -> ProjectNotificationChannelGetCall<'a, C> {
3440 ProjectNotificationChannelGetCall {
3441 hub: self.hub,
3442 _name: name.to_string(),
3443 _delegate: Default::default(),
3444 _additional_params: Default::default(),
3445 _scopes: Default::default(),
3446 }
3447 }
3448
3449 /// Create a builder to help you perform the following task:
3450 ///
3451 /// Requests a verification code for an already verified channel that can then be used in a call to VerifyNotificationChannel() on a different channel with an equivalent identity in the same or in a different project. This makes it possible to copy a channel between projects without requiring manual reverification of the channel. If the channel is not in the verified state, this method will fail (in other words, this may only be used if the SendNotificationChannelVerificationCode and VerifyNotificationChannel paths have already been used to put the given channel into the verified state).There is no guarantee that the verification codes returned by this method will be of a similar structure or form as the ones that are delivered to the channel via SendNotificationChannelVerificationCode; while VerifyNotificationChannel() will recognize both the codes delivered via SendNotificationChannelVerificationCode() and returned from GetNotificationChannelVerificationCode(), it is typically the case that the verification codes delivered via SendNotificationChannelVerificationCode() will be shorter and also have a shorter expiration (e.g. codes such as "G-123456") whereas GetVerificationCode() will typically return a much longer, websafe base 64 encoded string that has a longer expiration time.
3452 ///
3453 /// # Arguments
3454 ///
3455 /// * `request` - No description provided.
3456 /// * `name` - Required. The notification channel for which a verification code is to be generated and retrieved. This must name a channel that is already verified; if the specified channel is not verified, the request will fail.
3457 pub fn notification_channels_get_verification_code(
3458 &self,
3459 request: GetNotificationChannelVerificationCodeRequest,
3460 name: &str,
3461 ) -> ProjectNotificationChannelGetVerificationCodeCall<'a, C> {
3462 ProjectNotificationChannelGetVerificationCodeCall {
3463 hub: self.hub,
3464 _request: request,
3465 _name: name.to_string(),
3466 _delegate: Default::default(),
3467 _additional_params: Default::default(),
3468 _scopes: Default::default(),
3469 }
3470 }
3471
3472 /// Create a builder to help you perform the following task:
3473 ///
3474 /// Lists the notification channels that have been created for the project. To list the types of notification channels that are supported, use the ListNotificationChannelDescriptors method.
3475 ///
3476 /// # Arguments
3477 ///
3478 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER] This names the container in which to look for the notification channels; it does not name a specific channel. To query a specific channel by REST resource name, use the GetNotificationChannel operation.
3479 pub fn notification_channels_list(
3480 &self,
3481 name: &str,
3482 ) -> ProjectNotificationChannelListCall<'a, C> {
3483 ProjectNotificationChannelListCall {
3484 hub: self.hub,
3485 _name: name.to_string(),
3486 _page_token: Default::default(),
3487 _page_size: Default::default(),
3488 _order_by: Default::default(),
3489 _filter: Default::default(),
3490 _delegate: Default::default(),
3491 _additional_params: Default::default(),
3492 _scopes: Default::default(),
3493 }
3494 }
3495
3496 /// Create a builder to help you perform the following task:
3497 ///
3498 /// Updates a notification channel. Fields not specified in the field mask remain unchanged.Design your application to single-thread API calls that modify the state of notification channels in a single project. This includes calls to CreateNotificationChannel, DeleteNotificationChannel and UpdateNotificationChannel.
3499 ///
3500 /// # Arguments
3501 ///
3502 /// * `request` - No description provided.
3503 /// * `name` - The full REST resource name for this channel. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] The [CHANNEL_ID] is automatically assigned by the server on creation.
3504 pub fn notification_channels_patch(
3505 &self,
3506 request: NotificationChannel,
3507 name: &str,
3508 ) -> ProjectNotificationChannelPatchCall<'a, C> {
3509 ProjectNotificationChannelPatchCall {
3510 hub: self.hub,
3511 _request: request,
3512 _name: name.to_string(),
3513 _update_mask: Default::default(),
3514 _delegate: Default::default(),
3515 _additional_params: Default::default(),
3516 _scopes: Default::default(),
3517 }
3518 }
3519
3520 /// Create a builder to help you perform the following task:
3521 ///
3522 /// Causes a verification code to be delivered to the channel. The code can then be supplied in VerifyNotificationChannel to verify the channel.
3523 ///
3524 /// # Arguments
3525 ///
3526 /// * `request` - No description provided.
3527 /// * `name` - Required. The notification channel to which to send a verification code.
3528 pub fn notification_channels_send_verification_code(
3529 &self,
3530 request: SendNotificationChannelVerificationCodeRequest,
3531 name: &str,
3532 ) -> ProjectNotificationChannelSendVerificationCodeCall<'a, C> {
3533 ProjectNotificationChannelSendVerificationCodeCall {
3534 hub: self.hub,
3535 _request: request,
3536 _name: name.to_string(),
3537 _delegate: Default::default(),
3538 _additional_params: Default::default(),
3539 _scopes: Default::default(),
3540 }
3541 }
3542
3543 /// Create a builder to help you perform the following task:
3544 ///
3545 /// Verifies a NotificationChannel by proving receipt of the code delivered to the channel as a result of calling SendNotificationChannelVerificationCode.
3546 ///
3547 /// # Arguments
3548 ///
3549 /// * `request` - No description provided.
3550 /// * `name` - Required. The notification channel to verify.
3551 pub fn notification_channels_verify(
3552 &self,
3553 request: VerifyNotificationChannelRequest,
3554 name: &str,
3555 ) -> ProjectNotificationChannelVerifyCall<'a, C> {
3556 ProjectNotificationChannelVerifyCall {
3557 hub: self.hub,
3558 _request: request,
3559 _name: name.to_string(),
3560 _delegate: Default::default(),
3561 _additional_params: Default::default(),
3562 _scopes: Default::default(),
3563 }
3564 }
3565
3566 /// Create a builder to help you perform the following task:
3567 ///
3568 /// Creates a Snooze that will prevent alerts, which match the provided criteria, from being opened. The Snooze applies for a specific time interval.
3569 ///
3570 /// # Arguments
3571 ///
3572 /// * `request` - No description provided.
3573 /// * `parent` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) in which a Snooze should be created. The format is: projects/[PROJECT_ID_OR_NUMBER]
3574 pub fn snoozes_create(&self, request: Snooze, parent: &str) -> ProjectSnoozeCreateCall<'a, C> {
3575 ProjectSnoozeCreateCall {
3576 hub: self.hub,
3577 _request: request,
3578 _parent: parent.to_string(),
3579 _delegate: Default::default(),
3580 _additional_params: Default::default(),
3581 _scopes: Default::default(),
3582 }
3583 }
3584
3585 /// Create a builder to help you perform the following task:
3586 ///
3587 /// Retrieves a Snooze by name.
3588 ///
3589 /// # Arguments
3590 ///
3591 /// * `name` - Required. The ID of the Snooze to retrieve. The format is: projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID]
3592 pub fn snoozes_get(&self, name: &str) -> ProjectSnoozeGetCall<'a, C> {
3593 ProjectSnoozeGetCall {
3594 hub: self.hub,
3595 _name: name.to_string(),
3596 _delegate: Default::default(),
3597 _additional_params: Default::default(),
3598 _scopes: Default::default(),
3599 }
3600 }
3601
3602 /// Create a builder to help you perform the following task:
3603 ///
3604 /// Lists the Snoozes associated with a project. Can optionally pass in filter, which specifies predicates to match Snoozes.
3605 ///
3606 /// # Arguments
3607 ///
3608 /// * `parent` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) whose Snoozes should be listed. The format is: projects/[PROJECT_ID_OR_NUMBER]
3609 pub fn snoozes_list(&self, parent: &str) -> ProjectSnoozeListCall<'a, C> {
3610 ProjectSnoozeListCall {
3611 hub: self.hub,
3612 _parent: parent.to_string(),
3613 _page_token: Default::default(),
3614 _page_size: Default::default(),
3615 _filter: Default::default(),
3616 _delegate: Default::default(),
3617 _additional_params: Default::default(),
3618 _scopes: Default::default(),
3619 }
3620 }
3621
3622 /// Create a builder to help you perform the following task:
3623 ///
3624 /// Updates a Snooze, identified by its name, with the parameters in the given Snooze object.
3625 ///
3626 /// # Arguments
3627 ///
3628 /// * `request` - No description provided.
3629 /// * `name` - Required. Identifier. The name of the Snooze. The format is: projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID] The ID of the Snooze will be generated by the system.
3630 pub fn snoozes_patch(&self, request: Snooze, name: &str) -> ProjectSnoozePatchCall<'a, C> {
3631 ProjectSnoozePatchCall {
3632 hub: self.hub,
3633 _request: request,
3634 _name: name.to_string(),
3635 _update_mask: Default::default(),
3636 _delegate: Default::default(),
3637 _additional_params: Default::default(),
3638 _scopes: Default::default(),
3639 }
3640 }
3641
3642 /// Create a builder to help you perform the following task:
3643 ///
3644 /// Creates or adds data to one or more time series. The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response. This method does not support resource locations constraint of an organization policy (https://cloud.google.com/resource-manager/docs/organization-policy/defining-locations#setting_the_organization_policy).
3645 ///
3646 /// # Arguments
3647 ///
3648 /// * `request` - No description provided.
3649 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
3650 pub fn time_series_create(
3651 &self,
3652 request: CreateTimeSeriesRequest,
3653 name: &str,
3654 ) -> ProjectTimeSeryCreateCall<'a, C> {
3655 ProjectTimeSeryCreateCall {
3656 hub: self.hub,
3657 _request: request,
3658 _name: name.to_string(),
3659 _delegate: Default::default(),
3660 _additional_params: Default::default(),
3661 _scopes: Default::default(),
3662 }
3663 }
3664
3665 /// Create a builder to help you perform the following task:
3666 ///
3667 /// Creates or adds data to one or more service time series. A service time series is a time series for a metric from a Google Cloud service. The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response. This endpoint rejects writes to user-defined metrics. This method is only for use by Google Cloud services. Use projects.timeSeries.create instead.
3668 ///
3669 /// # Arguments
3670 ///
3671 /// * `request` - No description provided.
3672 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
3673 pub fn time_series_create_service(
3674 &self,
3675 request: CreateTimeSeriesRequest,
3676 name: &str,
3677 ) -> ProjectTimeSeryCreateServiceCall<'a, C> {
3678 ProjectTimeSeryCreateServiceCall {
3679 hub: self.hub,
3680 _request: request,
3681 _name: name.to_string(),
3682 _delegate: Default::default(),
3683 _additional_params: Default::default(),
3684 _scopes: Default::default(),
3685 }
3686 }
3687
3688 /// Create a builder to help you perform the following task:
3689 ///
3690 /// Lists time series that match a filter.
3691 ///
3692 /// # Arguments
3693 ///
3694 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name), organization or folder on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]
3695 pub fn time_series_list(&self, name: &str) -> ProjectTimeSeryListCall<'a, C> {
3696 ProjectTimeSeryListCall {
3697 hub: self.hub,
3698 _name: name.to_string(),
3699 _view: Default::default(),
3700 _secondary_aggregation_per_series_aligner: Default::default(),
3701 _secondary_aggregation_group_by_fields: Default::default(),
3702 _secondary_aggregation_cross_series_reducer: Default::default(),
3703 _secondary_aggregation_alignment_period: Default::default(),
3704 _page_token: Default::default(),
3705 _page_size: Default::default(),
3706 _order_by: Default::default(),
3707 _interval_start_time: Default::default(),
3708 _interval_end_time: Default::default(),
3709 _filter: Default::default(),
3710 _aggregation_per_series_aligner: Default::default(),
3711 _aggregation_group_by_fields: Default::default(),
3712 _aggregation_cross_series_reducer: Default::default(),
3713 _aggregation_alignment_period: Default::default(),
3714 _delegate: Default::default(),
3715 _additional_params: Default::default(),
3716 _scopes: Default::default(),
3717 }
3718 }
3719
3720 /// Create a builder to help you perform the following task:
3721 ///
3722 /// Queries time series using Monitoring Query Language.
3723 ///
3724 /// # Arguments
3725 ///
3726 /// * `request` - No description provided.
3727 /// * `name` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
3728 pub fn time_series_query(
3729 &self,
3730 request: QueryTimeSeriesRequest,
3731 name: &str,
3732 ) -> ProjectTimeSeryQueryCall<'a, C> {
3733 ProjectTimeSeryQueryCall {
3734 hub: self.hub,
3735 _request: request,
3736 _name: name.to_string(),
3737 _delegate: Default::default(),
3738 _additional_params: Default::default(),
3739 _scopes: Default::default(),
3740 }
3741 }
3742
3743 /// Create a builder to help you perform the following task:
3744 ///
3745 /// Creates a new Uptime check configuration.
3746 ///
3747 /// # Arguments
3748 ///
3749 /// * `request` - No description provided.
3750 /// * `parent` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) in which to create the Uptime check. The format is: projects/[PROJECT_ID_OR_NUMBER]
3751 pub fn uptime_check_configs_create(
3752 &self,
3753 request: UptimeCheckConfig,
3754 parent: &str,
3755 ) -> ProjectUptimeCheckConfigCreateCall<'a, C> {
3756 ProjectUptimeCheckConfigCreateCall {
3757 hub: self.hub,
3758 _request: request,
3759 _parent: parent.to_string(),
3760 _delegate: Default::default(),
3761 _additional_params: Default::default(),
3762 _scopes: Default::default(),
3763 }
3764 }
3765
3766 /// Create a builder to help you perform the following task:
3767 ///
3768 /// Deletes an Uptime check configuration. Note that this method will fail if the Uptime check configuration is referenced by an alert policy or other dependent configs that would be rendered invalid by the deletion.
3769 ///
3770 /// # Arguments
3771 ///
3772 /// * `name` - Required. The Uptime check configuration to delete. The format is: projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID]
3773 pub fn uptime_check_configs_delete(
3774 &self,
3775 name: &str,
3776 ) -> ProjectUptimeCheckConfigDeleteCall<'a, C> {
3777 ProjectUptimeCheckConfigDeleteCall {
3778 hub: self.hub,
3779 _name: name.to_string(),
3780 _delegate: Default::default(),
3781 _additional_params: Default::default(),
3782 _scopes: Default::default(),
3783 }
3784 }
3785
3786 /// Create a builder to help you perform the following task:
3787 ///
3788 /// Gets a single Uptime check configuration.
3789 ///
3790 /// # Arguments
3791 ///
3792 /// * `name` - Required. The Uptime check configuration to retrieve. The format is: projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID]
3793 pub fn uptime_check_configs_get(&self, name: &str) -> ProjectUptimeCheckConfigGetCall<'a, C> {
3794 ProjectUptimeCheckConfigGetCall {
3795 hub: self.hub,
3796 _name: name.to_string(),
3797 _delegate: Default::default(),
3798 _additional_params: Default::default(),
3799 _scopes: Default::default(),
3800 }
3801 }
3802
3803 /// Create a builder to help you perform the following task:
3804 ///
3805 /// Lists the existing valid Uptime check configurations for the project (leaving out any invalid configurations).
3806 ///
3807 /// # Arguments
3808 ///
3809 /// * `parent` - Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) whose Uptime check configurations are listed. The format is: projects/[PROJECT_ID_OR_NUMBER]
3810 pub fn uptime_check_configs_list(
3811 &self,
3812 parent: &str,
3813 ) -> ProjectUptimeCheckConfigListCall<'a, C> {
3814 ProjectUptimeCheckConfigListCall {
3815 hub: self.hub,
3816 _parent: parent.to_string(),
3817 _page_token: Default::default(),
3818 _page_size: Default::default(),
3819 _filter: Default::default(),
3820 _delegate: Default::default(),
3821 _additional_params: Default::default(),
3822 _scopes: Default::default(),
3823 }
3824 }
3825
3826 /// Create a builder to help you perform the following task:
3827 ///
3828 /// Updates an Uptime check configuration. You can either replace the entire configuration with a new one or replace only certain fields in the current configuration by specifying the fields to be updated via updateMask. Returns the updated configuration.
3829 ///
3830 /// # Arguments
3831 ///
3832 /// * `request` - No description provided.
3833 /// * `name` - Identifier. A unique resource name for this Uptime check configuration. The format is: projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] [PROJECT_ID_OR_NUMBER] is the Workspace host project associated with the Uptime check.This field should be omitted when creating the Uptime check configuration; on create, the resource name is assigned by the server and included in the response.
3834 pub fn uptime_check_configs_patch(
3835 &self,
3836 request: UptimeCheckConfig,
3837 name: &str,
3838 ) -> ProjectUptimeCheckConfigPatchCall<'a, C> {
3839 ProjectUptimeCheckConfigPatchCall {
3840 hub: self.hub,
3841 _request: request,
3842 _name: name.to_string(),
3843 _update_mask: Default::default(),
3844 _delegate: Default::default(),
3845 _additional_params: Default::default(),
3846 _scopes: Default::default(),
3847 }
3848 }
3849}
3850
3851/// A builder providing access to all methods supported on *service* resources.
3852/// It is not used directly, but through the [`Monitoring`] hub.
3853///
3854/// # Example
3855///
3856/// Instantiate a resource builder
3857///
3858/// ```test_harness,no_run
3859/// extern crate hyper;
3860/// extern crate hyper_rustls;
3861/// extern crate google_monitoring3 as monitoring3;
3862///
3863/// # async fn dox() {
3864/// use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3865///
3866/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3867/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3868/// secret,
3869/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3870/// ).build().await.unwrap();
3871///
3872/// let client = hyper_util::client::legacy::Client::builder(
3873/// hyper_util::rt::TokioExecutor::new()
3874/// )
3875/// .build(
3876/// hyper_rustls::HttpsConnectorBuilder::new()
3877/// .with_native_roots()
3878/// .unwrap()
3879/// .https_or_http()
3880/// .enable_http1()
3881/// .build()
3882/// );
3883/// let mut hub = Monitoring::new(client, auth);
3884/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3885/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)`, `service_level_objectives_create(...)`, `service_level_objectives_delete(...)`, `service_level_objectives_get(...)`, `service_level_objectives_list(...)` and `service_level_objectives_patch(...)`
3886/// // to build up your call.
3887/// let rb = hub.services();
3888/// # }
3889/// ```
3890pub struct ServiceMethods<'a, C>
3891where
3892 C: 'a,
3893{
3894 hub: &'a Monitoring<C>,
3895}
3896
3897impl<'a, C> common::MethodsBuilder for ServiceMethods<'a, C> {}
3898
3899impl<'a, C> ServiceMethods<'a, C> {
3900 /// Create a builder to help you perform the following task:
3901 ///
3902 /// Create a ServiceLevelObjective for the given Service.
3903 ///
3904 /// # Arguments
3905 ///
3906 /// * `request` - No description provided.
3907 /// * `parent` - Required. Resource name of the parent Service. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
3908 pub fn service_level_objectives_create(
3909 &self,
3910 request: ServiceLevelObjective,
3911 parent: &str,
3912 ) -> ServiceServiceLevelObjectiveCreateCall<'a, C> {
3913 ServiceServiceLevelObjectiveCreateCall {
3914 hub: self.hub,
3915 _request: request,
3916 _parent: parent.to_string(),
3917 _service_level_objective_id: Default::default(),
3918 _delegate: Default::default(),
3919 _additional_params: Default::default(),
3920 _scopes: Default::default(),
3921 }
3922 }
3923
3924 /// Create a builder to help you perform the following task:
3925 ///
3926 /// Delete the given ServiceLevelObjective.
3927 ///
3928 /// # Arguments
3929 ///
3930 /// * `name` - Required. Resource name of the ServiceLevelObjective to delete. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
3931 pub fn service_level_objectives_delete(
3932 &self,
3933 name: &str,
3934 ) -> ServiceServiceLevelObjectiveDeleteCall<'a, C> {
3935 ServiceServiceLevelObjectiveDeleteCall {
3936 hub: self.hub,
3937 _name: name.to_string(),
3938 _delegate: Default::default(),
3939 _additional_params: Default::default(),
3940 _scopes: Default::default(),
3941 }
3942 }
3943
3944 /// Create a builder to help you perform the following task:
3945 ///
3946 /// Get a ServiceLevelObjective by name.
3947 ///
3948 /// # Arguments
3949 ///
3950 /// * `name` - Required. Resource name of the ServiceLevelObjective to get. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
3951 pub fn service_level_objectives_get(
3952 &self,
3953 name: &str,
3954 ) -> ServiceServiceLevelObjectiveGetCall<'a, C> {
3955 ServiceServiceLevelObjectiveGetCall {
3956 hub: self.hub,
3957 _name: name.to_string(),
3958 _view: Default::default(),
3959 _delegate: Default::default(),
3960 _additional_params: Default::default(),
3961 _scopes: Default::default(),
3962 }
3963 }
3964
3965 /// Create a builder to help you perform the following task:
3966 ///
3967 /// List the ServiceLevelObjectives for the given Service.
3968 ///
3969 /// # Arguments
3970 ///
3971 /// * `parent` - Required. Resource name of the parent containing the listed SLOs, either a project or a Monitoring Metrics Scope. The formats are: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] workspaces/[HOST_PROJECT_ID_OR_NUMBER]/services/-
3972 pub fn service_level_objectives_list(
3973 &self,
3974 parent: &str,
3975 ) -> ServiceServiceLevelObjectiveListCall<'a, C> {
3976 ServiceServiceLevelObjectiveListCall {
3977 hub: self.hub,
3978 _parent: parent.to_string(),
3979 _view: Default::default(),
3980 _page_token: Default::default(),
3981 _page_size: Default::default(),
3982 _filter: Default::default(),
3983 _delegate: Default::default(),
3984 _additional_params: Default::default(),
3985 _scopes: Default::default(),
3986 }
3987 }
3988
3989 /// Create a builder to help you perform the following task:
3990 ///
3991 /// Update the given ServiceLevelObjective.
3992 ///
3993 /// # Arguments
3994 ///
3995 /// * `request` - No description provided.
3996 /// * `name` - Identifier. Resource name for this ServiceLevelObjective. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
3997 pub fn service_level_objectives_patch(
3998 &self,
3999 request: ServiceLevelObjective,
4000 name: &str,
4001 ) -> ServiceServiceLevelObjectivePatchCall<'a, C> {
4002 ServiceServiceLevelObjectivePatchCall {
4003 hub: self.hub,
4004 _request: request,
4005 _name: name.to_string(),
4006 _update_mask: Default::default(),
4007 _delegate: Default::default(),
4008 _additional_params: Default::default(),
4009 _scopes: Default::default(),
4010 }
4011 }
4012
4013 /// Create a builder to help you perform the following task:
4014 ///
4015 /// Create a Service.
4016 ///
4017 /// # Arguments
4018 ///
4019 /// * `request` - No description provided.
4020 /// * `parent` - Required. Resource name (https://cloud.google.com/monitoring/api/v3#project_name) of the parent Metrics Scope. The format is: projects/[PROJECT_ID_OR_NUMBER]
4021 pub fn create(&self, request: Service, parent: &str) -> ServiceCreateCall<'a, C> {
4022 ServiceCreateCall {
4023 hub: self.hub,
4024 _request: request,
4025 _parent: parent.to_string(),
4026 _service_id: Default::default(),
4027 _delegate: Default::default(),
4028 _additional_params: Default::default(),
4029 _scopes: Default::default(),
4030 }
4031 }
4032
4033 /// Create a builder to help you perform the following task:
4034 ///
4035 /// Soft delete this Service.
4036 ///
4037 /// # Arguments
4038 ///
4039 /// * `name` - Required. Resource name of the Service to delete. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
4040 pub fn delete(&self, name: &str) -> ServiceDeleteCall<'a, C> {
4041 ServiceDeleteCall {
4042 hub: self.hub,
4043 _name: name.to_string(),
4044 _delegate: Default::default(),
4045 _additional_params: Default::default(),
4046 _scopes: Default::default(),
4047 }
4048 }
4049
4050 /// Create a builder to help you perform the following task:
4051 ///
4052 /// Get the named Service.
4053 ///
4054 /// # Arguments
4055 ///
4056 /// * `name` - Required. Resource name of the Service. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
4057 pub fn get(&self, name: &str) -> ServiceGetCall<'a, C> {
4058 ServiceGetCall {
4059 hub: self.hub,
4060 _name: name.to_string(),
4061 _delegate: Default::default(),
4062 _additional_params: Default::default(),
4063 _scopes: Default::default(),
4064 }
4065 }
4066
4067 /// Create a builder to help you perform the following task:
4068 ///
4069 /// List Services for this Metrics Scope.
4070 ///
4071 /// # Arguments
4072 ///
4073 /// * `parent` - Required. Resource name of the parent containing the listed services, either a project (https://cloud.google.com/monitoring/api/v3#project_name) or a Monitoring Metrics Scope. The formats are: projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER]
4074 pub fn list(&self, parent: &str) -> ServiceListCall<'a, C> {
4075 ServiceListCall {
4076 hub: self.hub,
4077 _parent: parent.to_string(),
4078 _page_token: Default::default(),
4079 _page_size: Default::default(),
4080 _filter: Default::default(),
4081 _delegate: Default::default(),
4082 _additional_params: Default::default(),
4083 _scopes: Default::default(),
4084 }
4085 }
4086
4087 /// Create a builder to help you perform the following task:
4088 ///
4089 /// Update this Service.
4090 ///
4091 /// # Arguments
4092 ///
4093 /// * `request` - No description provided.
4094 /// * `name` - Identifier. Resource name for this Service. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
4095 pub fn patch(&self, request: Service, name: &str) -> ServicePatchCall<'a, C> {
4096 ServicePatchCall {
4097 hub: self.hub,
4098 _request: request,
4099 _name: name.to_string(),
4100 _update_mask: Default::default(),
4101 _delegate: Default::default(),
4102 _additional_params: Default::default(),
4103 _scopes: Default::default(),
4104 }
4105 }
4106}
4107
4108/// A builder providing access to all methods supported on *uptimeCheckIp* resources.
4109/// It is not used directly, but through the [`Monitoring`] hub.
4110///
4111/// # Example
4112///
4113/// Instantiate a resource builder
4114///
4115/// ```test_harness,no_run
4116/// extern crate hyper;
4117/// extern crate hyper_rustls;
4118/// extern crate google_monitoring3 as monitoring3;
4119///
4120/// # async fn dox() {
4121/// use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4122///
4123/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4124/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4125/// secret,
4126/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4127/// ).build().await.unwrap();
4128///
4129/// let client = hyper_util::client::legacy::Client::builder(
4130/// hyper_util::rt::TokioExecutor::new()
4131/// )
4132/// .build(
4133/// hyper_rustls::HttpsConnectorBuilder::new()
4134/// .with_native_roots()
4135/// .unwrap()
4136/// .https_or_http()
4137/// .enable_http1()
4138/// .build()
4139/// );
4140/// let mut hub = Monitoring::new(client, auth);
4141/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4142/// // like `list(...)`
4143/// // to build up your call.
4144/// let rb = hub.uptime_check_ips();
4145/// # }
4146/// ```
4147pub struct UptimeCheckIpMethods<'a, C>
4148where
4149 C: 'a,
4150{
4151 hub: &'a Monitoring<C>,
4152}
4153
4154impl<'a, C> common::MethodsBuilder for UptimeCheckIpMethods<'a, C> {}
4155
4156impl<'a, C> UptimeCheckIpMethods<'a, C> {
4157 /// Create a builder to help you perform the following task:
4158 ///
4159 /// Returns the list of IP addresses that checkers run from.
4160 pub fn list(&self) -> UptimeCheckIpListCall<'a, C> {
4161 UptimeCheckIpListCall {
4162 hub: self.hub,
4163 _page_token: Default::default(),
4164 _page_size: Default::default(),
4165 _delegate: Default::default(),
4166 _additional_params: Default::default(),
4167 _scopes: Default::default(),
4168 }
4169 }
4170}
4171
4172// ###################
4173// CallBuilders ###
4174// #################
4175
4176/// Lists time series that match a filter.
4177///
4178/// A builder for the *timeSeries.list* method supported by a *folder* resource.
4179/// It is not used directly, but through a [`FolderMethods`] instance.
4180///
4181/// # Example
4182///
4183/// Instantiate a resource method builder
4184///
4185/// ```test_harness,no_run
4186/// # extern crate hyper;
4187/// # extern crate hyper_rustls;
4188/// # extern crate google_monitoring3 as monitoring3;
4189/// # async fn dox() {
4190/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4191///
4192/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4193/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4194/// # secret,
4195/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4196/// # ).build().await.unwrap();
4197///
4198/// # let client = hyper_util::client::legacy::Client::builder(
4199/// # hyper_util::rt::TokioExecutor::new()
4200/// # )
4201/// # .build(
4202/// # hyper_rustls::HttpsConnectorBuilder::new()
4203/// # .with_native_roots()
4204/// # .unwrap()
4205/// # .https_or_http()
4206/// # .enable_http1()
4207/// # .build()
4208/// # );
4209/// # let mut hub = Monitoring::new(client, auth);
4210/// // You can configure optional parameters by calling the respective setters at will, and
4211/// // execute the final call using `doit()`.
4212/// // Values shown here are possibly random and not representative !
4213/// let result = hub.folders().time_series_list("name")
4214/// .view("eos")
4215/// .secondary_aggregation_per_series_aligner("dolor")
4216/// .add_secondary_aggregation_group_by_fields("ea")
4217/// .secondary_aggregation_cross_series_reducer("ipsum")
4218/// .secondary_aggregation_alignment_period(chrono::Duration::seconds(1833555))
4219/// .page_token("amet")
4220/// .page_size(-20)
4221/// .order_by("ipsum")
4222/// .interval_start_time(chrono::Utc::now())
4223/// .interval_end_time(chrono::Utc::now())
4224/// .filter("sed")
4225/// .aggregation_per_series_aligner("ut")
4226/// .add_aggregation_group_by_fields("gubergren")
4227/// .aggregation_cross_series_reducer("rebum.")
4228/// .aggregation_alignment_period(chrono::Duration::seconds(5840181))
4229/// .doit().await;
4230/// # }
4231/// ```
4232pub struct FolderTimeSeryListCall<'a, C>
4233where
4234 C: 'a,
4235{
4236 hub: &'a Monitoring<C>,
4237 _name: String,
4238 _view: Option<String>,
4239 _secondary_aggregation_per_series_aligner: Option<String>,
4240 _secondary_aggregation_group_by_fields: Vec<String>,
4241 _secondary_aggregation_cross_series_reducer: Option<String>,
4242 _secondary_aggregation_alignment_period: Option<chrono::Duration>,
4243 _page_token: Option<String>,
4244 _page_size: Option<i32>,
4245 _order_by: Option<String>,
4246 _interval_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
4247 _interval_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
4248 _filter: Option<String>,
4249 _aggregation_per_series_aligner: Option<String>,
4250 _aggregation_group_by_fields: Vec<String>,
4251 _aggregation_cross_series_reducer: Option<String>,
4252 _aggregation_alignment_period: Option<chrono::Duration>,
4253 _delegate: Option<&'a mut dyn common::Delegate>,
4254 _additional_params: HashMap<String, String>,
4255 _scopes: BTreeSet<String>,
4256}
4257
4258impl<'a, C> common::CallBuilder for FolderTimeSeryListCall<'a, C> {}
4259
4260impl<'a, C> FolderTimeSeryListCall<'a, C>
4261where
4262 C: common::Connector,
4263{
4264 /// Perform the operation you have build so far.
4265 pub async fn doit(mut self) -> common::Result<(common::Response, ListTimeSeriesResponse)> {
4266 use std::borrow::Cow;
4267 use std::io::{Read, Seek};
4268
4269 use common::{url::Params, ToParts};
4270 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4271
4272 let mut dd = common::DefaultDelegate;
4273 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4274 dlg.begin(common::MethodInfo {
4275 id: "monitoring.folders.timeSeries.list",
4276 http_method: hyper::Method::GET,
4277 });
4278
4279 for &field in [
4280 "alt",
4281 "name",
4282 "view",
4283 "secondaryAggregation.perSeriesAligner",
4284 "secondaryAggregation.groupByFields",
4285 "secondaryAggregation.crossSeriesReducer",
4286 "secondaryAggregation.alignmentPeriod",
4287 "pageToken",
4288 "pageSize",
4289 "orderBy",
4290 "interval.startTime",
4291 "interval.endTime",
4292 "filter",
4293 "aggregation.perSeriesAligner",
4294 "aggregation.groupByFields",
4295 "aggregation.crossSeriesReducer",
4296 "aggregation.alignmentPeriod",
4297 ]
4298 .iter()
4299 {
4300 if self._additional_params.contains_key(field) {
4301 dlg.finished(false);
4302 return Err(common::Error::FieldClash(field));
4303 }
4304 }
4305
4306 let mut params = Params::with_capacity(18 + self._additional_params.len());
4307 params.push("name", self._name);
4308 if let Some(value) = self._view.as_ref() {
4309 params.push("view", value);
4310 }
4311 if let Some(value) = self._secondary_aggregation_per_series_aligner.as_ref() {
4312 params.push("secondaryAggregation.perSeriesAligner", value);
4313 }
4314 if !self._secondary_aggregation_group_by_fields.is_empty() {
4315 for f in self._secondary_aggregation_group_by_fields.iter() {
4316 params.push("secondaryAggregation.groupByFields", f);
4317 }
4318 }
4319 if let Some(value) = self._secondary_aggregation_cross_series_reducer.as_ref() {
4320 params.push("secondaryAggregation.crossSeriesReducer", value);
4321 }
4322 if let Some(value) = self._secondary_aggregation_alignment_period.as_ref() {
4323 params.push(
4324 "secondaryAggregation.alignmentPeriod",
4325 common::serde::duration::to_string(&value),
4326 );
4327 }
4328 if let Some(value) = self._page_token.as_ref() {
4329 params.push("pageToken", value);
4330 }
4331 if let Some(value) = self._page_size.as_ref() {
4332 params.push("pageSize", value.to_string());
4333 }
4334 if let Some(value) = self._order_by.as_ref() {
4335 params.push("orderBy", value);
4336 }
4337 if let Some(value) = self._interval_start_time.as_ref() {
4338 params.push(
4339 "interval.startTime",
4340 common::serde::datetime_to_string(&value),
4341 );
4342 }
4343 if let Some(value) = self._interval_end_time.as_ref() {
4344 params.push(
4345 "interval.endTime",
4346 common::serde::datetime_to_string(&value),
4347 );
4348 }
4349 if let Some(value) = self._filter.as_ref() {
4350 params.push("filter", value);
4351 }
4352 if let Some(value) = self._aggregation_per_series_aligner.as_ref() {
4353 params.push("aggregation.perSeriesAligner", value);
4354 }
4355 if !self._aggregation_group_by_fields.is_empty() {
4356 for f in self._aggregation_group_by_fields.iter() {
4357 params.push("aggregation.groupByFields", f);
4358 }
4359 }
4360 if let Some(value) = self._aggregation_cross_series_reducer.as_ref() {
4361 params.push("aggregation.crossSeriesReducer", value);
4362 }
4363 if let Some(value) = self._aggregation_alignment_period.as_ref() {
4364 params.push(
4365 "aggregation.alignmentPeriod",
4366 common::serde::duration::to_string(&value),
4367 );
4368 }
4369
4370 params.extend(self._additional_params.iter());
4371
4372 params.push("alt", "json");
4373 let mut url = self.hub._base_url.clone() + "v3/{+name}/timeSeries";
4374 if self._scopes.is_empty() {
4375 self._scopes
4376 .insert(Scope::CloudPlatform.as_ref().to_string());
4377 }
4378
4379 #[allow(clippy::single_element_loop)]
4380 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4381 url = params.uri_replacement(url, param_name, find_this, true);
4382 }
4383 {
4384 let to_remove = ["name"];
4385 params.remove_params(&to_remove);
4386 }
4387
4388 let url = params.parse_with_url(&url);
4389
4390 loop {
4391 let token = match self
4392 .hub
4393 .auth
4394 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4395 .await
4396 {
4397 Ok(token) => token,
4398 Err(e) => match dlg.token(e) {
4399 Ok(token) => token,
4400 Err(e) => {
4401 dlg.finished(false);
4402 return Err(common::Error::MissingToken(e));
4403 }
4404 },
4405 };
4406 let mut req_result = {
4407 let client = &self.hub.client;
4408 dlg.pre_request();
4409 let mut req_builder = hyper::Request::builder()
4410 .method(hyper::Method::GET)
4411 .uri(url.as_str())
4412 .header(USER_AGENT, self.hub._user_agent.clone());
4413
4414 if let Some(token) = token.as_ref() {
4415 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4416 }
4417
4418 let request = req_builder
4419 .header(CONTENT_LENGTH, 0_u64)
4420 .body(common::to_body::<String>(None));
4421
4422 client.request(request.unwrap()).await
4423 };
4424
4425 match req_result {
4426 Err(err) => {
4427 if let common::Retry::After(d) = dlg.http_error(&err) {
4428 sleep(d).await;
4429 continue;
4430 }
4431 dlg.finished(false);
4432 return Err(common::Error::HttpError(err));
4433 }
4434 Ok(res) => {
4435 let (mut parts, body) = res.into_parts();
4436 let mut body = common::Body::new(body);
4437 if !parts.status.is_success() {
4438 let bytes = common::to_bytes(body).await.unwrap_or_default();
4439 let error = serde_json::from_str(&common::to_string(&bytes));
4440 let response = common::to_response(parts, bytes.into());
4441
4442 if let common::Retry::After(d) =
4443 dlg.http_failure(&response, error.as_ref().ok())
4444 {
4445 sleep(d).await;
4446 continue;
4447 }
4448
4449 dlg.finished(false);
4450
4451 return Err(match error {
4452 Ok(value) => common::Error::BadRequest(value),
4453 _ => common::Error::Failure(response),
4454 });
4455 }
4456 let response = {
4457 let bytes = common::to_bytes(body).await.unwrap_or_default();
4458 let encoded = common::to_string(&bytes);
4459 match serde_json::from_str(&encoded) {
4460 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4461 Err(error) => {
4462 dlg.response_json_decode_error(&encoded, &error);
4463 return Err(common::Error::JsonDecodeError(
4464 encoded.to_string(),
4465 error,
4466 ));
4467 }
4468 }
4469 };
4470
4471 dlg.finished(true);
4472 return Ok(response);
4473 }
4474 }
4475 }
4476 }
4477
4478 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name), organization or folder on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]
4479 ///
4480 /// Sets the *name* path property to the given value.
4481 ///
4482 /// Even though the property as already been set when instantiating this call,
4483 /// we provide this method for API completeness.
4484 pub fn name(mut self, new_value: &str) -> FolderTimeSeryListCall<'a, C> {
4485 self._name = new_value.to_string();
4486 self
4487 }
4488 /// Required. Specifies which information is returned about the time series.
4489 ///
4490 /// Sets the *view* query property to the given value.
4491 pub fn view(mut self, new_value: &str) -> FolderTimeSeryListCall<'a, C> {
4492 self._view = Some(new_value.to_string());
4493 self
4494 }
4495 /// An Aligner describes how to bring the data points in a single time series into temporal alignment. Except for ALIGN_NONE, all alignments cause all the data points in an alignment_period to be mathematically grouped together, resulting in a single data point for each alignment_period with end timestamp at the end of the period.Not all alignment operations may be applied to all time series. The valid choices depend on the metric_kind and value_type of the original time series. Alignment can change the metric_kind or the value_type of the time series.Time series data must be aligned in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified and not equal to ALIGN_NONE and alignment_period must be specified; otherwise, an error is returned.
4496 ///
4497 /// Sets the *secondary aggregation.per series aligner* query property to the given value.
4498 pub fn secondary_aggregation_per_series_aligner(
4499 mut self,
4500 new_value: &str,
4501 ) -> FolderTimeSeryListCall<'a, C> {
4502 self._secondary_aggregation_per_series_aligner = Some(new_value.to_string());
4503 self
4504 }
4505 /// The set of fields to preserve when cross_series_reducer is specified. The group_by_fields determine how the time series are partitioned into subsets prior to applying the aggregation operation. Each subset contains time series that have the same value for each of the grouping fields. Each individual time series is a member of exactly one subset. The cross_series_reducer is applied to each subset of time series. It is not possible to reduce across different resource types, so this field implicitly contains resource.type. Fields not specified in group_by_fields are aggregated away. If group_by_fields is not specified and all the time series have the same resource type, then the time series are aggregated into a single output time series. If cross_series_reducer is not defined, this field is ignored.
4506 ///
4507 /// Append the given value to the *secondary aggregation.group by fields* query property.
4508 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4509 pub fn add_secondary_aggregation_group_by_fields(
4510 mut self,
4511 new_value: &str,
4512 ) -> FolderTimeSeryListCall<'a, C> {
4513 self._secondary_aggregation_group_by_fields
4514 .push(new_value.to_string());
4515 self
4516 }
4517 /// The reduction operation to be used to combine time series into a single time series, where the value of each data point in the resulting series is a function of all the already aligned values in the input time series.Not all reducer operations can be applied to all time series. The valid choices depend on the metric_kind and the value_type of the original time series. Reduction can yield a time series with a different metric_kind or value_type than the input time series.Time series data must first be aligned (see per_series_aligner) in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified, and must not be ALIGN_NONE. An alignment_period must also be specified; otherwise, an error is returned.
4518 ///
4519 /// Sets the *secondary aggregation.cross series reducer* query property to the given value.
4520 pub fn secondary_aggregation_cross_series_reducer(
4521 mut self,
4522 new_value: &str,
4523 ) -> FolderTimeSeryListCall<'a, C> {
4524 self._secondary_aggregation_cross_series_reducer = Some(new_value.to_string());
4525 self
4526 }
4527 /// The alignment_period specifies a time interval, in seconds, that is used to divide the data in all the time series into consistent blocks of time. This will be done before the per-series aligner can be applied to the data.The value must be at least 60 seconds. If a per-series aligner other than ALIGN_NONE is specified, this field is required or an error is returned. If no per-series aligner is specified, or the aligner ALIGN_NONE is specified, then this field is ignored.The maximum value of the alignment_period is 104 weeks (2 years) for charts, and 90,000 seconds (25 hours) for alerting policies.
4528 ///
4529 /// Sets the *secondary aggregation.alignment period* query property to the given value.
4530 pub fn secondary_aggregation_alignment_period(
4531 mut self,
4532 new_value: chrono::Duration,
4533 ) -> FolderTimeSeryListCall<'a, C> {
4534 self._secondary_aggregation_alignment_period = Some(new_value);
4535 self
4536 }
4537 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
4538 ///
4539 /// Sets the *page token* query property to the given value.
4540 pub fn page_token(mut self, new_value: &str) -> FolderTimeSeryListCall<'a, C> {
4541 self._page_token = Some(new_value.to_string());
4542 self
4543 }
4544 /// A positive number that is the maximum number of results to return. If page_size is empty or more than 100,000 results, the effective page_size is 100,000 results. If view is set to FULL, this is the maximum number of Points returned. If view is set to HEADERS, this is the maximum number of TimeSeries returned.
4545 ///
4546 /// Sets the *page size* query property to the given value.
4547 pub fn page_size(mut self, new_value: i32) -> FolderTimeSeryListCall<'a, C> {
4548 self._page_size = Some(new_value);
4549 self
4550 }
4551 /// Unsupported: must be left blank. The points in each time series are currently returned in reverse time order (most recent to oldest).
4552 ///
4553 /// Sets the *order by* query property to the given value.
4554 pub fn order_by(mut self, new_value: &str) -> FolderTimeSeryListCall<'a, C> {
4555 self._order_by = Some(new_value.to_string());
4556 self
4557 }
4558 /// Optional. The beginning of the time interval. The default value for the start time is the end time. The start time must not be later than the end time.
4559 ///
4560 /// Sets the *interval.start time* query property to the given value.
4561 pub fn interval_start_time(
4562 mut self,
4563 new_value: chrono::DateTime<chrono::offset::Utc>,
4564 ) -> FolderTimeSeryListCall<'a, C> {
4565 self._interval_start_time = Some(new_value);
4566 self
4567 }
4568 /// Required. The end of the time interval.
4569 ///
4570 /// Sets the *interval.end time* query property to the given value.
4571 pub fn interval_end_time(
4572 mut self,
4573 new_value: chrono::DateTime<chrono::offset::Utc>,
4574 ) -> FolderTimeSeryListCall<'a, C> {
4575 self._interval_end_time = Some(new_value);
4576 self
4577 }
4578 /// Required. A monitoring filter (https://cloud.google.com/monitoring/api/v3/filters) that specifies which time series should be returned. The filter must specify a single metric type, and can additionally specify metric labels and other information. For example: metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND metric.labels.instance_name = "my-instance-name"
4579 ///
4580 /// Sets the *filter* query property to the given value.
4581 pub fn filter(mut self, new_value: &str) -> FolderTimeSeryListCall<'a, C> {
4582 self._filter = Some(new_value.to_string());
4583 self
4584 }
4585 /// An Aligner describes how to bring the data points in a single time series into temporal alignment. Except for ALIGN_NONE, all alignments cause all the data points in an alignment_period to be mathematically grouped together, resulting in a single data point for each alignment_period with end timestamp at the end of the period.Not all alignment operations may be applied to all time series. The valid choices depend on the metric_kind and value_type of the original time series. Alignment can change the metric_kind or the value_type of the time series.Time series data must be aligned in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified and not equal to ALIGN_NONE and alignment_period must be specified; otherwise, an error is returned.
4586 ///
4587 /// Sets the *aggregation.per series aligner* query property to the given value.
4588 pub fn aggregation_per_series_aligner(
4589 mut self,
4590 new_value: &str,
4591 ) -> FolderTimeSeryListCall<'a, C> {
4592 self._aggregation_per_series_aligner = Some(new_value.to_string());
4593 self
4594 }
4595 /// The set of fields to preserve when cross_series_reducer is specified. The group_by_fields determine how the time series are partitioned into subsets prior to applying the aggregation operation. Each subset contains time series that have the same value for each of the grouping fields. Each individual time series is a member of exactly one subset. The cross_series_reducer is applied to each subset of time series. It is not possible to reduce across different resource types, so this field implicitly contains resource.type. Fields not specified in group_by_fields are aggregated away. If group_by_fields is not specified and all the time series have the same resource type, then the time series are aggregated into a single output time series. If cross_series_reducer is not defined, this field is ignored.
4596 ///
4597 /// Append the given value to the *aggregation.group by fields* query property.
4598 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4599 pub fn add_aggregation_group_by_fields(
4600 mut self,
4601 new_value: &str,
4602 ) -> FolderTimeSeryListCall<'a, C> {
4603 self._aggregation_group_by_fields
4604 .push(new_value.to_string());
4605 self
4606 }
4607 /// The reduction operation to be used to combine time series into a single time series, where the value of each data point in the resulting series is a function of all the already aligned values in the input time series.Not all reducer operations can be applied to all time series. The valid choices depend on the metric_kind and the value_type of the original time series. Reduction can yield a time series with a different metric_kind or value_type than the input time series.Time series data must first be aligned (see per_series_aligner) in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified, and must not be ALIGN_NONE. An alignment_period must also be specified; otherwise, an error is returned.
4608 ///
4609 /// Sets the *aggregation.cross series reducer* query property to the given value.
4610 pub fn aggregation_cross_series_reducer(
4611 mut self,
4612 new_value: &str,
4613 ) -> FolderTimeSeryListCall<'a, C> {
4614 self._aggregation_cross_series_reducer = Some(new_value.to_string());
4615 self
4616 }
4617 /// The alignment_period specifies a time interval, in seconds, that is used to divide the data in all the time series into consistent blocks of time. This will be done before the per-series aligner can be applied to the data.The value must be at least 60 seconds. If a per-series aligner other than ALIGN_NONE is specified, this field is required or an error is returned. If no per-series aligner is specified, or the aligner ALIGN_NONE is specified, then this field is ignored.The maximum value of the alignment_period is 104 weeks (2 years) for charts, and 90,000 seconds (25 hours) for alerting policies.
4618 ///
4619 /// Sets the *aggregation.alignment period* query property to the given value.
4620 pub fn aggregation_alignment_period(
4621 mut self,
4622 new_value: chrono::Duration,
4623 ) -> FolderTimeSeryListCall<'a, C> {
4624 self._aggregation_alignment_period = Some(new_value);
4625 self
4626 }
4627 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4628 /// while executing the actual API request.
4629 ///
4630 /// ````text
4631 /// It should be used to handle progress information, and to implement a certain level of resilience.
4632 /// ````
4633 ///
4634 /// Sets the *delegate* property to the given value.
4635 pub fn delegate(
4636 mut self,
4637 new_value: &'a mut dyn common::Delegate,
4638 ) -> FolderTimeSeryListCall<'a, C> {
4639 self._delegate = Some(new_value);
4640 self
4641 }
4642
4643 /// Set any additional parameter of the query string used in the request.
4644 /// It should be used to set parameters which are not yet available through their own
4645 /// setters.
4646 ///
4647 /// Please note that this method must not be used to set any of the known parameters
4648 /// which have their own setter method. If done anyway, the request will fail.
4649 ///
4650 /// # Additional Parameters
4651 ///
4652 /// * *$.xgafv* (query-string) - V1 error format.
4653 /// * *access_token* (query-string) - OAuth access token.
4654 /// * *alt* (query-string) - Data format for response.
4655 /// * *callback* (query-string) - JSONP
4656 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4657 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4658 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4659 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4660 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4661 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4662 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4663 pub fn param<T>(mut self, name: T, value: T) -> FolderTimeSeryListCall<'a, C>
4664 where
4665 T: AsRef<str>,
4666 {
4667 self._additional_params
4668 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4669 self
4670 }
4671
4672 /// Identifies the authorization scope for the method you are building.
4673 ///
4674 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4675 /// [`Scope::CloudPlatform`].
4676 ///
4677 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4678 /// tokens for more than one scope.
4679 ///
4680 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4681 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4682 /// sufficient, a read-write scope will do as well.
4683 pub fn add_scope<St>(mut self, scope: St) -> FolderTimeSeryListCall<'a, C>
4684 where
4685 St: AsRef<str>,
4686 {
4687 self._scopes.insert(String::from(scope.as_ref()));
4688 self
4689 }
4690 /// Identifies the authorization scope(s) for the method you are building.
4691 ///
4692 /// See [`Self::add_scope()`] for details.
4693 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderTimeSeryListCall<'a, C>
4694 where
4695 I: IntoIterator<Item = St>,
4696 St: AsRef<str>,
4697 {
4698 self._scopes
4699 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4700 self
4701 }
4702
4703 /// Removes all scopes, and no default scope will be used either.
4704 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4705 /// for details).
4706 pub fn clear_scopes(mut self) -> FolderTimeSeryListCall<'a, C> {
4707 self._scopes.clear();
4708 self
4709 }
4710}
4711
4712/// Lists time series that match a filter.
4713///
4714/// A builder for the *timeSeries.list* method supported by a *organization* resource.
4715/// It is not used directly, but through a [`OrganizationMethods`] instance.
4716///
4717/// # Example
4718///
4719/// Instantiate a resource method builder
4720///
4721/// ```test_harness,no_run
4722/// # extern crate hyper;
4723/// # extern crate hyper_rustls;
4724/// # extern crate google_monitoring3 as monitoring3;
4725/// # async fn dox() {
4726/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4727///
4728/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4729/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4730/// # secret,
4731/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4732/// # ).build().await.unwrap();
4733///
4734/// # let client = hyper_util::client::legacy::Client::builder(
4735/// # hyper_util::rt::TokioExecutor::new()
4736/// # )
4737/// # .build(
4738/// # hyper_rustls::HttpsConnectorBuilder::new()
4739/// # .with_native_roots()
4740/// # .unwrap()
4741/// # .https_or_http()
4742/// # .enable_http1()
4743/// # .build()
4744/// # );
4745/// # let mut hub = Monitoring::new(client, auth);
4746/// // You can configure optional parameters by calling the respective setters at will, and
4747/// // execute the final call using `doit()`.
4748/// // Values shown here are possibly random and not representative !
4749/// let result = hub.organizations().time_series_list("name")
4750/// .view("ipsum")
4751/// .secondary_aggregation_per_series_aligner("est")
4752/// .add_secondary_aggregation_group_by_fields("gubergren")
4753/// .secondary_aggregation_cross_series_reducer("ea")
4754/// .secondary_aggregation_alignment_period(chrono::Duration::seconds(299065))
4755/// .page_token("Lorem")
4756/// .page_size(-25)
4757/// .order_by("labore")
4758/// .interval_start_time(chrono::Utc::now())
4759/// .interval_end_time(chrono::Utc::now())
4760/// .filter("sed")
4761/// .aggregation_per_series_aligner("duo")
4762/// .add_aggregation_group_by_fields("sed")
4763/// .aggregation_cross_series_reducer("no")
4764/// .aggregation_alignment_period(chrono::Duration::seconds(7669831))
4765/// .doit().await;
4766/// # }
4767/// ```
4768pub struct OrganizationTimeSeryListCall<'a, C>
4769where
4770 C: 'a,
4771{
4772 hub: &'a Monitoring<C>,
4773 _name: String,
4774 _view: Option<String>,
4775 _secondary_aggregation_per_series_aligner: Option<String>,
4776 _secondary_aggregation_group_by_fields: Vec<String>,
4777 _secondary_aggregation_cross_series_reducer: Option<String>,
4778 _secondary_aggregation_alignment_period: Option<chrono::Duration>,
4779 _page_token: Option<String>,
4780 _page_size: Option<i32>,
4781 _order_by: Option<String>,
4782 _interval_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
4783 _interval_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
4784 _filter: Option<String>,
4785 _aggregation_per_series_aligner: Option<String>,
4786 _aggregation_group_by_fields: Vec<String>,
4787 _aggregation_cross_series_reducer: Option<String>,
4788 _aggregation_alignment_period: Option<chrono::Duration>,
4789 _delegate: Option<&'a mut dyn common::Delegate>,
4790 _additional_params: HashMap<String, String>,
4791 _scopes: BTreeSet<String>,
4792}
4793
4794impl<'a, C> common::CallBuilder for OrganizationTimeSeryListCall<'a, C> {}
4795
4796impl<'a, C> OrganizationTimeSeryListCall<'a, C>
4797where
4798 C: common::Connector,
4799{
4800 /// Perform the operation you have build so far.
4801 pub async fn doit(mut self) -> common::Result<(common::Response, ListTimeSeriesResponse)> {
4802 use std::borrow::Cow;
4803 use std::io::{Read, Seek};
4804
4805 use common::{url::Params, ToParts};
4806 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4807
4808 let mut dd = common::DefaultDelegate;
4809 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4810 dlg.begin(common::MethodInfo {
4811 id: "monitoring.organizations.timeSeries.list",
4812 http_method: hyper::Method::GET,
4813 });
4814
4815 for &field in [
4816 "alt",
4817 "name",
4818 "view",
4819 "secondaryAggregation.perSeriesAligner",
4820 "secondaryAggregation.groupByFields",
4821 "secondaryAggregation.crossSeriesReducer",
4822 "secondaryAggregation.alignmentPeriod",
4823 "pageToken",
4824 "pageSize",
4825 "orderBy",
4826 "interval.startTime",
4827 "interval.endTime",
4828 "filter",
4829 "aggregation.perSeriesAligner",
4830 "aggregation.groupByFields",
4831 "aggregation.crossSeriesReducer",
4832 "aggregation.alignmentPeriod",
4833 ]
4834 .iter()
4835 {
4836 if self._additional_params.contains_key(field) {
4837 dlg.finished(false);
4838 return Err(common::Error::FieldClash(field));
4839 }
4840 }
4841
4842 let mut params = Params::with_capacity(18 + self._additional_params.len());
4843 params.push("name", self._name);
4844 if let Some(value) = self._view.as_ref() {
4845 params.push("view", value);
4846 }
4847 if let Some(value) = self._secondary_aggregation_per_series_aligner.as_ref() {
4848 params.push("secondaryAggregation.perSeriesAligner", value);
4849 }
4850 if !self._secondary_aggregation_group_by_fields.is_empty() {
4851 for f in self._secondary_aggregation_group_by_fields.iter() {
4852 params.push("secondaryAggregation.groupByFields", f);
4853 }
4854 }
4855 if let Some(value) = self._secondary_aggregation_cross_series_reducer.as_ref() {
4856 params.push("secondaryAggregation.crossSeriesReducer", value);
4857 }
4858 if let Some(value) = self._secondary_aggregation_alignment_period.as_ref() {
4859 params.push(
4860 "secondaryAggregation.alignmentPeriod",
4861 common::serde::duration::to_string(&value),
4862 );
4863 }
4864 if let Some(value) = self._page_token.as_ref() {
4865 params.push("pageToken", value);
4866 }
4867 if let Some(value) = self._page_size.as_ref() {
4868 params.push("pageSize", value.to_string());
4869 }
4870 if let Some(value) = self._order_by.as_ref() {
4871 params.push("orderBy", value);
4872 }
4873 if let Some(value) = self._interval_start_time.as_ref() {
4874 params.push(
4875 "interval.startTime",
4876 common::serde::datetime_to_string(&value),
4877 );
4878 }
4879 if let Some(value) = self._interval_end_time.as_ref() {
4880 params.push(
4881 "interval.endTime",
4882 common::serde::datetime_to_string(&value),
4883 );
4884 }
4885 if let Some(value) = self._filter.as_ref() {
4886 params.push("filter", value);
4887 }
4888 if let Some(value) = self._aggregation_per_series_aligner.as_ref() {
4889 params.push("aggregation.perSeriesAligner", value);
4890 }
4891 if !self._aggregation_group_by_fields.is_empty() {
4892 for f in self._aggregation_group_by_fields.iter() {
4893 params.push("aggregation.groupByFields", f);
4894 }
4895 }
4896 if let Some(value) = self._aggregation_cross_series_reducer.as_ref() {
4897 params.push("aggregation.crossSeriesReducer", value);
4898 }
4899 if let Some(value) = self._aggregation_alignment_period.as_ref() {
4900 params.push(
4901 "aggregation.alignmentPeriod",
4902 common::serde::duration::to_string(&value),
4903 );
4904 }
4905
4906 params.extend(self._additional_params.iter());
4907
4908 params.push("alt", "json");
4909 let mut url = self.hub._base_url.clone() + "v3/{+name}/timeSeries";
4910 if self._scopes.is_empty() {
4911 self._scopes
4912 .insert(Scope::CloudPlatform.as_ref().to_string());
4913 }
4914
4915 #[allow(clippy::single_element_loop)]
4916 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4917 url = params.uri_replacement(url, param_name, find_this, true);
4918 }
4919 {
4920 let to_remove = ["name"];
4921 params.remove_params(&to_remove);
4922 }
4923
4924 let url = params.parse_with_url(&url);
4925
4926 loop {
4927 let token = match self
4928 .hub
4929 .auth
4930 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4931 .await
4932 {
4933 Ok(token) => token,
4934 Err(e) => match dlg.token(e) {
4935 Ok(token) => token,
4936 Err(e) => {
4937 dlg.finished(false);
4938 return Err(common::Error::MissingToken(e));
4939 }
4940 },
4941 };
4942 let mut req_result = {
4943 let client = &self.hub.client;
4944 dlg.pre_request();
4945 let mut req_builder = hyper::Request::builder()
4946 .method(hyper::Method::GET)
4947 .uri(url.as_str())
4948 .header(USER_AGENT, self.hub._user_agent.clone());
4949
4950 if let Some(token) = token.as_ref() {
4951 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4952 }
4953
4954 let request = req_builder
4955 .header(CONTENT_LENGTH, 0_u64)
4956 .body(common::to_body::<String>(None));
4957
4958 client.request(request.unwrap()).await
4959 };
4960
4961 match req_result {
4962 Err(err) => {
4963 if let common::Retry::After(d) = dlg.http_error(&err) {
4964 sleep(d).await;
4965 continue;
4966 }
4967 dlg.finished(false);
4968 return Err(common::Error::HttpError(err));
4969 }
4970 Ok(res) => {
4971 let (mut parts, body) = res.into_parts();
4972 let mut body = common::Body::new(body);
4973 if !parts.status.is_success() {
4974 let bytes = common::to_bytes(body).await.unwrap_or_default();
4975 let error = serde_json::from_str(&common::to_string(&bytes));
4976 let response = common::to_response(parts, bytes.into());
4977
4978 if let common::Retry::After(d) =
4979 dlg.http_failure(&response, error.as_ref().ok())
4980 {
4981 sleep(d).await;
4982 continue;
4983 }
4984
4985 dlg.finished(false);
4986
4987 return Err(match error {
4988 Ok(value) => common::Error::BadRequest(value),
4989 _ => common::Error::Failure(response),
4990 });
4991 }
4992 let response = {
4993 let bytes = common::to_bytes(body).await.unwrap_or_default();
4994 let encoded = common::to_string(&bytes);
4995 match serde_json::from_str(&encoded) {
4996 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4997 Err(error) => {
4998 dlg.response_json_decode_error(&encoded, &error);
4999 return Err(common::Error::JsonDecodeError(
5000 encoded.to_string(),
5001 error,
5002 ));
5003 }
5004 }
5005 };
5006
5007 dlg.finished(true);
5008 return Ok(response);
5009 }
5010 }
5011 }
5012 }
5013
5014 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name), organization or folder on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]
5015 ///
5016 /// Sets the *name* path property to the given value.
5017 ///
5018 /// Even though the property as already been set when instantiating this call,
5019 /// we provide this method for API completeness.
5020 pub fn name(mut self, new_value: &str) -> OrganizationTimeSeryListCall<'a, C> {
5021 self._name = new_value.to_string();
5022 self
5023 }
5024 /// Required. Specifies which information is returned about the time series.
5025 ///
5026 /// Sets the *view* query property to the given value.
5027 pub fn view(mut self, new_value: &str) -> OrganizationTimeSeryListCall<'a, C> {
5028 self._view = Some(new_value.to_string());
5029 self
5030 }
5031 /// An Aligner describes how to bring the data points in a single time series into temporal alignment. Except for ALIGN_NONE, all alignments cause all the data points in an alignment_period to be mathematically grouped together, resulting in a single data point for each alignment_period with end timestamp at the end of the period.Not all alignment operations may be applied to all time series. The valid choices depend on the metric_kind and value_type of the original time series. Alignment can change the metric_kind or the value_type of the time series.Time series data must be aligned in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified and not equal to ALIGN_NONE and alignment_period must be specified; otherwise, an error is returned.
5032 ///
5033 /// Sets the *secondary aggregation.per series aligner* query property to the given value.
5034 pub fn secondary_aggregation_per_series_aligner(
5035 mut self,
5036 new_value: &str,
5037 ) -> OrganizationTimeSeryListCall<'a, C> {
5038 self._secondary_aggregation_per_series_aligner = Some(new_value.to_string());
5039 self
5040 }
5041 /// The set of fields to preserve when cross_series_reducer is specified. The group_by_fields determine how the time series are partitioned into subsets prior to applying the aggregation operation. Each subset contains time series that have the same value for each of the grouping fields. Each individual time series is a member of exactly one subset. The cross_series_reducer is applied to each subset of time series. It is not possible to reduce across different resource types, so this field implicitly contains resource.type. Fields not specified in group_by_fields are aggregated away. If group_by_fields is not specified and all the time series have the same resource type, then the time series are aggregated into a single output time series. If cross_series_reducer is not defined, this field is ignored.
5042 ///
5043 /// Append the given value to the *secondary aggregation.group by fields* query property.
5044 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5045 pub fn add_secondary_aggregation_group_by_fields(
5046 mut self,
5047 new_value: &str,
5048 ) -> OrganizationTimeSeryListCall<'a, C> {
5049 self._secondary_aggregation_group_by_fields
5050 .push(new_value.to_string());
5051 self
5052 }
5053 /// The reduction operation to be used to combine time series into a single time series, where the value of each data point in the resulting series is a function of all the already aligned values in the input time series.Not all reducer operations can be applied to all time series. The valid choices depend on the metric_kind and the value_type of the original time series. Reduction can yield a time series with a different metric_kind or value_type than the input time series.Time series data must first be aligned (see per_series_aligner) in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified, and must not be ALIGN_NONE. An alignment_period must also be specified; otherwise, an error is returned.
5054 ///
5055 /// Sets the *secondary aggregation.cross series reducer* query property to the given value.
5056 pub fn secondary_aggregation_cross_series_reducer(
5057 mut self,
5058 new_value: &str,
5059 ) -> OrganizationTimeSeryListCall<'a, C> {
5060 self._secondary_aggregation_cross_series_reducer = Some(new_value.to_string());
5061 self
5062 }
5063 /// The alignment_period specifies a time interval, in seconds, that is used to divide the data in all the time series into consistent blocks of time. This will be done before the per-series aligner can be applied to the data.The value must be at least 60 seconds. If a per-series aligner other than ALIGN_NONE is specified, this field is required or an error is returned. If no per-series aligner is specified, or the aligner ALIGN_NONE is specified, then this field is ignored.The maximum value of the alignment_period is 104 weeks (2 years) for charts, and 90,000 seconds (25 hours) for alerting policies.
5064 ///
5065 /// Sets the *secondary aggregation.alignment period* query property to the given value.
5066 pub fn secondary_aggregation_alignment_period(
5067 mut self,
5068 new_value: chrono::Duration,
5069 ) -> OrganizationTimeSeryListCall<'a, C> {
5070 self._secondary_aggregation_alignment_period = Some(new_value);
5071 self
5072 }
5073 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
5074 ///
5075 /// Sets the *page token* query property to the given value.
5076 pub fn page_token(mut self, new_value: &str) -> OrganizationTimeSeryListCall<'a, C> {
5077 self._page_token = Some(new_value.to_string());
5078 self
5079 }
5080 /// A positive number that is the maximum number of results to return. If page_size is empty or more than 100,000 results, the effective page_size is 100,000 results. If view is set to FULL, this is the maximum number of Points returned. If view is set to HEADERS, this is the maximum number of TimeSeries returned.
5081 ///
5082 /// Sets the *page size* query property to the given value.
5083 pub fn page_size(mut self, new_value: i32) -> OrganizationTimeSeryListCall<'a, C> {
5084 self._page_size = Some(new_value);
5085 self
5086 }
5087 /// Unsupported: must be left blank. The points in each time series are currently returned in reverse time order (most recent to oldest).
5088 ///
5089 /// Sets the *order by* query property to the given value.
5090 pub fn order_by(mut self, new_value: &str) -> OrganizationTimeSeryListCall<'a, C> {
5091 self._order_by = Some(new_value.to_string());
5092 self
5093 }
5094 /// Optional. The beginning of the time interval. The default value for the start time is the end time. The start time must not be later than the end time.
5095 ///
5096 /// Sets the *interval.start time* query property to the given value.
5097 pub fn interval_start_time(
5098 mut self,
5099 new_value: chrono::DateTime<chrono::offset::Utc>,
5100 ) -> OrganizationTimeSeryListCall<'a, C> {
5101 self._interval_start_time = Some(new_value);
5102 self
5103 }
5104 /// Required. The end of the time interval.
5105 ///
5106 /// Sets the *interval.end time* query property to the given value.
5107 pub fn interval_end_time(
5108 mut self,
5109 new_value: chrono::DateTime<chrono::offset::Utc>,
5110 ) -> OrganizationTimeSeryListCall<'a, C> {
5111 self._interval_end_time = Some(new_value);
5112 self
5113 }
5114 /// Required. A monitoring filter (https://cloud.google.com/monitoring/api/v3/filters) that specifies which time series should be returned. The filter must specify a single metric type, and can additionally specify metric labels and other information. For example: metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND metric.labels.instance_name = "my-instance-name"
5115 ///
5116 /// Sets the *filter* query property to the given value.
5117 pub fn filter(mut self, new_value: &str) -> OrganizationTimeSeryListCall<'a, C> {
5118 self._filter = Some(new_value.to_string());
5119 self
5120 }
5121 /// An Aligner describes how to bring the data points in a single time series into temporal alignment. Except for ALIGN_NONE, all alignments cause all the data points in an alignment_period to be mathematically grouped together, resulting in a single data point for each alignment_period with end timestamp at the end of the period.Not all alignment operations may be applied to all time series. The valid choices depend on the metric_kind and value_type of the original time series. Alignment can change the metric_kind or the value_type of the time series.Time series data must be aligned in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified and not equal to ALIGN_NONE and alignment_period must be specified; otherwise, an error is returned.
5122 ///
5123 /// Sets the *aggregation.per series aligner* query property to the given value.
5124 pub fn aggregation_per_series_aligner(
5125 mut self,
5126 new_value: &str,
5127 ) -> OrganizationTimeSeryListCall<'a, C> {
5128 self._aggregation_per_series_aligner = Some(new_value.to_string());
5129 self
5130 }
5131 /// The set of fields to preserve when cross_series_reducer is specified. The group_by_fields determine how the time series are partitioned into subsets prior to applying the aggregation operation. Each subset contains time series that have the same value for each of the grouping fields. Each individual time series is a member of exactly one subset. The cross_series_reducer is applied to each subset of time series. It is not possible to reduce across different resource types, so this field implicitly contains resource.type. Fields not specified in group_by_fields are aggregated away. If group_by_fields is not specified and all the time series have the same resource type, then the time series are aggregated into a single output time series. If cross_series_reducer is not defined, this field is ignored.
5132 ///
5133 /// Append the given value to the *aggregation.group by fields* query property.
5134 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5135 pub fn add_aggregation_group_by_fields(
5136 mut self,
5137 new_value: &str,
5138 ) -> OrganizationTimeSeryListCall<'a, C> {
5139 self._aggregation_group_by_fields
5140 .push(new_value.to_string());
5141 self
5142 }
5143 /// The reduction operation to be used to combine time series into a single time series, where the value of each data point in the resulting series is a function of all the already aligned values in the input time series.Not all reducer operations can be applied to all time series. The valid choices depend on the metric_kind and the value_type of the original time series. Reduction can yield a time series with a different metric_kind or value_type than the input time series.Time series data must first be aligned (see per_series_aligner) in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified, and must not be ALIGN_NONE. An alignment_period must also be specified; otherwise, an error is returned.
5144 ///
5145 /// Sets the *aggregation.cross series reducer* query property to the given value.
5146 pub fn aggregation_cross_series_reducer(
5147 mut self,
5148 new_value: &str,
5149 ) -> OrganizationTimeSeryListCall<'a, C> {
5150 self._aggregation_cross_series_reducer = Some(new_value.to_string());
5151 self
5152 }
5153 /// The alignment_period specifies a time interval, in seconds, that is used to divide the data in all the time series into consistent blocks of time. This will be done before the per-series aligner can be applied to the data.The value must be at least 60 seconds. If a per-series aligner other than ALIGN_NONE is specified, this field is required or an error is returned. If no per-series aligner is specified, or the aligner ALIGN_NONE is specified, then this field is ignored.The maximum value of the alignment_period is 104 weeks (2 years) for charts, and 90,000 seconds (25 hours) for alerting policies.
5154 ///
5155 /// Sets the *aggregation.alignment period* query property to the given value.
5156 pub fn aggregation_alignment_period(
5157 mut self,
5158 new_value: chrono::Duration,
5159 ) -> OrganizationTimeSeryListCall<'a, C> {
5160 self._aggregation_alignment_period = Some(new_value);
5161 self
5162 }
5163 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5164 /// while executing the actual API request.
5165 ///
5166 /// ````text
5167 /// It should be used to handle progress information, and to implement a certain level of resilience.
5168 /// ````
5169 ///
5170 /// Sets the *delegate* property to the given value.
5171 pub fn delegate(
5172 mut self,
5173 new_value: &'a mut dyn common::Delegate,
5174 ) -> OrganizationTimeSeryListCall<'a, C> {
5175 self._delegate = Some(new_value);
5176 self
5177 }
5178
5179 /// Set any additional parameter of the query string used in the request.
5180 /// It should be used to set parameters which are not yet available through their own
5181 /// setters.
5182 ///
5183 /// Please note that this method must not be used to set any of the known parameters
5184 /// which have their own setter method. If done anyway, the request will fail.
5185 ///
5186 /// # Additional Parameters
5187 ///
5188 /// * *$.xgafv* (query-string) - V1 error format.
5189 /// * *access_token* (query-string) - OAuth access token.
5190 /// * *alt* (query-string) - Data format for response.
5191 /// * *callback* (query-string) - JSONP
5192 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5193 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5194 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5195 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5196 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5197 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5198 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5199 pub fn param<T>(mut self, name: T, value: T) -> OrganizationTimeSeryListCall<'a, C>
5200 where
5201 T: AsRef<str>,
5202 {
5203 self._additional_params
5204 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5205 self
5206 }
5207
5208 /// Identifies the authorization scope for the method you are building.
5209 ///
5210 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5211 /// [`Scope::CloudPlatform`].
5212 ///
5213 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5214 /// tokens for more than one scope.
5215 ///
5216 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5217 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5218 /// sufficient, a read-write scope will do as well.
5219 pub fn add_scope<St>(mut self, scope: St) -> OrganizationTimeSeryListCall<'a, C>
5220 where
5221 St: AsRef<str>,
5222 {
5223 self._scopes.insert(String::from(scope.as_ref()));
5224 self
5225 }
5226 /// Identifies the authorization scope(s) for the method you are building.
5227 ///
5228 /// See [`Self::add_scope()`] for details.
5229 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationTimeSeryListCall<'a, C>
5230 where
5231 I: IntoIterator<Item = St>,
5232 St: AsRef<str>,
5233 {
5234 self._scopes
5235 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5236 self
5237 }
5238
5239 /// Removes all scopes, and no default scope will be used either.
5240 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5241 /// for details).
5242 pub fn clear_scopes(mut self) -> OrganizationTimeSeryListCall<'a, C> {
5243 self._scopes.clear();
5244 self
5245 }
5246}
5247
5248/// Creates a new alerting policy.Design your application to single-thread API calls that modify the state of alerting policies in a single project. This includes calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
5249///
5250/// A builder for the *alertPolicies.create* method supported by a *project* resource.
5251/// It is not used directly, but through a [`ProjectMethods`] instance.
5252///
5253/// # Example
5254///
5255/// Instantiate a resource method builder
5256///
5257/// ```test_harness,no_run
5258/// # extern crate hyper;
5259/// # extern crate hyper_rustls;
5260/// # extern crate google_monitoring3 as monitoring3;
5261/// use monitoring3::api::AlertPolicy;
5262/// # async fn dox() {
5263/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5264///
5265/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5266/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5267/// # secret,
5268/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5269/// # ).build().await.unwrap();
5270///
5271/// # let client = hyper_util::client::legacy::Client::builder(
5272/// # hyper_util::rt::TokioExecutor::new()
5273/// # )
5274/// # .build(
5275/// # hyper_rustls::HttpsConnectorBuilder::new()
5276/// # .with_native_roots()
5277/// # .unwrap()
5278/// # .https_or_http()
5279/// # .enable_http1()
5280/// # .build()
5281/// # );
5282/// # let mut hub = Monitoring::new(client, auth);
5283/// // As the method needs a request, you would usually fill it with the desired information
5284/// // into the respective structure. Some of the parts shown here might not be applicable !
5285/// // Values shown here are possibly random and not representative !
5286/// let mut req = AlertPolicy::default();
5287///
5288/// // You can configure optional parameters by calling the respective setters at will, and
5289/// // execute the final call using `doit()`.
5290/// // Values shown here are possibly random and not representative !
5291/// let result = hub.projects().alert_policies_create(req, "name")
5292/// .doit().await;
5293/// # }
5294/// ```
5295pub struct ProjectAlertPolicyCreateCall<'a, C>
5296where
5297 C: 'a,
5298{
5299 hub: &'a Monitoring<C>,
5300 _request: AlertPolicy,
5301 _name: String,
5302 _delegate: Option<&'a mut dyn common::Delegate>,
5303 _additional_params: HashMap<String, String>,
5304 _scopes: BTreeSet<String>,
5305}
5306
5307impl<'a, C> common::CallBuilder for ProjectAlertPolicyCreateCall<'a, C> {}
5308
5309impl<'a, C> ProjectAlertPolicyCreateCall<'a, C>
5310where
5311 C: common::Connector,
5312{
5313 /// Perform the operation you have build so far.
5314 pub async fn doit(mut self) -> common::Result<(common::Response, AlertPolicy)> {
5315 use std::borrow::Cow;
5316 use std::io::{Read, Seek};
5317
5318 use common::{url::Params, ToParts};
5319 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5320
5321 let mut dd = common::DefaultDelegate;
5322 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5323 dlg.begin(common::MethodInfo {
5324 id: "monitoring.projects.alertPolicies.create",
5325 http_method: hyper::Method::POST,
5326 });
5327
5328 for &field in ["alt", "name"].iter() {
5329 if self._additional_params.contains_key(field) {
5330 dlg.finished(false);
5331 return Err(common::Error::FieldClash(field));
5332 }
5333 }
5334
5335 let mut params = Params::with_capacity(4 + self._additional_params.len());
5336 params.push("name", self._name);
5337
5338 params.extend(self._additional_params.iter());
5339
5340 params.push("alt", "json");
5341 let mut url = self.hub._base_url.clone() + "v3/{+name}/alertPolicies";
5342 if self._scopes.is_empty() {
5343 self._scopes
5344 .insert(Scope::CloudPlatform.as_ref().to_string());
5345 }
5346
5347 #[allow(clippy::single_element_loop)]
5348 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5349 url = params.uri_replacement(url, param_name, find_this, true);
5350 }
5351 {
5352 let to_remove = ["name"];
5353 params.remove_params(&to_remove);
5354 }
5355
5356 let url = params.parse_with_url(&url);
5357
5358 let mut json_mime_type = mime::APPLICATION_JSON;
5359 let mut request_value_reader = {
5360 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5361 common::remove_json_null_values(&mut value);
5362 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5363 serde_json::to_writer(&mut dst, &value).unwrap();
5364 dst
5365 };
5366 let request_size = request_value_reader
5367 .seek(std::io::SeekFrom::End(0))
5368 .unwrap();
5369 request_value_reader
5370 .seek(std::io::SeekFrom::Start(0))
5371 .unwrap();
5372
5373 loop {
5374 let token = match self
5375 .hub
5376 .auth
5377 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5378 .await
5379 {
5380 Ok(token) => token,
5381 Err(e) => match dlg.token(e) {
5382 Ok(token) => token,
5383 Err(e) => {
5384 dlg.finished(false);
5385 return Err(common::Error::MissingToken(e));
5386 }
5387 },
5388 };
5389 request_value_reader
5390 .seek(std::io::SeekFrom::Start(0))
5391 .unwrap();
5392 let mut req_result = {
5393 let client = &self.hub.client;
5394 dlg.pre_request();
5395 let mut req_builder = hyper::Request::builder()
5396 .method(hyper::Method::POST)
5397 .uri(url.as_str())
5398 .header(USER_AGENT, self.hub._user_agent.clone());
5399
5400 if let Some(token) = token.as_ref() {
5401 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5402 }
5403
5404 let request = req_builder
5405 .header(CONTENT_TYPE, json_mime_type.to_string())
5406 .header(CONTENT_LENGTH, request_size as u64)
5407 .body(common::to_body(
5408 request_value_reader.get_ref().clone().into(),
5409 ));
5410
5411 client.request(request.unwrap()).await
5412 };
5413
5414 match req_result {
5415 Err(err) => {
5416 if let common::Retry::After(d) = dlg.http_error(&err) {
5417 sleep(d).await;
5418 continue;
5419 }
5420 dlg.finished(false);
5421 return Err(common::Error::HttpError(err));
5422 }
5423 Ok(res) => {
5424 let (mut parts, body) = res.into_parts();
5425 let mut body = common::Body::new(body);
5426 if !parts.status.is_success() {
5427 let bytes = common::to_bytes(body).await.unwrap_or_default();
5428 let error = serde_json::from_str(&common::to_string(&bytes));
5429 let response = common::to_response(parts, bytes.into());
5430
5431 if let common::Retry::After(d) =
5432 dlg.http_failure(&response, error.as_ref().ok())
5433 {
5434 sleep(d).await;
5435 continue;
5436 }
5437
5438 dlg.finished(false);
5439
5440 return Err(match error {
5441 Ok(value) => common::Error::BadRequest(value),
5442 _ => common::Error::Failure(response),
5443 });
5444 }
5445 let response = {
5446 let bytes = common::to_bytes(body).await.unwrap_or_default();
5447 let encoded = common::to_string(&bytes);
5448 match serde_json::from_str(&encoded) {
5449 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5450 Err(error) => {
5451 dlg.response_json_decode_error(&encoded, &error);
5452 return Err(common::Error::JsonDecodeError(
5453 encoded.to_string(),
5454 error,
5455 ));
5456 }
5457 }
5458 };
5459
5460 dlg.finished(true);
5461 return Ok(response);
5462 }
5463 }
5464 }
5465 }
5466
5467 ///
5468 /// Sets the *request* property to the given value.
5469 ///
5470 /// Even though the property as already been set when instantiating this call,
5471 /// we provide this method for API completeness.
5472 pub fn request(mut self, new_value: AlertPolicy) -> ProjectAlertPolicyCreateCall<'a, C> {
5473 self._request = new_value;
5474 self
5475 }
5476 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) in which to create the alerting policy. The format is: projects/[PROJECT_ID_OR_NUMBER] Note that this field names the parent container in which the alerting policy will be written, not the name of the created policy. |name| must be a host project of a Metrics Scope, otherwise INVALID_ARGUMENT error will return. The alerting policy that is returned will have a name that contains a normalized representation of this name as a prefix but adds a suffix of the form /alertPolicies/[ALERT_POLICY_ID], identifying the policy in the container.
5477 ///
5478 /// Sets the *name* path property to the given value.
5479 ///
5480 /// Even though the property as already been set when instantiating this call,
5481 /// we provide this method for API completeness.
5482 pub fn name(mut self, new_value: &str) -> ProjectAlertPolicyCreateCall<'a, C> {
5483 self._name = new_value.to_string();
5484 self
5485 }
5486 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5487 /// while executing the actual API request.
5488 ///
5489 /// ````text
5490 /// It should be used to handle progress information, and to implement a certain level of resilience.
5491 /// ````
5492 ///
5493 /// Sets the *delegate* property to the given value.
5494 pub fn delegate(
5495 mut self,
5496 new_value: &'a mut dyn common::Delegate,
5497 ) -> ProjectAlertPolicyCreateCall<'a, C> {
5498 self._delegate = Some(new_value);
5499 self
5500 }
5501
5502 /// Set any additional parameter of the query string used in the request.
5503 /// It should be used to set parameters which are not yet available through their own
5504 /// setters.
5505 ///
5506 /// Please note that this method must not be used to set any of the known parameters
5507 /// which have their own setter method. If done anyway, the request will fail.
5508 ///
5509 /// # Additional Parameters
5510 ///
5511 /// * *$.xgafv* (query-string) - V1 error format.
5512 /// * *access_token* (query-string) - OAuth access token.
5513 /// * *alt* (query-string) - Data format for response.
5514 /// * *callback* (query-string) - JSONP
5515 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5516 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5517 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5518 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5519 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5520 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5521 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5522 pub fn param<T>(mut self, name: T, value: T) -> ProjectAlertPolicyCreateCall<'a, C>
5523 where
5524 T: AsRef<str>,
5525 {
5526 self._additional_params
5527 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5528 self
5529 }
5530
5531 /// Identifies the authorization scope for the method you are building.
5532 ///
5533 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5534 /// [`Scope::CloudPlatform`].
5535 ///
5536 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5537 /// tokens for more than one scope.
5538 ///
5539 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5540 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5541 /// sufficient, a read-write scope will do as well.
5542 pub fn add_scope<St>(mut self, scope: St) -> ProjectAlertPolicyCreateCall<'a, C>
5543 where
5544 St: AsRef<str>,
5545 {
5546 self._scopes.insert(String::from(scope.as_ref()));
5547 self
5548 }
5549 /// Identifies the authorization scope(s) for the method you are building.
5550 ///
5551 /// See [`Self::add_scope()`] for details.
5552 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAlertPolicyCreateCall<'a, C>
5553 where
5554 I: IntoIterator<Item = St>,
5555 St: AsRef<str>,
5556 {
5557 self._scopes
5558 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5559 self
5560 }
5561
5562 /// Removes all scopes, and no default scope will be used either.
5563 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5564 /// for details).
5565 pub fn clear_scopes(mut self) -> ProjectAlertPolicyCreateCall<'a, C> {
5566 self._scopes.clear();
5567 self
5568 }
5569}
5570
5571/// Deletes an alerting policy.Design your application to single-thread API calls that modify the state of alerting policies in a single project. This includes calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
5572///
5573/// A builder for the *alertPolicies.delete* method supported by a *project* resource.
5574/// It is not used directly, but through a [`ProjectMethods`] instance.
5575///
5576/// # Example
5577///
5578/// Instantiate a resource method builder
5579///
5580/// ```test_harness,no_run
5581/// # extern crate hyper;
5582/// # extern crate hyper_rustls;
5583/// # extern crate google_monitoring3 as monitoring3;
5584/// # async fn dox() {
5585/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5586///
5587/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5589/// # secret,
5590/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5591/// # ).build().await.unwrap();
5592///
5593/// # let client = hyper_util::client::legacy::Client::builder(
5594/// # hyper_util::rt::TokioExecutor::new()
5595/// # )
5596/// # .build(
5597/// # hyper_rustls::HttpsConnectorBuilder::new()
5598/// # .with_native_roots()
5599/// # .unwrap()
5600/// # .https_or_http()
5601/// # .enable_http1()
5602/// # .build()
5603/// # );
5604/// # let mut hub = Monitoring::new(client, auth);
5605/// // You can configure optional parameters by calling the respective setters at will, and
5606/// // execute the final call using `doit()`.
5607/// // Values shown here are possibly random and not representative !
5608/// let result = hub.projects().alert_policies_delete("name")
5609/// .doit().await;
5610/// # }
5611/// ```
5612pub struct ProjectAlertPolicyDeleteCall<'a, C>
5613where
5614 C: 'a,
5615{
5616 hub: &'a Monitoring<C>,
5617 _name: String,
5618 _delegate: Option<&'a mut dyn common::Delegate>,
5619 _additional_params: HashMap<String, String>,
5620 _scopes: BTreeSet<String>,
5621}
5622
5623impl<'a, C> common::CallBuilder for ProjectAlertPolicyDeleteCall<'a, C> {}
5624
5625impl<'a, C> ProjectAlertPolicyDeleteCall<'a, C>
5626where
5627 C: common::Connector,
5628{
5629 /// Perform the operation you have build so far.
5630 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5631 use std::borrow::Cow;
5632 use std::io::{Read, Seek};
5633
5634 use common::{url::Params, ToParts};
5635 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5636
5637 let mut dd = common::DefaultDelegate;
5638 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5639 dlg.begin(common::MethodInfo {
5640 id: "monitoring.projects.alertPolicies.delete",
5641 http_method: hyper::Method::DELETE,
5642 });
5643
5644 for &field in ["alt", "name"].iter() {
5645 if self._additional_params.contains_key(field) {
5646 dlg.finished(false);
5647 return Err(common::Error::FieldClash(field));
5648 }
5649 }
5650
5651 let mut params = Params::with_capacity(3 + self._additional_params.len());
5652 params.push("name", self._name);
5653
5654 params.extend(self._additional_params.iter());
5655
5656 params.push("alt", "json");
5657 let mut url = self.hub._base_url.clone() + "v3/{+name}";
5658 if self._scopes.is_empty() {
5659 self._scopes
5660 .insert(Scope::CloudPlatform.as_ref().to_string());
5661 }
5662
5663 #[allow(clippy::single_element_loop)]
5664 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5665 url = params.uri_replacement(url, param_name, find_this, true);
5666 }
5667 {
5668 let to_remove = ["name"];
5669 params.remove_params(&to_remove);
5670 }
5671
5672 let url = params.parse_with_url(&url);
5673
5674 loop {
5675 let token = match self
5676 .hub
5677 .auth
5678 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5679 .await
5680 {
5681 Ok(token) => token,
5682 Err(e) => match dlg.token(e) {
5683 Ok(token) => token,
5684 Err(e) => {
5685 dlg.finished(false);
5686 return Err(common::Error::MissingToken(e));
5687 }
5688 },
5689 };
5690 let mut req_result = {
5691 let client = &self.hub.client;
5692 dlg.pre_request();
5693 let mut req_builder = hyper::Request::builder()
5694 .method(hyper::Method::DELETE)
5695 .uri(url.as_str())
5696 .header(USER_AGENT, self.hub._user_agent.clone());
5697
5698 if let Some(token) = token.as_ref() {
5699 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5700 }
5701
5702 let request = req_builder
5703 .header(CONTENT_LENGTH, 0_u64)
5704 .body(common::to_body::<String>(None));
5705
5706 client.request(request.unwrap()).await
5707 };
5708
5709 match req_result {
5710 Err(err) => {
5711 if let common::Retry::After(d) = dlg.http_error(&err) {
5712 sleep(d).await;
5713 continue;
5714 }
5715 dlg.finished(false);
5716 return Err(common::Error::HttpError(err));
5717 }
5718 Ok(res) => {
5719 let (mut parts, body) = res.into_parts();
5720 let mut body = common::Body::new(body);
5721 if !parts.status.is_success() {
5722 let bytes = common::to_bytes(body).await.unwrap_or_default();
5723 let error = serde_json::from_str(&common::to_string(&bytes));
5724 let response = common::to_response(parts, bytes.into());
5725
5726 if let common::Retry::After(d) =
5727 dlg.http_failure(&response, error.as_ref().ok())
5728 {
5729 sleep(d).await;
5730 continue;
5731 }
5732
5733 dlg.finished(false);
5734
5735 return Err(match error {
5736 Ok(value) => common::Error::BadRequest(value),
5737 _ => common::Error::Failure(response),
5738 });
5739 }
5740 let response = {
5741 let bytes = common::to_bytes(body).await.unwrap_or_default();
5742 let encoded = common::to_string(&bytes);
5743 match serde_json::from_str(&encoded) {
5744 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5745 Err(error) => {
5746 dlg.response_json_decode_error(&encoded, &error);
5747 return Err(common::Error::JsonDecodeError(
5748 encoded.to_string(),
5749 error,
5750 ));
5751 }
5752 }
5753 };
5754
5755 dlg.finished(true);
5756 return Ok(response);
5757 }
5758 }
5759 }
5760 }
5761
5762 /// Required. The alerting policy to delete. The format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] For more information, see AlertPolicy.
5763 ///
5764 /// Sets the *name* path property to the given value.
5765 ///
5766 /// Even though the property as already been set when instantiating this call,
5767 /// we provide this method for API completeness.
5768 pub fn name(mut self, new_value: &str) -> ProjectAlertPolicyDeleteCall<'a, C> {
5769 self._name = new_value.to_string();
5770 self
5771 }
5772 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5773 /// while executing the actual API request.
5774 ///
5775 /// ````text
5776 /// It should be used to handle progress information, and to implement a certain level of resilience.
5777 /// ````
5778 ///
5779 /// Sets the *delegate* property to the given value.
5780 pub fn delegate(
5781 mut self,
5782 new_value: &'a mut dyn common::Delegate,
5783 ) -> ProjectAlertPolicyDeleteCall<'a, C> {
5784 self._delegate = Some(new_value);
5785 self
5786 }
5787
5788 /// Set any additional parameter of the query string used in the request.
5789 /// It should be used to set parameters which are not yet available through their own
5790 /// setters.
5791 ///
5792 /// Please note that this method must not be used to set any of the known parameters
5793 /// which have their own setter method. If done anyway, the request will fail.
5794 ///
5795 /// # Additional Parameters
5796 ///
5797 /// * *$.xgafv* (query-string) - V1 error format.
5798 /// * *access_token* (query-string) - OAuth access token.
5799 /// * *alt* (query-string) - Data format for response.
5800 /// * *callback* (query-string) - JSONP
5801 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5802 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5803 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5804 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5805 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5806 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5807 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5808 pub fn param<T>(mut self, name: T, value: T) -> ProjectAlertPolicyDeleteCall<'a, C>
5809 where
5810 T: AsRef<str>,
5811 {
5812 self._additional_params
5813 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5814 self
5815 }
5816
5817 /// Identifies the authorization scope for the method you are building.
5818 ///
5819 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5820 /// [`Scope::CloudPlatform`].
5821 ///
5822 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5823 /// tokens for more than one scope.
5824 ///
5825 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5826 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5827 /// sufficient, a read-write scope will do as well.
5828 pub fn add_scope<St>(mut self, scope: St) -> ProjectAlertPolicyDeleteCall<'a, C>
5829 where
5830 St: AsRef<str>,
5831 {
5832 self._scopes.insert(String::from(scope.as_ref()));
5833 self
5834 }
5835 /// Identifies the authorization scope(s) for the method you are building.
5836 ///
5837 /// See [`Self::add_scope()`] for details.
5838 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAlertPolicyDeleteCall<'a, C>
5839 where
5840 I: IntoIterator<Item = St>,
5841 St: AsRef<str>,
5842 {
5843 self._scopes
5844 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5845 self
5846 }
5847
5848 /// Removes all scopes, and no default scope will be used either.
5849 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5850 /// for details).
5851 pub fn clear_scopes(mut self) -> ProjectAlertPolicyDeleteCall<'a, C> {
5852 self._scopes.clear();
5853 self
5854 }
5855}
5856
5857/// Gets a single alerting policy.
5858///
5859/// A builder for the *alertPolicies.get* method supported by a *project* resource.
5860/// It is not used directly, but through a [`ProjectMethods`] instance.
5861///
5862/// # Example
5863///
5864/// Instantiate a resource method builder
5865///
5866/// ```test_harness,no_run
5867/// # extern crate hyper;
5868/// # extern crate hyper_rustls;
5869/// # extern crate google_monitoring3 as monitoring3;
5870/// # async fn dox() {
5871/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5872///
5873/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5874/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5875/// # secret,
5876/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5877/// # ).build().await.unwrap();
5878///
5879/// # let client = hyper_util::client::legacy::Client::builder(
5880/// # hyper_util::rt::TokioExecutor::new()
5881/// # )
5882/// # .build(
5883/// # hyper_rustls::HttpsConnectorBuilder::new()
5884/// # .with_native_roots()
5885/// # .unwrap()
5886/// # .https_or_http()
5887/// # .enable_http1()
5888/// # .build()
5889/// # );
5890/// # let mut hub = Monitoring::new(client, auth);
5891/// // You can configure optional parameters by calling the respective setters at will, and
5892/// // execute the final call using `doit()`.
5893/// // Values shown here are possibly random and not representative !
5894/// let result = hub.projects().alert_policies_get("name")
5895/// .doit().await;
5896/// # }
5897/// ```
5898pub struct ProjectAlertPolicyGetCall<'a, C>
5899where
5900 C: 'a,
5901{
5902 hub: &'a Monitoring<C>,
5903 _name: String,
5904 _delegate: Option<&'a mut dyn common::Delegate>,
5905 _additional_params: HashMap<String, String>,
5906 _scopes: BTreeSet<String>,
5907}
5908
5909impl<'a, C> common::CallBuilder for ProjectAlertPolicyGetCall<'a, C> {}
5910
5911impl<'a, C> ProjectAlertPolicyGetCall<'a, C>
5912where
5913 C: common::Connector,
5914{
5915 /// Perform the operation you have build so far.
5916 pub async fn doit(mut self) -> common::Result<(common::Response, AlertPolicy)> {
5917 use std::borrow::Cow;
5918 use std::io::{Read, Seek};
5919
5920 use common::{url::Params, ToParts};
5921 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5922
5923 let mut dd = common::DefaultDelegate;
5924 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5925 dlg.begin(common::MethodInfo {
5926 id: "monitoring.projects.alertPolicies.get",
5927 http_method: hyper::Method::GET,
5928 });
5929
5930 for &field in ["alt", "name"].iter() {
5931 if self._additional_params.contains_key(field) {
5932 dlg.finished(false);
5933 return Err(common::Error::FieldClash(field));
5934 }
5935 }
5936
5937 let mut params = Params::with_capacity(3 + self._additional_params.len());
5938 params.push("name", self._name);
5939
5940 params.extend(self._additional_params.iter());
5941
5942 params.push("alt", "json");
5943 let mut url = self.hub._base_url.clone() + "v3/{+name}";
5944 if self._scopes.is_empty() {
5945 self._scopes
5946 .insert(Scope::CloudPlatform.as_ref().to_string());
5947 }
5948
5949 #[allow(clippy::single_element_loop)]
5950 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5951 url = params.uri_replacement(url, param_name, find_this, true);
5952 }
5953 {
5954 let to_remove = ["name"];
5955 params.remove_params(&to_remove);
5956 }
5957
5958 let url = params.parse_with_url(&url);
5959
5960 loop {
5961 let token = match self
5962 .hub
5963 .auth
5964 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5965 .await
5966 {
5967 Ok(token) => token,
5968 Err(e) => match dlg.token(e) {
5969 Ok(token) => token,
5970 Err(e) => {
5971 dlg.finished(false);
5972 return Err(common::Error::MissingToken(e));
5973 }
5974 },
5975 };
5976 let mut req_result = {
5977 let client = &self.hub.client;
5978 dlg.pre_request();
5979 let mut req_builder = hyper::Request::builder()
5980 .method(hyper::Method::GET)
5981 .uri(url.as_str())
5982 .header(USER_AGENT, self.hub._user_agent.clone());
5983
5984 if let Some(token) = token.as_ref() {
5985 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5986 }
5987
5988 let request = req_builder
5989 .header(CONTENT_LENGTH, 0_u64)
5990 .body(common::to_body::<String>(None));
5991
5992 client.request(request.unwrap()).await
5993 };
5994
5995 match req_result {
5996 Err(err) => {
5997 if let common::Retry::After(d) = dlg.http_error(&err) {
5998 sleep(d).await;
5999 continue;
6000 }
6001 dlg.finished(false);
6002 return Err(common::Error::HttpError(err));
6003 }
6004 Ok(res) => {
6005 let (mut parts, body) = res.into_parts();
6006 let mut body = common::Body::new(body);
6007 if !parts.status.is_success() {
6008 let bytes = common::to_bytes(body).await.unwrap_or_default();
6009 let error = serde_json::from_str(&common::to_string(&bytes));
6010 let response = common::to_response(parts, bytes.into());
6011
6012 if let common::Retry::After(d) =
6013 dlg.http_failure(&response, error.as_ref().ok())
6014 {
6015 sleep(d).await;
6016 continue;
6017 }
6018
6019 dlg.finished(false);
6020
6021 return Err(match error {
6022 Ok(value) => common::Error::BadRequest(value),
6023 _ => common::Error::Failure(response),
6024 });
6025 }
6026 let response = {
6027 let bytes = common::to_bytes(body).await.unwrap_or_default();
6028 let encoded = common::to_string(&bytes);
6029 match serde_json::from_str(&encoded) {
6030 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6031 Err(error) => {
6032 dlg.response_json_decode_error(&encoded, &error);
6033 return Err(common::Error::JsonDecodeError(
6034 encoded.to_string(),
6035 error,
6036 ));
6037 }
6038 }
6039 };
6040
6041 dlg.finished(true);
6042 return Ok(response);
6043 }
6044 }
6045 }
6046 }
6047
6048 /// Required. The alerting policy to retrieve. The format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
6049 ///
6050 /// Sets the *name* path property to the given value.
6051 ///
6052 /// Even though the property as already been set when instantiating this call,
6053 /// we provide this method for API completeness.
6054 pub fn name(mut self, new_value: &str) -> ProjectAlertPolicyGetCall<'a, C> {
6055 self._name = new_value.to_string();
6056 self
6057 }
6058 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6059 /// while executing the actual API request.
6060 ///
6061 /// ````text
6062 /// It should be used to handle progress information, and to implement a certain level of resilience.
6063 /// ````
6064 ///
6065 /// Sets the *delegate* property to the given value.
6066 pub fn delegate(
6067 mut self,
6068 new_value: &'a mut dyn common::Delegate,
6069 ) -> ProjectAlertPolicyGetCall<'a, C> {
6070 self._delegate = Some(new_value);
6071 self
6072 }
6073
6074 /// Set any additional parameter of the query string used in the request.
6075 /// It should be used to set parameters which are not yet available through their own
6076 /// setters.
6077 ///
6078 /// Please note that this method must not be used to set any of the known parameters
6079 /// which have their own setter method. If done anyway, the request will fail.
6080 ///
6081 /// # Additional Parameters
6082 ///
6083 /// * *$.xgafv* (query-string) - V1 error format.
6084 /// * *access_token* (query-string) - OAuth access token.
6085 /// * *alt* (query-string) - Data format for response.
6086 /// * *callback* (query-string) - JSONP
6087 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6088 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6089 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6090 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6091 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6092 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6093 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6094 pub fn param<T>(mut self, name: T, value: T) -> ProjectAlertPolicyGetCall<'a, C>
6095 where
6096 T: AsRef<str>,
6097 {
6098 self._additional_params
6099 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6100 self
6101 }
6102
6103 /// Identifies the authorization scope for the method you are building.
6104 ///
6105 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6106 /// [`Scope::CloudPlatform`].
6107 ///
6108 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6109 /// tokens for more than one scope.
6110 ///
6111 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6112 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6113 /// sufficient, a read-write scope will do as well.
6114 pub fn add_scope<St>(mut self, scope: St) -> ProjectAlertPolicyGetCall<'a, C>
6115 where
6116 St: AsRef<str>,
6117 {
6118 self._scopes.insert(String::from(scope.as_ref()));
6119 self
6120 }
6121 /// Identifies the authorization scope(s) for the method you are building.
6122 ///
6123 /// See [`Self::add_scope()`] for details.
6124 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAlertPolicyGetCall<'a, C>
6125 where
6126 I: IntoIterator<Item = St>,
6127 St: AsRef<str>,
6128 {
6129 self._scopes
6130 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6131 self
6132 }
6133
6134 /// Removes all scopes, and no default scope will be used either.
6135 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6136 /// for details).
6137 pub fn clear_scopes(mut self) -> ProjectAlertPolicyGetCall<'a, C> {
6138 self._scopes.clear();
6139 self
6140 }
6141}
6142
6143/// Lists the existing alerting policies for the workspace.
6144///
6145/// A builder for the *alertPolicies.list* method supported by a *project* resource.
6146/// It is not used directly, but through a [`ProjectMethods`] instance.
6147///
6148/// # Example
6149///
6150/// Instantiate a resource method builder
6151///
6152/// ```test_harness,no_run
6153/// # extern crate hyper;
6154/// # extern crate hyper_rustls;
6155/// # extern crate google_monitoring3 as monitoring3;
6156/// # async fn dox() {
6157/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6158///
6159/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6160/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6161/// # secret,
6162/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6163/// # ).build().await.unwrap();
6164///
6165/// # let client = hyper_util::client::legacy::Client::builder(
6166/// # hyper_util::rt::TokioExecutor::new()
6167/// # )
6168/// # .build(
6169/// # hyper_rustls::HttpsConnectorBuilder::new()
6170/// # .with_native_roots()
6171/// # .unwrap()
6172/// # .https_or_http()
6173/// # .enable_http1()
6174/// # .build()
6175/// # );
6176/// # let mut hub = Monitoring::new(client, auth);
6177/// // You can configure optional parameters by calling the respective setters at will, and
6178/// // execute the final call using `doit()`.
6179/// // Values shown here are possibly random and not representative !
6180/// let result = hub.projects().alert_policies_list("name")
6181/// .page_token("sed")
6182/// .page_size(-20)
6183/// .order_by("dolore")
6184/// .filter("et")
6185/// .doit().await;
6186/// # }
6187/// ```
6188pub struct ProjectAlertPolicyListCall<'a, C>
6189where
6190 C: 'a,
6191{
6192 hub: &'a Monitoring<C>,
6193 _name: String,
6194 _page_token: Option<String>,
6195 _page_size: Option<i32>,
6196 _order_by: Option<String>,
6197 _filter: Option<String>,
6198 _delegate: Option<&'a mut dyn common::Delegate>,
6199 _additional_params: HashMap<String, String>,
6200 _scopes: BTreeSet<String>,
6201}
6202
6203impl<'a, C> common::CallBuilder for ProjectAlertPolicyListCall<'a, C> {}
6204
6205impl<'a, C> ProjectAlertPolicyListCall<'a, C>
6206where
6207 C: common::Connector,
6208{
6209 /// Perform the operation you have build so far.
6210 pub async fn doit(mut self) -> common::Result<(common::Response, ListAlertPoliciesResponse)> {
6211 use std::borrow::Cow;
6212 use std::io::{Read, Seek};
6213
6214 use common::{url::Params, ToParts};
6215 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6216
6217 let mut dd = common::DefaultDelegate;
6218 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6219 dlg.begin(common::MethodInfo {
6220 id: "monitoring.projects.alertPolicies.list",
6221 http_method: hyper::Method::GET,
6222 });
6223
6224 for &field in ["alt", "name", "pageToken", "pageSize", "orderBy", "filter"].iter() {
6225 if self._additional_params.contains_key(field) {
6226 dlg.finished(false);
6227 return Err(common::Error::FieldClash(field));
6228 }
6229 }
6230
6231 let mut params = Params::with_capacity(7 + self._additional_params.len());
6232 params.push("name", self._name);
6233 if let Some(value) = self._page_token.as_ref() {
6234 params.push("pageToken", value);
6235 }
6236 if let Some(value) = self._page_size.as_ref() {
6237 params.push("pageSize", value.to_string());
6238 }
6239 if let Some(value) = self._order_by.as_ref() {
6240 params.push("orderBy", value);
6241 }
6242 if let Some(value) = self._filter.as_ref() {
6243 params.push("filter", value);
6244 }
6245
6246 params.extend(self._additional_params.iter());
6247
6248 params.push("alt", "json");
6249 let mut url = self.hub._base_url.clone() + "v3/{+name}/alertPolicies";
6250 if self._scopes.is_empty() {
6251 self._scopes
6252 .insert(Scope::CloudPlatform.as_ref().to_string());
6253 }
6254
6255 #[allow(clippy::single_element_loop)]
6256 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6257 url = params.uri_replacement(url, param_name, find_this, true);
6258 }
6259 {
6260 let to_remove = ["name"];
6261 params.remove_params(&to_remove);
6262 }
6263
6264 let url = params.parse_with_url(&url);
6265
6266 loop {
6267 let token = match self
6268 .hub
6269 .auth
6270 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6271 .await
6272 {
6273 Ok(token) => token,
6274 Err(e) => match dlg.token(e) {
6275 Ok(token) => token,
6276 Err(e) => {
6277 dlg.finished(false);
6278 return Err(common::Error::MissingToken(e));
6279 }
6280 },
6281 };
6282 let mut req_result = {
6283 let client = &self.hub.client;
6284 dlg.pre_request();
6285 let mut req_builder = hyper::Request::builder()
6286 .method(hyper::Method::GET)
6287 .uri(url.as_str())
6288 .header(USER_AGENT, self.hub._user_agent.clone());
6289
6290 if let Some(token) = token.as_ref() {
6291 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6292 }
6293
6294 let request = req_builder
6295 .header(CONTENT_LENGTH, 0_u64)
6296 .body(common::to_body::<String>(None));
6297
6298 client.request(request.unwrap()).await
6299 };
6300
6301 match req_result {
6302 Err(err) => {
6303 if let common::Retry::After(d) = dlg.http_error(&err) {
6304 sleep(d).await;
6305 continue;
6306 }
6307 dlg.finished(false);
6308 return Err(common::Error::HttpError(err));
6309 }
6310 Ok(res) => {
6311 let (mut parts, body) = res.into_parts();
6312 let mut body = common::Body::new(body);
6313 if !parts.status.is_success() {
6314 let bytes = common::to_bytes(body).await.unwrap_or_default();
6315 let error = serde_json::from_str(&common::to_string(&bytes));
6316 let response = common::to_response(parts, bytes.into());
6317
6318 if let common::Retry::After(d) =
6319 dlg.http_failure(&response, error.as_ref().ok())
6320 {
6321 sleep(d).await;
6322 continue;
6323 }
6324
6325 dlg.finished(false);
6326
6327 return Err(match error {
6328 Ok(value) => common::Error::BadRequest(value),
6329 _ => common::Error::Failure(response),
6330 });
6331 }
6332 let response = {
6333 let bytes = common::to_bytes(body).await.unwrap_or_default();
6334 let encoded = common::to_string(&bytes);
6335 match serde_json::from_str(&encoded) {
6336 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6337 Err(error) => {
6338 dlg.response_json_decode_error(&encoded, &error);
6339 return Err(common::Error::JsonDecodeError(
6340 encoded.to_string(),
6341 error,
6342 ));
6343 }
6344 }
6345 };
6346
6347 dlg.finished(true);
6348 return Ok(response);
6349 }
6350 }
6351 }
6352 }
6353
6354 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) whose alert policies are to be listed. The format is: projects/[PROJECT_ID_OR_NUMBER] Note that this field names the parent container in which the alerting policies to be listed are stored. To retrieve a single alerting policy by name, use the GetAlertPolicy operation, instead.
6355 ///
6356 /// Sets the *name* path property to the given value.
6357 ///
6358 /// Even though the property as already been set when instantiating this call,
6359 /// we provide this method for API completeness.
6360 pub fn name(mut self, new_value: &str) -> ProjectAlertPolicyListCall<'a, C> {
6361 self._name = new_value.to_string();
6362 self
6363 }
6364 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return more results from the previous method call.
6365 ///
6366 /// Sets the *page token* query property to the given value.
6367 pub fn page_token(mut self, new_value: &str) -> ProjectAlertPolicyListCall<'a, C> {
6368 self._page_token = Some(new_value.to_string());
6369 self
6370 }
6371 /// The maximum number of results to return in a single response.
6372 ///
6373 /// Sets the *page size* query property to the given value.
6374 pub fn page_size(mut self, new_value: i32) -> ProjectAlertPolicyListCall<'a, C> {
6375 self._page_size = Some(new_value);
6376 self
6377 }
6378 /// A comma-separated list of fields by which to sort the result. Supports the same set of field references as the filter field. Entries can be prefixed with a minus sign to sort by the field in descending order.For more details, see sorting and filtering (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
6379 ///
6380 /// Sets the *order by* query property to the given value.
6381 pub fn order_by(mut self, new_value: &str) -> ProjectAlertPolicyListCall<'a, C> {
6382 self._order_by = Some(new_value.to_string());
6383 self
6384 }
6385 /// If provided, this field specifies the criteria that must be met by alert policies to be included in the response.For more details, see sorting and filtering (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
6386 ///
6387 /// Sets the *filter* query property to the given value.
6388 pub fn filter(mut self, new_value: &str) -> ProjectAlertPolicyListCall<'a, C> {
6389 self._filter = Some(new_value.to_string());
6390 self
6391 }
6392 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6393 /// while executing the actual API request.
6394 ///
6395 /// ````text
6396 /// It should be used to handle progress information, and to implement a certain level of resilience.
6397 /// ````
6398 ///
6399 /// Sets the *delegate* property to the given value.
6400 pub fn delegate(
6401 mut self,
6402 new_value: &'a mut dyn common::Delegate,
6403 ) -> ProjectAlertPolicyListCall<'a, C> {
6404 self._delegate = Some(new_value);
6405 self
6406 }
6407
6408 /// Set any additional parameter of the query string used in the request.
6409 /// It should be used to set parameters which are not yet available through their own
6410 /// setters.
6411 ///
6412 /// Please note that this method must not be used to set any of the known parameters
6413 /// which have their own setter method. If done anyway, the request will fail.
6414 ///
6415 /// # Additional Parameters
6416 ///
6417 /// * *$.xgafv* (query-string) - V1 error format.
6418 /// * *access_token* (query-string) - OAuth access token.
6419 /// * *alt* (query-string) - Data format for response.
6420 /// * *callback* (query-string) - JSONP
6421 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6422 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6423 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6424 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6425 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6426 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6427 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6428 pub fn param<T>(mut self, name: T, value: T) -> ProjectAlertPolicyListCall<'a, C>
6429 where
6430 T: AsRef<str>,
6431 {
6432 self._additional_params
6433 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6434 self
6435 }
6436
6437 /// Identifies the authorization scope for the method you are building.
6438 ///
6439 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6440 /// [`Scope::CloudPlatform`].
6441 ///
6442 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6443 /// tokens for more than one scope.
6444 ///
6445 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6446 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6447 /// sufficient, a read-write scope will do as well.
6448 pub fn add_scope<St>(mut self, scope: St) -> ProjectAlertPolicyListCall<'a, C>
6449 where
6450 St: AsRef<str>,
6451 {
6452 self._scopes.insert(String::from(scope.as_ref()));
6453 self
6454 }
6455 /// Identifies the authorization scope(s) for the method you are building.
6456 ///
6457 /// See [`Self::add_scope()`] for details.
6458 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAlertPolicyListCall<'a, C>
6459 where
6460 I: IntoIterator<Item = St>,
6461 St: AsRef<str>,
6462 {
6463 self._scopes
6464 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6465 self
6466 }
6467
6468 /// Removes all scopes, and no default scope will be used either.
6469 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6470 /// for details).
6471 pub fn clear_scopes(mut self) -> ProjectAlertPolicyListCall<'a, C> {
6472 self._scopes.clear();
6473 self
6474 }
6475}
6476
6477/// Updates an alerting policy. You can either replace the entire policy with a new one or replace only certain fields in the current alerting policy by specifying the fields to be updated via updateMask. Returns the updated alerting policy.Design your application to single-thread API calls that modify the state of alerting policies in a single project. This includes calls to CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy.
6478///
6479/// A builder for the *alertPolicies.patch* method supported by a *project* resource.
6480/// It is not used directly, but through a [`ProjectMethods`] instance.
6481///
6482/// # Example
6483///
6484/// Instantiate a resource method builder
6485///
6486/// ```test_harness,no_run
6487/// # extern crate hyper;
6488/// # extern crate hyper_rustls;
6489/// # extern crate google_monitoring3 as monitoring3;
6490/// use monitoring3::api::AlertPolicy;
6491/// # async fn dox() {
6492/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6493///
6494/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6495/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6496/// # secret,
6497/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6498/// # ).build().await.unwrap();
6499///
6500/// # let client = hyper_util::client::legacy::Client::builder(
6501/// # hyper_util::rt::TokioExecutor::new()
6502/// # )
6503/// # .build(
6504/// # hyper_rustls::HttpsConnectorBuilder::new()
6505/// # .with_native_roots()
6506/// # .unwrap()
6507/// # .https_or_http()
6508/// # .enable_http1()
6509/// # .build()
6510/// # );
6511/// # let mut hub = Monitoring::new(client, auth);
6512/// // As the method needs a request, you would usually fill it with the desired information
6513/// // into the respective structure. Some of the parts shown here might not be applicable !
6514/// // Values shown here are possibly random and not representative !
6515/// let mut req = AlertPolicy::default();
6516///
6517/// // You can configure optional parameters by calling the respective setters at will, and
6518/// // execute the final call using `doit()`.
6519/// // Values shown here are possibly random and not representative !
6520/// let result = hub.projects().alert_policies_patch(req, "name")
6521/// .update_mask(FieldMask::new::<&str>(&[]))
6522/// .doit().await;
6523/// # }
6524/// ```
6525pub struct ProjectAlertPolicyPatchCall<'a, C>
6526where
6527 C: 'a,
6528{
6529 hub: &'a Monitoring<C>,
6530 _request: AlertPolicy,
6531 _name: String,
6532 _update_mask: Option<common::FieldMask>,
6533 _delegate: Option<&'a mut dyn common::Delegate>,
6534 _additional_params: HashMap<String, String>,
6535 _scopes: BTreeSet<String>,
6536}
6537
6538impl<'a, C> common::CallBuilder for ProjectAlertPolicyPatchCall<'a, C> {}
6539
6540impl<'a, C> ProjectAlertPolicyPatchCall<'a, C>
6541where
6542 C: common::Connector,
6543{
6544 /// Perform the operation you have build so far.
6545 pub async fn doit(mut self) -> common::Result<(common::Response, AlertPolicy)> {
6546 use std::borrow::Cow;
6547 use std::io::{Read, Seek};
6548
6549 use common::{url::Params, ToParts};
6550 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6551
6552 let mut dd = common::DefaultDelegate;
6553 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6554 dlg.begin(common::MethodInfo {
6555 id: "monitoring.projects.alertPolicies.patch",
6556 http_method: hyper::Method::PATCH,
6557 });
6558
6559 for &field in ["alt", "name", "updateMask"].iter() {
6560 if self._additional_params.contains_key(field) {
6561 dlg.finished(false);
6562 return Err(common::Error::FieldClash(field));
6563 }
6564 }
6565
6566 let mut params = Params::with_capacity(5 + self._additional_params.len());
6567 params.push("name", self._name);
6568 if let Some(value) = self._update_mask.as_ref() {
6569 params.push("updateMask", value.to_string());
6570 }
6571
6572 params.extend(self._additional_params.iter());
6573
6574 params.push("alt", "json");
6575 let mut url = self.hub._base_url.clone() + "v3/{+name}";
6576 if self._scopes.is_empty() {
6577 self._scopes
6578 .insert(Scope::CloudPlatform.as_ref().to_string());
6579 }
6580
6581 #[allow(clippy::single_element_loop)]
6582 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6583 url = params.uri_replacement(url, param_name, find_this, true);
6584 }
6585 {
6586 let to_remove = ["name"];
6587 params.remove_params(&to_remove);
6588 }
6589
6590 let url = params.parse_with_url(&url);
6591
6592 let mut json_mime_type = mime::APPLICATION_JSON;
6593 let mut request_value_reader = {
6594 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6595 common::remove_json_null_values(&mut value);
6596 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6597 serde_json::to_writer(&mut dst, &value).unwrap();
6598 dst
6599 };
6600 let request_size = request_value_reader
6601 .seek(std::io::SeekFrom::End(0))
6602 .unwrap();
6603 request_value_reader
6604 .seek(std::io::SeekFrom::Start(0))
6605 .unwrap();
6606
6607 loop {
6608 let token = match self
6609 .hub
6610 .auth
6611 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6612 .await
6613 {
6614 Ok(token) => token,
6615 Err(e) => match dlg.token(e) {
6616 Ok(token) => token,
6617 Err(e) => {
6618 dlg.finished(false);
6619 return Err(common::Error::MissingToken(e));
6620 }
6621 },
6622 };
6623 request_value_reader
6624 .seek(std::io::SeekFrom::Start(0))
6625 .unwrap();
6626 let mut req_result = {
6627 let client = &self.hub.client;
6628 dlg.pre_request();
6629 let mut req_builder = hyper::Request::builder()
6630 .method(hyper::Method::PATCH)
6631 .uri(url.as_str())
6632 .header(USER_AGENT, self.hub._user_agent.clone());
6633
6634 if let Some(token) = token.as_ref() {
6635 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6636 }
6637
6638 let request = req_builder
6639 .header(CONTENT_TYPE, json_mime_type.to_string())
6640 .header(CONTENT_LENGTH, request_size as u64)
6641 .body(common::to_body(
6642 request_value_reader.get_ref().clone().into(),
6643 ));
6644
6645 client.request(request.unwrap()).await
6646 };
6647
6648 match req_result {
6649 Err(err) => {
6650 if let common::Retry::After(d) = dlg.http_error(&err) {
6651 sleep(d).await;
6652 continue;
6653 }
6654 dlg.finished(false);
6655 return Err(common::Error::HttpError(err));
6656 }
6657 Ok(res) => {
6658 let (mut parts, body) = res.into_parts();
6659 let mut body = common::Body::new(body);
6660 if !parts.status.is_success() {
6661 let bytes = common::to_bytes(body).await.unwrap_or_default();
6662 let error = serde_json::from_str(&common::to_string(&bytes));
6663 let response = common::to_response(parts, bytes.into());
6664
6665 if let common::Retry::After(d) =
6666 dlg.http_failure(&response, error.as_ref().ok())
6667 {
6668 sleep(d).await;
6669 continue;
6670 }
6671
6672 dlg.finished(false);
6673
6674 return Err(match error {
6675 Ok(value) => common::Error::BadRequest(value),
6676 _ => common::Error::Failure(response),
6677 });
6678 }
6679 let response = {
6680 let bytes = common::to_bytes(body).await.unwrap_or_default();
6681 let encoded = common::to_string(&bytes);
6682 match serde_json::from_str(&encoded) {
6683 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6684 Err(error) => {
6685 dlg.response_json_decode_error(&encoded, &error);
6686 return Err(common::Error::JsonDecodeError(
6687 encoded.to_string(),
6688 error,
6689 ));
6690 }
6691 }
6692 };
6693
6694 dlg.finished(true);
6695 return Ok(response);
6696 }
6697 }
6698 }
6699 }
6700
6701 ///
6702 /// Sets the *request* property to the given value.
6703 ///
6704 /// Even though the property as already been set when instantiating this call,
6705 /// we provide this method for API completeness.
6706 pub fn request(mut self, new_value: AlertPolicy) -> ProjectAlertPolicyPatchCall<'a, C> {
6707 self._request = new_value;
6708 self
6709 }
6710 /// Required if the policy exists. The resource name for this policy. The format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] [ALERT_POLICY_ID] is assigned by Cloud Monitoring when the policy is created. When calling the alertPolicies.create method, do not include the name field in the alerting policy passed as part of the request.
6711 ///
6712 /// Sets the *name* path property to the given value.
6713 ///
6714 /// Even though the property as already been set when instantiating this call,
6715 /// we provide this method for API completeness.
6716 pub fn name(mut self, new_value: &str) -> ProjectAlertPolicyPatchCall<'a, C> {
6717 self._name = new_value.to_string();
6718 self
6719 }
6720 /// Optional. A list of alerting policy field names. If this field is not empty, each listed field in the existing alerting policy is set to the value of the corresponding field in the supplied policy (alert_policy), or to the field's default value if the field is not in the supplied alerting policy. Fields not listed retain their previous value.Examples of valid field masks include display_name, documentation, documentation.content, documentation.mime_type, user_labels, user_label.nameofkey, enabled, conditions, combiner, etc.If this field is empty, then the supplied alerting policy replaces the existing policy. It is the same as deleting the existing policy and adding the supplied policy, except for the following: The new policy will have the same [ALERT_POLICY_ID] as the former policy. This gives you continuity with the former policy in your notifications and incidents. Conditions in the new policy will keep their former [CONDITION_ID] if the supplied condition includes the name field with that [CONDITION_ID]. If the supplied condition omits the name field, then a new [CONDITION_ID] is created.
6721 ///
6722 /// Sets the *update mask* query property to the given value.
6723 pub fn update_mask(
6724 mut self,
6725 new_value: common::FieldMask,
6726 ) -> ProjectAlertPolicyPatchCall<'a, C> {
6727 self._update_mask = Some(new_value);
6728 self
6729 }
6730 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6731 /// while executing the actual API request.
6732 ///
6733 /// ````text
6734 /// It should be used to handle progress information, and to implement a certain level of resilience.
6735 /// ````
6736 ///
6737 /// Sets the *delegate* property to the given value.
6738 pub fn delegate(
6739 mut self,
6740 new_value: &'a mut dyn common::Delegate,
6741 ) -> ProjectAlertPolicyPatchCall<'a, C> {
6742 self._delegate = Some(new_value);
6743 self
6744 }
6745
6746 /// Set any additional parameter of the query string used in the request.
6747 /// It should be used to set parameters which are not yet available through their own
6748 /// setters.
6749 ///
6750 /// Please note that this method must not be used to set any of the known parameters
6751 /// which have their own setter method. If done anyway, the request will fail.
6752 ///
6753 /// # Additional Parameters
6754 ///
6755 /// * *$.xgafv* (query-string) - V1 error format.
6756 /// * *access_token* (query-string) - OAuth access token.
6757 /// * *alt* (query-string) - Data format for response.
6758 /// * *callback* (query-string) - JSONP
6759 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6760 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6761 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6762 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6763 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6764 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6765 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6766 pub fn param<T>(mut self, name: T, value: T) -> ProjectAlertPolicyPatchCall<'a, C>
6767 where
6768 T: AsRef<str>,
6769 {
6770 self._additional_params
6771 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6772 self
6773 }
6774
6775 /// Identifies the authorization scope for the method you are building.
6776 ///
6777 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6778 /// [`Scope::CloudPlatform`].
6779 ///
6780 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6781 /// tokens for more than one scope.
6782 ///
6783 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6784 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6785 /// sufficient, a read-write scope will do as well.
6786 pub fn add_scope<St>(mut self, scope: St) -> ProjectAlertPolicyPatchCall<'a, C>
6787 where
6788 St: AsRef<str>,
6789 {
6790 self._scopes.insert(String::from(scope.as_ref()));
6791 self
6792 }
6793 /// Identifies the authorization scope(s) for the method you are building.
6794 ///
6795 /// See [`Self::add_scope()`] for details.
6796 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAlertPolicyPatchCall<'a, C>
6797 where
6798 I: IntoIterator<Item = St>,
6799 St: AsRef<str>,
6800 {
6801 self._scopes
6802 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6803 self
6804 }
6805
6806 /// Removes all scopes, and no default scope will be used either.
6807 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6808 /// for details).
6809 pub fn clear_scopes(mut self) -> ProjectAlertPolicyPatchCall<'a, C> {
6810 self._scopes.clear();
6811 self
6812 }
6813}
6814
6815/// Cloud Monitoring Agent only: Creates a new time series.This method is only for use by the Cloud Monitoring Agent. Use projects.timeSeries.create instead.
6816///
6817/// A builder for the *collectdTimeSeries.create* method supported by a *project* resource.
6818/// It is not used directly, but through a [`ProjectMethods`] instance.
6819///
6820/// # Example
6821///
6822/// Instantiate a resource method builder
6823///
6824/// ```test_harness,no_run
6825/// # extern crate hyper;
6826/// # extern crate hyper_rustls;
6827/// # extern crate google_monitoring3 as monitoring3;
6828/// use monitoring3::api::CreateCollectdTimeSeriesRequest;
6829/// # async fn dox() {
6830/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6831///
6832/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6833/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6834/// # secret,
6835/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6836/// # ).build().await.unwrap();
6837///
6838/// # let client = hyper_util::client::legacy::Client::builder(
6839/// # hyper_util::rt::TokioExecutor::new()
6840/// # )
6841/// # .build(
6842/// # hyper_rustls::HttpsConnectorBuilder::new()
6843/// # .with_native_roots()
6844/// # .unwrap()
6845/// # .https_or_http()
6846/// # .enable_http1()
6847/// # .build()
6848/// # );
6849/// # let mut hub = Monitoring::new(client, auth);
6850/// // As the method needs a request, you would usually fill it with the desired information
6851/// // into the respective structure. Some of the parts shown here might not be applicable !
6852/// // Values shown here are possibly random and not representative !
6853/// let mut req = CreateCollectdTimeSeriesRequest::default();
6854///
6855/// // You can configure optional parameters by calling the respective setters at will, and
6856/// // execute the final call using `doit()`.
6857/// // Values shown here are possibly random and not representative !
6858/// let result = hub.projects().collectd_time_series_create(req, "name")
6859/// .doit().await;
6860/// # }
6861/// ```
6862pub struct ProjectCollectdTimeSeryCreateCall<'a, C>
6863where
6864 C: 'a,
6865{
6866 hub: &'a Monitoring<C>,
6867 _request: CreateCollectdTimeSeriesRequest,
6868 _name: String,
6869 _delegate: Option<&'a mut dyn common::Delegate>,
6870 _additional_params: HashMap<String, String>,
6871 _scopes: BTreeSet<String>,
6872}
6873
6874impl<'a, C> common::CallBuilder for ProjectCollectdTimeSeryCreateCall<'a, C> {}
6875
6876impl<'a, C> ProjectCollectdTimeSeryCreateCall<'a, C>
6877where
6878 C: common::Connector,
6879{
6880 /// Perform the operation you have build so far.
6881 pub async fn doit(
6882 mut self,
6883 ) -> common::Result<(common::Response, CreateCollectdTimeSeriesResponse)> {
6884 use std::borrow::Cow;
6885 use std::io::{Read, Seek};
6886
6887 use common::{url::Params, ToParts};
6888 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6889
6890 let mut dd = common::DefaultDelegate;
6891 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6892 dlg.begin(common::MethodInfo {
6893 id: "monitoring.projects.collectdTimeSeries.create",
6894 http_method: hyper::Method::POST,
6895 });
6896
6897 for &field in ["alt", "name"].iter() {
6898 if self._additional_params.contains_key(field) {
6899 dlg.finished(false);
6900 return Err(common::Error::FieldClash(field));
6901 }
6902 }
6903
6904 let mut params = Params::with_capacity(4 + self._additional_params.len());
6905 params.push("name", self._name);
6906
6907 params.extend(self._additional_params.iter());
6908
6909 params.push("alt", "json");
6910 let mut url = self.hub._base_url.clone() + "v3/{+name}/collectdTimeSeries";
6911 if self._scopes.is_empty() {
6912 self._scopes
6913 .insert(Scope::CloudPlatform.as_ref().to_string());
6914 }
6915
6916 #[allow(clippy::single_element_loop)]
6917 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6918 url = params.uri_replacement(url, param_name, find_this, true);
6919 }
6920 {
6921 let to_remove = ["name"];
6922 params.remove_params(&to_remove);
6923 }
6924
6925 let url = params.parse_with_url(&url);
6926
6927 let mut json_mime_type = mime::APPLICATION_JSON;
6928 let mut request_value_reader = {
6929 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6930 common::remove_json_null_values(&mut value);
6931 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6932 serde_json::to_writer(&mut dst, &value).unwrap();
6933 dst
6934 };
6935 let request_size = request_value_reader
6936 .seek(std::io::SeekFrom::End(0))
6937 .unwrap();
6938 request_value_reader
6939 .seek(std::io::SeekFrom::Start(0))
6940 .unwrap();
6941
6942 loop {
6943 let token = match self
6944 .hub
6945 .auth
6946 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6947 .await
6948 {
6949 Ok(token) => token,
6950 Err(e) => match dlg.token(e) {
6951 Ok(token) => token,
6952 Err(e) => {
6953 dlg.finished(false);
6954 return Err(common::Error::MissingToken(e));
6955 }
6956 },
6957 };
6958 request_value_reader
6959 .seek(std::io::SeekFrom::Start(0))
6960 .unwrap();
6961 let mut req_result = {
6962 let client = &self.hub.client;
6963 dlg.pre_request();
6964 let mut req_builder = hyper::Request::builder()
6965 .method(hyper::Method::POST)
6966 .uri(url.as_str())
6967 .header(USER_AGENT, self.hub._user_agent.clone());
6968
6969 if let Some(token) = token.as_ref() {
6970 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6971 }
6972
6973 let request = req_builder
6974 .header(CONTENT_TYPE, json_mime_type.to_string())
6975 .header(CONTENT_LENGTH, request_size as u64)
6976 .body(common::to_body(
6977 request_value_reader.get_ref().clone().into(),
6978 ));
6979
6980 client.request(request.unwrap()).await
6981 };
6982
6983 match req_result {
6984 Err(err) => {
6985 if let common::Retry::After(d) = dlg.http_error(&err) {
6986 sleep(d).await;
6987 continue;
6988 }
6989 dlg.finished(false);
6990 return Err(common::Error::HttpError(err));
6991 }
6992 Ok(res) => {
6993 let (mut parts, body) = res.into_parts();
6994 let mut body = common::Body::new(body);
6995 if !parts.status.is_success() {
6996 let bytes = common::to_bytes(body).await.unwrap_or_default();
6997 let error = serde_json::from_str(&common::to_string(&bytes));
6998 let response = common::to_response(parts, bytes.into());
6999
7000 if let common::Retry::After(d) =
7001 dlg.http_failure(&response, error.as_ref().ok())
7002 {
7003 sleep(d).await;
7004 continue;
7005 }
7006
7007 dlg.finished(false);
7008
7009 return Err(match error {
7010 Ok(value) => common::Error::BadRequest(value),
7011 _ => common::Error::Failure(response),
7012 });
7013 }
7014 let response = {
7015 let bytes = common::to_bytes(body).await.unwrap_or_default();
7016 let encoded = common::to_string(&bytes);
7017 match serde_json::from_str(&encoded) {
7018 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7019 Err(error) => {
7020 dlg.response_json_decode_error(&encoded, &error);
7021 return Err(common::Error::JsonDecodeError(
7022 encoded.to_string(),
7023 error,
7024 ));
7025 }
7026 }
7027 };
7028
7029 dlg.finished(true);
7030 return Ok(response);
7031 }
7032 }
7033 }
7034 }
7035
7036 ///
7037 /// Sets the *request* property to the given value.
7038 ///
7039 /// Even though the property as already been set when instantiating this call,
7040 /// we provide this method for API completeness.
7041 pub fn request(
7042 mut self,
7043 new_value: CreateCollectdTimeSeriesRequest,
7044 ) -> ProjectCollectdTimeSeryCreateCall<'a, C> {
7045 self._request = new_value;
7046 self
7047 }
7048 /// The project (https://cloud.google.com/monitoring/api/v3#project_name) in which to create the time series. The format is: projects/[PROJECT_ID_OR_NUMBER]
7049 ///
7050 /// Sets the *name* path property to the given value.
7051 ///
7052 /// Even though the property as already been set when instantiating this call,
7053 /// we provide this method for API completeness.
7054 pub fn name(mut self, new_value: &str) -> ProjectCollectdTimeSeryCreateCall<'a, C> {
7055 self._name = new_value.to_string();
7056 self
7057 }
7058 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7059 /// while executing the actual API request.
7060 ///
7061 /// ````text
7062 /// It should be used to handle progress information, and to implement a certain level of resilience.
7063 /// ````
7064 ///
7065 /// Sets the *delegate* property to the given value.
7066 pub fn delegate(
7067 mut self,
7068 new_value: &'a mut dyn common::Delegate,
7069 ) -> ProjectCollectdTimeSeryCreateCall<'a, C> {
7070 self._delegate = Some(new_value);
7071 self
7072 }
7073
7074 /// Set any additional parameter of the query string used in the request.
7075 /// It should be used to set parameters which are not yet available through their own
7076 /// setters.
7077 ///
7078 /// Please note that this method must not be used to set any of the known parameters
7079 /// which have their own setter method. If done anyway, the request will fail.
7080 ///
7081 /// # Additional Parameters
7082 ///
7083 /// * *$.xgafv* (query-string) - V1 error format.
7084 /// * *access_token* (query-string) - OAuth access token.
7085 /// * *alt* (query-string) - Data format for response.
7086 /// * *callback* (query-string) - JSONP
7087 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7088 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7089 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7090 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7091 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7092 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7093 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7094 pub fn param<T>(mut self, name: T, value: T) -> ProjectCollectdTimeSeryCreateCall<'a, C>
7095 where
7096 T: AsRef<str>,
7097 {
7098 self._additional_params
7099 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7100 self
7101 }
7102
7103 /// Identifies the authorization scope for the method you are building.
7104 ///
7105 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7106 /// [`Scope::CloudPlatform`].
7107 ///
7108 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7109 /// tokens for more than one scope.
7110 ///
7111 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7112 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7113 /// sufficient, a read-write scope will do as well.
7114 pub fn add_scope<St>(mut self, scope: St) -> ProjectCollectdTimeSeryCreateCall<'a, C>
7115 where
7116 St: AsRef<str>,
7117 {
7118 self._scopes.insert(String::from(scope.as_ref()));
7119 self
7120 }
7121 /// Identifies the authorization scope(s) for the method you are building.
7122 ///
7123 /// See [`Self::add_scope()`] for details.
7124 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectCollectdTimeSeryCreateCall<'a, C>
7125 where
7126 I: IntoIterator<Item = St>,
7127 St: AsRef<str>,
7128 {
7129 self._scopes
7130 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7131 self
7132 }
7133
7134 /// Removes all scopes, and no default scope will be used either.
7135 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7136 /// for details).
7137 pub fn clear_scopes(mut self) -> ProjectCollectdTimeSeryCreateCall<'a, C> {
7138 self._scopes.clear();
7139 self
7140 }
7141}
7142
7143/// Lists the monitored resources that are members of a group.
7144///
7145/// A builder for the *groups.members.list* method supported by a *project* resource.
7146/// It is not used directly, but through a [`ProjectMethods`] instance.
7147///
7148/// # Example
7149///
7150/// Instantiate a resource method builder
7151///
7152/// ```test_harness,no_run
7153/// # extern crate hyper;
7154/// # extern crate hyper_rustls;
7155/// # extern crate google_monitoring3 as monitoring3;
7156/// # async fn dox() {
7157/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7158///
7159/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7160/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7161/// # secret,
7162/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7163/// # ).build().await.unwrap();
7164///
7165/// # let client = hyper_util::client::legacy::Client::builder(
7166/// # hyper_util::rt::TokioExecutor::new()
7167/// # )
7168/// # .build(
7169/// # hyper_rustls::HttpsConnectorBuilder::new()
7170/// # .with_native_roots()
7171/// # .unwrap()
7172/// # .https_or_http()
7173/// # .enable_http1()
7174/// # .build()
7175/// # );
7176/// # let mut hub = Monitoring::new(client, auth);
7177/// // You can configure optional parameters by calling the respective setters at will, and
7178/// // execute the final call using `doit()`.
7179/// // Values shown here are possibly random and not representative !
7180/// let result = hub.projects().groups_members_list("name")
7181/// .page_token("diam")
7182/// .page_size(-49)
7183/// .interval_start_time(chrono::Utc::now())
7184/// .interval_end_time(chrono::Utc::now())
7185/// .filter("et")
7186/// .doit().await;
7187/// # }
7188/// ```
7189pub struct ProjectGroupMemberListCall<'a, C>
7190where
7191 C: 'a,
7192{
7193 hub: &'a Monitoring<C>,
7194 _name: String,
7195 _page_token: Option<String>,
7196 _page_size: Option<i32>,
7197 _interval_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
7198 _interval_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
7199 _filter: Option<String>,
7200 _delegate: Option<&'a mut dyn common::Delegate>,
7201 _additional_params: HashMap<String, String>,
7202 _scopes: BTreeSet<String>,
7203}
7204
7205impl<'a, C> common::CallBuilder for ProjectGroupMemberListCall<'a, C> {}
7206
7207impl<'a, C> ProjectGroupMemberListCall<'a, C>
7208where
7209 C: common::Connector,
7210{
7211 /// Perform the operation you have build so far.
7212 pub async fn doit(mut self) -> common::Result<(common::Response, ListGroupMembersResponse)> {
7213 use std::borrow::Cow;
7214 use std::io::{Read, Seek};
7215
7216 use common::{url::Params, ToParts};
7217 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7218
7219 let mut dd = common::DefaultDelegate;
7220 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7221 dlg.begin(common::MethodInfo {
7222 id: "monitoring.projects.groups.members.list",
7223 http_method: hyper::Method::GET,
7224 });
7225
7226 for &field in [
7227 "alt",
7228 "name",
7229 "pageToken",
7230 "pageSize",
7231 "interval.startTime",
7232 "interval.endTime",
7233 "filter",
7234 ]
7235 .iter()
7236 {
7237 if self._additional_params.contains_key(field) {
7238 dlg.finished(false);
7239 return Err(common::Error::FieldClash(field));
7240 }
7241 }
7242
7243 let mut params = Params::with_capacity(8 + self._additional_params.len());
7244 params.push("name", self._name);
7245 if let Some(value) = self._page_token.as_ref() {
7246 params.push("pageToken", value);
7247 }
7248 if let Some(value) = self._page_size.as_ref() {
7249 params.push("pageSize", value.to_string());
7250 }
7251 if let Some(value) = self._interval_start_time.as_ref() {
7252 params.push(
7253 "interval.startTime",
7254 common::serde::datetime_to_string(&value),
7255 );
7256 }
7257 if let Some(value) = self._interval_end_time.as_ref() {
7258 params.push(
7259 "interval.endTime",
7260 common::serde::datetime_to_string(&value),
7261 );
7262 }
7263 if let Some(value) = self._filter.as_ref() {
7264 params.push("filter", value);
7265 }
7266
7267 params.extend(self._additional_params.iter());
7268
7269 params.push("alt", "json");
7270 let mut url = self.hub._base_url.clone() + "v3/{+name}/members";
7271 if self._scopes.is_empty() {
7272 self._scopes
7273 .insert(Scope::CloudPlatform.as_ref().to_string());
7274 }
7275
7276 #[allow(clippy::single_element_loop)]
7277 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7278 url = params.uri_replacement(url, param_name, find_this, true);
7279 }
7280 {
7281 let to_remove = ["name"];
7282 params.remove_params(&to_remove);
7283 }
7284
7285 let url = params.parse_with_url(&url);
7286
7287 loop {
7288 let token = match self
7289 .hub
7290 .auth
7291 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7292 .await
7293 {
7294 Ok(token) => token,
7295 Err(e) => match dlg.token(e) {
7296 Ok(token) => token,
7297 Err(e) => {
7298 dlg.finished(false);
7299 return Err(common::Error::MissingToken(e));
7300 }
7301 },
7302 };
7303 let mut req_result = {
7304 let client = &self.hub.client;
7305 dlg.pre_request();
7306 let mut req_builder = hyper::Request::builder()
7307 .method(hyper::Method::GET)
7308 .uri(url.as_str())
7309 .header(USER_AGENT, self.hub._user_agent.clone());
7310
7311 if let Some(token) = token.as_ref() {
7312 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7313 }
7314
7315 let request = req_builder
7316 .header(CONTENT_LENGTH, 0_u64)
7317 .body(common::to_body::<String>(None));
7318
7319 client.request(request.unwrap()).await
7320 };
7321
7322 match req_result {
7323 Err(err) => {
7324 if let common::Retry::After(d) = dlg.http_error(&err) {
7325 sleep(d).await;
7326 continue;
7327 }
7328 dlg.finished(false);
7329 return Err(common::Error::HttpError(err));
7330 }
7331 Ok(res) => {
7332 let (mut parts, body) = res.into_parts();
7333 let mut body = common::Body::new(body);
7334 if !parts.status.is_success() {
7335 let bytes = common::to_bytes(body).await.unwrap_or_default();
7336 let error = serde_json::from_str(&common::to_string(&bytes));
7337 let response = common::to_response(parts, bytes.into());
7338
7339 if let common::Retry::After(d) =
7340 dlg.http_failure(&response, error.as_ref().ok())
7341 {
7342 sleep(d).await;
7343 continue;
7344 }
7345
7346 dlg.finished(false);
7347
7348 return Err(match error {
7349 Ok(value) => common::Error::BadRequest(value),
7350 _ => common::Error::Failure(response),
7351 });
7352 }
7353 let response = {
7354 let bytes = common::to_bytes(body).await.unwrap_or_default();
7355 let encoded = common::to_string(&bytes);
7356 match serde_json::from_str(&encoded) {
7357 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7358 Err(error) => {
7359 dlg.response_json_decode_error(&encoded, &error);
7360 return Err(common::Error::JsonDecodeError(
7361 encoded.to_string(),
7362 error,
7363 ));
7364 }
7365 }
7366 };
7367
7368 dlg.finished(true);
7369 return Ok(response);
7370 }
7371 }
7372 }
7373 }
7374
7375 /// Required. The group whose members are listed. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
7376 ///
7377 /// Sets the *name* path property to the given value.
7378 ///
7379 /// Even though the property as already been set when instantiating this call,
7380 /// we provide this method for API completeness.
7381 pub fn name(mut self, new_value: &str) -> ProjectGroupMemberListCall<'a, C> {
7382 self._name = new_value.to_string();
7383 self
7384 }
7385 /// If this field is not empty then it must contain the next_page_token value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
7386 ///
7387 /// Sets the *page token* query property to the given value.
7388 pub fn page_token(mut self, new_value: &str) -> ProjectGroupMemberListCall<'a, C> {
7389 self._page_token = Some(new_value.to_string());
7390 self
7391 }
7392 /// A positive number that is the maximum number of results to return.
7393 ///
7394 /// Sets the *page size* query property to the given value.
7395 pub fn page_size(mut self, new_value: i32) -> ProjectGroupMemberListCall<'a, C> {
7396 self._page_size = Some(new_value);
7397 self
7398 }
7399 /// Optional. The beginning of the time interval. The default value for the start time is the end time. The start time must not be later than the end time.
7400 ///
7401 /// Sets the *interval.start time* query property to the given value.
7402 pub fn interval_start_time(
7403 mut self,
7404 new_value: chrono::DateTime<chrono::offset::Utc>,
7405 ) -> ProjectGroupMemberListCall<'a, C> {
7406 self._interval_start_time = Some(new_value);
7407 self
7408 }
7409 /// Required. The end of the time interval.
7410 ///
7411 /// Sets the *interval.end time* query property to the given value.
7412 pub fn interval_end_time(
7413 mut self,
7414 new_value: chrono::DateTime<chrono::offset::Utc>,
7415 ) -> ProjectGroupMemberListCall<'a, C> {
7416 self._interval_end_time = Some(new_value);
7417 self
7418 }
7419 /// An optional list filter (https://cloud.google.com/monitoring/api/learn_more#filtering) describing the members to be returned. The filter may reference the type, labels, and metadata of monitored resources that comprise the group. For example, to return only resources representing Compute Engine VM instances, use this filter: `resource.type = "gce_instance"`
7420 ///
7421 /// Sets the *filter* query property to the given value.
7422 pub fn filter(mut self, new_value: &str) -> ProjectGroupMemberListCall<'a, C> {
7423 self._filter = Some(new_value.to_string());
7424 self
7425 }
7426 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7427 /// while executing the actual API request.
7428 ///
7429 /// ````text
7430 /// It should be used to handle progress information, and to implement a certain level of resilience.
7431 /// ````
7432 ///
7433 /// Sets the *delegate* property to the given value.
7434 pub fn delegate(
7435 mut self,
7436 new_value: &'a mut dyn common::Delegate,
7437 ) -> ProjectGroupMemberListCall<'a, C> {
7438 self._delegate = Some(new_value);
7439 self
7440 }
7441
7442 /// Set any additional parameter of the query string used in the request.
7443 /// It should be used to set parameters which are not yet available through their own
7444 /// setters.
7445 ///
7446 /// Please note that this method must not be used to set any of the known parameters
7447 /// which have their own setter method. If done anyway, the request will fail.
7448 ///
7449 /// # Additional Parameters
7450 ///
7451 /// * *$.xgafv* (query-string) - V1 error format.
7452 /// * *access_token* (query-string) - OAuth access token.
7453 /// * *alt* (query-string) - Data format for response.
7454 /// * *callback* (query-string) - JSONP
7455 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7456 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7457 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7458 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7459 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7460 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7461 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7462 pub fn param<T>(mut self, name: T, value: T) -> ProjectGroupMemberListCall<'a, C>
7463 where
7464 T: AsRef<str>,
7465 {
7466 self._additional_params
7467 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7468 self
7469 }
7470
7471 /// Identifies the authorization scope for the method you are building.
7472 ///
7473 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7474 /// [`Scope::CloudPlatform`].
7475 ///
7476 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7477 /// tokens for more than one scope.
7478 ///
7479 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7480 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7481 /// sufficient, a read-write scope will do as well.
7482 pub fn add_scope<St>(mut self, scope: St) -> ProjectGroupMemberListCall<'a, C>
7483 where
7484 St: AsRef<str>,
7485 {
7486 self._scopes.insert(String::from(scope.as_ref()));
7487 self
7488 }
7489 /// Identifies the authorization scope(s) for the method you are building.
7490 ///
7491 /// See [`Self::add_scope()`] for details.
7492 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGroupMemberListCall<'a, C>
7493 where
7494 I: IntoIterator<Item = St>,
7495 St: AsRef<str>,
7496 {
7497 self._scopes
7498 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7499 self
7500 }
7501
7502 /// Removes all scopes, and no default scope will be used either.
7503 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7504 /// for details).
7505 pub fn clear_scopes(mut self) -> ProjectGroupMemberListCall<'a, C> {
7506 self._scopes.clear();
7507 self
7508 }
7509}
7510
7511/// Creates a new group.
7512///
7513/// A builder for the *groups.create* method supported by a *project* resource.
7514/// It is not used directly, but through a [`ProjectMethods`] instance.
7515///
7516/// # Example
7517///
7518/// Instantiate a resource method builder
7519///
7520/// ```test_harness,no_run
7521/// # extern crate hyper;
7522/// # extern crate hyper_rustls;
7523/// # extern crate google_monitoring3 as monitoring3;
7524/// use monitoring3::api::Group;
7525/// # async fn dox() {
7526/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7527///
7528/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7529/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7530/// # secret,
7531/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7532/// # ).build().await.unwrap();
7533///
7534/// # let client = hyper_util::client::legacy::Client::builder(
7535/// # hyper_util::rt::TokioExecutor::new()
7536/// # )
7537/// # .build(
7538/// # hyper_rustls::HttpsConnectorBuilder::new()
7539/// # .with_native_roots()
7540/// # .unwrap()
7541/// # .https_or_http()
7542/// # .enable_http1()
7543/// # .build()
7544/// # );
7545/// # let mut hub = Monitoring::new(client, auth);
7546/// // As the method needs a request, you would usually fill it with the desired information
7547/// // into the respective structure. Some of the parts shown here might not be applicable !
7548/// // Values shown here are possibly random and not representative !
7549/// let mut req = Group::default();
7550///
7551/// // You can configure optional parameters by calling the respective setters at will, and
7552/// // execute the final call using `doit()`.
7553/// // Values shown here are possibly random and not representative !
7554/// let result = hub.projects().groups_create(req, "name")
7555/// .validate_only(false)
7556/// .doit().await;
7557/// # }
7558/// ```
7559pub struct ProjectGroupCreateCall<'a, C>
7560where
7561 C: 'a,
7562{
7563 hub: &'a Monitoring<C>,
7564 _request: Group,
7565 _name: String,
7566 _validate_only: Option<bool>,
7567 _delegate: Option<&'a mut dyn common::Delegate>,
7568 _additional_params: HashMap<String, String>,
7569 _scopes: BTreeSet<String>,
7570}
7571
7572impl<'a, C> common::CallBuilder for ProjectGroupCreateCall<'a, C> {}
7573
7574impl<'a, C> ProjectGroupCreateCall<'a, C>
7575where
7576 C: common::Connector,
7577{
7578 /// Perform the operation you have build so far.
7579 pub async fn doit(mut self) -> common::Result<(common::Response, Group)> {
7580 use std::borrow::Cow;
7581 use std::io::{Read, Seek};
7582
7583 use common::{url::Params, ToParts};
7584 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7585
7586 let mut dd = common::DefaultDelegate;
7587 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7588 dlg.begin(common::MethodInfo {
7589 id: "monitoring.projects.groups.create",
7590 http_method: hyper::Method::POST,
7591 });
7592
7593 for &field in ["alt", "name", "validateOnly"].iter() {
7594 if self._additional_params.contains_key(field) {
7595 dlg.finished(false);
7596 return Err(common::Error::FieldClash(field));
7597 }
7598 }
7599
7600 let mut params = Params::with_capacity(5 + self._additional_params.len());
7601 params.push("name", self._name);
7602 if let Some(value) = self._validate_only.as_ref() {
7603 params.push("validateOnly", value.to_string());
7604 }
7605
7606 params.extend(self._additional_params.iter());
7607
7608 params.push("alt", "json");
7609 let mut url = self.hub._base_url.clone() + "v3/{+name}/groups";
7610 if self._scopes.is_empty() {
7611 self._scopes
7612 .insert(Scope::CloudPlatform.as_ref().to_string());
7613 }
7614
7615 #[allow(clippy::single_element_loop)]
7616 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7617 url = params.uri_replacement(url, param_name, find_this, true);
7618 }
7619 {
7620 let to_remove = ["name"];
7621 params.remove_params(&to_remove);
7622 }
7623
7624 let url = params.parse_with_url(&url);
7625
7626 let mut json_mime_type = mime::APPLICATION_JSON;
7627 let mut request_value_reader = {
7628 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7629 common::remove_json_null_values(&mut value);
7630 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7631 serde_json::to_writer(&mut dst, &value).unwrap();
7632 dst
7633 };
7634 let request_size = request_value_reader
7635 .seek(std::io::SeekFrom::End(0))
7636 .unwrap();
7637 request_value_reader
7638 .seek(std::io::SeekFrom::Start(0))
7639 .unwrap();
7640
7641 loop {
7642 let token = match self
7643 .hub
7644 .auth
7645 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7646 .await
7647 {
7648 Ok(token) => token,
7649 Err(e) => match dlg.token(e) {
7650 Ok(token) => token,
7651 Err(e) => {
7652 dlg.finished(false);
7653 return Err(common::Error::MissingToken(e));
7654 }
7655 },
7656 };
7657 request_value_reader
7658 .seek(std::io::SeekFrom::Start(0))
7659 .unwrap();
7660 let mut req_result = {
7661 let client = &self.hub.client;
7662 dlg.pre_request();
7663 let mut req_builder = hyper::Request::builder()
7664 .method(hyper::Method::POST)
7665 .uri(url.as_str())
7666 .header(USER_AGENT, self.hub._user_agent.clone());
7667
7668 if let Some(token) = token.as_ref() {
7669 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7670 }
7671
7672 let request = req_builder
7673 .header(CONTENT_TYPE, json_mime_type.to_string())
7674 .header(CONTENT_LENGTH, request_size as u64)
7675 .body(common::to_body(
7676 request_value_reader.get_ref().clone().into(),
7677 ));
7678
7679 client.request(request.unwrap()).await
7680 };
7681
7682 match req_result {
7683 Err(err) => {
7684 if let common::Retry::After(d) = dlg.http_error(&err) {
7685 sleep(d).await;
7686 continue;
7687 }
7688 dlg.finished(false);
7689 return Err(common::Error::HttpError(err));
7690 }
7691 Ok(res) => {
7692 let (mut parts, body) = res.into_parts();
7693 let mut body = common::Body::new(body);
7694 if !parts.status.is_success() {
7695 let bytes = common::to_bytes(body).await.unwrap_or_default();
7696 let error = serde_json::from_str(&common::to_string(&bytes));
7697 let response = common::to_response(parts, bytes.into());
7698
7699 if let common::Retry::After(d) =
7700 dlg.http_failure(&response, error.as_ref().ok())
7701 {
7702 sleep(d).await;
7703 continue;
7704 }
7705
7706 dlg.finished(false);
7707
7708 return Err(match error {
7709 Ok(value) => common::Error::BadRequest(value),
7710 _ => common::Error::Failure(response),
7711 });
7712 }
7713 let response = {
7714 let bytes = common::to_bytes(body).await.unwrap_or_default();
7715 let encoded = common::to_string(&bytes);
7716 match serde_json::from_str(&encoded) {
7717 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7718 Err(error) => {
7719 dlg.response_json_decode_error(&encoded, &error);
7720 return Err(common::Error::JsonDecodeError(
7721 encoded.to_string(),
7722 error,
7723 ));
7724 }
7725 }
7726 };
7727
7728 dlg.finished(true);
7729 return Ok(response);
7730 }
7731 }
7732 }
7733 }
7734
7735 ///
7736 /// Sets the *request* property to the given value.
7737 ///
7738 /// Even though the property as already been set when instantiating this call,
7739 /// we provide this method for API completeness.
7740 pub fn request(mut self, new_value: Group) -> ProjectGroupCreateCall<'a, C> {
7741 self._request = new_value;
7742 self
7743 }
7744 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) in which to create the group. The format is: projects/[PROJECT_ID_OR_NUMBER]
7745 ///
7746 /// Sets the *name* path property to the given value.
7747 ///
7748 /// Even though the property as already been set when instantiating this call,
7749 /// we provide this method for API completeness.
7750 pub fn name(mut self, new_value: &str) -> ProjectGroupCreateCall<'a, C> {
7751 self._name = new_value.to_string();
7752 self
7753 }
7754 /// If true, validate this request but do not create the group.
7755 ///
7756 /// Sets the *validate only* query property to the given value.
7757 pub fn validate_only(mut self, new_value: bool) -> ProjectGroupCreateCall<'a, C> {
7758 self._validate_only = Some(new_value);
7759 self
7760 }
7761 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7762 /// while executing the actual API request.
7763 ///
7764 /// ````text
7765 /// It should be used to handle progress information, and to implement a certain level of resilience.
7766 /// ````
7767 ///
7768 /// Sets the *delegate* property to the given value.
7769 pub fn delegate(
7770 mut self,
7771 new_value: &'a mut dyn common::Delegate,
7772 ) -> ProjectGroupCreateCall<'a, C> {
7773 self._delegate = Some(new_value);
7774 self
7775 }
7776
7777 /// Set any additional parameter of the query string used in the request.
7778 /// It should be used to set parameters which are not yet available through their own
7779 /// setters.
7780 ///
7781 /// Please note that this method must not be used to set any of the known parameters
7782 /// which have their own setter method. If done anyway, the request will fail.
7783 ///
7784 /// # Additional Parameters
7785 ///
7786 /// * *$.xgafv* (query-string) - V1 error format.
7787 /// * *access_token* (query-string) - OAuth access token.
7788 /// * *alt* (query-string) - Data format for response.
7789 /// * *callback* (query-string) - JSONP
7790 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7791 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7792 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7793 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7794 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7795 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7796 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7797 pub fn param<T>(mut self, name: T, value: T) -> ProjectGroupCreateCall<'a, C>
7798 where
7799 T: AsRef<str>,
7800 {
7801 self._additional_params
7802 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7803 self
7804 }
7805
7806 /// Identifies the authorization scope for the method you are building.
7807 ///
7808 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7809 /// [`Scope::CloudPlatform`].
7810 ///
7811 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7812 /// tokens for more than one scope.
7813 ///
7814 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7815 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7816 /// sufficient, a read-write scope will do as well.
7817 pub fn add_scope<St>(mut self, scope: St) -> ProjectGroupCreateCall<'a, C>
7818 where
7819 St: AsRef<str>,
7820 {
7821 self._scopes.insert(String::from(scope.as_ref()));
7822 self
7823 }
7824 /// Identifies the authorization scope(s) for the method you are building.
7825 ///
7826 /// See [`Self::add_scope()`] for details.
7827 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGroupCreateCall<'a, C>
7828 where
7829 I: IntoIterator<Item = St>,
7830 St: AsRef<str>,
7831 {
7832 self._scopes
7833 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7834 self
7835 }
7836
7837 /// Removes all scopes, and no default scope will be used either.
7838 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7839 /// for details).
7840 pub fn clear_scopes(mut self) -> ProjectGroupCreateCall<'a, C> {
7841 self._scopes.clear();
7842 self
7843 }
7844}
7845
7846/// Deletes an existing group.
7847///
7848/// A builder for the *groups.delete* method supported by a *project* resource.
7849/// It is not used directly, but through a [`ProjectMethods`] instance.
7850///
7851/// # Example
7852///
7853/// Instantiate a resource method builder
7854///
7855/// ```test_harness,no_run
7856/// # extern crate hyper;
7857/// # extern crate hyper_rustls;
7858/// # extern crate google_monitoring3 as monitoring3;
7859/// # async fn dox() {
7860/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7861///
7862/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7863/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7864/// # secret,
7865/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7866/// # ).build().await.unwrap();
7867///
7868/// # let client = hyper_util::client::legacy::Client::builder(
7869/// # hyper_util::rt::TokioExecutor::new()
7870/// # )
7871/// # .build(
7872/// # hyper_rustls::HttpsConnectorBuilder::new()
7873/// # .with_native_roots()
7874/// # .unwrap()
7875/// # .https_or_http()
7876/// # .enable_http1()
7877/// # .build()
7878/// # );
7879/// # let mut hub = Monitoring::new(client, auth);
7880/// // You can configure optional parameters by calling the respective setters at will, and
7881/// // execute the final call using `doit()`.
7882/// // Values shown here are possibly random and not representative !
7883/// let result = hub.projects().groups_delete("name")
7884/// .recursive(false)
7885/// .doit().await;
7886/// # }
7887/// ```
7888pub struct ProjectGroupDeleteCall<'a, C>
7889where
7890 C: 'a,
7891{
7892 hub: &'a Monitoring<C>,
7893 _name: String,
7894 _recursive: Option<bool>,
7895 _delegate: Option<&'a mut dyn common::Delegate>,
7896 _additional_params: HashMap<String, String>,
7897 _scopes: BTreeSet<String>,
7898}
7899
7900impl<'a, C> common::CallBuilder for ProjectGroupDeleteCall<'a, C> {}
7901
7902impl<'a, C> ProjectGroupDeleteCall<'a, C>
7903where
7904 C: common::Connector,
7905{
7906 /// Perform the operation you have build so far.
7907 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7908 use std::borrow::Cow;
7909 use std::io::{Read, Seek};
7910
7911 use common::{url::Params, ToParts};
7912 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7913
7914 let mut dd = common::DefaultDelegate;
7915 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7916 dlg.begin(common::MethodInfo {
7917 id: "monitoring.projects.groups.delete",
7918 http_method: hyper::Method::DELETE,
7919 });
7920
7921 for &field in ["alt", "name", "recursive"].iter() {
7922 if self._additional_params.contains_key(field) {
7923 dlg.finished(false);
7924 return Err(common::Error::FieldClash(field));
7925 }
7926 }
7927
7928 let mut params = Params::with_capacity(4 + self._additional_params.len());
7929 params.push("name", self._name);
7930 if let Some(value) = self._recursive.as_ref() {
7931 params.push("recursive", value.to_string());
7932 }
7933
7934 params.extend(self._additional_params.iter());
7935
7936 params.push("alt", "json");
7937 let mut url = self.hub._base_url.clone() + "v3/{+name}";
7938 if self._scopes.is_empty() {
7939 self._scopes
7940 .insert(Scope::CloudPlatform.as_ref().to_string());
7941 }
7942
7943 #[allow(clippy::single_element_loop)]
7944 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7945 url = params.uri_replacement(url, param_name, find_this, true);
7946 }
7947 {
7948 let to_remove = ["name"];
7949 params.remove_params(&to_remove);
7950 }
7951
7952 let url = params.parse_with_url(&url);
7953
7954 loop {
7955 let token = match self
7956 .hub
7957 .auth
7958 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7959 .await
7960 {
7961 Ok(token) => token,
7962 Err(e) => match dlg.token(e) {
7963 Ok(token) => token,
7964 Err(e) => {
7965 dlg.finished(false);
7966 return Err(common::Error::MissingToken(e));
7967 }
7968 },
7969 };
7970 let mut req_result = {
7971 let client = &self.hub.client;
7972 dlg.pre_request();
7973 let mut req_builder = hyper::Request::builder()
7974 .method(hyper::Method::DELETE)
7975 .uri(url.as_str())
7976 .header(USER_AGENT, self.hub._user_agent.clone());
7977
7978 if let Some(token) = token.as_ref() {
7979 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7980 }
7981
7982 let request = req_builder
7983 .header(CONTENT_LENGTH, 0_u64)
7984 .body(common::to_body::<String>(None));
7985
7986 client.request(request.unwrap()).await
7987 };
7988
7989 match req_result {
7990 Err(err) => {
7991 if let common::Retry::After(d) = dlg.http_error(&err) {
7992 sleep(d).await;
7993 continue;
7994 }
7995 dlg.finished(false);
7996 return Err(common::Error::HttpError(err));
7997 }
7998 Ok(res) => {
7999 let (mut parts, body) = res.into_parts();
8000 let mut body = common::Body::new(body);
8001 if !parts.status.is_success() {
8002 let bytes = common::to_bytes(body).await.unwrap_or_default();
8003 let error = serde_json::from_str(&common::to_string(&bytes));
8004 let response = common::to_response(parts, bytes.into());
8005
8006 if let common::Retry::After(d) =
8007 dlg.http_failure(&response, error.as_ref().ok())
8008 {
8009 sleep(d).await;
8010 continue;
8011 }
8012
8013 dlg.finished(false);
8014
8015 return Err(match error {
8016 Ok(value) => common::Error::BadRequest(value),
8017 _ => common::Error::Failure(response),
8018 });
8019 }
8020 let response = {
8021 let bytes = common::to_bytes(body).await.unwrap_or_default();
8022 let encoded = common::to_string(&bytes);
8023 match serde_json::from_str(&encoded) {
8024 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8025 Err(error) => {
8026 dlg.response_json_decode_error(&encoded, &error);
8027 return Err(common::Error::JsonDecodeError(
8028 encoded.to_string(),
8029 error,
8030 ));
8031 }
8032 }
8033 };
8034
8035 dlg.finished(true);
8036 return Ok(response);
8037 }
8038 }
8039 }
8040 }
8041
8042 /// Required. The group to delete. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
8043 ///
8044 /// Sets the *name* path property to the given value.
8045 ///
8046 /// Even though the property as already been set when instantiating this call,
8047 /// we provide this method for API completeness.
8048 pub fn name(mut self, new_value: &str) -> ProjectGroupDeleteCall<'a, C> {
8049 self._name = new_value.to_string();
8050 self
8051 }
8052 /// If this field is true, then the request means to delete a group with all its descendants. Otherwise, the request means to delete a group only when it has no descendants. The default value is false.
8053 ///
8054 /// Sets the *recursive* query property to the given value.
8055 pub fn recursive(mut self, new_value: bool) -> ProjectGroupDeleteCall<'a, C> {
8056 self._recursive = Some(new_value);
8057 self
8058 }
8059 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8060 /// while executing the actual API request.
8061 ///
8062 /// ````text
8063 /// It should be used to handle progress information, and to implement a certain level of resilience.
8064 /// ````
8065 ///
8066 /// Sets the *delegate* property to the given value.
8067 pub fn delegate(
8068 mut self,
8069 new_value: &'a mut dyn common::Delegate,
8070 ) -> ProjectGroupDeleteCall<'a, C> {
8071 self._delegate = Some(new_value);
8072 self
8073 }
8074
8075 /// Set any additional parameter of the query string used in the request.
8076 /// It should be used to set parameters which are not yet available through their own
8077 /// setters.
8078 ///
8079 /// Please note that this method must not be used to set any of the known parameters
8080 /// which have their own setter method. If done anyway, the request will fail.
8081 ///
8082 /// # Additional Parameters
8083 ///
8084 /// * *$.xgafv* (query-string) - V1 error format.
8085 /// * *access_token* (query-string) - OAuth access token.
8086 /// * *alt* (query-string) - Data format for response.
8087 /// * *callback* (query-string) - JSONP
8088 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8089 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8090 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8091 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8092 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8093 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8094 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8095 pub fn param<T>(mut self, name: T, value: T) -> ProjectGroupDeleteCall<'a, C>
8096 where
8097 T: AsRef<str>,
8098 {
8099 self._additional_params
8100 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8101 self
8102 }
8103
8104 /// Identifies the authorization scope for the method you are building.
8105 ///
8106 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8107 /// [`Scope::CloudPlatform`].
8108 ///
8109 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8110 /// tokens for more than one scope.
8111 ///
8112 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8113 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8114 /// sufficient, a read-write scope will do as well.
8115 pub fn add_scope<St>(mut self, scope: St) -> ProjectGroupDeleteCall<'a, C>
8116 where
8117 St: AsRef<str>,
8118 {
8119 self._scopes.insert(String::from(scope.as_ref()));
8120 self
8121 }
8122 /// Identifies the authorization scope(s) for the method you are building.
8123 ///
8124 /// See [`Self::add_scope()`] for details.
8125 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGroupDeleteCall<'a, C>
8126 where
8127 I: IntoIterator<Item = St>,
8128 St: AsRef<str>,
8129 {
8130 self._scopes
8131 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8132 self
8133 }
8134
8135 /// Removes all scopes, and no default scope will be used either.
8136 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8137 /// for details).
8138 pub fn clear_scopes(mut self) -> ProjectGroupDeleteCall<'a, C> {
8139 self._scopes.clear();
8140 self
8141 }
8142}
8143
8144/// Gets a single group.
8145///
8146/// A builder for the *groups.get* method supported by a *project* resource.
8147/// It is not used directly, but through a [`ProjectMethods`] instance.
8148///
8149/// # Example
8150///
8151/// Instantiate a resource method builder
8152///
8153/// ```test_harness,no_run
8154/// # extern crate hyper;
8155/// # extern crate hyper_rustls;
8156/// # extern crate google_monitoring3 as monitoring3;
8157/// # async fn dox() {
8158/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8159///
8160/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8161/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8162/// # secret,
8163/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8164/// # ).build().await.unwrap();
8165///
8166/// # let client = hyper_util::client::legacy::Client::builder(
8167/// # hyper_util::rt::TokioExecutor::new()
8168/// # )
8169/// # .build(
8170/// # hyper_rustls::HttpsConnectorBuilder::new()
8171/// # .with_native_roots()
8172/// # .unwrap()
8173/// # .https_or_http()
8174/// # .enable_http1()
8175/// # .build()
8176/// # );
8177/// # let mut hub = Monitoring::new(client, auth);
8178/// // You can configure optional parameters by calling the respective setters at will, and
8179/// // execute the final call using `doit()`.
8180/// // Values shown here are possibly random and not representative !
8181/// let result = hub.projects().groups_get("name")
8182/// .doit().await;
8183/// # }
8184/// ```
8185pub struct ProjectGroupGetCall<'a, C>
8186where
8187 C: 'a,
8188{
8189 hub: &'a Monitoring<C>,
8190 _name: String,
8191 _delegate: Option<&'a mut dyn common::Delegate>,
8192 _additional_params: HashMap<String, String>,
8193 _scopes: BTreeSet<String>,
8194}
8195
8196impl<'a, C> common::CallBuilder for ProjectGroupGetCall<'a, C> {}
8197
8198impl<'a, C> ProjectGroupGetCall<'a, C>
8199where
8200 C: common::Connector,
8201{
8202 /// Perform the operation you have build so far.
8203 pub async fn doit(mut self) -> common::Result<(common::Response, Group)> {
8204 use std::borrow::Cow;
8205 use std::io::{Read, Seek};
8206
8207 use common::{url::Params, ToParts};
8208 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8209
8210 let mut dd = common::DefaultDelegate;
8211 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8212 dlg.begin(common::MethodInfo {
8213 id: "monitoring.projects.groups.get",
8214 http_method: hyper::Method::GET,
8215 });
8216
8217 for &field in ["alt", "name"].iter() {
8218 if self._additional_params.contains_key(field) {
8219 dlg.finished(false);
8220 return Err(common::Error::FieldClash(field));
8221 }
8222 }
8223
8224 let mut params = Params::with_capacity(3 + self._additional_params.len());
8225 params.push("name", self._name);
8226
8227 params.extend(self._additional_params.iter());
8228
8229 params.push("alt", "json");
8230 let mut url = self.hub._base_url.clone() + "v3/{+name}";
8231 if self._scopes.is_empty() {
8232 self._scopes
8233 .insert(Scope::CloudPlatform.as_ref().to_string());
8234 }
8235
8236 #[allow(clippy::single_element_loop)]
8237 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8238 url = params.uri_replacement(url, param_name, find_this, true);
8239 }
8240 {
8241 let to_remove = ["name"];
8242 params.remove_params(&to_remove);
8243 }
8244
8245 let url = params.parse_with_url(&url);
8246
8247 loop {
8248 let token = match self
8249 .hub
8250 .auth
8251 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8252 .await
8253 {
8254 Ok(token) => token,
8255 Err(e) => match dlg.token(e) {
8256 Ok(token) => token,
8257 Err(e) => {
8258 dlg.finished(false);
8259 return Err(common::Error::MissingToken(e));
8260 }
8261 },
8262 };
8263 let mut req_result = {
8264 let client = &self.hub.client;
8265 dlg.pre_request();
8266 let mut req_builder = hyper::Request::builder()
8267 .method(hyper::Method::GET)
8268 .uri(url.as_str())
8269 .header(USER_AGENT, self.hub._user_agent.clone());
8270
8271 if let Some(token) = token.as_ref() {
8272 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8273 }
8274
8275 let request = req_builder
8276 .header(CONTENT_LENGTH, 0_u64)
8277 .body(common::to_body::<String>(None));
8278
8279 client.request(request.unwrap()).await
8280 };
8281
8282 match req_result {
8283 Err(err) => {
8284 if let common::Retry::After(d) = dlg.http_error(&err) {
8285 sleep(d).await;
8286 continue;
8287 }
8288 dlg.finished(false);
8289 return Err(common::Error::HttpError(err));
8290 }
8291 Ok(res) => {
8292 let (mut parts, body) = res.into_parts();
8293 let mut body = common::Body::new(body);
8294 if !parts.status.is_success() {
8295 let bytes = common::to_bytes(body).await.unwrap_or_default();
8296 let error = serde_json::from_str(&common::to_string(&bytes));
8297 let response = common::to_response(parts, bytes.into());
8298
8299 if let common::Retry::After(d) =
8300 dlg.http_failure(&response, error.as_ref().ok())
8301 {
8302 sleep(d).await;
8303 continue;
8304 }
8305
8306 dlg.finished(false);
8307
8308 return Err(match error {
8309 Ok(value) => common::Error::BadRequest(value),
8310 _ => common::Error::Failure(response),
8311 });
8312 }
8313 let response = {
8314 let bytes = common::to_bytes(body).await.unwrap_or_default();
8315 let encoded = common::to_string(&bytes);
8316 match serde_json::from_str(&encoded) {
8317 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8318 Err(error) => {
8319 dlg.response_json_decode_error(&encoded, &error);
8320 return Err(common::Error::JsonDecodeError(
8321 encoded.to_string(),
8322 error,
8323 ));
8324 }
8325 }
8326 };
8327
8328 dlg.finished(true);
8329 return Ok(response);
8330 }
8331 }
8332 }
8333 }
8334
8335 /// Required. The group to retrieve. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID]
8336 ///
8337 /// Sets the *name* path property to the given value.
8338 ///
8339 /// Even though the property as already been set when instantiating this call,
8340 /// we provide this method for API completeness.
8341 pub fn name(mut self, new_value: &str) -> ProjectGroupGetCall<'a, C> {
8342 self._name = new_value.to_string();
8343 self
8344 }
8345 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8346 /// while executing the actual API request.
8347 ///
8348 /// ````text
8349 /// It should be used to handle progress information, and to implement a certain level of resilience.
8350 /// ````
8351 ///
8352 /// Sets the *delegate* property to the given value.
8353 pub fn delegate(
8354 mut self,
8355 new_value: &'a mut dyn common::Delegate,
8356 ) -> ProjectGroupGetCall<'a, C> {
8357 self._delegate = Some(new_value);
8358 self
8359 }
8360
8361 /// Set any additional parameter of the query string used in the request.
8362 /// It should be used to set parameters which are not yet available through their own
8363 /// setters.
8364 ///
8365 /// Please note that this method must not be used to set any of the known parameters
8366 /// which have their own setter method. If done anyway, the request will fail.
8367 ///
8368 /// # Additional Parameters
8369 ///
8370 /// * *$.xgafv* (query-string) - V1 error format.
8371 /// * *access_token* (query-string) - OAuth access token.
8372 /// * *alt* (query-string) - Data format for response.
8373 /// * *callback* (query-string) - JSONP
8374 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8375 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8376 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8377 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8378 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8379 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8380 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8381 pub fn param<T>(mut self, name: T, value: T) -> ProjectGroupGetCall<'a, C>
8382 where
8383 T: AsRef<str>,
8384 {
8385 self._additional_params
8386 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8387 self
8388 }
8389
8390 /// Identifies the authorization scope for the method you are building.
8391 ///
8392 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8393 /// [`Scope::CloudPlatform`].
8394 ///
8395 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8396 /// tokens for more than one scope.
8397 ///
8398 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8399 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8400 /// sufficient, a read-write scope will do as well.
8401 pub fn add_scope<St>(mut self, scope: St) -> ProjectGroupGetCall<'a, C>
8402 where
8403 St: AsRef<str>,
8404 {
8405 self._scopes.insert(String::from(scope.as_ref()));
8406 self
8407 }
8408 /// Identifies the authorization scope(s) for the method you are building.
8409 ///
8410 /// See [`Self::add_scope()`] for details.
8411 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGroupGetCall<'a, C>
8412 where
8413 I: IntoIterator<Item = St>,
8414 St: AsRef<str>,
8415 {
8416 self._scopes
8417 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8418 self
8419 }
8420
8421 /// Removes all scopes, and no default scope will be used either.
8422 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8423 /// for details).
8424 pub fn clear_scopes(mut self) -> ProjectGroupGetCall<'a, C> {
8425 self._scopes.clear();
8426 self
8427 }
8428}
8429
8430/// Lists the existing groups.
8431///
8432/// A builder for the *groups.list* method supported by a *project* resource.
8433/// It is not used directly, but through a [`ProjectMethods`] instance.
8434///
8435/// # Example
8436///
8437/// Instantiate a resource method builder
8438///
8439/// ```test_harness,no_run
8440/// # extern crate hyper;
8441/// # extern crate hyper_rustls;
8442/// # extern crate google_monitoring3 as monitoring3;
8443/// # async fn dox() {
8444/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8445///
8446/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8447/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8448/// # secret,
8449/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8450/// # ).build().await.unwrap();
8451///
8452/// # let client = hyper_util::client::legacy::Client::builder(
8453/// # hyper_util::rt::TokioExecutor::new()
8454/// # )
8455/// # .build(
8456/// # hyper_rustls::HttpsConnectorBuilder::new()
8457/// # .with_native_roots()
8458/// # .unwrap()
8459/// # .https_or_http()
8460/// # .enable_http1()
8461/// # .build()
8462/// # );
8463/// # let mut hub = Monitoring::new(client, auth);
8464/// // You can configure optional parameters by calling the respective setters at will, and
8465/// // execute the final call using `doit()`.
8466/// // Values shown here are possibly random and not representative !
8467/// let result = hub.projects().groups_list("name")
8468/// .page_token("vero")
8469/// .page_size(-88)
8470/// .descendants_of_group("Stet")
8471/// .children_of_group("vero")
8472/// .ancestors_of_group("elitr")
8473/// .doit().await;
8474/// # }
8475/// ```
8476pub struct ProjectGroupListCall<'a, C>
8477where
8478 C: 'a,
8479{
8480 hub: &'a Monitoring<C>,
8481 _name: String,
8482 _page_token: Option<String>,
8483 _page_size: Option<i32>,
8484 _descendants_of_group: Option<String>,
8485 _children_of_group: Option<String>,
8486 _ancestors_of_group: Option<String>,
8487 _delegate: Option<&'a mut dyn common::Delegate>,
8488 _additional_params: HashMap<String, String>,
8489 _scopes: BTreeSet<String>,
8490}
8491
8492impl<'a, C> common::CallBuilder for ProjectGroupListCall<'a, C> {}
8493
8494impl<'a, C> ProjectGroupListCall<'a, C>
8495where
8496 C: common::Connector,
8497{
8498 /// Perform the operation you have build so far.
8499 pub async fn doit(mut self) -> common::Result<(common::Response, ListGroupsResponse)> {
8500 use std::borrow::Cow;
8501 use std::io::{Read, Seek};
8502
8503 use common::{url::Params, ToParts};
8504 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8505
8506 let mut dd = common::DefaultDelegate;
8507 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8508 dlg.begin(common::MethodInfo {
8509 id: "monitoring.projects.groups.list",
8510 http_method: hyper::Method::GET,
8511 });
8512
8513 for &field in [
8514 "alt",
8515 "name",
8516 "pageToken",
8517 "pageSize",
8518 "descendantsOfGroup",
8519 "childrenOfGroup",
8520 "ancestorsOfGroup",
8521 ]
8522 .iter()
8523 {
8524 if self._additional_params.contains_key(field) {
8525 dlg.finished(false);
8526 return Err(common::Error::FieldClash(field));
8527 }
8528 }
8529
8530 let mut params = Params::with_capacity(8 + self._additional_params.len());
8531 params.push("name", self._name);
8532 if let Some(value) = self._page_token.as_ref() {
8533 params.push("pageToken", value);
8534 }
8535 if let Some(value) = self._page_size.as_ref() {
8536 params.push("pageSize", value.to_string());
8537 }
8538 if let Some(value) = self._descendants_of_group.as_ref() {
8539 params.push("descendantsOfGroup", value);
8540 }
8541 if let Some(value) = self._children_of_group.as_ref() {
8542 params.push("childrenOfGroup", value);
8543 }
8544 if let Some(value) = self._ancestors_of_group.as_ref() {
8545 params.push("ancestorsOfGroup", value);
8546 }
8547
8548 params.extend(self._additional_params.iter());
8549
8550 params.push("alt", "json");
8551 let mut url = self.hub._base_url.clone() + "v3/{+name}/groups";
8552 if self._scopes.is_empty() {
8553 self._scopes
8554 .insert(Scope::CloudPlatform.as_ref().to_string());
8555 }
8556
8557 #[allow(clippy::single_element_loop)]
8558 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8559 url = params.uri_replacement(url, param_name, find_this, true);
8560 }
8561 {
8562 let to_remove = ["name"];
8563 params.remove_params(&to_remove);
8564 }
8565
8566 let url = params.parse_with_url(&url);
8567
8568 loop {
8569 let token = match self
8570 .hub
8571 .auth
8572 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8573 .await
8574 {
8575 Ok(token) => token,
8576 Err(e) => match dlg.token(e) {
8577 Ok(token) => token,
8578 Err(e) => {
8579 dlg.finished(false);
8580 return Err(common::Error::MissingToken(e));
8581 }
8582 },
8583 };
8584 let mut req_result = {
8585 let client = &self.hub.client;
8586 dlg.pre_request();
8587 let mut req_builder = hyper::Request::builder()
8588 .method(hyper::Method::GET)
8589 .uri(url.as_str())
8590 .header(USER_AGENT, self.hub._user_agent.clone());
8591
8592 if let Some(token) = token.as_ref() {
8593 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8594 }
8595
8596 let request = req_builder
8597 .header(CONTENT_LENGTH, 0_u64)
8598 .body(common::to_body::<String>(None));
8599
8600 client.request(request.unwrap()).await
8601 };
8602
8603 match req_result {
8604 Err(err) => {
8605 if let common::Retry::After(d) = dlg.http_error(&err) {
8606 sleep(d).await;
8607 continue;
8608 }
8609 dlg.finished(false);
8610 return Err(common::Error::HttpError(err));
8611 }
8612 Ok(res) => {
8613 let (mut parts, body) = res.into_parts();
8614 let mut body = common::Body::new(body);
8615 if !parts.status.is_success() {
8616 let bytes = common::to_bytes(body).await.unwrap_or_default();
8617 let error = serde_json::from_str(&common::to_string(&bytes));
8618 let response = common::to_response(parts, bytes.into());
8619
8620 if let common::Retry::After(d) =
8621 dlg.http_failure(&response, error.as_ref().ok())
8622 {
8623 sleep(d).await;
8624 continue;
8625 }
8626
8627 dlg.finished(false);
8628
8629 return Err(match error {
8630 Ok(value) => common::Error::BadRequest(value),
8631 _ => common::Error::Failure(response),
8632 });
8633 }
8634 let response = {
8635 let bytes = common::to_bytes(body).await.unwrap_or_default();
8636 let encoded = common::to_string(&bytes);
8637 match serde_json::from_str(&encoded) {
8638 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8639 Err(error) => {
8640 dlg.response_json_decode_error(&encoded, &error);
8641 return Err(common::Error::JsonDecodeError(
8642 encoded.to_string(),
8643 error,
8644 ));
8645 }
8646 }
8647 };
8648
8649 dlg.finished(true);
8650 return Ok(response);
8651 }
8652 }
8653 }
8654 }
8655
8656 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) whose groups are to be listed. The format is: projects/[PROJECT_ID_OR_NUMBER]
8657 ///
8658 /// Sets the *name* path property to the given value.
8659 ///
8660 /// Even though the property as already been set when instantiating this call,
8661 /// we provide this method for API completeness.
8662 pub fn name(mut self, new_value: &str) -> ProjectGroupListCall<'a, C> {
8663 self._name = new_value.to_string();
8664 self
8665 }
8666 /// If this field is not empty then it must contain the next_page_token value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
8667 ///
8668 /// Sets the *page token* query property to the given value.
8669 pub fn page_token(mut self, new_value: &str) -> ProjectGroupListCall<'a, C> {
8670 self._page_token = Some(new_value.to_string());
8671 self
8672 }
8673 /// A positive number that is the maximum number of results to return.
8674 ///
8675 /// Sets the *page size* query property to the given value.
8676 pub fn page_size(mut self, new_value: i32) -> ProjectGroupListCall<'a, C> {
8677 self._page_size = Some(new_value);
8678 self
8679 }
8680 /// A group name. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] Returns the descendants of the specified group. This is a superset of the results returned by the children_of_group filter, and includes children-of-children, and so forth.
8681 ///
8682 /// Sets the *descendants of group* query property to the given value.
8683 pub fn descendants_of_group(mut self, new_value: &str) -> ProjectGroupListCall<'a, C> {
8684 self._descendants_of_group = Some(new_value.to_string());
8685 self
8686 }
8687 /// A group name. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] Returns groups whose parent_name field contains the group name. If no groups have this parent, the results are empty.
8688 ///
8689 /// Sets the *children of group* query property to the given value.
8690 pub fn children_of_group(mut self, new_value: &str) -> ProjectGroupListCall<'a, C> {
8691 self._children_of_group = Some(new_value.to_string());
8692 self
8693 }
8694 /// A group name. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] Returns groups that are ancestors of the specified group. The groups are returned in order, starting with the immediate parent and ending with the most distant ancestor. If the specified group has no immediate parent, the results are empty.
8695 ///
8696 /// Sets the *ancestors of group* query property to the given value.
8697 pub fn ancestors_of_group(mut self, new_value: &str) -> ProjectGroupListCall<'a, C> {
8698 self._ancestors_of_group = Some(new_value.to_string());
8699 self
8700 }
8701 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8702 /// while executing the actual API request.
8703 ///
8704 /// ````text
8705 /// It should be used to handle progress information, and to implement a certain level of resilience.
8706 /// ````
8707 ///
8708 /// Sets the *delegate* property to the given value.
8709 pub fn delegate(
8710 mut self,
8711 new_value: &'a mut dyn common::Delegate,
8712 ) -> ProjectGroupListCall<'a, C> {
8713 self._delegate = Some(new_value);
8714 self
8715 }
8716
8717 /// Set any additional parameter of the query string used in the request.
8718 /// It should be used to set parameters which are not yet available through their own
8719 /// setters.
8720 ///
8721 /// Please note that this method must not be used to set any of the known parameters
8722 /// which have their own setter method. If done anyway, the request will fail.
8723 ///
8724 /// # Additional Parameters
8725 ///
8726 /// * *$.xgafv* (query-string) - V1 error format.
8727 /// * *access_token* (query-string) - OAuth access token.
8728 /// * *alt* (query-string) - Data format for response.
8729 /// * *callback* (query-string) - JSONP
8730 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8731 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8732 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8733 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8734 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8735 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8736 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8737 pub fn param<T>(mut self, name: T, value: T) -> ProjectGroupListCall<'a, C>
8738 where
8739 T: AsRef<str>,
8740 {
8741 self._additional_params
8742 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8743 self
8744 }
8745
8746 /// Identifies the authorization scope for the method you are building.
8747 ///
8748 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8749 /// [`Scope::CloudPlatform`].
8750 ///
8751 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8752 /// tokens for more than one scope.
8753 ///
8754 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8755 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8756 /// sufficient, a read-write scope will do as well.
8757 pub fn add_scope<St>(mut self, scope: St) -> ProjectGroupListCall<'a, C>
8758 where
8759 St: AsRef<str>,
8760 {
8761 self._scopes.insert(String::from(scope.as_ref()));
8762 self
8763 }
8764 /// Identifies the authorization scope(s) for the method you are building.
8765 ///
8766 /// See [`Self::add_scope()`] for details.
8767 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGroupListCall<'a, C>
8768 where
8769 I: IntoIterator<Item = St>,
8770 St: AsRef<str>,
8771 {
8772 self._scopes
8773 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8774 self
8775 }
8776
8777 /// Removes all scopes, and no default scope will be used either.
8778 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8779 /// for details).
8780 pub fn clear_scopes(mut self) -> ProjectGroupListCall<'a, C> {
8781 self._scopes.clear();
8782 self
8783 }
8784}
8785
8786/// Updates an existing group. You can change any group attributes except name.
8787///
8788/// A builder for the *groups.update* method supported by a *project* resource.
8789/// It is not used directly, but through a [`ProjectMethods`] instance.
8790///
8791/// # Example
8792///
8793/// Instantiate a resource method builder
8794///
8795/// ```test_harness,no_run
8796/// # extern crate hyper;
8797/// # extern crate hyper_rustls;
8798/// # extern crate google_monitoring3 as monitoring3;
8799/// use monitoring3::api::Group;
8800/// # async fn dox() {
8801/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8802///
8803/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8804/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8805/// # secret,
8806/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8807/// # ).build().await.unwrap();
8808///
8809/// # let client = hyper_util::client::legacy::Client::builder(
8810/// # hyper_util::rt::TokioExecutor::new()
8811/// # )
8812/// # .build(
8813/// # hyper_rustls::HttpsConnectorBuilder::new()
8814/// # .with_native_roots()
8815/// # .unwrap()
8816/// # .https_or_http()
8817/// # .enable_http1()
8818/// # .build()
8819/// # );
8820/// # let mut hub = Monitoring::new(client, auth);
8821/// // As the method needs a request, you would usually fill it with the desired information
8822/// // into the respective structure. Some of the parts shown here might not be applicable !
8823/// // Values shown here are possibly random and not representative !
8824/// let mut req = Group::default();
8825///
8826/// // You can configure optional parameters by calling the respective setters at will, and
8827/// // execute the final call using `doit()`.
8828/// // Values shown here are possibly random and not representative !
8829/// let result = hub.projects().groups_update(req, "name")
8830/// .validate_only(true)
8831/// .doit().await;
8832/// # }
8833/// ```
8834pub struct ProjectGroupUpdateCall<'a, C>
8835where
8836 C: 'a,
8837{
8838 hub: &'a Monitoring<C>,
8839 _request: Group,
8840 _name: String,
8841 _validate_only: Option<bool>,
8842 _delegate: Option<&'a mut dyn common::Delegate>,
8843 _additional_params: HashMap<String, String>,
8844 _scopes: BTreeSet<String>,
8845}
8846
8847impl<'a, C> common::CallBuilder for ProjectGroupUpdateCall<'a, C> {}
8848
8849impl<'a, C> ProjectGroupUpdateCall<'a, C>
8850where
8851 C: common::Connector,
8852{
8853 /// Perform the operation you have build so far.
8854 pub async fn doit(mut self) -> common::Result<(common::Response, Group)> {
8855 use std::borrow::Cow;
8856 use std::io::{Read, Seek};
8857
8858 use common::{url::Params, ToParts};
8859 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8860
8861 let mut dd = common::DefaultDelegate;
8862 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8863 dlg.begin(common::MethodInfo {
8864 id: "monitoring.projects.groups.update",
8865 http_method: hyper::Method::PUT,
8866 });
8867
8868 for &field in ["alt", "name", "validateOnly"].iter() {
8869 if self._additional_params.contains_key(field) {
8870 dlg.finished(false);
8871 return Err(common::Error::FieldClash(field));
8872 }
8873 }
8874
8875 let mut params = Params::with_capacity(5 + self._additional_params.len());
8876 params.push("name", self._name);
8877 if let Some(value) = self._validate_only.as_ref() {
8878 params.push("validateOnly", value.to_string());
8879 }
8880
8881 params.extend(self._additional_params.iter());
8882
8883 params.push("alt", "json");
8884 let mut url = self.hub._base_url.clone() + "v3/{+name}";
8885 if self._scopes.is_empty() {
8886 self._scopes
8887 .insert(Scope::CloudPlatform.as_ref().to_string());
8888 }
8889
8890 #[allow(clippy::single_element_loop)]
8891 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8892 url = params.uri_replacement(url, param_name, find_this, true);
8893 }
8894 {
8895 let to_remove = ["name"];
8896 params.remove_params(&to_remove);
8897 }
8898
8899 let url = params.parse_with_url(&url);
8900
8901 let mut json_mime_type = mime::APPLICATION_JSON;
8902 let mut request_value_reader = {
8903 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8904 common::remove_json_null_values(&mut value);
8905 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8906 serde_json::to_writer(&mut dst, &value).unwrap();
8907 dst
8908 };
8909 let request_size = request_value_reader
8910 .seek(std::io::SeekFrom::End(0))
8911 .unwrap();
8912 request_value_reader
8913 .seek(std::io::SeekFrom::Start(0))
8914 .unwrap();
8915
8916 loop {
8917 let token = match self
8918 .hub
8919 .auth
8920 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8921 .await
8922 {
8923 Ok(token) => token,
8924 Err(e) => match dlg.token(e) {
8925 Ok(token) => token,
8926 Err(e) => {
8927 dlg.finished(false);
8928 return Err(common::Error::MissingToken(e));
8929 }
8930 },
8931 };
8932 request_value_reader
8933 .seek(std::io::SeekFrom::Start(0))
8934 .unwrap();
8935 let mut req_result = {
8936 let client = &self.hub.client;
8937 dlg.pre_request();
8938 let mut req_builder = hyper::Request::builder()
8939 .method(hyper::Method::PUT)
8940 .uri(url.as_str())
8941 .header(USER_AGENT, self.hub._user_agent.clone());
8942
8943 if let Some(token) = token.as_ref() {
8944 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8945 }
8946
8947 let request = req_builder
8948 .header(CONTENT_TYPE, json_mime_type.to_string())
8949 .header(CONTENT_LENGTH, request_size as u64)
8950 .body(common::to_body(
8951 request_value_reader.get_ref().clone().into(),
8952 ));
8953
8954 client.request(request.unwrap()).await
8955 };
8956
8957 match req_result {
8958 Err(err) => {
8959 if let common::Retry::After(d) = dlg.http_error(&err) {
8960 sleep(d).await;
8961 continue;
8962 }
8963 dlg.finished(false);
8964 return Err(common::Error::HttpError(err));
8965 }
8966 Ok(res) => {
8967 let (mut parts, body) = res.into_parts();
8968 let mut body = common::Body::new(body);
8969 if !parts.status.is_success() {
8970 let bytes = common::to_bytes(body).await.unwrap_or_default();
8971 let error = serde_json::from_str(&common::to_string(&bytes));
8972 let response = common::to_response(parts, bytes.into());
8973
8974 if let common::Retry::After(d) =
8975 dlg.http_failure(&response, error.as_ref().ok())
8976 {
8977 sleep(d).await;
8978 continue;
8979 }
8980
8981 dlg.finished(false);
8982
8983 return Err(match error {
8984 Ok(value) => common::Error::BadRequest(value),
8985 _ => common::Error::Failure(response),
8986 });
8987 }
8988 let response = {
8989 let bytes = common::to_bytes(body).await.unwrap_or_default();
8990 let encoded = common::to_string(&bytes);
8991 match serde_json::from_str(&encoded) {
8992 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8993 Err(error) => {
8994 dlg.response_json_decode_error(&encoded, &error);
8995 return Err(common::Error::JsonDecodeError(
8996 encoded.to_string(),
8997 error,
8998 ));
8999 }
9000 }
9001 };
9002
9003 dlg.finished(true);
9004 return Ok(response);
9005 }
9006 }
9007 }
9008 }
9009
9010 ///
9011 /// Sets the *request* property to the given value.
9012 ///
9013 /// Even though the property as already been set when instantiating this call,
9014 /// we provide this method for API completeness.
9015 pub fn request(mut self, new_value: Group) -> ProjectGroupUpdateCall<'a, C> {
9016 self._request = new_value;
9017 self
9018 }
9019 /// Output only. The name of this group. The format is: projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] When creating a group, this field is ignored and a new name is created consisting of the project specified in the call to CreateGroup and a unique [GROUP_ID] that is generated automatically.
9020 ///
9021 /// Sets the *name* path property to the given value.
9022 ///
9023 /// Even though the property as already been set when instantiating this call,
9024 /// we provide this method for API completeness.
9025 pub fn name(mut self, new_value: &str) -> ProjectGroupUpdateCall<'a, C> {
9026 self._name = new_value.to_string();
9027 self
9028 }
9029 /// If true, validate this request but do not update the existing group.
9030 ///
9031 /// Sets the *validate only* query property to the given value.
9032 pub fn validate_only(mut self, new_value: bool) -> ProjectGroupUpdateCall<'a, C> {
9033 self._validate_only = Some(new_value);
9034 self
9035 }
9036 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9037 /// while executing the actual API request.
9038 ///
9039 /// ````text
9040 /// It should be used to handle progress information, and to implement a certain level of resilience.
9041 /// ````
9042 ///
9043 /// Sets the *delegate* property to the given value.
9044 pub fn delegate(
9045 mut self,
9046 new_value: &'a mut dyn common::Delegate,
9047 ) -> ProjectGroupUpdateCall<'a, C> {
9048 self._delegate = Some(new_value);
9049 self
9050 }
9051
9052 /// Set any additional parameter of the query string used in the request.
9053 /// It should be used to set parameters which are not yet available through their own
9054 /// setters.
9055 ///
9056 /// Please note that this method must not be used to set any of the known parameters
9057 /// which have their own setter method. If done anyway, the request will fail.
9058 ///
9059 /// # Additional Parameters
9060 ///
9061 /// * *$.xgafv* (query-string) - V1 error format.
9062 /// * *access_token* (query-string) - OAuth access token.
9063 /// * *alt* (query-string) - Data format for response.
9064 /// * *callback* (query-string) - JSONP
9065 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9066 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9067 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9068 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9069 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9070 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9071 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9072 pub fn param<T>(mut self, name: T, value: T) -> ProjectGroupUpdateCall<'a, C>
9073 where
9074 T: AsRef<str>,
9075 {
9076 self._additional_params
9077 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9078 self
9079 }
9080
9081 /// Identifies the authorization scope for the method you are building.
9082 ///
9083 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9084 /// [`Scope::CloudPlatform`].
9085 ///
9086 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9087 /// tokens for more than one scope.
9088 ///
9089 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9090 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9091 /// sufficient, a read-write scope will do as well.
9092 pub fn add_scope<St>(mut self, scope: St) -> ProjectGroupUpdateCall<'a, C>
9093 where
9094 St: AsRef<str>,
9095 {
9096 self._scopes.insert(String::from(scope.as_ref()));
9097 self
9098 }
9099 /// Identifies the authorization scope(s) for the method you are building.
9100 ///
9101 /// See [`Self::add_scope()`] for details.
9102 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGroupUpdateCall<'a, C>
9103 where
9104 I: IntoIterator<Item = St>,
9105 St: AsRef<str>,
9106 {
9107 self._scopes
9108 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9109 self
9110 }
9111
9112 /// Removes all scopes, and no default scope will be used either.
9113 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9114 /// for details).
9115 pub fn clear_scopes(mut self) -> ProjectGroupUpdateCall<'a, C> {
9116 self._scopes.clear();
9117 self
9118 }
9119}
9120
9121/// Creates a new metric descriptor. The creation is executed asynchronously. User-created metric descriptors define custom metrics (https://cloud.google.com/monitoring/custom-metrics). The metric descriptor is updated if it already exists, except that metric labels are never removed.
9122///
9123/// A builder for the *metricDescriptors.create* method supported by a *project* resource.
9124/// It is not used directly, but through a [`ProjectMethods`] instance.
9125///
9126/// # Example
9127///
9128/// Instantiate a resource method builder
9129///
9130/// ```test_harness,no_run
9131/// # extern crate hyper;
9132/// # extern crate hyper_rustls;
9133/// # extern crate google_monitoring3 as monitoring3;
9134/// use monitoring3::api::MetricDescriptor;
9135/// # async fn dox() {
9136/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9137///
9138/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9139/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9140/// # secret,
9141/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9142/// # ).build().await.unwrap();
9143///
9144/// # let client = hyper_util::client::legacy::Client::builder(
9145/// # hyper_util::rt::TokioExecutor::new()
9146/// # )
9147/// # .build(
9148/// # hyper_rustls::HttpsConnectorBuilder::new()
9149/// # .with_native_roots()
9150/// # .unwrap()
9151/// # .https_or_http()
9152/// # .enable_http1()
9153/// # .build()
9154/// # );
9155/// # let mut hub = Monitoring::new(client, auth);
9156/// // As the method needs a request, you would usually fill it with the desired information
9157/// // into the respective structure. Some of the parts shown here might not be applicable !
9158/// // Values shown here are possibly random and not representative !
9159/// let mut req = MetricDescriptor::default();
9160///
9161/// // You can configure optional parameters by calling the respective setters at will, and
9162/// // execute the final call using `doit()`.
9163/// // Values shown here are possibly random and not representative !
9164/// let result = hub.projects().metric_descriptors_create(req, "name")
9165/// .doit().await;
9166/// # }
9167/// ```
9168pub struct ProjectMetricDescriptorCreateCall<'a, C>
9169where
9170 C: 'a,
9171{
9172 hub: &'a Monitoring<C>,
9173 _request: MetricDescriptor,
9174 _name: String,
9175 _delegate: Option<&'a mut dyn common::Delegate>,
9176 _additional_params: HashMap<String, String>,
9177 _scopes: BTreeSet<String>,
9178}
9179
9180impl<'a, C> common::CallBuilder for ProjectMetricDescriptorCreateCall<'a, C> {}
9181
9182impl<'a, C> ProjectMetricDescriptorCreateCall<'a, C>
9183where
9184 C: common::Connector,
9185{
9186 /// Perform the operation you have build so far.
9187 pub async fn doit(mut self) -> common::Result<(common::Response, MetricDescriptor)> {
9188 use std::borrow::Cow;
9189 use std::io::{Read, Seek};
9190
9191 use common::{url::Params, ToParts};
9192 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9193
9194 let mut dd = common::DefaultDelegate;
9195 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9196 dlg.begin(common::MethodInfo {
9197 id: "monitoring.projects.metricDescriptors.create",
9198 http_method: hyper::Method::POST,
9199 });
9200
9201 for &field in ["alt", "name"].iter() {
9202 if self._additional_params.contains_key(field) {
9203 dlg.finished(false);
9204 return Err(common::Error::FieldClash(field));
9205 }
9206 }
9207
9208 let mut params = Params::with_capacity(4 + self._additional_params.len());
9209 params.push("name", self._name);
9210
9211 params.extend(self._additional_params.iter());
9212
9213 params.push("alt", "json");
9214 let mut url = self.hub._base_url.clone() + "v3/{+name}/metricDescriptors";
9215 if self._scopes.is_empty() {
9216 self._scopes
9217 .insert(Scope::CloudPlatform.as_ref().to_string());
9218 }
9219
9220 #[allow(clippy::single_element_loop)]
9221 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9222 url = params.uri_replacement(url, param_name, find_this, true);
9223 }
9224 {
9225 let to_remove = ["name"];
9226 params.remove_params(&to_remove);
9227 }
9228
9229 let url = params.parse_with_url(&url);
9230
9231 let mut json_mime_type = mime::APPLICATION_JSON;
9232 let mut request_value_reader = {
9233 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9234 common::remove_json_null_values(&mut value);
9235 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9236 serde_json::to_writer(&mut dst, &value).unwrap();
9237 dst
9238 };
9239 let request_size = request_value_reader
9240 .seek(std::io::SeekFrom::End(0))
9241 .unwrap();
9242 request_value_reader
9243 .seek(std::io::SeekFrom::Start(0))
9244 .unwrap();
9245
9246 loop {
9247 let token = match self
9248 .hub
9249 .auth
9250 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9251 .await
9252 {
9253 Ok(token) => token,
9254 Err(e) => match dlg.token(e) {
9255 Ok(token) => token,
9256 Err(e) => {
9257 dlg.finished(false);
9258 return Err(common::Error::MissingToken(e));
9259 }
9260 },
9261 };
9262 request_value_reader
9263 .seek(std::io::SeekFrom::Start(0))
9264 .unwrap();
9265 let mut req_result = {
9266 let client = &self.hub.client;
9267 dlg.pre_request();
9268 let mut req_builder = hyper::Request::builder()
9269 .method(hyper::Method::POST)
9270 .uri(url.as_str())
9271 .header(USER_AGENT, self.hub._user_agent.clone());
9272
9273 if let Some(token) = token.as_ref() {
9274 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9275 }
9276
9277 let request = req_builder
9278 .header(CONTENT_TYPE, json_mime_type.to_string())
9279 .header(CONTENT_LENGTH, request_size as u64)
9280 .body(common::to_body(
9281 request_value_reader.get_ref().clone().into(),
9282 ));
9283
9284 client.request(request.unwrap()).await
9285 };
9286
9287 match req_result {
9288 Err(err) => {
9289 if let common::Retry::After(d) = dlg.http_error(&err) {
9290 sleep(d).await;
9291 continue;
9292 }
9293 dlg.finished(false);
9294 return Err(common::Error::HttpError(err));
9295 }
9296 Ok(res) => {
9297 let (mut parts, body) = res.into_parts();
9298 let mut body = common::Body::new(body);
9299 if !parts.status.is_success() {
9300 let bytes = common::to_bytes(body).await.unwrap_or_default();
9301 let error = serde_json::from_str(&common::to_string(&bytes));
9302 let response = common::to_response(parts, bytes.into());
9303
9304 if let common::Retry::After(d) =
9305 dlg.http_failure(&response, error.as_ref().ok())
9306 {
9307 sleep(d).await;
9308 continue;
9309 }
9310
9311 dlg.finished(false);
9312
9313 return Err(match error {
9314 Ok(value) => common::Error::BadRequest(value),
9315 _ => common::Error::Failure(response),
9316 });
9317 }
9318 let response = {
9319 let bytes = common::to_bytes(body).await.unwrap_or_default();
9320 let encoded = common::to_string(&bytes);
9321 match serde_json::from_str(&encoded) {
9322 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9323 Err(error) => {
9324 dlg.response_json_decode_error(&encoded, &error);
9325 return Err(common::Error::JsonDecodeError(
9326 encoded.to_string(),
9327 error,
9328 ));
9329 }
9330 }
9331 };
9332
9333 dlg.finished(true);
9334 return Ok(response);
9335 }
9336 }
9337 }
9338 }
9339
9340 ///
9341 /// Sets the *request* property to the given value.
9342 ///
9343 /// Even though the property as already been set when instantiating this call,
9344 /// we provide this method for API completeness.
9345 pub fn request(
9346 mut self,
9347 new_value: MetricDescriptor,
9348 ) -> ProjectMetricDescriptorCreateCall<'a, C> {
9349 self._request = new_value;
9350 self
9351 }
9352 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: 4 projects/PROJECT_ID_OR_NUMBER
9353 ///
9354 /// Sets the *name* path property to the given value.
9355 ///
9356 /// Even though the property as already been set when instantiating this call,
9357 /// we provide this method for API completeness.
9358 pub fn name(mut self, new_value: &str) -> ProjectMetricDescriptorCreateCall<'a, C> {
9359 self._name = new_value.to_string();
9360 self
9361 }
9362 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9363 /// while executing the actual API request.
9364 ///
9365 /// ````text
9366 /// It should be used to handle progress information, and to implement a certain level of resilience.
9367 /// ````
9368 ///
9369 /// Sets the *delegate* property to the given value.
9370 pub fn delegate(
9371 mut self,
9372 new_value: &'a mut dyn common::Delegate,
9373 ) -> ProjectMetricDescriptorCreateCall<'a, C> {
9374 self._delegate = Some(new_value);
9375 self
9376 }
9377
9378 /// Set any additional parameter of the query string used in the request.
9379 /// It should be used to set parameters which are not yet available through their own
9380 /// setters.
9381 ///
9382 /// Please note that this method must not be used to set any of the known parameters
9383 /// which have their own setter method. If done anyway, the request will fail.
9384 ///
9385 /// # Additional Parameters
9386 ///
9387 /// * *$.xgafv* (query-string) - V1 error format.
9388 /// * *access_token* (query-string) - OAuth access token.
9389 /// * *alt* (query-string) - Data format for response.
9390 /// * *callback* (query-string) - JSONP
9391 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9392 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9393 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9394 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9395 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9396 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9397 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9398 pub fn param<T>(mut self, name: T, value: T) -> ProjectMetricDescriptorCreateCall<'a, C>
9399 where
9400 T: AsRef<str>,
9401 {
9402 self._additional_params
9403 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9404 self
9405 }
9406
9407 /// Identifies the authorization scope for the method you are building.
9408 ///
9409 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9410 /// [`Scope::CloudPlatform`].
9411 ///
9412 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9413 /// tokens for more than one scope.
9414 ///
9415 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9416 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9417 /// sufficient, a read-write scope will do as well.
9418 pub fn add_scope<St>(mut self, scope: St) -> ProjectMetricDescriptorCreateCall<'a, C>
9419 where
9420 St: AsRef<str>,
9421 {
9422 self._scopes.insert(String::from(scope.as_ref()));
9423 self
9424 }
9425 /// Identifies the authorization scope(s) for the method you are building.
9426 ///
9427 /// See [`Self::add_scope()`] for details.
9428 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectMetricDescriptorCreateCall<'a, C>
9429 where
9430 I: IntoIterator<Item = St>,
9431 St: AsRef<str>,
9432 {
9433 self._scopes
9434 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9435 self
9436 }
9437
9438 /// Removes all scopes, and no default scope will be used either.
9439 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9440 /// for details).
9441 pub fn clear_scopes(mut self) -> ProjectMetricDescriptorCreateCall<'a, C> {
9442 self._scopes.clear();
9443 self
9444 }
9445}
9446
9447/// Deletes a metric descriptor. Only user-created custom metrics (https://cloud.google.com/monitoring/custom-metrics) can be deleted.
9448///
9449/// A builder for the *metricDescriptors.delete* method supported by a *project* resource.
9450/// It is not used directly, but through a [`ProjectMethods`] instance.
9451///
9452/// # Example
9453///
9454/// Instantiate a resource method builder
9455///
9456/// ```test_harness,no_run
9457/// # extern crate hyper;
9458/// # extern crate hyper_rustls;
9459/// # extern crate google_monitoring3 as monitoring3;
9460/// # async fn dox() {
9461/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9462///
9463/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9464/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9465/// # secret,
9466/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9467/// # ).build().await.unwrap();
9468///
9469/// # let client = hyper_util::client::legacy::Client::builder(
9470/// # hyper_util::rt::TokioExecutor::new()
9471/// # )
9472/// # .build(
9473/// # hyper_rustls::HttpsConnectorBuilder::new()
9474/// # .with_native_roots()
9475/// # .unwrap()
9476/// # .https_or_http()
9477/// # .enable_http1()
9478/// # .build()
9479/// # );
9480/// # let mut hub = Monitoring::new(client, auth);
9481/// // You can configure optional parameters by calling the respective setters at will, and
9482/// // execute the final call using `doit()`.
9483/// // Values shown here are possibly random and not representative !
9484/// let result = hub.projects().metric_descriptors_delete("name")
9485/// .doit().await;
9486/// # }
9487/// ```
9488pub struct ProjectMetricDescriptorDeleteCall<'a, C>
9489where
9490 C: 'a,
9491{
9492 hub: &'a Monitoring<C>,
9493 _name: String,
9494 _delegate: Option<&'a mut dyn common::Delegate>,
9495 _additional_params: HashMap<String, String>,
9496 _scopes: BTreeSet<String>,
9497}
9498
9499impl<'a, C> common::CallBuilder for ProjectMetricDescriptorDeleteCall<'a, C> {}
9500
9501impl<'a, C> ProjectMetricDescriptorDeleteCall<'a, C>
9502where
9503 C: common::Connector,
9504{
9505 /// Perform the operation you have build so far.
9506 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9507 use std::borrow::Cow;
9508 use std::io::{Read, Seek};
9509
9510 use common::{url::Params, ToParts};
9511 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9512
9513 let mut dd = common::DefaultDelegate;
9514 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9515 dlg.begin(common::MethodInfo {
9516 id: "monitoring.projects.metricDescriptors.delete",
9517 http_method: hyper::Method::DELETE,
9518 });
9519
9520 for &field in ["alt", "name"].iter() {
9521 if self._additional_params.contains_key(field) {
9522 dlg.finished(false);
9523 return Err(common::Error::FieldClash(field));
9524 }
9525 }
9526
9527 let mut params = Params::with_capacity(3 + self._additional_params.len());
9528 params.push("name", self._name);
9529
9530 params.extend(self._additional_params.iter());
9531
9532 params.push("alt", "json");
9533 let mut url = self.hub._base_url.clone() + "v3/{+name}";
9534 if self._scopes.is_empty() {
9535 self._scopes
9536 .insert(Scope::CloudPlatform.as_ref().to_string());
9537 }
9538
9539 #[allow(clippy::single_element_loop)]
9540 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9541 url = params.uri_replacement(url, param_name, find_this, true);
9542 }
9543 {
9544 let to_remove = ["name"];
9545 params.remove_params(&to_remove);
9546 }
9547
9548 let url = params.parse_with_url(&url);
9549
9550 loop {
9551 let token = match self
9552 .hub
9553 .auth
9554 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9555 .await
9556 {
9557 Ok(token) => token,
9558 Err(e) => match dlg.token(e) {
9559 Ok(token) => token,
9560 Err(e) => {
9561 dlg.finished(false);
9562 return Err(common::Error::MissingToken(e));
9563 }
9564 },
9565 };
9566 let mut req_result = {
9567 let client = &self.hub.client;
9568 dlg.pre_request();
9569 let mut req_builder = hyper::Request::builder()
9570 .method(hyper::Method::DELETE)
9571 .uri(url.as_str())
9572 .header(USER_AGENT, self.hub._user_agent.clone());
9573
9574 if let Some(token) = token.as_ref() {
9575 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9576 }
9577
9578 let request = req_builder
9579 .header(CONTENT_LENGTH, 0_u64)
9580 .body(common::to_body::<String>(None));
9581
9582 client.request(request.unwrap()).await
9583 };
9584
9585 match req_result {
9586 Err(err) => {
9587 if let common::Retry::After(d) = dlg.http_error(&err) {
9588 sleep(d).await;
9589 continue;
9590 }
9591 dlg.finished(false);
9592 return Err(common::Error::HttpError(err));
9593 }
9594 Ok(res) => {
9595 let (mut parts, body) = res.into_parts();
9596 let mut body = common::Body::new(body);
9597 if !parts.status.is_success() {
9598 let bytes = common::to_bytes(body).await.unwrap_or_default();
9599 let error = serde_json::from_str(&common::to_string(&bytes));
9600 let response = common::to_response(parts, bytes.into());
9601
9602 if let common::Retry::After(d) =
9603 dlg.http_failure(&response, error.as_ref().ok())
9604 {
9605 sleep(d).await;
9606 continue;
9607 }
9608
9609 dlg.finished(false);
9610
9611 return Err(match error {
9612 Ok(value) => common::Error::BadRequest(value),
9613 _ => common::Error::Failure(response),
9614 });
9615 }
9616 let response = {
9617 let bytes = common::to_bytes(body).await.unwrap_or_default();
9618 let encoded = common::to_string(&bytes);
9619 match serde_json::from_str(&encoded) {
9620 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9621 Err(error) => {
9622 dlg.response_json_decode_error(&encoded, &error);
9623 return Err(common::Error::JsonDecodeError(
9624 encoded.to_string(),
9625 error,
9626 ));
9627 }
9628 }
9629 };
9630
9631 dlg.finished(true);
9632 return Ok(response);
9633 }
9634 }
9635 }
9636 }
9637
9638 /// Required. The metric descriptor on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID] An example of [METRIC_ID] is: "custom.googleapis.com/my_test_metric".
9639 ///
9640 /// Sets the *name* path property to the given value.
9641 ///
9642 /// Even though the property as already been set when instantiating this call,
9643 /// we provide this method for API completeness.
9644 pub fn name(mut self, new_value: &str) -> ProjectMetricDescriptorDeleteCall<'a, C> {
9645 self._name = new_value.to_string();
9646 self
9647 }
9648 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9649 /// while executing the actual API request.
9650 ///
9651 /// ````text
9652 /// It should be used to handle progress information, and to implement a certain level of resilience.
9653 /// ````
9654 ///
9655 /// Sets the *delegate* property to the given value.
9656 pub fn delegate(
9657 mut self,
9658 new_value: &'a mut dyn common::Delegate,
9659 ) -> ProjectMetricDescriptorDeleteCall<'a, C> {
9660 self._delegate = Some(new_value);
9661 self
9662 }
9663
9664 /// Set any additional parameter of the query string used in the request.
9665 /// It should be used to set parameters which are not yet available through their own
9666 /// setters.
9667 ///
9668 /// Please note that this method must not be used to set any of the known parameters
9669 /// which have their own setter method. If done anyway, the request will fail.
9670 ///
9671 /// # Additional Parameters
9672 ///
9673 /// * *$.xgafv* (query-string) - V1 error format.
9674 /// * *access_token* (query-string) - OAuth access token.
9675 /// * *alt* (query-string) - Data format for response.
9676 /// * *callback* (query-string) - JSONP
9677 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9678 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9679 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9680 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9681 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9682 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9683 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9684 pub fn param<T>(mut self, name: T, value: T) -> ProjectMetricDescriptorDeleteCall<'a, C>
9685 where
9686 T: AsRef<str>,
9687 {
9688 self._additional_params
9689 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9690 self
9691 }
9692
9693 /// Identifies the authorization scope for the method you are building.
9694 ///
9695 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9696 /// [`Scope::CloudPlatform`].
9697 ///
9698 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9699 /// tokens for more than one scope.
9700 ///
9701 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9702 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9703 /// sufficient, a read-write scope will do as well.
9704 pub fn add_scope<St>(mut self, scope: St) -> ProjectMetricDescriptorDeleteCall<'a, C>
9705 where
9706 St: AsRef<str>,
9707 {
9708 self._scopes.insert(String::from(scope.as_ref()));
9709 self
9710 }
9711 /// Identifies the authorization scope(s) for the method you are building.
9712 ///
9713 /// See [`Self::add_scope()`] for details.
9714 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectMetricDescriptorDeleteCall<'a, C>
9715 where
9716 I: IntoIterator<Item = St>,
9717 St: AsRef<str>,
9718 {
9719 self._scopes
9720 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9721 self
9722 }
9723
9724 /// Removes all scopes, and no default scope will be used either.
9725 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9726 /// for details).
9727 pub fn clear_scopes(mut self) -> ProjectMetricDescriptorDeleteCall<'a, C> {
9728 self._scopes.clear();
9729 self
9730 }
9731}
9732
9733/// Gets a single metric descriptor.
9734///
9735/// A builder for the *metricDescriptors.get* method supported by a *project* resource.
9736/// It is not used directly, but through a [`ProjectMethods`] instance.
9737///
9738/// # Example
9739///
9740/// Instantiate a resource method builder
9741///
9742/// ```test_harness,no_run
9743/// # extern crate hyper;
9744/// # extern crate hyper_rustls;
9745/// # extern crate google_monitoring3 as monitoring3;
9746/// # async fn dox() {
9747/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9748///
9749/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9750/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9751/// # secret,
9752/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9753/// # ).build().await.unwrap();
9754///
9755/// # let client = hyper_util::client::legacy::Client::builder(
9756/// # hyper_util::rt::TokioExecutor::new()
9757/// # )
9758/// # .build(
9759/// # hyper_rustls::HttpsConnectorBuilder::new()
9760/// # .with_native_roots()
9761/// # .unwrap()
9762/// # .https_or_http()
9763/// # .enable_http1()
9764/// # .build()
9765/// # );
9766/// # let mut hub = Monitoring::new(client, auth);
9767/// // You can configure optional parameters by calling the respective setters at will, and
9768/// // execute the final call using `doit()`.
9769/// // Values shown here are possibly random and not representative !
9770/// let result = hub.projects().metric_descriptors_get("name")
9771/// .doit().await;
9772/// # }
9773/// ```
9774pub struct ProjectMetricDescriptorGetCall<'a, C>
9775where
9776 C: 'a,
9777{
9778 hub: &'a Monitoring<C>,
9779 _name: String,
9780 _delegate: Option<&'a mut dyn common::Delegate>,
9781 _additional_params: HashMap<String, String>,
9782 _scopes: BTreeSet<String>,
9783}
9784
9785impl<'a, C> common::CallBuilder for ProjectMetricDescriptorGetCall<'a, C> {}
9786
9787impl<'a, C> ProjectMetricDescriptorGetCall<'a, C>
9788where
9789 C: common::Connector,
9790{
9791 /// Perform the operation you have build so far.
9792 pub async fn doit(mut self) -> common::Result<(common::Response, MetricDescriptor)> {
9793 use std::borrow::Cow;
9794 use std::io::{Read, Seek};
9795
9796 use common::{url::Params, ToParts};
9797 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9798
9799 let mut dd = common::DefaultDelegate;
9800 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9801 dlg.begin(common::MethodInfo {
9802 id: "monitoring.projects.metricDescriptors.get",
9803 http_method: hyper::Method::GET,
9804 });
9805
9806 for &field in ["alt", "name"].iter() {
9807 if self._additional_params.contains_key(field) {
9808 dlg.finished(false);
9809 return Err(common::Error::FieldClash(field));
9810 }
9811 }
9812
9813 let mut params = Params::with_capacity(3 + self._additional_params.len());
9814 params.push("name", self._name);
9815
9816 params.extend(self._additional_params.iter());
9817
9818 params.push("alt", "json");
9819 let mut url = self.hub._base_url.clone() + "v3/{+name}";
9820 if self._scopes.is_empty() {
9821 self._scopes
9822 .insert(Scope::CloudPlatform.as_ref().to_string());
9823 }
9824
9825 #[allow(clippy::single_element_loop)]
9826 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9827 url = params.uri_replacement(url, param_name, find_this, true);
9828 }
9829 {
9830 let to_remove = ["name"];
9831 params.remove_params(&to_remove);
9832 }
9833
9834 let url = params.parse_with_url(&url);
9835
9836 loop {
9837 let token = match self
9838 .hub
9839 .auth
9840 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9841 .await
9842 {
9843 Ok(token) => token,
9844 Err(e) => match dlg.token(e) {
9845 Ok(token) => token,
9846 Err(e) => {
9847 dlg.finished(false);
9848 return Err(common::Error::MissingToken(e));
9849 }
9850 },
9851 };
9852 let mut req_result = {
9853 let client = &self.hub.client;
9854 dlg.pre_request();
9855 let mut req_builder = hyper::Request::builder()
9856 .method(hyper::Method::GET)
9857 .uri(url.as_str())
9858 .header(USER_AGENT, self.hub._user_agent.clone());
9859
9860 if let Some(token) = token.as_ref() {
9861 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9862 }
9863
9864 let request = req_builder
9865 .header(CONTENT_LENGTH, 0_u64)
9866 .body(common::to_body::<String>(None));
9867
9868 client.request(request.unwrap()).await
9869 };
9870
9871 match req_result {
9872 Err(err) => {
9873 if let common::Retry::After(d) = dlg.http_error(&err) {
9874 sleep(d).await;
9875 continue;
9876 }
9877 dlg.finished(false);
9878 return Err(common::Error::HttpError(err));
9879 }
9880 Ok(res) => {
9881 let (mut parts, body) = res.into_parts();
9882 let mut body = common::Body::new(body);
9883 if !parts.status.is_success() {
9884 let bytes = common::to_bytes(body).await.unwrap_or_default();
9885 let error = serde_json::from_str(&common::to_string(&bytes));
9886 let response = common::to_response(parts, bytes.into());
9887
9888 if let common::Retry::After(d) =
9889 dlg.http_failure(&response, error.as_ref().ok())
9890 {
9891 sleep(d).await;
9892 continue;
9893 }
9894
9895 dlg.finished(false);
9896
9897 return Err(match error {
9898 Ok(value) => common::Error::BadRequest(value),
9899 _ => common::Error::Failure(response),
9900 });
9901 }
9902 let response = {
9903 let bytes = common::to_bytes(body).await.unwrap_or_default();
9904 let encoded = common::to_string(&bytes);
9905 match serde_json::from_str(&encoded) {
9906 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9907 Err(error) => {
9908 dlg.response_json_decode_error(&encoded, &error);
9909 return Err(common::Error::JsonDecodeError(
9910 encoded.to_string(),
9911 error,
9912 ));
9913 }
9914 }
9915 };
9916
9917 dlg.finished(true);
9918 return Ok(response);
9919 }
9920 }
9921 }
9922 }
9923
9924 /// Required. The metric descriptor on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID] An example value of [METRIC_ID] is "compute.googleapis.com/instance/disk/read_bytes_count".
9925 ///
9926 /// Sets the *name* path property to the given value.
9927 ///
9928 /// Even though the property as already been set when instantiating this call,
9929 /// we provide this method for API completeness.
9930 pub fn name(mut self, new_value: &str) -> ProjectMetricDescriptorGetCall<'a, C> {
9931 self._name = new_value.to_string();
9932 self
9933 }
9934 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9935 /// while executing the actual API request.
9936 ///
9937 /// ````text
9938 /// It should be used to handle progress information, and to implement a certain level of resilience.
9939 /// ````
9940 ///
9941 /// Sets the *delegate* property to the given value.
9942 pub fn delegate(
9943 mut self,
9944 new_value: &'a mut dyn common::Delegate,
9945 ) -> ProjectMetricDescriptorGetCall<'a, C> {
9946 self._delegate = Some(new_value);
9947 self
9948 }
9949
9950 /// Set any additional parameter of the query string used in the request.
9951 /// It should be used to set parameters which are not yet available through their own
9952 /// setters.
9953 ///
9954 /// Please note that this method must not be used to set any of the known parameters
9955 /// which have their own setter method. If done anyway, the request will fail.
9956 ///
9957 /// # Additional Parameters
9958 ///
9959 /// * *$.xgafv* (query-string) - V1 error format.
9960 /// * *access_token* (query-string) - OAuth access token.
9961 /// * *alt* (query-string) - Data format for response.
9962 /// * *callback* (query-string) - JSONP
9963 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9964 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9965 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9966 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9967 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9968 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9969 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9970 pub fn param<T>(mut self, name: T, value: T) -> ProjectMetricDescriptorGetCall<'a, C>
9971 where
9972 T: AsRef<str>,
9973 {
9974 self._additional_params
9975 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9976 self
9977 }
9978
9979 /// Identifies the authorization scope for the method you are building.
9980 ///
9981 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9982 /// [`Scope::CloudPlatform`].
9983 ///
9984 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9985 /// tokens for more than one scope.
9986 ///
9987 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9988 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9989 /// sufficient, a read-write scope will do as well.
9990 pub fn add_scope<St>(mut self, scope: St) -> ProjectMetricDescriptorGetCall<'a, C>
9991 where
9992 St: AsRef<str>,
9993 {
9994 self._scopes.insert(String::from(scope.as_ref()));
9995 self
9996 }
9997 /// Identifies the authorization scope(s) for the method you are building.
9998 ///
9999 /// See [`Self::add_scope()`] for details.
10000 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectMetricDescriptorGetCall<'a, C>
10001 where
10002 I: IntoIterator<Item = St>,
10003 St: AsRef<str>,
10004 {
10005 self._scopes
10006 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10007 self
10008 }
10009
10010 /// Removes all scopes, and no default scope will be used either.
10011 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10012 /// for details).
10013 pub fn clear_scopes(mut self) -> ProjectMetricDescriptorGetCall<'a, C> {
10014 self._scopes.clear();
10015 self
10016 }
10017}
10018
10019/// Lists metric descriptors that match a filter.
10020///
10021/// A builder for the *metricDescriptors.list* method supported by a *project* resource.
10022/// It is not used directly, but through a [`ProjectMethods`] instance.
10023///
10024/// # Example
10025///
10026/// Instantiate a resource method builder
10027///
10028/// ```test_harness,no_run
10029/// # extern crate hyper;
10030/// # extern crate hyper_rustls;
10031/// # extern crate google_monitoring3 as monitoring3;
10032/// # async fn dox() {
10033/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10034///
10035/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10036/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10037/// # secret,
10038/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10039/// # ).build().await.unwrap();
10040///
10041/// # let client = hyper_util::client::legacy::Client::builder(
10042/// # hyper_util::rt::TokioExecutor::new()
10043/// # )
10044/// # .build(
10045/// # hyper_rustls::HttpsConnectorBuilder::new()
10046/// # .with_native_roots()
10047/// # .unwrap()
10048/// # .https_or_http()
10049/// # .enable_http1()
10050/// # .build()
10051/// # );
10052/// # let mut hub = Monitoring::new(client, auth);
10053/// // You can configure optional parameters by calling the respective setters at will, and
10054/// // execute the final call using `doit()`.
10055/// // Values shown here are possibly random and not representative !
10056/// let result = hub.projects().metric_descriptors_list("name")
10057/// .page_token("voluptua.")
10058/// .page_size(-72)
10059/// .filter("erat")
10060/// .doit().await;
10061/// # }
10062/// ```
10063pub struct ProjectMetricDescriptorListCall<'a, C>
10064where
10065 C: 'a,
10066{
10067 hub: &'a Monitoring<C>,
10068 _name: String,
10069 _page_token: Option<String>,
10070 _page_size: Option<i32>,
10071 _filter: Option<String>,
10072 _delegate: Option<&'a mut dyn common::Delegate>,
10073 _additional_params: HashMap<String, String>,
10074 _scopes: BTreeSet<String>,
10075}
10076
10077impl<'a, C> common::CallBuilder for ProjectMetricDescriptorListCall<'a, C> {}
10078
10079impl<'a, C> ProjectMetricDescriptorListCall<'a, C>
10080where
10081 C: common::Connector,
10082{
10083 /// Perform the operation you have build so far.
10084 pub async fn doit(
10085 mut self,
10086 ) -> common::Result<(common::Response, ListMetricDescriptorsResponse)> {
10087 use std::borrow::Cow;
10088 use std::io::{Read, Seek};
10089
10090 use common::{url::Params, ToParts};
10091 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10092
10093 let mut dd = common::DefaultDelegate;
10094 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10095 dlg.begin(common::MethodInfo {
10096 id: "monitoring.projects.metricDescriptors.list",
10097 http_method: hyper::Method::GET,
10098 });
10099
10100 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
10101 if self._additional_params.contains_key(field) {
10102 dlg.finished(false);
10103 return Err(common::Error::FieldClash(field));
10104 }
10105 }
10106
10107 let mut params = Params::with_capacity(6 + self._additional_params.len());
10108 params.push("name", self._name);
10109 if let Some(value) = self._page_token.as_ref() {
10110 params.push("pageToken", value);
10111 }
10112 if let Some(value) = self._page_size.as_ref() {
10113 params.push("pageSize", value.to_string());
10114 }
10115 if let Some(value) = self._filter.as_ref() {
10116 params.push("filter", value);
10117 }
10118
10119 params.extend(self._additional_params.iter());
10120
10121 params.push("alt", "json");
10122 let mut url = self.hub._base_url.clone() + "v3/{+name}/metricDescriptors";
10123 if self._scopes.is_empty() {
10124 self._scopes
10125 .insert(Scope::CloudPlatform.as_ref().to_string());
10126 }
10127
10128 #[allow(clippy::single_element_loop)]
10129 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10130 url = params.uri_replacement(url, param_name, find_this, true);
10131 }
10132 {
10133 let to_remove = ["name"];
10134 params.remove_params(&to_remove);
10135 }
10136
10137 let url = params.parse_with_url(&url);
10138
10139 loop {
10140 let token = match self
10141 .hub
10142 .auth
10143 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10144 .await
10145 {
10146 Ok(token) => token,
10147 Err(e) => match dlg.token(e) {
10148 Ok(token) => token,
10149 Err(e) => {
10150 dlg.finished(false);
10151 return Err(common::Error::MissingToken(e));
10152 }
10153 },
10154 };
10155 let mut req_result = {
10156 let client = &self.hub.client;
10157 dlg.pre_request();
10158 let mut req_builder = hyper::Request::builder()
10159 .method(hyper::Method::GET)
10160 .uri(url.as_str())
10161 .header(USER_AGENT, self.hub._user_agent.clone());
10162
10163 if let Some(token) = token.as_ref() {
10164 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10165 }
10166
10167 let request = req_builder
10168 .header(CONTENT_LENGTH, 0_u64)
10169 .body(common::to_body::<String>(None));
10170
10171 client.request(request.unwrap()).await
10172 };
10173
10174 match req_result {
10175 Err(err) => {
10176 if let common::Retry::After(d) = dlg.http_error(&err) {
10177 sleep(d).await;
10178 continue;
10179 }
10180 dlg.finished(false);
10181 return Err(common::Error::HttpError(err));
10182 }
10183 Ok(res) => {
10184 let (mut parts, body) = res.into_parts();
10185 let mut body = common::Body::new(body);
10186 if !parts.status.is_success() {
10187 let bytes = common::to_bytes(body).await.unwrap_or_default();
10188 let error = serde_json::from_str(&common::to_string(&bytes));
10189 let response = common::to_response(parts, bytes.into());
10190
10191 if let common::Retry::After(d) =
10192 dlg.http_failure(&response, error.as_ref().ok())
10193 {
10194 sleep(d).await;
10195 continue;
10196 }
10197
10198 dlg.finished(false);
10199
10200 return Err(match error {
10201 Ok(value) => common::Error::BadRequest(value),
10202 _ => common::Error::Failure(response),
10203 });
10204 }
10205 let response = {
10206 let bytes = common::to_bytes(body).await.unwrap_or_default();
10207 let encoded = common::to_string(&bytes);
10208 match serde_json::from_str(&encoded) {
10209 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10210 Err(error) => {
10211 dlg.response_json_decode_error(&encoded, &error);
10212 return Err(common::Error::JsonDecodeError(
10213 encoded.to_string(),
10214 error,
10215 ));
10216 }
10217 }
10218 };
10219
10220 dlg.finished(true);
10221 return Ok(response);
10222 }
10223 }
10224 }
10225 }
10226
10227 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
10228 ///
10229 /// Sets the *name* path property to the given value.
10230 ///
10231 /// Even though the property as already been set when instantiating this call,
10232 /// we provide this method for API completeness.
10233 pub fn name(mut self, new_value: &str) -> ProjectMetricDescriptorListCall<'a, C> {
10234 self._name = new_value.to_string();
10235 self
10236 }
10237 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
10238 ///
10239 /// Sets the *page token* query property to the given value.
10240 pub fn page_token(mut self, new_value: &str) -> ProjectMetricDescriptorListCall<'a, C> {
10241 self._page_token = Some(new_value.to_string());
10242 self
10243 }
10244 /// A positive number that is the maximum number of results to return. The default and maximum value is 10,000. If a page_size <= 0 or > 10,000 is submitted, will instead return a maximum of 10,000 results.
10245 ///
10246 /// Sets the *page size* query property to the given value.
10247 pub fn page_size(mut self, new_value: i32) -> ProjectMetricDescriptorListCall<'a, C> {
10248 self._page_size = Some(new_value);
10249 self
10250 }
10251 /// If this field is empty, all custom and system-defined metric descriptors are returned. Otherwise, the filter (https://cloud.google.com/monitoring/api/v3/filters) specifies which metric descriptors are to be returned. For example, the following filter matches all custom metrics (https://cloud.google.com/monitoring/custom-metrics): metric.type = starts_with("custom.googleapis.com/")
10252 ///
10253 /// Sets the *filter* query property to the given value.
10254 pub fn filter(mut self, new_value: &str) -> ProjectMetricDescriptorListCall<'a, C> {
10255 self._filter = Some(new_value.to_string());
10256 self
10257 }
10258 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10259 /// while executing the actual API request.
10260 ///
10261 /// ````text
10262 /// It should be used to handle progress information, and to implement a certain level of resilience.
10263 /// ````
10264 ///
10265 /// Sets the *delegate* property to the given value.
10266 pub fn delegate(
10267 mut self,
10268 new_value: &'a mut dyn common::Delegate,
10269 ) -> ProjectMetricDescriptorListCall<'a, C> {
10270 self._delegate = Some(new_value);
10271 self
10272 }
10273
10274 /// Set any additional parameter of the query string used in the request.
10275 /// It should be used to set parameters which are not yet available through their own
10276 /// setters.
10277 ///
10278 /// Please note that this method must not be used to set any of the known parameters
10279 /// which have their own setter method. If done anyway, the request will fail.
10280 ///
10281 /// # Additional Parameters
10282 ///
10283 /// * *$.xgafv* (query-string) - V1 error format.
10284 /// * *access_token* (query-string) - OAuth access token.
10285 /// * *alt* (query-string) - Data format for response.
10286 /// * *callback* (query-string) - JSONP
10287 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10288 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10289 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10290 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10291 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10292 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10293 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10294 pub fn param<T>(mut self, name: T, value: T) -> ProjectMetricDescriptorListCall<'a, C>
10295 where
10296 T: AsRef<str>,
10297 {
10298 self._additional_params
10299 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10300 self
10301 }
10302
10303 /// Identifies the authorization scope for the method you are building.
10304 ///
10305 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10306 /// [`Scope::CloudPlatform`].
10307 ///
10308 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10309 /// tokens for more than one scope.
10310 ///
10311 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10312 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10313 /// sufficient, a read-write scope will do as well.
10314 pub fn add_scope<St>(mut self, scope: St) -> ProjectMetricDescriptorListCall<'a, C>
10315 where
10316 St: AsRef<str>,
10317 {
10318 self._scopes.insert(String::from(scope.as_ref()));
10319 self
10320 }
10321 /// Identifies the authorization scope(s) for the method you are building.
10322 ///
10323 /// See [`Self::add_scope()`] for details.
10324 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectMetricDescriptorListCall<'a, C>
10325 where
10326 I: IntoIterator<Item = St>,
10327 St: AsRef<str>,
10328 {
10329 self._scopes
10330 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10331 self
10332 }
10333
10334 /// Removes all scopes, and no default scope will be used either.
10335 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10336 /// for details).
10337 pub fn clear_scopes(mut self) -> ProjectMetricDescriptorListCall<'a, C> {
10338 self._scopes.clear();
10339 self
10340 }
10341}
10342
10343/// Gets a single monitored resource descriptor.
10344///
10345/// A builder for the *monitoredResourceDescriptors.get* method supported by a *project* resource.
10346/// It is not used directly, but through a [`ProjectMethods`] instance.
10347///
10348/// # Example
10349///
10350/// Instantiate a resource method builder
10351///
10352/// ```test_harness,no_run
10353/// # extern crate hyper;
10354/// # extern crate hyper_rustls;
10355/// # extern crate google_monitoring3 as monitoring3;
10356/// # async fn dox() {
10357/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10358///
10359/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10360/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10361/// # secret,
10362/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10363/// # ).build().await.unwrap();
10364///
10365/// # let client = hyper_util::client::legacy::Client::builder(
10366/// # hyper_util::rt::TokioExecutor::new()
10367/// # )
10368/// # .build(
10369/// # hyper_rustls::HttpsConnectorBuilder::new()
10370/// # .with_native_roots()
10371/// # .unwrap()
10372/// # .https_or_http()
10373/// # .enable_http1()
10374/// # .build()
10375/// # );
10376/// # let mut hub = Monitoring::new(client, auth);
10377/// // You can configure optional parameters by calling the respective setters at will, and
10378/// // execute the final call using `doit()`.
10379/// // Values shown here are possibly random and not representative !
10380/// let result = hub.projects().monitored_resource_descriptors_get("name")
10381/// .doit().await;
10382/// # }
10383/// ```
10384pub struct ProjectMonitoredResourceDescriptorGetCall<'a, C>
10385where
10386 C: 'a,
10387{
10388 hub: &'a Monitoring<C>,
10389 _name: String,
10390 _delegate: Option<&'a mut dyn common::Delegate>,
10391 _additional_params: HashMap<String, String>,
10392 _scopes: BTreeSet<String>,
10393}
10394
10395impl<'a, C> common::CallBuilder for ProjectMonitoredResourceDescriptorGetCall<'a, C> {}
10396
10397impl<'a, C> ProjectMonitoredResourceDescriptorGetCall<'a, C>
10398where
10399 C: common::Connector,
10400{
10401 /// Perform the operation you have build so far.
10402 pub async fn doit(mut self) -> common::Result<(common::Response, MonitoredResourceDescriptor)> {
10403 use std::borrow::Cow;
10404 use std::io::{Read, Seek};
10405
10406 use common::{url::Params, ToParts};
10407 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10408
10409 let mut dd = common::DefaultDelegate;
10410 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10411 dlg.begin(common::MethodInfo {
10412 id: "monitoring.projects.monitoredResourceDescriptors.get",
10413 http_method: hyper::Method::GET,
10414 });
10415
10416 for &field in ["alt", "name"].iter() {
10417 if self._additional_params.contains_key(field) {
10418 dlg.finished(false);
10419 return Err(common::Error::FieldClash(field));
10420 }
10421 }
10422
10423 let mut params = Params::with_capacity(3 + self._additional_params.len());
10424 params.push("name", self._name);
10425
10426 params.extend(self._additional_params.iter());
10427
10428 params.push("alt", "json");
10429 let mut url = self.hub._base_url.clone() + "v3/{+name}";
10430 if self._scopes.is_empty() {
10431 self._scopes
10432 .insert(Scope::CloudPlatform.as_ref().to_string());
10433 }
10434
10435 #[allow(clippy::single_element_loop)]
10436 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10437 url = params.uri_replacement(url, param_name, find_this, true);
10438 }
10439 {
10440 let to_remove = ["name"];
10441 params.remove_params(&to_remove);
10442 }
10443
10444 let url = params.parse_with_url(&url);
10445
10446 loop {
10447 let token = match self
10448 .hub
10449 .auth
10450 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10451 .await
10452 {
10453 Ok(token) => token,
10454 Err(e) => match dlg.token(e) {
10455 Ok(token) => token,
10456 Err(e) => {
10457 dlg.finished(false);
10458 return Err(common::Error::MissingToken(e));
10459 }
10460 },
10461 };
10462 let mut req_result = {
10463 let client = &self.hub.client;
10464 dlg.pre_request();
10465 let mut req_builder = hyper::Request::builder()
10466 .method(hyper::Method::GET)
10467 .uri(url.as_str())
10468 .header(USER_AGENT, self.hub._user_agent.clone());
10469
10470 if let Some(token) = token.as_ref() {
10471 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10472 }
10473
10474 let request = req_builder
10475 .header(CONTENT_LENGTH, 0_u64)
10476 .body(common::to_body::<String>(None));
10477
10478 client.request(request.unwrap()).await
10479 };
10480
10481 match req_result {
10482 Err(err) => {
10483 if let common::Retry::After(d) = dlg.http_error(&err) {
10484 sleep(d).await;
10485 continue;
10486 }
10487 dlg.finished(false);
10488 return Err(common::Error::HttpError(err));
10489 }
10490 Ok(res) => {
10491 let (mut parts, body) = res.into_parts();
10492 let mut body = common::Body::new(body);
10493 if !parts.status.is_success() {
10494 let bytes = common::to_bytes(body).await.unwrap_or_default();
10495 let error = serde_json::from_str(&common::to_string(&bytes));
10496 let response = common::to_response(parts, bytes.into());
10497
10498 if let common::Retry::After(d) =
10499 dlg.http_failure(&response, error.as_ref().ok())
10500 {
10501 sleep(d).await;
10502 continue;
10503 }
10504
10505 dlg.finished(false);
10506
10507 return Err(match error {
10508 Ok(value) => common::Error::BadRequest(value),
10509 _ => common::Error::Failure(response),
10510 });
10511 }
10512 let response = {
10513 let bytes = common::to_bytes(body).await.unwrap_or_default();
10514 let encoded = common::to_string(&bytes);
10515 match serde_json::from_str(&encoded) {
10516 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10517 Err(error) => {
10518 dlg.response_json_decode_error(&encoded, &error);
10519 return Err(common::Error::JsonDecodeError(
10520 encoded.to_string(),
10521 error,
10522 ));
10523 }
10524 }
10525 };
10526
10527 dlg.finished(true);
10528 return Ok(response);
10529 }
10530 }
10531 }
10532 }
10533
10534 /// Required. The monitored resource descriptor to get. The format is: projects/[PROJECT_ID_OR_NUMBER]/monitoredResourceDescriptors/[RESOURCE_TYPE] The [RESOURCE_TYPE] is a predefined type, such as cloudsql_database.
10535 ///
10536 /// Sets the *name* path property to the given value.
10537 ///
10538 /// Even though the property as already been set when instantiating this call,
10539 /// we provide this method for API completeness.
10540 pub fn name(mut self, new_value: &str) -> ProjectMonitoredResourceDescriptorGetCall<'a, C> {
10541 self._name = new_value.to_string();
10542 self
10543 }
10544 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10545 /// while executing the actual API request.
10546 ///
10547 /// ````text
10548 /// It should be used to handle progress information, and to implement a certain level of resilience.
10549 /// ````
10550 ///
10551 /// Sets the *delegate* property to the given value.
10552 pub fn delegate(
10553 mut self,
10554 new_value: &'a mut dyn common::Delegate,
10555 ) -> ProjectMonitoredResourceDescriptorGetCall<'a, C> {
10556 self._delegate = Some(new_value);
10557 self
10558 }
10559
10560 /// Set any additional parameter of the query string used in the request.
10561 /// It should be used to set parameters which are not yet available through their own
10562 /// setters.
10563 ///
10564 /// Please note that this method must not be used to set any of the known parameters
10565 /// which have their own setter method. If done anyway, the request will fail.
10566 ///
10567 /// # Additional Parameters
10568 ///
10569 /// * *$.xgafv* (query-string) - V1 error format.
10570 /// * *access_token* (query-string) - OAuth access token.
10571 /// * *alt* (query-string) - Data format for response.
10572 /// * *callback* (query-string) - JSONP
10573 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10574 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10575 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10576 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10577 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10578 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10579 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10580 pub fn param<T>(mut self, name: T, value: T) -> ProjectMonitoredResourceDescriptorGetCall<'a, C>
10581 where
10582 T: AsRef<str>,
10583 {
10584 self._additional_params
10585 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10586 self
10587 }
10588
10589 /// Identifies the authorization scope for the method you are building.
10590 ///
10591 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10592 /// [`Scope::CloudPlatform`].
10593 ///
10594 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10595 /// tokens for more than one scope.
10596 ///
10597 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10598 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10599 /// sufficient, a read-write scope will do as well.
10600 pub fn add_scope<St>(mut self, scope: St) -> ProjectMonitoredResourceDescriptorGetCall<'a, C>
10601 where
10602 St: AsRef<str>,
10603 {
10604 self._scopes.insert(String::from(scope.as_ref()));
10605 self
10606 }
10607 /// Identifies the authorization scope(s) for the method you are building.
10608 ///
10609 /// See [`Self::add_scope()`] for details.
10610 pub fn add_scopes<I, St>(
10611 mut self,
10612 scopes: I,
10613 ) -> ProjectMonitoredResourceDescriptorGetCall<'a, C>
10614 where
10615 I: IntoIterator<Item = St>,
10616 St: AsRef<str>,
10617 {
10618 self._scopes
10619 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10620 self
10621 }
10622
10623 /// Removes all scopes, and no default scope will be used either.
10624 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10625 /// for details).
10626 pub fn clear_scopes(mut self) -> ProjectMonitoredResourceDescriptorGetCall<'a, C> {
10627 self._scopes.clear();
10628 self
10629 }
10630}
10631
10632/// Lists monitored resource descriptors that match a filter.
10633///
10634/// A builder for the *monitoredResourceDescriptors.list* method supported by a *project* resource.
10635/// It is not used directly, but through a [`ProjectMethods`] instance.
10636///
10637/// # Example
10638///
10639/// Instantiate a resource method builder
10640///
10641/// ```test_harness,no_run
10642/// # extern crate hyper;
10643/// # extern crate hyper_rustls;
10644/// # extern crate google_monitoring3 as monitoring3;
10645/// # async fn dox() {
10646/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10647///
10648/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10649/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10650/// # secret,
10651/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10652/// # ).build().await.unwrap();
10653///
10654/// # let client = hyper_util::client::legacy::Client::builder(
10655/// # hyper_util::rt::TokioExecutor::new()
10656/// # )
10657/// # .build(
10658/// # hyper_rustls::HttpsConnectorBuilder::new()
10659/// # .with_native_roots()
10660/// # .unwrap()
10661/// # .https_or_http()
10662/// # .enable_http1()
10663/// # .build()
10664/// # );
10665/// # let mut hub = Monitoring::new(client, auth);
10666/// // You can configure optional parameters by calling the respective setters at will, and
10667/// // execute the final call using `doit()`.
10668/// // Values shown here are possibly random and not representative !
10669/// let result = hub.projects().monitored_resource_descriptors_list("name")
10670/// .page_token("sed")
10671/// .page_size(-9)
10672/// .filter("dolores")
10673/// .doit().await;
10674/// # }
10675/// ```
10676pub struct ProjectMonitoredResourceDescriptorListCall<'a, C>
10677where
10678 C: 'a,
10679{
10680 hub: &'a Monitoring<C>,
10681 _name: String,
10682 _page_token: Option<String>,
10683 _page_size: Option<i32>,
10684 _filter: Option<String>,
10685 _delegate: Option<&'a mut dyn common::Delegate>,
10686 _additional_params: HashMap<String, String>,
10687 _scopes: BTreeSet<String>,
10688}
10689
10690impl<'a, C> common::CallBuilder for ProjectMonitoredResourceDescriptorListCall<'a, C> {}
10691
10692impl<'a, C> ProjectMonitoredResourceDescriptorListCall<'a, C>
10693where
10694 C: common::Connector,
10695{
10696 /// Perform the operation you have build so far.
10697 pub async fn doit(
10698 mut self,
10699 ) -> common::Result<(common::Response, ListMonitoredResourceDescriptorsResponse)> {
10700 use std::borrow::Cow;
10701 use std::io::{Read, Seek};
10702
10703 use common::{url::Params, ToParts};
10704 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10705
10706 let mut dd = common::DefaultDelegate;
10707 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10708 dlg.begin(common::MethodInfo {
10709 id: "monitoring.projects.monitoredResourceDescriptors.list",
10710 http_method: hyper::Method::GET,
10711 });
10712
10713 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
10714 if self._additional_params.contains_key(field) {
10715 dlg.finished(false);
10716 return Err(common::Error::FieldClash(field));
10717 }
10718 }
10719
10720 let mut params = Params::with_capacity(6 + self._additional_params.len());
10721 params.push("name", self._name);
10722 if let Some(value) = self._page_token.as_ref() {
10723 params.push("pageToken", value);
10724 }
10725 if let Some(value) = self._page_size.as_ref() {
10726 params.push("pageSize", value.to_string());
10727 }
10728 if let Some(value) = self._filter.as_ref() {
10729 params.push("filter", value);
10730 }
10731
10732 params.extend(self._additional_params.iter());
10733
10734 params.push("alt", "json");
10735 let mut url = self.hub._base_url.clone() + "v3/{+name}/monitoredResourceDescriptors";
10736 if self._scopes.is_empty() {
10737 self._scopes
10738 .insert(Scope::CloudPlatform.as_ref().to_string());
10739 }
10740
10741 #[allow(clippy::single_element_loop)]
10742 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10743 url = params.uri_replacement(url, param_name, find_this, true);
10744 }
10745 {
10746 let to_remove = ["name"];
10747 params.remove_params(&to_remove);
10748 }
10749
10750 let url = params.parse_with_url(&url);
10751
10752 loop {
10753 let token = match self
10754 .hub
10755 .auth
10756 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10757 .await
10758 {
10759 Ok(token) => token,
10760 Err(e) => match dlg.token(e) {
10761 Ok(token) => token,
10762 Err(e) => {
10763 dlg.finished(false);
10764 return Err(common::Error::MissingToken(e));
10765 }
10766 },
10767 };
10768 let mut req_result = {
10769 let client = &self.hub.client;
10770 dlg.pre_request();
10771 let mut req_builder = hyper::Request::builder()
10772 .method(hyper::Method::GET)
10773 .uri(url.as_str())
10774 .header(USER_AGENT, self.hub._user_agent.clone());
10775
10776 if let Some(token) = token.as_ref() {
10777 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10778 }
10779
10780 let request = req_builder
10781 .header(CONTENT_LENGTH, 0_u64)
10782 .body(common::to_body::<String>(None));
10783
10784 client.request(request.unwrap()).await
10785 };
10786
10787 match req_result {
10788 Err(err) => {
10789 if let common::Retry::After(d) = dlg.http_error(&err) {
10790 sleep(d).await;
10791 continue;
10792 }
10793 dlg.finished(false);
10794 return Err(common::Error::HttpError(err));
10795 }
10796 Ok(res) => {
10797 let (mut parts, body) = res.into_parts();
10798 let mut body = common::Body::new(body);
10799 if !parts.status.is_success() {
10800 let bytes = common::to_bytes(body).await.unwrap_or_default();
10801 let error = serde_json::from_str(&common::to_string(&bytes));
10802 let response = common::to_response(parts, bytes.into());
10803
10804 if let common::Retry::After(d) =
10805 dlg.http_failure(&response, error.as_ref().ok())
10806 {
10807 sleep(d).await;
10808 continue;
10809 }
10810
10811 dlg.finished(false);
10812
10813 return Err(match error {
10814 Ok(value) => common::Error::BadRequest(value),
10815 _ => common::Error::Failure(response),
10816 });
10817 }
10818 let response = {
10819 let bytes = common::to_bytes(body).await.unwrap_or_default();
10820 let encoded = common::to_string(&bytes);
10821 match serde_json::from_str(&encoded) {
10822 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10823 Err(error) => {
10824 dlg.response_json_decode_error(&encoded, &error);
10825 return Err(common::Error::JsonDecodeError(
10826 encoded.to_string(),
10827 error,
10828 ));
10829 }
10830 }
10831 };
10832
10833 dlg.finished(true);
10834 return Ok(response);
10835 }
10836 }
10837 }
10838 }
10839
10840 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
10841 ///
10842 /// Sets the *name* path property to the given value.
10843 ///
10844 /// Even though the property as already been set when instantiating this call,
10845 /// we provide this method for API completeness.
10846 pub fn name(mut self, new_value: &str) -> ProjectMonitoredResourceDescriptorListCall<'a, C> {
10847 self._name = new_value.to_string();
10848 self
10849 }
10850 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
10851 ///
10852 /// Sets the *page token* query property to the given value.
10853 pub fn page_token(
10854 mut self,
10855 new_value: &str,
10856 ) -> ProjectMonitoredResourceDescriptorListCall<'a, C> {
10857 self._page_token = Some(new_value.to_string());
10858 self
10859 }
10860 /// A positive number that is the maximum number of results to return.
10861 ///
10862 /// Sets the *page size* query property to the given value.
10863 pub fn page_size(
10864 mut self,
10865 new_value: i32,
10866 ) -> ProjectMonitoredResourceDescriptorListCall<'a, C> {
10867 self._page_size = Some(new_value);
10868 self
10869 }
10870 /// An optional filter (https://cloud.google.com/monitoring/api/v3/filters) describing the descriptors to be returned. The filter can reference the descriptor's type and labels. For example, the following filter returns only Google Compute Engine descriptors that have an id label: resource.type = starts_with("gce_") AND resource.label:id
10871 ///
10872 /// Sets the *filter* query property to the given value.
10873 pub fn filter(mut self, new_value: &str) -> ProjectMonitoredResourceDescriptorListCall<'a, C> {
10874 self._filter = Some(new_value.to_string());
10875 self
10876 }
10877 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10878 /// while executing the actual API request.
10879 ///
10880 /// ````text
10881 /// It should be used to handle progress information, and to implement a certain level of resilience.
10882 /// ````
10883 ///
10884 /// Sets the *delegate* property to the given value.
10885 pub fn delegate(
10886 mut self,
10887 new_value: &'a mut dyn common::Delegate,
10888 ) -> ProjectMonitoredResourceDescriptorListCall<'a, C> {
10889 self._delegate = Some(new_value);
10890 self
10891 }
10892
10893 /// Set any additional parameter of the query string used in the request.
10894 /// It should be used to set parameters which are not yet available through their own
10895 /// setters.
10896 ///
10897 /// Please note that this method must not be used to set any of the known parameters
10898 /// which have their own setter method. If done anyway, the request will fail.
10899 ///
10900 /// # Additional Parameters
10901 ///
10902 /// * *$.xgafv* (query-string) - V1 error format.
10903 /// * *access_token* (query-string) - OAuth access token.
10904 /// * *alt* (query-string) - Data format for response.
10905 /// * *callback* (query-string) - JSONP
10906 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10907 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10908 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10909 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10910 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10911 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10912 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10913 pub fn param<T>(
10914 mut self,
10915 name: T,
10916 value: T,
10917 ) -> ProjectMonitoredResourceDescriptorListCall<'a, C>
10918 where
10919 T: AsRef<str>,
10920 {
10921 self._additional_params
10922 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10923 self
10924 }
10925
10926 /// Identifies the authorization scope for the method you are building.
10927 ///
10928 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10929 /// [`Scope::CloudPlatform`].
10930 ///
10931 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10932 /// tokens for more than one scope.
10933 ///
10934 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10935 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10936 /// sufficient, a read-write scope will do as well.
10937 pub fn add_scope<St>(mut self, scope: St) -> ProjectMonitoredResourceDescriptorListCall<'a, C>
10938 where
10939 St: AsRef<str>,
10940 {
10941 self._scopes.insert(String::from(scope.as_ref()));
10942 self
10943 }
10944 /// Identifies the authorization scope(s) for the method you are building.
10945 ///
10946 /// See [`Self::add_scope()`] for details.
10947 pub fn add_scopes<I, St>(
10948 mut self,
10949 scopes: I,
10950 ) -> ProjectMonitoredResourceDescriptorListCall<'a, C>
10951 where
10952 I: IntoIterator<Item = St>,
10953 St: AsRef<str>,
10954 {
10955 self._scopes
10956 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10957 self
10958 }
10959
10960 /// Removes all scopes, and no default scope will be used either.
10961 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10962 /// for details).
10963 pub fn clear_scopes(mut self) -> ProjectMonitoredResourceDescriptorListCall<'a, C> {
10964 self._scopes.clear();
10965 self
10966 }
10967}
10968
10969/// Gets a single channel descriptor. The descriptor indicates which fields are expected / permitted for a notification channel of the given type.
10970///
10971/// A builder for the *notificationChannelDescriptors.get* method supported by a *project* resource.
10972/// It is not used directly, but through a [`ProjectMethods`] instance.
10973///
10974/// # Example
10975///
10976/// Instantiate a resource method builder
10977///
10978/// ```test_harness,no_run
10979/// # extern crate hyper;
10980/// # extern crate hyper_rustls;
10981/// # extern crate google_monitoring3 as monitoring3;
10982/// # async fn dox() {
10983/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10984///
10985/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10986/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10987/// # secret,
10988/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10989/// # ).build().await.unwrap();
10990///
10991/// # let client = hyper_util::client::legacy::Client::builder(
10992/// # hyper_util::rt::TokioExecutor::new()
10993/// # )
10994/// # .build(
10995/// # hyper_rustls::HttpsConnectorBuilder::new()
10996/// # .with_native_roots()
10997/// # .unwrap()
10998/// # .https_or_http()
10999/// # .enable_http1()
11000/// # .build()
11001/// # );
11002/// # let mut hub = Monitoring::new(client, auth);
11003/// // You can configure optional parameters by calling the respective setters at will, and
11004/// // execute the final call using `doit()`.
11005/// // Values shown here are possibly random and not representative !
11006/// let result = hub.projects().notification_channel_descriptors_get("name")
11007/// .doit().await;
11008/// # }
11009/// ```
11010pub struct ProjectNotificationChannelDescriptorGetCall<'a, C>
11011where
11012 C: 'a,
11013{
11014 hub: &'a Monitoring<C>,
11015 _name: String,
11016 _delegate: Option<&'a mut dyn common::Delegate>,
11017 _additional_params: HashMap<String, String>,
11018 _scopes: BTreeSet<String>,
11019}
11020
11021impl<'a, C> common::CallBuilder for ProjectNotificationChannelDescriptorGetCall<'a, C> {}
11022
11023impl<'a, C> ProjectNotificationChannelDescriptorGetCall<'a, C>
11024where
11025 C: common::Connector,
11026{
11027 /// Perform the operation you have build so far.
11028 pub async fn doit(
11029 mut self,
11030 ) -> common::Result<(common::Response, NotificationChannelDescriptor)> {
11031 use std::borrow::Cow;
11032 use std::io::{Read, Seek};
11033
11034 use common::{url::Params, ToParts};
11035 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11036
11037 let mut dd = common::DefaultDelegate;
11038 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11039 dlg.begin(common::MethodInfo {
11040 id: "monitoring.projects.notificationChannelDescriptors.get",
11041 http_method: hyper::Method::GET,
11042 });
11043
11044 for &field in ["alt", "name"].iter() {
11045 if self._additional_params.contains_key(field) {
11046 dlg.finished(false);
11047 return Err(common::Error::FieldClash(field));
11048 }
11049 }
11050
11051 let mut params = Params::with_capacity(3 + self._additional_params.len());
11052 params.push("name", self._name);
11053
11054 params.extend(self._additional_params.iter());
11055
11056 params.push("alt", "json");
11057 let mut url = self.hub._base_url.clone() + "v3/{+name}";
11058 if self._scopes.is_empty() {
11059 self._scopes
11060 .insert(Scope::CloudPlatform.as_ref().to_string());
11061 }
11062
11063 #[allow(clippy::single_element_loop)]
11064 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11065 url = params.uri_replacement(url, param_name, find_this, true);
11066 }
11067 {
11068 let to_remove = ["name"];
11069 params.remove_params(&to_remove);
11070 }
11071
11072 let url = params.parse_with_url(&url);
11073
11074 loop {
11075 let token = match self
11076 .hub
11077 .auth
11078 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11079 .await
11080 {
11081 Ok(token) => token,
11082 Err(e) => match dlg.token(e) {
11083 Ok(token) => token,
11084 Err(e) => {
11085 dlg.finished(false);
11086 return Err(common::Error::MissingToken(e));
11087 }
11088 },
11089 };
11090 let mut req_result = {
11091 let client = &self.hub.client;
11092 dlg.pre_request();
11093 let mut req_builder = hyper::Request::builder()
11094 .method(hyper::Method::GET)
11095 .uri(url.as_str())
11096 .header(USER_AGENT, self.hub._user_agent.clone());
11097
11098 if let Some(token) = token.as_ref() {
11099 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11100 }
11101
11102 let request = req_builder
11103 .header(CONTENT_LENGTH, 0_u64)
11104 .body(common::to_body::<String>(None));
11105
11106 client.request(request.unwrap()).await
11107 };
11108
11109 match req_result {
11110 Err(err) => {
11111 if let common::Retry::After(d) = dlg.http_error(&err) {
11112 sleep(d).await;
11113 continue;
11114 }
11115 dlg.finished(false);
11116 return Err(common::Error::HttpError(err));
11117 }
11118 Ok(res) => {
11119 let (mut parts, body) = res.into_parts();
11120 let mut body = common::Body::new(body);
11121 if !parts.status.is_success() {
11122 let bytes = common::to_bytes(body).await.unwrap_or_default();
11123 let error = serde_json::from_str(&common::to_string(&bytes));
11124 let response = common::to_response(parts, bytes.into());
11125
11126 if let common::Retry::After(d) =
11127 dlg.http_failure(&response, error.as_ref().ok())
11128 {
11129 sleep(d).await;
11130 continue;
11131 }
11132
11133 dlg.finished(false);
11134
11135 return Err(match error {
11136 Ok(value) => common::Error::BadRequest(value),
11137 _ => common::Error::Failure(response),
11138 });
11139 }
11140 let response = {
11141 let bytes = common::to_bytes(body).await.unwrap_or_default();
11142 let encoded = common::to_string(&bytes);
11143 match serde_json::from_str(&encoded) {
11144 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11145 Err(error) => {
11146 dlg.response_json_decode_error(&encoded, &error);
11147 return Err(common::Error::JsonDecodeError(
11148 encoded.to_string(),
11149 error,
11150 ));
11151 }
11152 }
11153 };
11154
11155 dlg.finished(true);
11156 return Ok(response);
11157 }
11158 }
11159 }
11160 }
11161
11162 /// Required. The channel type for which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannelDescriptors/[CHANNEL_TYPE]
11163 ///
11164 /// Sets the *name* path property to the given value.
11165 ///
11166 /// Even though the property as already been set when instantiating this call,
11167 /// we provide this method for API completeness.
11168 pub fn name(mut self, new_value: &str) -> ProjectNotificationChannelDescriptorGetCall<'a, C> {
11169 self._name = new_value.to_string();
11170 self
11171 }
11172 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11173 /// while executing the actual API request.
11174 ///
11175 /// ````text
11176 /// It should be used to handle progress information, and to implement a certain level of resilience.
11177 /// ````
11178 ///
11179 /// Sets the *delegate* property to the given value.
11180 pub fn delegate(
11181 mut self,
11182 new_value: &'a mut dyn common::Delegate,
11183 ) -> ProjectNotificationChannelDescriptorGetCall<'a, C> {
11184 self._delegate = Some(new_value);
11185 self
11186 }
11187
11188 /// Set any additional parameter of the query string used in the request.
11189 /// It should be used to set parameters which are not yet available through their own
11190 /// setters.
11191 ///
11192 /// Please note that this method must not be used to set any of the known parameters
11193 /// which have their own setter method. If done anyway, the request will fail.
11194 ///
11195 /// # Additional Parameters
11196 ///
11197 /// * *$.xgafv* (query-string) - V1 error format.
11198 /// * *access_token* (query-string) - OAuth access token.
11199 /// * *alt* (query-string) - Data format for response.
11200 /// * *callback* (query-string) - JSONP
11201 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11202 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11203 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11204 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11205 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11206 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11207 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11208 pub fn param<T>(
11209 mut self,
11210 name: T,
11211 value: T,
11212 ) -> ProjectNotificationChannelDescriptorGetCall<'a, C>
11213 where
11214 T: AsRef<str>,
11215 {
11216 self._additional_params
11217 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11218 self
11219 }
11220
11221 /// Identifies the authorization scope for the method you are building.
11222 ///
11223 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11224 /// [`Scope::CloudPlatform`].
11225 ///
11226 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11227 /// tokens for more than one scope.
11228 ///
11229 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11230 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11231 /// sufficient, a read-write scope will do as well.
11232 pub fn add_scope<St>(mut self, scope: St) -> ProjectNotificationChannelDescriptorGetCall<'a, C>
11233 where
11234 St: AsRef<str>,
11235 {
11236 self._scopes.insert(String::from(scope.as_ref()));
11237 self
11238 }
11239 /// Identifies the authorization scope(s) for the method you are building.
11240 ///
11241 /// See [`Self::add_scope()`] for details.
11242 pub fn add_scopes<I, St>(
11243 mut self,
11244 scopes: I,
11245 ) -> ProjectNotificationChannelDescriptorGetCall<'a, C>
11246 where
11247 I: IntoIterator<Item = St>,
11248 St: AsRef<str>,
11249 {
11250 self._scopes
11251 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11252 self
11253 }
11254
11255 /// Removes all scopes, and no default scope will be used either.
11256 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11257 /// for details).
11258 pub fn clear_scopes(mut self) -> ProjectNotificationChannelDescriptorGetCall<'a, C> {
11259 self._scopes.clear();
11260 self
11261 }
11262}
11263
11264/// Lists the descriptors for supported channel types. The use of descriptors makes it possible for new channel types to be dynamically added.
11265///
11266/// A builder for the *notificationChannelDescriptors.list* method supported by a *project* resource.
11267/// It is not used directly, but through a [`ProjectMethods`] instance.
11268///
11269/// # Example
11270///
11271/// Instantiate a resource method builder
11272///
11273/// ```test_harness,no_run
11274/// # extern crate hyper;
11275/// # extern crate hyper_rustls;
11276/// # extern crate google_monitoring3 as monitoring3;
11277/// # async fn dox() {
11278/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11279///
11280/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11281/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11282/// # secret,
11283/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11284/// # ).build().await.unwrap();
11285///
11286/// # let client = hyper_util::client::legacy::Client::builder(
11287/// # hyper_util::rt::TokioExecutor::new()
11288/// # )
11289/// # .build(
11290/// # hyper_rustls::HttpsConnectorBuilder::new()
11291/// # .with_native_roots()
11292/// # .unwrap()
11293/// # .https_or_http()
11294/// # .enable_http1()
11295/// # .build()
11296/// # );
11297/// # let mut hub = Monitoring::new(client, auth);
11298/// // You can configure optional parameters by calling the respective setters at will, and
11299/// // execute the final call using `doit()`.
11300/// // Values shown here are possibly random and not representative !
11301/// let result = hub.projects().notification_channel_descriptors_list("name")
11302/// .page_token("accusam")
11303/// .page_size(-78)
11304/// .doit().await;
11305/// # }
11306/// ```
11307pub struct ProjectNotificationChannelDescriptorListCall<'a, C>
11308where
11309 C: 'a,
11310{
11311 hub: &'a Monitoring<C>,
11312 _name: String,
11313 _page_token: Option<String>,
11314 _page_size: Option<i32>,
11315 _delegate: Option<&'a mut dyn common::Delegate>,
11316 _additional_params: HashMap<String, String>,
11317 _scopes: BTreeSet<String>,
11318}
11319
11320impl<'a, C> common::CallBuilder for ProjectNotificationChannelDescriptorListCall<'a, C> {}
11321
11322impl<'a, C> ProjectNotificationChannelDescriptorListCall<'a, C>
11323where
11324 C: common::Connector,
11325{
11326 /// Perform the operation you have build so far.
11327 pub async fn doit(
11328 mut self,
11329 ) -> common::Result<(common::Response, ListNotificationChannelDescriptorsResponse)> {
11330 use std::borrow::Cow;
11331 use std::io::{Read, Seek};
11332
11333 use common::{url::Params, ToParts};
11334 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11335
11336 let mut dd = common::DefaultDelegate;
11337 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11338 dlg.begin(common::MethodInfo {
11339 id: "monitoring.projects.notificationChannelDescriptors.list",
11340 http_method: hyper::Method::GET,
11341 });
11342
11343 for &field in ["alt", "name", "pageToken", "pageSize"].iter() {
11344 if self._additional_params.contains_key(field) {
11345 dlg.finished(false);
11346 return Err(common::Error::FieldClash(field));
11347 }
11348 }
11349
11350 let mut params = Params::with_capacity(5 + self._additional_params.len());
11351 params.push("name", self._name);
11352 if let Some(value) = self._page_token.as_ref() {
11353 params.push("pageToken", value);
11354 }
11355 if let Some(value) = self._page_size.as_ref() {
11356 params.push("pageSize", value.to_string());
11357 }
11358
11359 params.extend(self._additional_params.iter());
11360
11361 params.push("alt", "json");
11362 let mut url = self.hub._base_url.clone() + "v3/{+name}/notificationChannelDescriptors";
11363 if self._scopes.is_empty() {
11364 self._scopes
11365 .insert(Scope::CloudPlatform.as_ref().to_string());
11366 }
11367
11368 #[allow(clippy::single_element_loop)]
11369 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11370 url = params.uri_replacement(url, param_name, find_this, true);
11371 }
11372 {
11373 let to_remove = ["name"];
11374 params.remove_params(&to_remove);
11375 }
11376
11377 let url = params.parse_with_url(&url);
11378
11379 loop {
11380 let token = match self
11381 .hub
11382 .auth
11383 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11384 .await
11385 {
11386 Ok(token) => token,
11387 Err(e) => match dlg.token(e) {
11388 Ok(token) => token,
11389 Err(e) => {
11390 dlg.finished(false);
11391 return Err(common::Error::MissingToken(e));
11392 }
11393 },
11394 };
11395 let mut req_result = {
11396 let client = &self.hub.client;
11397 dlg.pre_request();
11398 let mut req_builder = hyper::Request::builder()
11399 .method(hyper::Method::GET)
11400 .uri(url.as_str())
11401 .header(USER_AGENT, self.hub._user_agent.clone());
11402
11403 if let Some(token) = token.as_ref() {
11404 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11405 }
11406
11407 let request = req_builder
11408 .header(CONTENT_LENGTH, 0_u64)
11409 .body(common::to_body::<String>(None));
11410
11411 client.request(request.unwrap()).await
11412 };
11413
11414 match req_result {
11415 Err(err) => {
11416 if let common::Retry::After(d) = dlg.http_error(&err) {
11417 sleep(d).await;
11418 continue;
11419 }
11420 dlg.finished(false);
11421 return Err(common::Error::HttpError(err));
11422 }
11423 Ok(res) => {
11424 let (mut parts, body) = res.into_parts();
11425 let mut body = common::Body::new(body);
11426 if !parts.status.is_success() {
11427 let bytes = common::to_bytes(body).await.unwrap_or_default();
11428 let error = serde_json::from_str(&common::to_string(&bytes));
11429 let response = common::to_response(parts, bytes.into());
11430
11431 if let common::Retry::After(d) =
11432 dlg.http_failure(&response, error.as_ref().ok())
11433 {
11434 sleep(d).await;
11435 continue;
11436 }
11437
11438 dlg.finished(false);
11439
11440 return Err(match error {
11441 Ok(value) => common::Error::BadRequest(value),
11442 _ => common::Error::Failure(response),
11443 });
11444 }
11445 let response = {
11446 let bytes = common::to_bytes(body).await.unwrap_or_default();
11447 let encoded = common::to_string(&bytes);
11448 match serde_json::from_str(&encoded) {
11449 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11450 Err(error) => {
11451 dlg.response_json_decode_error(&encoded, &error);
11452 return Err(common::Error::JsonDecodeError(
11453 encoded.to_string(),
11454 error,
11455 ));
11456 }
11457 }
11458 };
11459
11460 dlg.finished(true);
11461 return Ok(response);
11462 }
11463 }
11464 }
11465 }
11466
11467 /// Required. The REST resource name of the parent from which to retrieve the notification channel descriptors. The expected syntax is: projects/[PROJECT_ID_OR_NUMBER] Note that this names (https://cloud.google.com/monitoring/api/v3#project_name) the parent container in which to look for the descriptors; to retrieve a single descriptor by name, use the GetNotificationChannelDescriptor operation, instead.
11468 ///
11469 /// Sets the *name* path property to the given value.
11470 ///
11471 /// Even though the property as already been set when instantiating this call,
11472 /// we provide this method for API completeness.
11473 pub fn name(mut self, new_value: &str) -> ProjectNotificationChannelDescriptorListCall<'a, C> {
11474 self._name = new_value.to_string();
11475 self
11476 }
11477 /// If non-empty, page_token must contain a value returned as the next_page_token in a previous response to request the next set of results.
11478 ///
11479 /// Sets the *page token* query property to the given value.
11480 pub fn page_token(
11481 mut self,
11482 new_value: &str,
11483 ) -> ProjectNotificationChannelDescriptorListCall<'a, C> {
11484 self._page_token = Some(new_value.to_string());
11485 self
11486 }
11487 /// The maximum number of results to return in a single response. If not set to a positive number, a reasonable value will be chosen by the service.
11488 ///
11489 /// Sets the *page size* query property to the given value.
11490 pub fn page_size(
11491 mut self,
11492 new_value: i32,
11493 ) -> ProjectNotificationChannelDescriptorListCall<'a, C> {
11494 self._page_size = Some(new_value);
11495 self
11496 }
11497 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11498 /// while executing the actual API request.
11499 ///
11500 /// ````text
11501 /// It should be used to handle progress information, and to implement a certain level of resilience.
11502 /// ````
11503 ///
11504 /// Sets the *delegate* property to the given value.
11505 pub fn delegate(
11506 mut self,
11507 new_value: &'a mut dyn common::Delegate,
11508 ) -> ProjectNotificationChannelDescriptorListCall<'a, C> {
11509 self._delegate = Some(new_value);
11510 self
11511 }
11512
11513 /// Set any additional parameter of the query string used in the request.
11514 /// It should be used to set parameters which are not yet available through their own
11515 /// setters.
11516 ///
11517 /// Please note that this method must not be used to set any of the known parameters
11518 /// which have their own setter method. If done anyway, the request will fail.
11519 ///
11520 /// # Additional Parameters
11521 ///
11522 /// * *$.xgafv* (query-string) - V1 error format.
11523 /// * *access_token* (query-string) - OAuth access token.
11524 /// * *alt* (query-string) - Data format for response.
11525 /// * *callback* (query-string) - JSONP
11526 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11527 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11528 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11529 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11530 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11531 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11532 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11533 pub fn param<T>(
11534 mut self,
11535 name: T,
11536 value: T,
11537 ) -> ProjectNotificationChannelDescriptorListCall<'a, C>
11538 where
11539 T: AsRef<str>,
11540 {
11541 self._additional_params
11542 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11543 self
11544 }
11545
11546 /// Identifies the authorization scope for the method you are building.
11547 ///
11548 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11549 /// [`Scope::CloudPlatform`].
11550 ///
11551 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11552 /// tokens for more than one scope.
11553 ///
11554 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11555 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11556 /// sufficient, a read-write scope will do as well.
11557 pub fn add_scope<St>(mut self, scope: St) -> ProjectNotificationChannelDescriptorListCall<'a, C>
11558 where
11559 St: AsRef<str>,
11560 {
11561 self._scopes.insert(String::from(scope.as_ref()));
11562 self
11563 }
11564 /// Identifies the authorization scope(s) for the method you are building.
11565 ///
11566 /// See [`Self::add_scope()`] for details.
11567 pub fn add_scopes<I, St>(
11568 mut self,
11569 scopes: I,
11570 ) -> ProjectNotificationChannelDescriptorListCall<'a, C>
11571 where
11572 I: IntoIterator<Item = St>,
11573 St: AsRef<str>,
11574 {
11575 self._scopes
11576 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11577 self
11578 }
11579
11580 /// Removes all scopes, and no default scope will be used either.
11581 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11582 /// for details).
11583 pub fn clear_scopes(mut self) -> ProjectNotificationChannelDescriptorListCall<'a, C> {
11584 self._scopes.clear();
11585 self
11586 }
11587}
11588
11589/// Creates a new notification channel, representing a single notification endpoint such as an email address, SMS number, or PagerDuty service.Design your application to single-thread API calls that modify the state of notification channels in a single project. This includes calls to CreateNotificationChannel, DeleteNotificationChannel and UpdateNotificationChannel.
11590///
11591/// A builder for the *notificationChannels.create* method supported by a *project* resource.
11592/// It is not used directly, but through a [`ProjectMethods`] instance.
11593///
11594/// # Example
11595///
11596/// Instantiate a resource method builder
11597///
11598/// ```test_harness,no_run
11599/// # extern crate hyper;
11600/// # extern crate hyper_rustls;
11601/// # extern crate google_monitoring3 as monitoring3;
11602/// use monitoring3::api::NotificationChannel;
11603/// # async fn dox() {
11604/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11605///
11606/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11607/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11608/// # secret,
11609/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11610/// # ).build().await.unwrap();
11611///
11612/// # let client = hyper_util::client::legacy::Client::builder(
11613/// # hyper_util::rt::TokioExecutor::new()
11614/// # )
11615/// # .build(
11616/// # hyper_rustls::HttpsConnectorBuilder::new()
11617/// # .with_native_roots()
11618/// # .unwrap()
11619/// # .https_or_http()
11620/// # .enable_http1()
11621/// # .build()
11622/// # );
11623/// # let mut hub = Monitoring::new(client, auth);
11624/// // As the method needs a request, you would usually fill it with the desired information
11625/// // into the respective structure. Some of the parts shown here might not be applicable !
11626/// // Values shown here are possibly random and not representative !
11627/// let mut req = NotificationChannel::default();
11628///
11629/// // You can configure optional parameters by calling the respective setters at will, and
11630/// // execute the final call using `doit()`.
11631/// // Values shown here are possibly random and not representative !
11632/// let result = hub.projects().notification_channels_create(req, "name")
11633/// .doit().await;
11634/// # }
11635/// ```
11636pub struct ProjectNotificationChannelCreateCall<'a, C>
11637where
11638 C: 'a,
11639{
11640 hub: &'a Monitoring<C>,
11641 _request: NotificationChannel,
11642 _name: String,
11643 _delegate: Option<&'a mut dyn common::Delegate>,
11644 _additional_params: HashMap<String, String>,
11645 _scopes: BTreeSet<String>,
11646}
11647
11648impl<'a, C> common::CallBuilder for ProjectNotificationChannelCreateCall<'a, C> {}
11649
11650impl<'a, C> ProjectNotificationChannelCreateCall<'a, C>
11651where
11652 C: common::Connector,
11653{
11654 /// Perform the operation you have build so far.
11655 pub async fn doit(mut self) -> common::Result<(common::Response, NotificationChannel)> {
11656 use std::borrow::Cow;
11657 use std::io::{Read, Seek};
11658
11659 use common::{url::Params, ToParts};
11660 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11661
11662 let mut dd = common::DefaultDelegate;
11663 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11664 dlg.begin(common::MethodInfo {
11665 id: "monitoring.projects.notificationChannels.create",
11666 http_method: hyper::Method::POST,
11667 });
11668
11669 for &field in ["alt", "name"].iter() {
11670 if self._additional_params.contains_key(field) {
11671 dlg.finished(false);
11672 return Err(common::Error::FieldClash(field));
11673 }
11674 }
11675
11676 let mut params = Params::with_capacity(4 + self._additional_params.len());
11677 params.push("name", self._name);
11678
11679 params.extend(self._additional_params.iter());
11680
11681 params.push("alt", "json");
11682 let mut url = self.hub._base_url.clone() + "v3/{+name}/notificationChannels";
11683 if self._scopes.is_empty() {
11684 self._scopes
11685 .insert(Scope::CloudPlatform.as_ref().to_string());
11686 }
11687
11688 #[allow(clippy::single_element_loop)]
11689 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11690 url = params.uri_replacement(url, param_name, find_this, true);
11691 }
11692 {
11693 let to_remove = ["name"];
11694 params.remove_params(&to_remove);
11695 }
11696
11697 let url = params.parse_with_url(&url);
11698
11699 let mut json_mime_type = mime::APPLICATION_JSON;
11700 let mut request_value_reader = {
11701 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11702 common::remove_json_null_values(&mut value);
11703 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11704 serde_json::to_writer(&mut dst, &value).unwrap();
11705 dst
11706 };
11707 let request_size = request_value_reader
11708 .seek(std::io::SeekFrom::End(0))
11709 .unwrap();
11710 request_value_reader
11711 .seek(std::io::SeekFrom::Start(0))
11712 .unwrap();
11713
11714 loop {
11715 let token = match self
11716 .hub
11717 .auth
11718 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11719 .await
11720 {
11721 Ok(token) => token,
11722 Err(e) => match dlg.token(e) {
11723 Ok(token) => token,
11724 Err(e) => {
11725 dlg.finished(false);
11726 return Err(common::Error::MissingToken(e));
11727 }
11728 },
11729 };
11730 request_value_reader
11731 .seek(std::io::SeekFrom::Start(0))
11732 .unwrap();
11733 let mut req_result = {
11734 let client = &self.hub.client;
11735 dlg.pre_request();
11736 let mut req_builder = hyper::Request::builder()
11737 .method(hyper::Method::POST)
11738 .uri(url.as_str())
11739 .header(USER_AGENT, self.hub._user_agent.clone());
11740
11741 if let Some(token) = token.as_ref() {
11742 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11743 }
11744
11745 let request = req_builder
11746 .header(CONTENT_TYPE, json_mime_type.to_string())
11747 .header(CONTENT_LENGTH, request_size as u64)
11748 .body(common::to_body(
11749 request_value_reader.get_ref().clone().into(),
11750 ));
11751
11752 client.request(request.unwrap()).await
11753 };
11754
11755 match req_result {
11756 Err(err) => {
11757 if let common::Retry::After(d) = dlg.http_error(&err) {
11758 sleep(d).await;
11759 continue;
11760 }
11761 dlg.finished(false);
11762 return Err(common::Error::HttpError(err));
11763 }
11764 Ok(res) => {
11765 let (mut parts, body) = res.into_parts();
11766 let mut body = common::Body::new(body);
11767 if !parts.status.is_success() {
11768 let bytes = common::to_bytes(body).await.unwrap_or_default();
11769 let error = serde_json::from_str(&common::to_string(&bytes));
11770 let response = common::to_response(parts, bytes.into());
11771
11772 if let common::Retry::After(d) =
11773 dlg.http_failure(&response, error.as_ref().ok())
11774 {
11775 sleep(d).await;
11776 continue;
11777 }
11778
11779 dlg.finished(false);
11780
11781 return Err(match error {
11782 Ok(value) => common::Error::BadRequest(value),
11783 _ => common::Error::Failure(response),
11784 });
11785 }
11786 let response = {
11787 let bytes = common::to_bytes(body).await.unwrap_or_default();
11788 let encoded = common::to_string(&bytes);
11789 match serde_json::from_str(&encoded) {
11790 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11791 Err(error) => {
11792 dlg.response_json_decode_error(&encoded, &error);
11793 return Err(common::Error::JsonDecodeError(
11794 encoded.to_string(),
11795 error,
11796 ));
11797 }
11798 }
11799 };
11800
11801 dlg.finished(true);
11802 return Ok(response);
11803 }
11804 }
11805 }
11806 }
11807
11808 ///
11809 /// Sets the *request* property to the given value.
11810 ///
11811 /// Even though the property as already been set when instantiating this call,
11812 /// we provide this method for API completeness.
11813 pub fn request(
11814 mut self,
11815 new_value: NotificationChannel,
11816 ) -> ProjectNotificationChannelCreateCall<'a, C> {
11817 self._request = new_value;
11818 self
11819 }
11820 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER] This names the container into which the channel will be written, this does not name the newly created channel. The resulting channel's name will have a normalized version of this field as a prefix, but will add /notificationChannels/[CHANNEL_ID] to identify the channel.
11821 ///
11822 /// Sets the *name* path property to the given value.
11823 ///
11824 /// Even though the property as already been set when instantiating this call,
11825 /// we provide this method for API completeness.
11826 pub fn name(mut self, new_value: &str) -> ProjectNotificationChannelCreateCall<'a, C> {
11827 self._name = new_value.to_string();
11828 self
11829 }
11830 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11831 /// while executing the actual API request.
11832 ///
11833 /// ````text
11834 /// It should be used to handle progress information, and to implement a certain level of resilience.
11835 /// ````
11836 ///
11837 /// Sets the *delegate* property to the given value.
11838 pub fn delegate(
11839 mut self,
11840 new_value: &'a mut dyn common::Delegate,
11841 ) -> ProjectNotificationChannelCreateCall<'a, C> {
11842 self._delegate = Some(new_value);
11843 self
11844 }
11845
11846 /// Set any additional parameter of the query string used in the request.
11847 /// It should be used to set parameters which are not yet available through their own
11848 /// setters.
11849 ///
11850 /// Please note that this method must not be used to set any of the known parameters
11851 /// which have their own setter method. If done anyway, the request will fail.
11852 ///
11853 /// # Additional Parameters
11854 ///
11855 /// * *$.xgafv* (query-string) - V1 error format.
11856 /// * *access_token* (query-string) - OAuth access token.
11857 /// * *alt* (query-string) - Data format for response.
11858 /// * *callback* (query-string) - JSONP
11859 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11860 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11861 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11862 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11863 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11864 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11865 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11866 pub fn param<T>(mut self, name: T, value: T) -> ProjectNotificationChannelCreateCall<'a, C>
11867 where
11868 T: AsRef<str>,
11869 {
11870 self._additional_params
11871 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11872 self
11873 }
11874
11875 /// Identifies the authorization scope for the method you are building.
11876 ///
11877 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11878 /// [`Scope::CloudPlatform`].
11879 ///
11880 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11881 /// tokens for more than one scope.
11882 ///
11883 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11884 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11885 /// sufficient, a read-write scope will do as well.
11886 pub fn add_scope<St>(mut self, scope: St) -> ProjectNotificationChannelCreateCall<'a, C>
11887 where
11888 St: AsRef<str>,
11889 {
11890 self._scopes.insert(String::from(scope.as_ref()));
11891 self
11892 }
11893 /// Identifies the authorization scope(s) for the method you are building.
11894 ///
11895 /// See [`Self::add_scope()`] for details.
11896 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNotificationChannelCreateCall<'a, C>
11897 where
11898 I: IntoIterator<Item = St>,
11899 St: AsRef<str>,
11900 {
11901 self._scopes
11902 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11903 self
11904 }
11905
11906 /// Removes all scopes, and no default scope will be used either.
11907 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11908 /// for details).
11909 pub fn clear_scopes(mut self) -> ProjectNotificationChannelCreateCall<'a, C> {
11910 self._scopes.clear();
11911 self
11912 }
11913}
11914
11915/// Deletes a notification channel.Design your application to single-thread API calls that modify the state of notification channels in a single project. This includes calls to CreateNotificationChannel, DeleteNotificationChannel and UpdateNotificationChannel.
11916///
11917/// A builder for the *notificationChannels.delete* method supported by a *project* resource.
11918/// It is not used directly, but through a [`ProjectMethods`] instance.
11919///
11920/// # Example
11921///
11922/// Instantiate a resource method builder
11923///
11924/// ```test_harness,no_run
11925/// # extern crate hyper;
11926/// # extern crate hyper_rustls;
11927/// # extern crate google_monitoring3 as monitoring3;
11928/// # async fn dox() {
11929/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11930///
11931/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11932/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11933/// # secret,
11934/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11935/// # ).build().await.unwrap();
11936///
11937/// # let client = hyper_util::client::legacy::Client::builder(
11938/// # hyper_util::rt::TokioExecutor::new()
11939/// # )
11940/// # .build(
11941/// # hyper_rustls::HttpsConnectorBuilder::new()
11942/// # .with_native_roots()
11943/// # .unwrap()
11944/// # .https_or_http()
11945/// # .enable_http1()
11946/// # .build()
11947/// # );
11948/// # let mut hub = Monitoring::new(client, auth);
11949/// // You can configure optional parameters by calling the respective setters at will, and
11950/// // execute the final call using `doit()`.
11951/// // Values shown here are possibly random and not representative !
11952/// let result = hub.projects().notification_channels_delete("name")
11953/// .force(false)
11954/// .doit().await;
11955/// # }
11956/// ```
11957pub struct ProjectNotificationChannelDeleteCall<'a, C>
11958where
11959 C: 'a,
11960{
11961 hub: &'a Monitoring<C>,
11962 _name: String,
11963 _force: Option<bool>,
11964 _delegate: Option<&'a mut dyn common::Delegate>,
11965 _additional_params: HashMap<String, String>,
11966 _scopes: BTreeSet<String>,
11967}
11968
11969impl<'a, C> common::CallBuilder for ProjectNotificationChannelDeleteCall<'a, C> {}
11970
11971impl<'a, C> ProjectNotificationChannelDeleteCall<'a, C>
11972where
11973 C: common::Connector,
11974{
11975 /// Perform the operation you have build so far.
11976 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11977 use std::borrow::Cow;
11978 use std::io::{Read, Seek};
11979
11980 use common::{url::Params, ToParts};
11981 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11982
11983 let mut dd = common::DefaultDelegate;
11984 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11985 dlg.begin(common::MethodInfo {
11986 id: "monitoring.projects.notificationChannels.delete",
11987 http_method: hyper::Method::DELETE,
11988 });
11989
11990 for &field in ["alt", "name", "force"].iter() {
11991 if self._additional_params.contains_key(field) {
11992 dlg.finished(false);
11993 return Err(common::Error::FieldClash(field));
11994 }
11995 }
11996
11997 let mut params = Params::with_capacity(4 + self._additional_params.len());
11998 params.push("name", self._name);
11999 if let Some(value) = self._force.as_ref() {
12000 params.push("force", value.to_string());
12001 }
12002
12003 params.extend(self._additional_params.iter());
12004
12005 params.push("alt", "json");
12006 let mut url = self.hub._base_url.clone() + "v3/{+name}";
12007 if self._scopes.is_empty() {
12008 self._scopes
12009 .insert(Scope::CloudPlatform.as_ref().to_string());
12010 }
12011
12012 #[allow(clippy::single_element_loop)]
12013 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12014 url = params.uri_replacement(url, param_name, find_this, true);
12015 }
12016 {
12017 let to_remove = ["name"];
12018 params.remove_params(&to_remove);
12019 }
12020
12021 let url = params.parse_with_url(&url);
12022
12023 loop {
12024 let token = match self
12025 .hub
12026 .auth
12027 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12028 .await
12029 {
12030 Ok(token) => token,
12031 Err(e) => match dlg.token(e) {
12032 Ok(token) => token,
12033 Err(e) => {
12034 dlg.finished(false);
12035 return Err(common::Error::MissingToken(e));
12036 }
12037 },
12038 };
12039 let mut req_result = {
12040 let client = &self.hub.client;
12041 dlg.pre_request();
12042 let mut req_builder = hyper::Request::builder()
12043 .method(hyper::Method::DELETE)
12044 .uri(url.as_str())
12045 .header(USER_AGENT, self.hub._user_agent.clone());
12046
12047 if let Some(token) = token.as_ref() {
12048 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12049 }
12050
12051 let request = req_builder
12052 .header(CONTENT_LENGTH, 0_u64)
12053 .body(common::to_body::<String>(None));
12054
12055 client.request(request.unwrap()).await
12056 };
12057
12058 match req_result {
12059 Err(err) => {
12060 if let common::Retry::After(d) = dlg.http_error(&err) {
12061 sleep(d).await;
12062 continue;
12063 }
12064 dlg.finished(false);
12065 return Err(common::Error::HttpError(err));
12066 }
12067 Ok(res) => {
12068 let (mut parts, body) = res.into_parts();
12069 let mut body = common::Body::new(body);
12070 if !parts.status.is_success() {
12071 let bytes = common::to_bytes(body).await.unwrap_or_default();
12072 let error = serde_json::from_str(&common::to_string(&bytes));
12073 let response = common::to_response(parts, bytes.into());
12074
12075 if let common::Retry::After(d) =
12076 dlg.http_failure(&response, error.as_ref().ok())
12077 {
12078 sleep(d).await;
12079 continue;
12080 }
12081
12082 dlg.finished(false);
12083
12084 return Err(match error {
12085 Ok(value) => common::Error::BadRequest(value),
12086 _ => common::Error::Failure(response),
12087 });
12088 }
12089 let response = {
12090 let bytes = common::to_bytes(body).await.unwrap_or_default();
12091 let encoded = common::to_string(&bytes);
12092 match serde_json::from_str(&encoded) {
12093 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12094 Err(error) => {
12095 dlg.response_json_decode_error(&encoded, &error);
12096 return Err(common::Error::JsonDecodeError(
12097 encoded.to_string(),
12098 error,
12099 ));
12100 }
12101 }
12102 };
12103
12104 dlg.finished(true);
12105 return Ok(response);
12106 }
12107 }
12108 }
12109 }
12110
12111 /// Required. The channel for which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
12112 ///
12113 /// Sets the *name* path property to the given value.
12114 ///
12115 /// Even though the property as already been set when instantiating this call,
12116 /// we provide this method for API completeness.
12117 pub fn name(mut self, new_value: &str) -> ProjectNotificationChannelDeleteCall<'a, C> {
12118 self._name = new_value.to_string();
12119 self
12120 }
12121 /// If true, the notification channel will be deleted regardless of its use in alert policies (the policies will be updated to remove the channel). If false, channels that are still referenced by an existing alerting policy will fail to be deleted in a delete operation.
12122 ///
12123 /// Sets the *force* query property to the given value.
12124 pub fn force(mut self, new_value: bool) -> ProjectNotificationChannelDeleteCall<'a, C> {
12125 self._force = Some(new_value);
12126 self
12127 }
12128 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12129 /// while executing the actual API request.
12130 ///
12131 /// ````text
12132 /// It should be used to handle progress information, and to implement a certain level of resilience.
12133 /// ````
12134 ///
12135 /// Sets the *delegate* property to the given value.
12136 pub fn delegate(
12137 mut self,
12138 new_value: &'a mut dyn common::Delegate,
12139 ) -> ProjectNotificationChannelDeleteCall<'a, C> {
12140 self._delegate = Some(new_value);
12141 self
12142 }
12143
12144 /// Set any additional parameter of the query string used in the request.
12145 /// It should be used to set parameters which are not yet available through their own
12146 /// setters.
12147 ///
12148 /// Please note that this method must not be used to set any of the known parameters
12149 /// which have their own setter method. If done anyway, the request will fail.
12150 ///
12151 /// # Additional Parameters
12152 ///
12153 /// * *$.xgafv* (query-string) - V1 error format.
12154 /// * *access_token* (query-string) - OAuth access token.
12155 /// * *alt* (query-string) - Data format for response.
12156 /// * *callback* (query-string) - JSONP
12157 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12158 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12159 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12160 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12161 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12162 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12163 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12164 pub fn param<T>(mut self, name: T, value: T) -> ProjectNotificationChannelDeleteCall<'a, C>
12165 where
12166 T: AsRef<str>,
12167 {
12168 self._additional_params
12169 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12170 self
12171 }
12172
12173 /// Identifies the authorization scope for the method you are building.
12174 ///
12175 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12176 /// [`Scope::CloudPlatform`].
12177 ///
12178 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12179 /// tokens for more than one scope.
12180 ///
12181 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12182 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12183 /// sufficient, a read-write scope will do as well.
12184 pub fn add_scope<St>(mut self, scope: St) -> ProjectNotificationChannelDeleteCall<'a, C>
12185 where
12186 St: AsRef<str>,
12187 {
12188 self._scopes.insert(String::from(scope.as_ref()));
12189 self
12190 }
12191 /// Identifies the authorization scope(s) for the method you are building.
12192 ///
12193 /// See [`Self::add_scope()`] for details.
12194 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNotificationChannelDeleteCall<'a, C>
12195 where
12196 I: IntoIterator<Item = St>,
12197 St: AsRef<str>,
12198 {
12199 self._scopes
12200 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12201 self
12202 }
12203
12204 /// Removes all scopes, and no default scope will be used either.
12205 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12206 /// for details).
12207 pub fn clear_scopes(mut self) -> ProjectNotificationChannelDeleteCall<'a, C> {
12208 self._scopes.clear();
12209 self
12210 }
12211}
12212
12213/// Gets a single notification channel. The channel includes the relevant configuration details with which the channel was created. However, the response may truncate or omit passwords, API keys, or other private key matter and thus the response may not be 100% identical to the information that was supplied in the call to the create method.
12214///
12215/// A builder for the *notificationChannels.get* method supported by a *project* resource.
12216/// It is not used directly, but through a [`ProjectMethods`] instance.
12217///
12218/// # Example
12219///
12220/// Instantiate a resource method builder
12221///
12222/// ```test_harness,no_run
12223/// # extern crate hyper;
12224/// # extern crate hyper_rustls;
12225/// # extern crate google_monitoring3 as monitoring3;
12226/// # async fn dox() {
12227/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12228///
12229/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12230/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12231/// # secret,
12232/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12233/// # ).build().await.unwrap();
12234///
12235/// # let client = hyper_util::client::legacy::Client::builder(
12236/// # hyper_util::rt::TokioExecutor::new()
12237/// # )
12238/// # .build(
12239/// # hyper_rustls::HttpsConnectorBuilder::new()
12240/// # .with_native_roots()
12241/// # .unwrap()
12242/// # .https_or_http()
12243/// # .enable_http1()
12244/// # .build()
12245/// # );
12246/// # let mut hub = Monitoring::new(client, auth);
12247/// // You can configure optional parameters by calling the respective setters at will, and
12248/// // execute the final call using `doit()`.
12249/// // Values shown here are possibly random and not representative !
12250/// let result = hub.projects().notification_channels_get("name")
12251/// .doit().await;
12252/// # }
12253/// ```
12254pub struct ProjectNotificationChannelGetCall<'a, C>
12255where
12256 C: 'a,
12257{
12258 hub: &'a Monitoring<C>,
12259 _name: String,
12260 _delegate: Option<&'a mut dyn common::Delegate>,
12261 _additional_params: HashMap<String, String>,
12262 _scopes: BTreeSet<String>,
12263}
12264
12265impl<'a, C> common::CallBuilder for ProjectNotificationChannelGetCall<'a, C> {}
12266
12267impl<'a, C> ProjectNotificationChannelGetCall<'a, C>
12268where
12269 C: common::Connector,
12270{
12271 /// Perform the operation you have build so far.
12272 pub async fn doit(mut self) -> common::Result<(common::Response, NotificationChannel)> {
12273 use std::borrow::Cow;
12274 use std::io::{Read, Seek};
12275
12276 use common::{url::Params, ToParts};
12277 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12278
12279 let mut dd = common::DefaultDelegate;
12280 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12281 dlg.begin(common::MethodInfo {
12282 id: "monitoring.projects.notificationChannels.get",
12283 http_method: hyper::Method::GET,
12284 });
12285
12286 for &field in ["alt", "name"].iter() {
12287 if self._additional_params.contains_key(field) {
12288 dlg.finished(false);
12289 return Err(common::Error::FieldClash(field));
12290 }
12291 }
12292
12293 let mut params = Params::with_capacity(3 + self._additional_params.len());
12294 params.push("name", self._name);
12295
12296 params.extend(self._additional_params.iter());
12297
12298 params.push("alt", "json");
12299 let mut url = self.hub._base_url.clone() + "v3/{+name}";
12300 if self._scopes.is_empty() {
12301 self._scopes
12302 .insert(Scope::CloudPlatform.as_ref().to_string());
12303 }
12304
12305 #[allow(clippy::single_element_loop)]
12306 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12307 url = params.uri_replacement(url, param_name, find_this, true);
12308 }
12309 {
12310 let to_remove = ["name"];
12311 params.remove_params(&to_remove);
12312 }
12313
12314 let url = params.parse_with_url(&url);
12315
12316 loop {
12317 let token = match self
12318 .hub
12319 .auth
12320 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12321 .await
12322 {
12323 Ok(token) => token,
12324 Err(e) => match dlg.token(e) {
12325 Ok(token) => token,
12326 Err(e) => {
12327 dlg.finished(false);
12328 return Err(common::Error::MissingToken(e));
12329 }
12330 },
12331 };
12332 let mut req_result = {
12333 let client = &self.hub.client;
12334 dlg.pre_request();
12335 let mut req_builder = hyper::Request::builder()
12336 .method(hyper::Method::GET)
12337 .uri(url.as_str())
12338 .header(USER_AGENT, self.hub._user_agent.clone());
12339
12340 if let Some(token) = token.as_ref() {
12341 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12342 }
12343
12344 let request = req_builder
12345 .header(CONTENT_LENGTH, 0_u64)
12346 .body(common::to_body::<String>(None));
12347
12348 client.request(request.unwrap()).await
12349 };
12350
12351 match req_result {
12352 Err(err) => {
12353 if let common::Retry::After(d) = dlg.http_error(&err) {
12354 sleep(d).await;
12355 continue;
12356 }
12357 dlg.finished(false);
12358 return Err(common::Error::HttpError(err));
12359 }
12360 Ok(res) => {
12361 let (mut parts, body) = res.into_parts();
12362 let mut body = common::Body::new(body);
12363 if !parts.status.is_success() {
12364 let bytes = common::to_bytes(body).await.unwrap_or_default();
12365 let error = serde_json::from_str(&common::to_string(&bytes));
12366 let response = common::to_response(parts, bytes.into());
12367
12368 if let common::Retry::After(d) =
12369 dlg.http_failure(&response, error.as_ref().ok())
12370 {
12371 sleep(d).await;
12372 continue;
12373 }
12374
12375 dlg.finished(false);
12376
12377 return Err(match error {
12378 Ok(value) => common::Error::BadRequest(value),
12379 _ => common::Error::Failure(response),
12380 });
12381 }
12382 let response = {
12383 let bytes = common::to_bytes(body).await.unwrap_or_default();
12384 let encoded = common::to_string(&bytes);
12385 match serde_json::from_str(&encoded) {
12386 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12387 Err(error) => {
12388 dlg.response_json_decode_error(&encoded, &error);
12389 return Err(common::Error::JsonDecodeError(
12390 encoded.to_string(),
12391 error,
12392 ));
12393 }
12394 }
12395 };
12396
12397 dlg.finished(true);
12398 return Ok(response);
12399 }
12400 }
12401 }
12402 }
12403
12404 /// Required. The channel for which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
12405 ///
12406 /// Sets the *name* path property to the given value.
12407 ///
12408 /// Even though the property as already been set when instantiating this call,
12409 /// we provide this method for API completeness.
12410 pub fn name(mut self, new_value: &str) -> ProjectNotificationChannelGetCall<'a, C> {
12411 self._name = new_value.to_string();
12412 self
12413 }
12414 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12415 /// while executing the actual API request.
12416 ///
12417 /// ````text
12418 /// It should be used to handle progress information, and to implement a certain level of resilience.
12419 /// ````
12420 ///
12421 /// Sets the *delegate* property to the given value.
12422 pub fn delegate(
12423 mut self,
12424 new_value: &'a mut dyn common::Delegate,
12425 ) -> ProjectNotificationChannelGetCall<'a, C> {
12426 self._delegate = Some(new_value);
12427 self
12428 }
12429
12430 /// Set any additional parameter of the query string used in the request.
12431 /// It should be used to set parameters which are not yet available through their own
12432 /// setters.
12433 ///
12434 /// Please note that this method must not be used to set any of the known parameters
12435 /// which have their own setter method. If done anyway, the request will fail.
12436 ///
12437 /// # Additional Parameters
12438 ///
12439 /// * *$.xgafv* (query-string) - V1 error format.
12440 /// * *access_token* (query-string) - OAuth access token.
12441 /// * *alt* (query-string) - Data format for response.
12442 /// * *callback* (query-string) - JSONP
12443 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12444 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12445 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12446 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12447 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12448 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12449 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12450 pub fn param<T>(mut self, name: T, value: T) -> ProjectNotificationChannelGetCall<'a, C>
12451 where
12452 T: AsRef<str>,
12453 {
12454 self._additional_params
12455 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12456 self
12457 }
12458
12459 /// Identifies the authorization scope for the method you are building.
12460 ///
12461 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12462 /// [`Scope::CloudPlatform`].
12463 ///
12464 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12465 /// tokens for more than one scope.
12466 ///
12467 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12468 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12469 /// sufficient, a read-write scope will do as well.
12470 pub fn add_scope<St>(mut self, scope: St) -> ProjectNotificationChannelGetCall<'a, C>
12471 where
12472 St: AsRef<str>,
12473 {
12474 self._scopes.insert(String::from(scope.as_ref()));
12475 self
12476 }
12477 /// Identifies the authorization scope(s) for the method you are building.
12478 ///
12479 /// See [`Self::add_scope()`] for details.
12480 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNotificationChannelGetCall<'a, C>
12481 where
12482 I: IntoIterator<Item = St>,
12483 St: AsRef<str>,
12484 {
12485 self._scopes
12486 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12487 self
12488 }
12489
12490 /// Removes all scopes, and no default scope will be used either.
12491 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12492 /// for details).
12493 pub fn clear_scopes(mut self) -> ProjectNotificationChannelGetCall<'a, C> {
12494 self._scopes.clear();
12495 self
12496 }
12497}
12498
12499/// Requests a verification code for an already verified channel that can then be used in a call to VerifyNotificationChannel() on a different channel with an equivalent identity in the same or in a different project. This makes it possible to copy a channel between projects without requiring manual reverification of the channel. If the channel is not in the verified state, this method will fail (in other words, this may only be used if the SendNotificationChannelVerificationCode and VerifyNotificationChannel paths have already been used to put the given channel into the verified state).There is no guarantee that the verification codes returned by this method will be of a similar structure or form as the ones that are delivered to the channel via SendNotificationChannelVerificationCode; while VerifyNotificationChannel() will recognize both the codes delivered via SendNotificationChannelVerificationCode() and returned from GetNotificationChannelVerificationCode(), it is typically the case that the verification codes delivered via SendNotificationChannelVerificationCode() will be shorter and also have a shorter expiration (e.g. codes such as "G-123456") whereas GetVerificationCode() will typically return a much longer, websafe base 64 encoded string that has a longer expiration time.
12500///
12501/// A builder for the *notificationChannels.getVerificationCode* method supported by a *project* resource.
12502/// It is not used directly, but through a [`ProjectMethods`] instance.
12503///
12504/// # Example
12505///
12506/// Instantiate a resource method builder
12507///
12508/// ```test_harness,no_run
12509/// # extern crate hyper;
12510/// # extern crate hyper_rustls;
12511/// # extern crate google_monitoring3 as monitoring3;
12512/// use monitoring3::api::GetNotificationChannelVerificationCodeRequest;
12513/// # async fn dox() {
12514/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12515///
12516/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12517/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12518/// # secret,
12519/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12520/// # ).build().await.unwrap();
12521///
12522/// # let client = hyper_util::client::legacy::Client::builder(
12523/// # hyper_util::rt::TokioExecutor::new()
12524/// # )
12525/// # .build(
12526/// # hyper_rustls::HttpsConnectorBuilder::new()
12527/// # .with_native_roots()
12528/// # .unwrap()
12529/// # .https_or_http()
12530/// # .enable_http1()
12531/// # .build()
12532/// # );
12533/// # let mut hub = Monitoring::new(client, auth);
12534/// // As the method needs a request, you would usually fill it with the desired information
12535/// // into the respective structure. Some of the parts shown here might not be applicable !
12536/// // Values shown here are possibly random and not representative !
12537/// let mut req = GetNotificationChannelVerificationCodeRequest::default();
12538///
12539/// // You can configure optional parameters by calling the respective setters at will, and
12540/// // execute the final call using `doit()`.
12541/// // Values shown here are possibly random and not representative !
12542/// let result = hub.projects().notification_channels_get_verification_code(req, "name")
12543/// .doit().await;
12544/// # }
12545/// ```
12546pub struct ProjectNotificationChannelGetVerificationCodeCall<'a, C>
12547where
12548 C: 'a,
12549{
12550 hub: &'a Monitoring<C>,
12551 _request: GetNotificationChannelVerificationCodeRequest,
12552 _name: String,
12553 _delegate: Option<&'a mut dyn common::Delegate>,
12554 _additional_params: HashMap<String, String>,
12555 _scopes: BTreeSet<String>,
12556}
12557
12558impl<'a, C> common::CallBuilder for ProjectNotificationChannelGetVerificationCodeCall<'a, C> {}
12559
12560impl<'a, C> ProjectNotificationChannelGetVerificationCodeCall<'a, C>
12561where
12562 C: common::Connector,
12563{
12564 /// Perform the operation you have build so far.
12565 pub async fn doit(
12566 mut self,
12567 ) -> common::Result<(
12568 common::Response,
12569 GetNotificationChannelVerificationCodeResponse,
12570 )> {
12571 use std::borrow::Cow;
12572 use std::io::{Read, Seek};
12573
12574 use common::{url::Params, ToParts};
12575 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12576
12577 let mut dd = common::DefaultDelegate;
12578 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12579 dlg.begin(common::MethodInfo {
12580 id: "monitoring.projects.notificationChannels.getVerificationCode",
12581 http_method: hyper::Method::POST,
12582 });
12583
12584 for &field in ["alt", "name"].iter() {
12585 if self._additional_params.contains_key(field) {
12586 dlg.finished(false);
12587 return Err(common::Error::FieldClash(field));
12588 }
12589 }
12590
12591 let mut params = Params::with_capacity(4 + self._additional_params.len());
12592 params.push("name", self._name);
12593
12594 params.extend(self._additional_params.iter());
12595
12596 params.push("alt", "json");
12597 let mut url = self.hub._base_url.clone() + "v3/{+name}:getVerificationCode";
12598 if self._scopes.is_empty() {
12599 self._scopes
12600 .insert(Scope::CloudPlatform.as_ref().to_string());
12601 }
12602
12603 #[allow(clippy::single_element_loop)]
12604 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12605 url = params.uri_replacement(url, param_name, find_this, true);
12606 }
12607 {
12608 let to_remove = ["name"];
12609 params.remove_params(&to_remove);
12610 }
12611
12612 let url = params.parse_with_url(&url);
12613
12614 let mut json_mime_type = mime::APPLICATION_JSON;
12615 let mut request_value_reader = {
12616 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12617 common::remove_json_null_values(&mut value);
12618 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12619 serde_json::to_writer(&mut dst, &value).unwrap();
12620 dst
12621 };
12622 let request_size = request_value_reader
12623 .seek(std::io::SeekFrom::End(0))
12624 .unwrap();
12625 request_value_reader
12626 .seek(std::io::SeekFrom::Start(0))
12627 .unwrap();
12628
12629 loop {
12630 let token = match self
12631 .hub
12632 .auth
12633 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12634 .await
12635 {
12636 Ok(token) => token,
12637 Err(e) => match dlg.token(e) {
12638 Ok(token) => token,
12639 Err(e) => {
12640 dlg.finished(false);
12641 return Err(common::Error::MissingToken(e));
12642 }
12643 },
12644 };
12645 request_value_reader
12646 .seek(std::io::SeekFrom::Start(0))
12647 .unwrap();
12648 let mut req_result = {
12649 let client = &self.hub.client;
12650 dlg.pre_request();
12651 let mut req_builder = hyper::Request::builder()
12652 .method(hyper::Method::POST)
12653 .uri(url.as_str())
12654 .header(USER_AGENT, self.hub._user_agent.clone());
12655
12656 if let Some(token) = token.as_ref() {
12657 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12658 }
12659
12660 let request = req_builder
12661 .header(CONTENT_TYPE, json_mime_type.to_string())
12662 .header(CONTENT_LENGTH, request_size as u64)
12663 .body(common::to_body(
12664 request_value_reader.get_ref().clone().into(),
12665 ));
12666
12667 client.request(request.unwrap()).await
12668 };
12669
12670 match req_result {
12671 Err(err) => {
12672 if let common::Retry::After(d) = dlg.http_error(&err) {
12673 sleep(d).await;
12674 continue;
12675 }
12676 dlg.finished(false);
12677 return Err(common::Error::HttpError(err));
12678 }
12679 Ok(res) => {
12680 let (mut parts, body) = res.into_parts();
12681 let mut body = common::Body::new(body);
12682 if !parts.status.is_success() {
12683 let bytes = common::to_bytes(body).await.unwrap_or_default();
12684 let error = serde_json::from_str(&common::to_string(&bytes));
12685 let response = common::to_response(parts, bytes.into());
12686
12687 if let common::Retry::After(d) =
12688 dlg.http_failure(&response, error.as_ref().ok())
12689 {
12690 sleep(d).await;
12691 continue;
12692 }
12693
12694 dlg.finished(false);
12695
12696 return Err(match error {
12697 Ok(value) => common::Error::BadRequest(value),
12698 _ => common::Error::Failure(response),
12699 });
12700 }
12701 let response = {
12702 let bytes = common::to_bytes(body).await.unwrap_or_default();
12703 let encoded = common::to_string(&bytes);
12704 match serde_json::from_str(&encoded) {
12705 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12706 Err(error) => {
12707 dlg.response_json_decode_error(&encoded, &error);
12708 return Err(common::Error::JsonDecodeError(
12709 encoded.to_string(),
12710 error,
12711 ));
12712 }
12713 }
12714 };
12715
12716 dlg.finished(true);
12717 return Ok(response);
12718 }
12719 }
12720 }
12721 }
12722
12723 ///
12724 /// Sets the *request* property to the given value.
12725 ///
12726 /// Even though the property as already been set when instantiating this call,
12727 /// we provide this method for API completeness.
12728 pub fn request(
12729 mut self,
12730 new_value: GetNotificationChannelVerificationCodeRequest,
12731 ) -> ProjectNotificationChannelGetVerificationCodeCall<'a, C> {
12732 self._request = new_value;
12733 self
12734 }
12735 /// Required. The notification channel for which a verification code is to be generated and retrieved. This must name a channel that is already verified; if the specified channel is not verified, the request will fail.
12736 ///
12737 /// Sets the *name* path property to the given value.
12738 ///
12739 /// Even though the property as already been set when instantiating this call,
12740 /// we provide this method for API completeness.
12741 pub fn name(
12742 mut self,
12743 new_value: &str,
12744 ) -> ProjectNotificationChannelGetVerificationCodeCall<'a, C> {
12745 self._name = new_value.to_string();
12746 self
12747 }
12748 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12749 /// while executing the actual API request.
12750 ///
12751 /// ````text
12752 /// It should be used to handle progress information, and to implement a certain level of resilience.
12753 /// ````
12754 ///
12755 /// Sets the *delegate* property to the given value.
12756 pub fn delegate(
12757 mut self,
12758 new_value: &'a mut dyn common::Delegate,
12759 ) -> ProjectNotificationChannelGetVerificationCodeCall<'a, C> {
12760 self._delegate = Some(new_value);
12761 self
12762 }
12763
12764 /// Set any additional parameter of the query string used in the request.
12765 /// It should be used to set parameters which are not yet available through their own
12766 /// setters.
12767 ///
12768 /// Please note that this method must not be used to set any of the known parameters
12769 /// which have their own setter method. If done anyway, the request will fail.
12770 ///
12771 /// # Additional Parameters
12772 ///
12773 /// * *$.xgafv* (query-string) - V1 error format.
12774 /// * *access_token* (query-string) - OAuth access token.
12775 /// * *alt* (query-string) - Data format for response.
12776 /// * *callback* (query-string) - JSONP
12777 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12778 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12779 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12780 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12781 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12782 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12783 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12784 pub fn param<T>(
12785 mut self,
12786 name: T,
12787 value: T,
12788 ) -> ProjectNotificationChannelGetVerificationCodeCall<'a, C>
12789 where
12790 T: AsRef<str>,
12791 {
12792 self._additional_params
12793 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12794 self
12795 }
12796
12797 /// Identifies the authorization scope for the method you are building.
12798 ///
12799 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12800 /// [`Scope::CloudPlatform`].
12801 ///
12802 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12803 /// tokens for more than one scope.
12804 ///
12805 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12806 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12807 /// sufficient, a read-write scope will do as well.
12808 pub fn add_scope<St>(
12809 mut self,
12810 scope: St,
12811 ) -> ProjectNotificationChannelGetVerificationCodeCall<'a, C>
12812 where
12813 St: AsRef<str>,
12814 {
12815 self._scopes.insert(String::from(scope.as_ref()));
12816 self
12817 }
12818 /// Identifies the authorization scope(s) for the method you are building.
12819 ///
12820 /// See [`Self::add_scope()`] for details.
12821 pub fn add_scopes<I, St>(
12822 mut self,
12823 scopes: I,
12824 ) -> ProjectNotificationChannelGetVerificationCodeCall<'a, C>
12825 where
12826 I: IntoIterator<Item = St>,
12827 St: AsRef<str>,
12828 {
12829 self._scopes
12830 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12831 self
12832 }
12833
12834 /// Removes all scopes, and no default scope will be used either.
12835 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12836 /// for details).
12837 pub fn clear_scopes(mut self) -> ProjectNotificationChannelGetVerificationCodeCall<'a, C> {
12838 self._scopes.clear();
12839 self
12840 }
12841}
12842
12843/// Lists the notification channels that have been created for the project. To list the types of notification channels that are supported, use the ListNotificationChannelDescriptors method.
12844///
12845/// A builder for the *notificationChannels.list* method supported by a *project* resource.
12846/// It is not used directly, but through a [`ProjectMethods`] instance.
12847///
12848/// # Example
12849///
12850/// Instantiate a resource method builder
12851///
12852/// ```test_harness,no_run
12853/// # extern crate hyper;
12854/// # extern crate hyper_rustls;
12855/// # extern crate google_monitoring3 as monitoring3;
12856/// # async fn dox() {
12857/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12858///
12859/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12860/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12861/// # secret,
12862/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12863/// # ).build().await.unwrap();
12864///
12865/// # let client = hyper_util::client::legacy::Client::builder(
12866/// # hyper_util::rt::TokioExecutor::new()
12867/// # )
12868/// # .build(
12869/// # hyper_rustls::HttpsConnectorBuilder::new()
12870/// # .with_native_roots()
12871/// # .unwrap()
12872/// # .https_or_http()
12873/// # .enable_http1()
12874/// # .build()
12875/// # );
12876/// # let mut hub = Monitoring::new(client, auth);
12877/// // You can configure optional parameters by calling the respective setters at will, and
12878/// // execute the final call using `doit()`.
12879/// // Values shown here are possibly random and not representative !
12880/// let result = hub.projects().notification_channels_list("name")
12881/// .page_token("Lorem")
12882/// .page_size(-38)
12883/// .order_by("no")
12884/// .filter("est")
12885/// .doit().await;
12886/// # }
12887/// ```
12888pub struct ProjectNotificationChannelListCall<'a, C>
12889where
12890 C: 'a,
12891{
12892 hub: &'a Monitoring<C>,
12893 _name: String,
12894 _page_token: Option<String>,
12895 _page_size: Option<i32>,
12896 _order_by: Option<String>,
12897 _filter: Option<String>,
12898 _delegate: Option<&'a mut dyn common::Delegate>,
12899 _additional_params: HashMap<String, String>,
12900 _scopes: BTreeSet<String>,
12901}
12902
12903impl<'a, C> common::CallBuilder for ProjectNotificationChannelListCall<'a, C> {}
12904
12905impl<'a, C> ProjectNotificationChannelListCall<'a, C>
12906where
12907 C: common::Connector,
12908{
12909 /// Perform the operation you have build so far.
12910 pub async fn doit(
12911 mut self,
12912 ) -> common::Result<(common::Response, ListNotificationChannelsResponse)> {
12913 use std::borrow::Cow;
12914 use std::io::{Read, Seek};
12915
12916 use common::{url::Params, ToParts};
12917 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12918
12919 let mut dd = common::DefaultDelegate;
12920 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12921 dlg.begin(common::MethodInfo {
12922 id: "monitoring.projects.notificationChannels.list",
12923 http_method: hyper::Method::GET,
12924 });
12925
12926 for &field in ["alt", "name", "pageToken", "pageSize", "orderBy", "filter"].iter() {
12927 if self._additional_params.contains_key(field) {
12928 dlg.finished(false);
12929 return Err(common::Error::FieldClash(field));
12930 }
12931 }
12932
12933 let mut params = Params::with_capacity(7 + self._additional_params.len());
12934 params.push("name", self._name);
12935 if let Some(value) = self._page_token.as_ref() {
12936 params.push("pageToken", value);
12937 }
12938 if let Some(value) = self._page_size.as_ref() {
12939 params.push("pageSize", value.to_string());
12940 }
12941 if let Some(value) = self._order_by.as_ref() {
12942 params.push("orderBy", value);
12943 }
12944 if let Some(value) = self._filter.as_ref() {
12945 params.push("filter", value);
12946 }
12947
12948 params.extend(self._additional_params.iter());
12949
12950 params.push("alt", "json");
12951 let mut url = self.hub._base_url.clone() + "v3/{+name}/notificationChannels";
12952 if self._scopes.is_empty() {
12953 self._scopes
12954 .insert(Scope::CloudPlatform.as_ref().to_string());
12955 }
12956
12957 #[allow(clippy::single_element_loop)]
12958 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12959 url = params.uri_replacement(url, param_name, find_this, true);
12960 }
12961 {
12962 let to_remove = ["name"];
12963 params.remove_params(&to_remove);
12964 }
12965
12966 let url = params.parse_with_url(&url);
12967
12968 loop {
12969 let token = match self
12970 .hub
12971 .auth
12972 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12973 .await
12974 {
12975 Ok(token) => token,
12976 Err(e) => match dlg.token(e) {
12977 Ok(token) => token,
12978 Err(e) => {
12979 dlg.finished(false);
12980 return Err(common::Error::MissingToken(e));
12981 }
12982 },
12983 };
12984 let mut req_result = {
12985 let client = &self.hub.client;
12986 dlg.pre_request();
12987 let mut req_builder = hyper::Request::builder()
12988 .method(hyper::Method::GET)
12989 .uri(url.as_str())
12990 .header(USER_AGENT, self.hub._user_agent.clone());
12991
12992 if let Some(token) = token.as_ref() {
12993 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12994 }
12995
12996 let request = req_builder
12997 .header(CONTENT_LENGTH, 0_u64)
12998 .body(common::to_body::<String>(None));
12999
13000 client.request(request.unwrap()).await
13001 };
13002
13003 match req_result {
13004 Err(err) => {
13005 if let common::Retry::After(d) = dlg.http_error(&err) {
13006 sleep(d).await;
13007 continue;
13008 }
13009 dlg.finished(false);
13010 return Err(common::Error::HttpError(err));
13011 }
13012 Ok(res) => {
13013 let (mut parts, body) = res.into_parts();
13014 let mut body = common::Body::new(body);
13015 if !parts.status.is_success() {
13016 let bytes = common::to_bytes(body).await.unwrap_or_default();
13017 let error = serde_json::from_str(&common::to_string(&bytes));
13018 let response = common::to_response(parts, bytes.into());
13019
13020 if let common::Retry::After(d) =
13021 dlg.http_failure(&response, error.as_ref().ok())
13022 {
13023 sleep(d).await;
13024 continue;
13025 }
13026
13027 dlg.finished(false);
13028
13029 return Err(match error {
13030 Ok(value) => common::Error::BadRequest(value),
13031 _ => common::Error::Failure(response),
13032 });
13033 }
13034 let response = {
13035 let bytes = common::to_bytes(body).await.unwrap_or_default();
13036 let encoded = common::to_string(&bytes);
13037 match serde_json::from_str(&encoded) {
13038 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13039 Err(error) => {
13040 dlg.response_json_decode_error(&encoded, &error);
13041 return Err(common::Error::JsonDecodeError(
13042 encoded.to_string(),
13043 error,
13044 ));
13045 }
13046 }
13047 };
13048
13049 dlg.finished(true);
13050 return Ok(response);
13051 }
13052 }
13053 }
13054 }
13055
13056 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER] This names the container in which to look for the notification channels; it does not name a specific channel. To query a specific channel by REST resource name, use the GetNotificationChannel operation.
13057 ///
13058 /// Sets the *name* path property to the given value.
13059 ///
13060 /// Even though the property as already been set when instantiating this call,
13061 /// we provide this method for API completeness.
13062 pub fn name(mut self, new_value: &str) -> ProjectNotificationChannelListCall<'a, C> {
13063 self._name = new_value.to_string();
13064 self
13065 }
13066 /// If non-empty, page_token must contain a value returned as the next_page_token in a previous response to request the next set of results.
13067 ///
13068 /// Sets the *page token* query property to the given value.
13069 pub fn page_token(mut self, new_value: &str) -> ProjectNotificationChannelListCall<'a, C> {
13070 self._page_token = Some(new_value.to_string());
13071 self
13072 }
13073 /// The maximum number of results to return in a single response. If not set to a positive number, a reasonable value will be chosen by the service.
13074 ///
13075 /// Sets the *page size* query property to the given value.
13076 pub fn page_size(mut self, new_value: i32) -> ProjectNotificationChannelListCall<'a, C> {
13077 self._page_size = Some(new_value);
13078 self
13079 }
13080 /// A comma-separated list of fields by which to sort the result. Supports the same set of fields as in filter. Entries can be prefixed with a minus sign to sort in descending rather than ascending order.For more details, see sorting and filtering (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
13081 ///
13082 /// Sets the *order by* query property to the given value.
13083 pub fn order_by(mut self, new_value: &str) -> ProjectNotificationChannelListCall<'a, C> {
13084 self._order_by = Some(new_value.to_string());
13085 self
13086 }
13087 /// If provided, this field specifies the criteria that must be met by notification channels to be included in the response.For more details, see sorting and filtering (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
13088 ///
13089 /// Sets the *filter* query property to the given value.
13090 pub fn filter(mut self, new_value: &str) -> ProjectNotificationChannelListCall<'a, C> {
13091 self._filter = Some(new_value.to_string());
13092 self
13093 }
13094 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13095 /// while executing the actual API request.
13096 ///
13097 /// ````text
13098 /// It should be used to handle progress information, and to implement a certain level of resilience.
13099 /// ````
13100 ///
13101 /// Sets the *delegate* property to the given value.
13102 pub fn delegate(
13103 mut self,
13104 new_value: &'a mut dyn common::Delegate,
13105 ) -> ProjectNotificationChannelListCall<'a, C> {
13106 self._delegate = Some(new_value);
13107 self
13108 }
13109
13110 /// Set any additional parameter of the query string used in the request.
13111 /// It should be used to set parameters which are not yet available through their own
13112 /// setters.
13113 ///
13114 /// Please note that this method must not be used to set any of the known parameters
13115 /// which have their own setter method. If done anyway, the request will fail.
13116 ///
13117 /// # Additional Parameters
13118 ///
13119 /// * *$.xgafv* (query-string) - V1 error format.
13120 /// * *access_token* (query-string) - OAuth access token.
13121 /// * *alt* (query-string) - Data format for response.
13122 /// * *callback* (query-string) - JSONP
13123 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13124 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13125 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13126 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13127 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13128 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13129 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13130 pub fn param<T>(mut self, name: T, value: T) -> ProjectNotificationChannelListCall<'a, C>
13131 where
13132 T: AsRef<str>,
13133 {
13134 self._additional_params
13135 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13136 self
13137 }
13138
13139 /// Identifies the authorization scope for the method you are building.
13140 ///
13141 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13142 /// [`Scope::CloudPlatform`].
13143 ///
13144 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13145 /// tokens for more than one scope.
13146 ///
13147 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13148 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13149 /// sufficient, a read-write scope will do as well.
13150 pub fn add_scope<St>(mut self, scope: St) -> ProjectNotificationChannelListCall<'a, C>
13151 where
13152 St: AsRef<str>,
13153 {
13154 self._scopes.insert(String::from(scope.as_ref()));
13155 self
13156 }
13157 /// Identifies the authorization scope(s) for the method you are building.
13158 ///
13159 /// See [`Self::add_scope()`] for details.
13160 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNotificationChannelListCall<'a, C>
13161 where
13162 I: IntoIterator<Item = St>,
13163 St: AsRef<str>,
13164 {
13165 self._scopes
13166 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13167 self
13168 }
13169
13170 /// Removes all scopes, and no default scope will be used either.
13171 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13172 /// for details).
13173 pub fn clear_scopes(mut self) -> ProjectNotificationChannelListCall<'a, C> {
13174 self._scopes.clear();
13175 self
13176 }
13177}
13178
13179/// Updates a notification channel. Fields not specified in the field mask remain unchanged.Design your application to single-thread API calls that modify the state of notification channels in a single project. This includes calls to CreateNotificationChannel, DeleteNotificationChannel and UpdateNotificationChannel.
13180///
13181/// A builder for the *notificationChannels.patch* method supported by a *project* resource.
13182/// It is not used directly, but through a [`ProjectMethods`] instance.
13183///
13184/// # Example
13185///
13186/// Instantiate a resource method builder
13187///
13188/// ```test_harness,no_run
13189/// # extern crate hyper;
13190/// # extern crate hyper_rustls;
13191/// # extern crate google_monitoring3 as monitoring3;
13192/// use monitoring3::api::NotificationChannel;
13193/// # async fn dox() {
13194/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13195///
13196/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13197/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13198/// # secret,
13199/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13200/// # ).build().await.unwrap();
13201///
13202/// # let client = hyper_util::client::legacy::Client::builder(
13203/// # hyper_util::rt::TokioExecutor::new()
13204/// # )
13205/// # .build(
13206/// # hyper_rustls::HttpsConnectorBuilder::new()
13207/// # .with_native_roots()
13208/// # .unwrap()
13209/// # .https_or_http()
13210/// # .enable_http1()
13211/// # .build()
13212/// # );
13213/// # let mut hub = Monitoring::new(client, auth);
13214/// // As the method needs a request, you would usually fill it with the desired information
13215/// // into the respective structure. Some of the parts shown here might not be applicable !
13216/// // Values shown here are possibly random and not representative !
13217/// let mut req = NotificationChannel::default();
13218///
13219/// // You can configure optional parameters by calling the respective setters at will, and
13220/// // execute the final call using `doit()`.
13221/// // Values shown here are possibly random and not representative !
13222/// let result = hub.projects().notification_channels_patch(req, "name")
13223/// .update_mask(FieldMask::new::<&str>(&[]))
13224/// .doit().await;
13225/// # }
13226/// ```
13227pub struct ProjectNotificationChannelPatchCall<'a, C>
13228where
13229 C: 'a,
13230{
13231 hub: &'a Monitoring<C>,
13232 _request: NotificationChannel,
13233 _name: String,
13234 _update_mask: Option<common::FieldMask>,
13235 _delegate: Option<&'a mut dyn common::Delegate>,
13236 _additional_params: HashMap<String, String>,
13237 _scopes: BTreeSet<String>,
13238}
13239
13240impl<'a, C> common::CallBuilder for ProjectNotificationChannelPatchCall<'a, C> {}
13241
13242impl<'a, C> ProjectNotificationChannelPatchCall<'a, C>
13243where
13244 C: common::Connector,
13245{
13246 /// Perform the operation you have build so far.
13247 pub async fn doit(mut self) -> common::Result<(common::Response, NotificationChannel)> {
13248 use std::borrow::Cow;
13249 use std::io::{Read, Seek};
13250
13251 use common::{url::Params, ToParts};
13252 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13253
13254 let mut dd = common::DefaultDelegate;
13255 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13256 dlg.begin(common::MethodInfo {
13257 id: "monitoring.projects.notificationChannels.patch",
13258 http_method: hyper::Method::PATCH,
13259 });
13260
13261 for &field in ["alt", "name", "updateMask"].iter() {
13262 if self._additional_params.contains_key(field) {
13263 dlg.finished(false);
13264 return Err(common::Error::FieldClash(field));
13265 }
13266 }
13267
13268 let mut params = Params::with_capacity(5 + self._additional_params.len());
13269 params.push("name", self._name);
13270 if let Some(value) = self._update_mask.as_ref() {
13271 params.push("updateMask", value.to_string());
13272 }
13273
13274 params.extend(self._additional_params.iter());
13275
13276 params.push("alt", "json");
13277 let mut url = self.hub._base_url.clone() + "v3/{+name}";
13278 if self._scopes.is_empty() {
13279 self._scopes
13280 .insert(Scope::CloudPlatform.as_ref().to_string());
13281 }
13282
13283 #[allow(clippy::single_element_loop)]
13284 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13285 url = params.uri_replacement(url, param_name, find_this, true);
13286 }
13287 {
13288 let to_remove = ["name"];
13289 params.remove_params(&to_remove);
13290 }
13291
13292 let url = params.parse_with_url(&url);
13293
13294 let mut json_mime_type = mime::APPLICATION_JSON;
13295 let mut request_value_reader = {
13296 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13297 common::remove_json_null_values(&mut value);
13298 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13299 serde_json::to_writer(&mut dst, &value).unwrap();
13300 dst
13301 };
13302 let request_size = request_value_reader
13303 .seek(std::io::SeekFrom::End(0))
13304 .unwrap();
13305 request_value_reader
13306 .seek(std::io::SeekFrom::Start(0))
13307 .unwrap();
13308
13309 loop {
13310 let token = match self
13311 .hub
13312 .auth
13313 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13314 .await
13315 {
13316 Ok(token) => token,
13317 Err(e) => match dlg.token(e) {
13318 Ok(token) => token,
13319 Err(e) => {
13320 dlg.finished(false);
13321 return Err(common::Error::MissingToken(e));
13322 }
13323 },
13324 };
13325 request_value_reader
13326 .seek(std::io::SeekFrom::Start(0))
13327 .unwrap();
13328 let mut req_result = {
13329 let client = &self.hub.client;
13330 dlg.pre_request();
13331 let mut req_builder = hyper::Request::builder()
13332 .method(hyper::Method::PATCH)
13333 .uri(url.as_str())
13334 .header(USER_AGENT, self.hub._user_agent.clone());
13335
13336 if let Some(token) = token.as_ref() {
13337 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13338 }
13339
13340 let request = req_builder
13341 .header(CONTENT_TYPE, json_mime_type.to_string())
13342 .header(CONTENT_LENGTH, request_size as u64)
13343 .body(common::to_body(
13344 request_value_reader.get_ref().clone().into(),
13345 ));
13346
13347 client.request(request.unwrap()).await
13348 };
13349
13350 match req_result {
13351 Err(err) => {
13352 if let common::Retry::After(d) = dlg.http_error(&err) {
13353 sleep(d).await;
13354 continue;
13355 }
13356 dlg.finished(false);
13357 return Err(common::Error::HttpError(err));
13358 }
13359 Ok(res) => {
13360 let (mut parts, body) = res.into_parts();
13361 let mut body = common::Body::new(body);
13362 if !parts.status.is_success() {
13363 let bytes = common::to_bytes(body).await.unwrap_or_default();
13364 let error = serde_json::from_str(&common::to_string(&bytes));
13365 let response = common::to_response(parts, bytes.into());
13366
13367 if let common::Retry::After(d) =
13368 dlg.http_failure(&response, error.as_ref().ok())
13369 {
13370 sleep(d).await;
13371 continue;
13372 }
13373
13374 dlg.finished(false);
13375
13376 return Err(match error {
13377 Ok(value) => common::Error::BadRequest(value),
13378 _ => common::Error::Failure(response),
13379 });
13380 }
13381 let response = {
13382 let bytes = common::to_bytes(body).await.unwrap_or_default();
13383 let encoded = common::to_string(&bytes);
13384 match serde_json::from_str(&encoded) {
13385 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13386 Err(error) => {
13387 dlg.response_json_decode_error(&encoded, &error);
13388 return Err(common::Error::JsonDecodeError(
13389 encoded.to_string(),
13390 error,
13391 ));
13392 }
13393 }
13394 };
13395
13396 dlg.finished(true);
13397 return Ok(response);
13398 }
13399 }
13400 }
13401 }
13402
13403 ///
13404 /// Sets the *request* property to the given value.
13405 ///
13406 /// Even though the property as already been set when instantiating this call,
13407 /// we provide this method for API completeness.
13408 pub fn request(
13409 mut self,
13410 new_value: NotificationChannel,
13411 ) -> ProjectNotificationChannelPatchCall<'a, C> {
13412 self._request = new_value;
13413 self
13414 }
13415 /// The full REST resource name for this channel. The format is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] The [CHANNEL_ID] is automatically assigned by the server on creation.
13416 ///
13417 /// Sets the *name* path property to the given value.
13418 ///
13419 /// Even though the property as already been set when instantiating this call,
13420 /// we provide this method for API completeness.
13421 pub fn name(mut self, new_value: &str) -> ProjectNotificationChannelPatchCall<'a, C> {
13422 self._name = new_value.to_string();
13423 self
13424 }
13425 /// The fields to update.
13426 ///
13427 /// Sets the *update mask* query property to the given value.
13428 pub fn update_mask(
13429 mut self,
13430 new_value: common::FieldMask,
13431 ) -> ProjectNotificationChannelPatchCall<'a, C> {
13432 self._update_mask = Some(new_value);
13433 self
13434 }
13435 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13436 /// while executing the actual API request.
13437 ///
13438 /// ````text
13439 /// It should be used to handle progress information, and to implement a certain level of resilience.
13440 /// ````
13441 ///
13442 /// Sets the *delegate* property to the given value.
13443 pub fn delegate(
13444 mut self,
13445 new_value: &'a mut dyn common::Delegate,
13446 ) -> ProjectNotificationChannelPatchCall<'a, C> {
13447 self._delegate = Some(new_value);
13448 self
13449 }
13450
13451 /// Set any additional parameter of the query string used in the request.
13452 /// It should be used to set parameters which are not yet available through their own
13453 /// setters.
13454 ///
13455 /// Please note that this method must not be used to set any of the known parameters
13456 /// which have their own setter method. If done anyway, the request will fail.
13457 ///
13458 /// # Additional Parameters
13459 ///
13460 /// * *$.xgafv* (query-string) - V1 error format.
13461 /// * *access_token* (query-string) - OAuth access token.
13462 /// * *alt* (query-string) - Data format for response.
13463 /// * *callback* (query-string) - JSONP
13464 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13465 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13466 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13467 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13468 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13469 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13470 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13471 pub fn param<T>(mut self, name: T, value: T) -> ProjectNotificationChannelPatchCall<'a, C>
13472 where
13473 T: AsRef<str>,
13474 {
13475 self._additional_params
13476 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13477 self
13478 }
13479
13480 /// Identifies the authorization scope for the method you are building.
13481 ///
13482 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13483 /// [`Scope::CloudPlatform`].
13484 ///
13485 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13486 /// tokens for more than one scope.
13487 ///
13488 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13489 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13490 /// sufficient, a read-write scope will do as well.
13491 pub fn add_scope<St>(mut self, scope: St) -> ProjectNotificationChannelPatchCall<'a, C>
13492 where
13493 St: AsRef<str>,
13494 {
13495 self._scopes.insert(String::from(scope.as_ref()));
13496 self
13497 }
13498 /// Identifies the authorization scope(s) for the method you are building.
13499 ///
13500 /// See [`Self::add_scope()`] for details.
13501 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNotificationChannelPatchCall<'a, C>
13502 where
13503 I: IntoIterator<Item = St>,
13504 St: AsRef<str>,
13505 {
13506 self._scopes
13507 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13508 self
13509 }
13510
13511 /// Removes all scopes, and no default scope will be used either.
13512 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13513 /// for details).
13514 pub fn clear_scopes(mut self) -> ProjectNotificationChannelPatchCall<'a, C> {
13515 self._scopes.clear();
13516 self
13517 }
13518}
13519
13520/// Causes a verification code to be delivered to the channel. The code can then be supplied in VerifyNotificationChannel to verify the channel.
13521///
13522/// A builder for the *notificationChannels.sendVerificationCode* method supported by a *project* resource.
13523/// It is not used directly, but through a [`ProjectMethods`] instance.
13524///
13525/// # Example
13526///
13527/// Instantiate a resource method builder
13528///
13529/// ```test_harness,no_run
13530/// # extern crate hyper;
13531/// # extern crate hyper_rustls;
13532/// # extern crate google_monitoring3 as monitoring3;
13533/// use monitoring3::api::SendNotificationChannelVerificationCodeRequest;
13534/// # async fn dox() {
13535/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13536///
13537/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13538/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13539/// # secret,
13540/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13541/// # ).build().await.unwrap();
13542///
13543/// # let client = hyper_util::client::legacy::Client::builder(
13544/// # hyper_util::rt::TokioExecutor::new()
13545/// # )
13546/// # .build(
13547/// # hyper_rustls::HttpsConnectorBuilder::new()
13548/// # .with_native_roots()
13549/// # .unwrap()
13550/// # .https_or_http()
13551/// # .enable_http1()
13552/// # .build()
13553/// # );
13554/// # let mut hub = Monitoring::new(client, auth);
13555/// // As the method needs a request, you would usually fill it with the desired information
13556/// // into the respective structure. Some of the parts shown here might not be applicable !
13557/// // Values shown here are possibly random and not representative !
13558/// let mut req = SendNotificationChannelVerificationCodeRequest::default();
13559///
13560/// // You can configure optional parameters by calling the respective setters at will, and
13561/// // execute the final call using `doit()`.
13562/// // Values shown here are possibly random and not representative !
13563/// let result = hub.projects().notification_channels_send_verification_code(req, "name")
13564/// .doit().await;
13565/// # }
13566/// ```
13567pub struct ProjectNotificationChannelSendVerificationCodeCall<'a, C>
13568where
13569 C: 'a,
13570{
13571 hub: &'a Monitoring<C>,
13572 _request: SendNotificationChannelVerificationCodeRequest,
13573 _name: String,
13574 _delegate: Option<&'a mut dyn common::Delegate>,
13575 _additional_params: HashMap<String, String>,
13576 _scopes: BTreeSet<String>,
13577}
13578
13579impl<'a, C> common::CallBuilder for ProjectNotificationChannelSendVerificationCodeCall<'a, C> {}
13580
13581impl<'a, C> ProjectNotificationChannelSendVerificationCodeCall<'a, C>
13582where
13583 C: common::Connector,
13584{
13585 /// Perform the operation you have build so far.
13586 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
13587 use std::borrow::Cow;
13588 use std::io::{Read, Seek};
13589
13590 use common::{url::Params, ToParts};
13591 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13592
13593 let mut dd = common::DefaultDelegate;
13594 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13595 dlg.begin(common::MethodInfo {
13596 id: "monitoring.projects.notificationChannels.sendVerificationCode",
13597 http_method: hyper::Method::POST,
13598 });
13599
13600 for &field in ["alt", "name"].iter() {
13601 if self._additional_params.contains_key(field) {
13602 dlg.finished(false);
13603 return Err(common::Error::FieldClash(field));
13604 }
13605 }
13606
13607 let mut params = Params::with_capacity(4 + self._additional_params.len());
13608 params.push("name", self._name);
13609
13610 params.extend(self._additional_params.iter());
13611
13612 params.push("alt", "json");
13613 let mut url = self.hub._base_url.clone() + "v3/{+name}:sendVerificationCode";
13614 if self._scopes.is_empty() {
13615 self._scopes
13616 .insert(Scope::CloudPlatform.as_ref().to_string());
13617 }
13618
13619 #[allow(clippy::single_element_loop)]
13620 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13621 url = params.uri_replacement(url, param_name, find_this, true);
13622 }
13623 {
13624 let to_remove = ["name"];
13625 params.remove_params(&to_remove);
13626 }
13627
13628 let url = params.parse_with_url(&url);
13629
13630 let mut json_mime_type = mime::APPLICATION_JSON;
13631 let mut request_value_reader = {
13632 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13633 common::remove_json_null_values(&mut value);
13634 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13635 serde_json::to_writer(&mut dst, &value).unwrap();
13636 dst
13637 };
13638 let request_size = request_value_reader
13639 .seek(std::io::SeekFrom::End(0))
13640 .unwrap();
13641 request_value_reader
13642 .seek(std::io::SeekFrom::Start(0))
13643 .unwrap();
13644
13645 loop {
13646 let token = match self
13647 .hub
13648 .auth
13649 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13650 .await
13651 {
13652 Ok(token) => token,
13653 Err(e) => match dlg.token(e) {
13654 Ok(token) => token,
13655 Err(e) => {
13656 dlg.finished(false);
13657 return Err(common::Error::MissingToken(e));
13658 }
13659 },
13660 };
13661 request_value_reader
13662 .seek(std::io::SeekFrom::Start(0))
13663 .unwrap();
13664 let mut req_result = {
13665 let client = &self.hub.client;
13666 dlg.pre_request();
13667 let mut req_builder = hyper::Request::builder()
13668 .method(hyper::Method::POST)
13669 .uri(url.as_str())
13670 .header(USER_AGENT, self.hub._user_agent.clone());
13671
13672 if let Some(token) = token.as_ref() {
13673 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13674 }
13675
13676 let request = req_builder
13677 .header(CONTENT_TYPE, json_mime_type.to_string())
13678 .header(CONTENT_LENGTH, request_size as u64)
13679 .body(common::to_body(
13680 request_value_reader.get_ref().clone().into(),
13681 ));
13682
13683 client.request(request.unwrap()).await
13684 };
13685
13686 match req_result {
13687 Err(err) => {
13688 if let common::Retry::After(d) = dlg.http_error(&err) {
13689 sleep(d).await;
13690 continue;
13691 }
13692 dlg.finished(false);
13693 return Err(common::Error::HttpError(err));
13694 }
13695 Ok(res) => {
13696 let (mut parts, body) = res.into_parts();
13697 let mut body = common::Body::new(body);
13698 if !parts.status.is_success() {
13699 let bytes = common::to_bytes(body).await.unwrap_or_default();
13700 let error = serde_json::from_str(&common::to_string(&bytes));
13701 let response = common::to_response(parts, bytes.into());
13702
13703 if let common::Retry::After(d) =
13704 dlg.http_failure(&response, error.as_ref().ok())
13705 {
13706 sleep(d).await;
13707 continue;
13708 }
13709
13710 dlg.finished(false);
13711
13712 return Err(match error {
13713 Ok(value) => common::Error::BadRequest(value),
13714 _ => common::Error::Failure(response),
13715 });
13716 }
13717 let response = {
13718 let bytes = common::to_bytes(body).await.unwrap_or_default();
13719 let encoded = common::to_string(&bytes);
13720 match serde_json::from_str(&encoded) {
13721 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13722 Err(error) => {
13723 dlg.response_json_decode_error(&encoded, &error);
13724 return Err(common::Error::JsonDecodeError(
13725 encoded.to_string(),
13726 error,
13727 ));
13728 }
13729 }
13730 };
13731
13732 dlg.finished(true);
13733 return Ok(response);
13734 }
13735 }
13736 }
13737 }
13738
13739 ///
13740 /// Sets the *request* property to the given value.
13741 ///
13742 /// Even though the property as already been set when instantiating this call,
13743 /// we provide this method for API completeness.
13744 pub fn request(
13745 mut self,
13746 new_value: SendNotificationChannelVerificationCodeRequest,
13747 ) -> ProjectNotificationChannelSendVerificationCodeCall<'a, C> {
13748 self._request = new_value;
13749 self
13750 }
13751 /// Required. The notification channel to which to send a verification code.
13752 ///
13753 /// Sets the *name* path property to the given value.
13754 ///
13755 /// Even though the property as already been set when instantiating this call,
13756 /// we provide this method for API completeness.
13757 pub fn name(
13758 mut self,
13759 new_value: &str,
13760 ) -> ProjectNotificationChannelSendVerificationCodeCall<'a, C> {
13761 self._name = new_value.to_string();
13762 self
13763 }
13764 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13765 /// while executing the actual API request.
13766 ///
13767 /// ````text
13768 /// It should be used to handle progress information, and to implement a certain level of resilience.
13769 /// ````
13770 ///
13771 /// Sets the *delegate* property to the given value.
13772 pub fn delegate(
13773 mut self,
13774 new_value: &'a mut dyn common::Delegate,
13775 ) -> ProjectNotificationChannelSendVerificationCodeCall<'a, C> {
13776 self._delegate = Some(new_value);
13777 self
13778 }
13779
13780 /// Set any additional parameter of the query string used in the request.
13781 /// It should be used to set parameters which are not yet available through their own
13782 /// setters.
13783 ///
13784 /// Please note that this method must not be used to set any of the known parameters
13785 /// which have their own setter method. If done anyway, the request will fail.
13786 ///
13787 /// # Additional Parameters
13788 ///
13789 /// * *$.xgafv* (query-string) - V1 error format.
13790 /// * *access_token* (query-string) - OAuth access token.
13791 /// * *alt* (query-string) - Data format for response.
13792 /// * *callback* (query-string) - JSONP
13793 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13794 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13795 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13796 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13797 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13798 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13799 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13800 pub fn param<T>(
13801 mut self,
13802 name: T,
13803 value: T,
13804 ) -> ProjectNotificationChannelSendVerificationCodeCall<'a, C>
13805 where
13806 T: AsRef<str>,
13807 {
13808 self._additional_params
13809 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13810 self
13811 }
13812
13813 /// Identifies the authorization scope for the method you are building.
13814 ///
13815 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13816 /// [`Scope::CloudPlatform`].
13817 ///
13818 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13819 /// tokens for more than one scope.
13820 ///
13821 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13822 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13823 /// sufficient, a read-write scope will do as well.
13824 pub fn add_scope<St>(
13825 mut self,
13826 scope: St,
13827 ) -> ProjectNotificationChannelSendVerificationCodeCall<'a, C>
13828 where
13829 St: AsRef<str>,
13830 {
13831 self._scopes.insert(String::from(scope.as_ref()));
13832 self
13833 }
13834 /// Identifies the authorization scope(s) for the method you are building.
13835 ///
13836 /// See [`Self::add_scope()`] for details.
13837 pub fn add_scopes<I, St>(
13838 mut self,
13839 scopes: I,
13840 ) -> ProjectNotificationChannelSendVerificationCodeCall<'a, C>
13841 where
13842 I: IntoIterator<Item = St>,
13843 St: AsRef<str>,
13844 {
13845 self._scopes
13846 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13847 self
13848 }
13849
13850 /// Removes all scopes, and no default scope will be used either.
13851 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13852 /// for details).
13853 pub fn clear_scopes(mut self) -> ProjectNotificationChannelSendVerificationCodeCall<'a, C> {
13854 self._scopes.clear();
13855 self
13856 }
13857}
13858
13859/// Verifies a NotificationChannel by proving receipt of the code delivered to the channel as a result of calling SendNotificationChannelVerificationCode.
13860///
13861/// A builder for the *notificationChannels.verify* method supported by a *project* resource.
13862/// It is not used directly, but through a [`ProjectMethods`] instance.
13863///
13864/// # Example
13865///
13866/// Instantiate a resource method builder
13867///
13868/// ```test_harness,no_run
13869/// # extern crate hyper;
13870/// # extern crate hyper_rustls;
13871/// # extern crate google_monitoring3 as monitoring3;
13872/// use monitoring3::api::VerifyNotificationChannelRequest;
13873/// # async fn dox() {
13874/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13875///
13876/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13877/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13878/// # secret,
13879/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13880/// # ).build().await.unwrap();
13881///
13882/// # let client = hyper_util::client::legacy::Client::builder(
13883/// # hyper_util::rt::TokioExecutor::new()
13884/// # )
13885/// # .build(
13886/// # hyper_rustls::HttpsConnectorBuilder::new()
13887/// # .with_native_roots()
13888/// # .unwrap()
13889/// # .https_or_http()
13890/// # .enable_http1()
13891/// # .build()
13892/// # );
13893/// # let mut hub = Monitoring::new(client, auth);
13894/// // As the method needs a request, you would usually fill it with the desired information
13895/// // into the respective structure. Some of the parts shown here might not be applicable !
13896/// // Values shown here are possibly random and not representative !
13897/// let mut req = VerifyNotificationChannelRequest::default();
13898///
13899/// // You can configure optional parameters by calling the respective setters at will, and
13900/// // execute the final call using `doit()`.
13901/// // Values shown here are possibly random and not representative !
13902/// let result = hub.projects().notification_channels_verify(req, "name")
13903/// .doit().await;
13904/// # }
13905/// ```
13906pub struct ProjectNotificationChannelVerifyCall<'a, C>
13907where
13908 C: 'a,
13909{
13910 hub: &'a Monitoring<C>,
13911 _request: VerifyNotificationChannelRequest,
13912 _name: String,
13913 _delegate: Option<&'a mut dyn common::Delegate>,
13914 _additional_params: HashMap<String, String>,
13915 _scopes: BTreeSet<String>,
13916}
13917
13918impl<'a, C> common::CallBuilder for ProjectNotificationChannelVerifyCall<'a, C> {}
13919
13920impl<'a, C> ProjectNotificationChannelVerifyCall<'a, C>
13921where
13922 C: common::Connector,
13923{
13924 /// Perform the operation you have build so far.
13925 pub async fn doit(mut self) -> common::Result<(common::Response, NotificationChannel)> {
13926 use std::borrow::Cow;
13927 use std::io::{Read, Seek};
13928
13929 use common::{url::Params, ToParts};
13930 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13931
13932 let mut dd = common::DefaultDelegate;
13933 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13934 dlg.begin(common::MethodInfo {
13935 id: "monitoring.projects.notificationChannels.verify",
13936 http_method: hyper::Method::POST,
13937 });
13938
13939 for &field in ["alt", "name"].iter() {
13940 if self._additional_params.contains_key(field) {
13941 dlg.finished(false);
13942 return Err(common::Error::FieldClash(field));
13943 }
13944 }
13945
13946 let mut params = Params::with_capacity(4 + self._additional_params.len());
13947 params.push("name", self._name);
13948
13949 params.extend(self._additional_params.iter());
13950
13951 params.push("alt", "json");
13952 let mut url = self.hub._base_url.clone() + "v3/{+name}:verify";
13953 if self._scopes.is_empty() {
13954 self._scopes
13955 .insert(Scope::CloudPlatform.as_ref().to_string());
13956 }
13957
13958 #[allow(clippy::single_element_loop)]
13959 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13960 url = params.uri_replacement(url, param_name, find_this, true);
13961 }
13962 {
13963 let to_remove = ["name"];
13964 params.remove_params(&to_remove);
13965 }
13966
13967 let url = params.parse_with_url(&url);
13968
13969 let mut json_mime_type = mime::APPLICATION_JSON;
13970 let mut request_value_reader = {
13971 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13972 common::remove_json_null_values(&mut value);
13973 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13974 serde_json::to_writer(&mut dst, &value).unwrap();
13975 dst
13976 };
13977 let request_size = request_value_reader
13978 .seek(std::io::SeekFrom::End(0))
13979 .unwrap();
13980 request_value_reader
13981 .seek(std::io::SeekFrom::Start(0))
13982 .unwrap();
13983
13984 loop {
13985 let token = match self
13986 .hub
13987 .auth
13988 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13989 .await
13990 {
13991 Ok(token) => token,
13992 Err(e) => match dlg.token(e) {
13993 Ok(token) => token,
13994 Err(e) => {
13995 dlg.finished(false);
13996 return Err(common::Error::MissingToken(e));
13997 }
13998 },
13999 };
14000 request_value_reader
14001 .seek(std::io::SeekFrom::Start(0))
14002 .unwrap();
14003 let mut req_result = {
14004 let client = &self.hub.client;
14005 dlg.pre_request();
14006 let mut req_builder = hyper::Request::builder()
14007 .method(hyper::Method::POST)
14008 .uri(url.as_str())
14009 .header(USER_AGENT, self.hub._user_agent.clone());
14010
14011 if let Some(token) = token.as_ref() {
14012 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14013 }
14014
14015 let request = req_builder
14016 .header(CONTENT_TYPE, json_mime_type.to_string())
14017 .header(CONTENT_LENGTH, request_size as u64)
14018 .body(common::to_body(
14019 request_value_reader.get_ref().clone().into(),
14020 ));
14021
14022 client.request(request.unwrap()).await
14023 };
14024
14025 match req_result {
14026 Err(err) => {
14027 if let common::Retry::After(d) = dlg.http_error(&err) {
14028 sleep(d).await;
14029 continue;
14030 }
14031 dlg.finished(false);
14032 return Err(common::Error::HttpError(err));
14033 }
14034 Ok(res) => {
14035 let (mut parts, body) = res.into_parts();
14036 let mut body = common::Body::new(body);
14037 if !parts.status.is_success() {
14038 let bytes = common::to_bytes(body).await.unwrap_or_default();
14039 let error = serde_json::from_str(&common::to_string(&bytes));
14040 let response = common::to_response(parts, bytes.into());
14041
14042 if let common::Retry::After(d) =
14043 dlg.http_failure(&response, error.as_ref().ok())
14044 {
14045 sleep(d).await;
14046 continue;
14047 }
14048
14049 dlg.finished(false);
14050
14051 return Err(match error {
14052 Ok(value) => common::Error::BadRequest(value),
14053 _ => common::Error::Failure(response),
14054 });
14055 }
14056 let response = {
14057 let bytes = common::to_bytes(body).await.unwrap_or_default();
14058 let encoded = common::to_string(&bytes);
14059 match serde_json::from_str(&encoded) {
14060 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14061 Err(error) => {
14062 dlg.response_json_decode_error(&encoded, &error);
14063 return Err(common::Error::JsonDecodeError(
14064 encoded.to_string(),
14065 error,
14066 ));
14067 }
14068 }
14069 };
14070
14071 dlg.finished(true);
14072 return Ok(response);
14073 }
14074 }
14075 }
14076 }
14077
14078 ///
14079 /// Sets the *request* property to the given value.
14080 ///
14081 /// Even though the property as already been set when instantiating this call,
14082 /// we provide this method for API completeness.
14083 pub fn request(
14084 mut self,
14085 new_value: VerifyNotificationChannelRequest,
14086 ) -> ProjectNotificationChannelVerifyCall<'a, C> {
14087 self._request = new_value;
14088 self
14089 }
14090 /// Required. The notification channel to verify.
14091 ///
14092 /// Sets the *name* path property to the given value.
14093 ///
14094 /// Even though the property as already been set when instantiating this call,
14095 /// we provide this method for API completeness.
14096 pub fn name(mut self, new_value: &str) -> ProjectNotificationChannelVerifyCall<'a, C> {
14097 self._name = new_value.to_string();
14098 self
14099 }
14100 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14101 /// while executing the actual API request.
14102 ///
14103 /// ````text
14104 /// It should be used to handle progress information, and to implement a certain level of resilience.
14105 /// ````
14106 ///
14107 /// Sets the *delegate* property to the given value.
14108 pub fn delegate(
14109 mut self,
14110 new_value: &'a mut dyn common::Delegate,
14111 ) -> ProjectNotificationChannelVerifyCall<'a, C> {
14112 self._delegate = Some(new_value);
14113 self
14114 }
14115
14116 /// Set any additional parameter of the query string used in the request.
14117 /// It should be used to set parameters which are not yet available through their own
14118 /// setters.
14119 ///
14120 /// Please note that this method must not be used to set any of the known parameters
14121 /// which have their own setter method. If done anyway, the request will fail.
14122 ///
14123 /// # Additional Parameters
14124 ///
14125 /// * *$.xgafv* (query-string) - V1 error format.
14126 /// * *access_token* (query-string) - OAuth access token.
14127 /// * *alt* (query-string) - Data format for response.
14128 /// * *callback* (query-string) - JSONP
14129 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14130 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14131 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14132 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14133 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14134 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14135 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14136 pub fn param<T>(mut self, name: T, value: T) -> ProjectNotificationChannelVerifyCall<'a, C>
14137 where
14138 T: AsRef<str>,
14139 {
14140 self._additional_params
14141 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14142 self
14143 }
14144
14145 /// Identifies the authorization scope for the method you are building.
14146 ///
14147 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14148 /// [`Scope::CloudPlatform`].
14149 ///
14150 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14151 /// tokens for more than one scope.
14152 ///
14153 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14154 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14155 /// sufficient, a read-write scope will do as well.
14156 pub fn add_scope<St>(mut self, scope: St) -> ProjectNotificationChannelVerifyCall<'a, C>
14157 where
14158 St: AsRef<str>,
14159 {
14160 self._scopes.insert(String::from(scope.as_ref()));
14161 self
14162 }
14163 /// Identifies the authorization scope(s) for the method you are building.
14164 ///
14165 /// See [`Self::add_scope()`] for details.
14166 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNotificationChannelVerifyCall<'a, C>
14167 where
14168 I: IntoIterator<Item = St>,
14169 St: AsRef<str>,
14170 {
14171 self._scopes
14172 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14173 self
14174 }
14175
14176 /// Removes all scopes, and no default scope will be used either.
14177 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14178 /// for details).
14179 pub fn clear_scopes(mut self) -> ProjectNotificationChannelVerifyCall<'a, C> {
14180 self._scopes.clear();
14181 self
14182 }
14183}
14184
14185/// Creates a Snooze that will prevent alerts, which match the provided criteria, from being opened. The Snooze applies for a specific time interval.
14186///
14187/// A builder for the *snoozes.create* method supported by a *project* resource.
14188/// It is not used directly, but through a [`ProjectMethods`] instance.
14189///
14190/// # Example
14191///
14192/// Instantiate a resource method builder
14193///
14194/// ```test_harness,no_run
14195/// # extern crate hyper;
14196/// # extern crate hyper_rustls;
14197/// # extern crate google_monitoring3 as monitoring3;
14198/// use monitoring3::api::Snooze;
14199/// # async fn dox() {
14200/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14201///
14202/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14203/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14204/// # secret,
14205/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14206/// # ).build().await.unwrap();
14207///
14208/// # let client = hyper_util::client::legacy::Client::builder(
14209/// # hyper_util::rt::TokioExecutor::new()
14210/// # )
14211/// # .build(
14212/// # hyper_rustls::HttpsConnectorBuilder::new()
14213/// # .with_native_roots()
14214/// # .unwrap()
14215/// # .https_or_http()
14216/// # .enable_http1()
14217/// # .build()
14218/// # );
14219/// # let mut hub = Monitoring::new(client, auth);
14220/// // As the method needs a request, you would usually fill it with the desired information
14221/// // into the respective structure. Some of the parts shown here might not be applicable !
14222/// // Values shown here are possibly random and not representative !
14223/// let mut req = Snooze::default();
14224///
14225/// // You can configure optional parameters by calling the respective setters at will, and
14226/// // execute the final call using `doit()`.
14227/// // Values shown here are possibly random and not representative !
14228/// let result = hub.projects().snoozes_create(req, "parent")
14229/// .doit().await;
14230/// # }
14231/// ```
14232pub struct ProjectSnoozeCreateCall<'a, C>
14233where
14234 C: 'a,
14235{
14236 hub: &'a Monitoring<C>,
14237 _request: Snooze,
14238 _parent: String,
14239 _delegate: Option<&'a mut dyn common::Delegate>,
14240 _additional_params: HashMap<String, String>,
14241 _scopes: BTreeSet<String>,
14242}
14243
14244impl<'a, C> common::CallBuilder for ProjectSnoozeCreateCall<'a, C> {}
14245
14246impl<'a, C> ProjectSnoozeCreateCall<'a, C>
14247where
14248 C: common::Connector,
14249{
14250 /// Perform the operation you have build so far.
14251 pub async fn doit(mut self) -> common::Result<(common::Response, Snooze)> {
14252 use std::borrow::Cow;
14253 use std::io::{Read, Seek};
14254
14255 use common::{url::Params, ToParts};
14256 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14257
14258 let mut dd = common::DefaultDelegate;
14259 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14260 dlg.begin(common::MethodInfo {
14261 id: "monitoring.projects.snoozes.create",
14262 http_method: hyper::Method::POST,
14263 });
14264
14265 for &field in ["alt", "parent"].iter() {
14266 if self._additional_params.contains_key(field) {
14267 dlg.finished(false);
14268 return Err(common::Error::FieldClash(field));
14269 }
14270 }
14271
14272 let mut params = Params::with_capacity(4 + self._additional_params.len());
14273 params.push("parent", self._parent);
14274
14275 params.extend(self._additional_params.iter());
14276
14277 params.push("alt", "json");
14278 let mut url = self.hub._base_url.clone() + "v3/{+parent}/snoozes";
14279 if self._scopes.is_empty() {
14280 self._scopes
14281 .insert(Scope::CloudPlatform.as_ref().to_string());
14282 }
14283
14284 #[allow(clippy::single_element_loop)]
14285 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14286 url = params.uri_replacement(url, param_name, find_this, true);
14287 }
14288 {
14289 let to_remove = ["parent"];
14290 params.remove_params(&to_remove);
14291 }
14292
14293 let url = params.parse_with_url(&url);
14294
14295 let mut json_mime_type = mime::APPLICATION_JSON;
14296 let mut request_value_reader = {
14297 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14298 common::remove_json_null_values(&mut value);
14299 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14300 serde_json::to_writer(&mut dst, &value).unwrap();
14301 dst
14302 };
14303 let request_size = request_value_reader
14304 .seek(std::io::SeekFrom::End(0))
14305 .unwrap();
14306 request_value_reader
14307 .seek(std::io::SeekFrom::Start(0))
14308 .unwrap();
14309
14310 loop {
14311 let token = match self
14312 .hub
14313 .auth
14314 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14315 .await
14316 {
14317 Ok(token) => token,
14318 Err(e) => match dlg.token(e) {
14319 Ok(token) => token,
14320 Err(e) => {
14321 dlg.finished(false);
14322 return Err(common::Error::MissingToken(e));
14323 }
14324 },
14325 };
14326 request_value_reader
14327 .seek(std::io::SeekFrom::Start(0))
14328 .unwrap();
14329 let mut req_result = {
14330 let client = &self.hub.client;
14331 dlg.pre_request();
14332 let mut req_builder = hyper::Request::builder()
14333 .method(hyper::Method::POST)
14334 .uri(url.as_str())
14335 .header(USER_AGENT, self.hub._user_agent.clone());
14336
14337 if let Some(token) = token.as_ref() {
14338 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14339 }
14340
14341 let request = req_builder
14342 .header(CONTENT_TYPE, json_mime_type.to_string())
14343 .header(CONTENT_LENGTH, request_size as u64)
14344 .body(common::to_body(
14345 request_value_reader.get_ref().clone().into(),
14346 ));
14347
14348 client.request(request.unwrap()).await
14349 };
14350
14351 match req_result {
14352 Err(err) => {
14353 if let common::Retry::After(d) = dlg.http_error(&err) {
14354 sleep(d).await;
14355 continue;
14356 }
14357 dlg.finished(false);
14358 return Err(common::Error::HttpError(err));
14359 }
14360 Ok(res) => {
14361 let (mut parts, body) = res.into_parts();
14362 let mut body = common::Body::new(body);
14363 if !parts.status.is_success() {
14364 let bytes = common::to_bytes(body).await.unwrap_or_default();
14365 let error = serde_json::from_str(&common::to_string(&bytes));
14366 let response = common::to_response(parts, bytes.into());
14367
14368 if let common::Retry::After(d) =
14369 dlg.http_failure(&response, error.as_ref().ok())
14370 {
14371 sleep(d).await;
14372 continue;
14373 }
14374
14375 dlg.finished(false);
14376
14377 return Err(match error {
14378 Ok(value) => common::Error::BadRequest(value),
14379 _ => common::Error::Failure(response),
14380 });
14381 }
14382 let response = {
14383 let bytes = common::to_bytes(body).await.unwrap_or_default();
14384 let encoded = common::to_string(&bytes);
14385 match serde_json::from_str(&encoded) {
14386 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14387 Err(error) => {
14388 dlg.response_json_decode_error(&encoded, &error);
14389 return Err(common::Error::JsonDecodeError(
14390 encoded.to_string(),
14391 error,
14392 ));
14393 }
14394 }
14395 };
14396
14397 dlg.finished(true);
14398 return Ok(response);
14399 }
14400 }
14401 }
14402 }
14403
14404 ///
14405 /// Sets the *request* property to the given value.
14406 ///
14407 /// Even though the property as already been set when instantiating this call,
14408 /// we provide this method for API completeness.
14409 pub fn request(mut self, new_value: Snooze) -> ProjectSnoozeCreateCall<'a, C> {
14410 self._request = new_value;
14411 self
14412 }
14413 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) in which a Snooze should be created. The format is: projects/[PROJECT_ID_OR_NUMBER]
14414 ///
14415 /// Sets the *parent* path property to the given value.
14416 ///
14417 /// Even though the property as already been set when instantiating this call,
14418 /// we provide this method for API completeness.
14419 pub fn parent(mut self, new_value: &str) -> ProjectSnoozeCreateCall<'a, C> {
14420 self._parent = new_value.to_string();
14421 self
14422 }
14423 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14424 /// while executing the actual API request.
14425 ///
14426 /// ````text
14427 /// It should be used to handle progress information, and to implement a certain level of resilience.
14428 /// ````
14429 ///
14430 /// Sets the *delegate* property to the given value.
14431 pub fn delegate(
14432 mut self,
14433 new_value: &'a mut dyn common::Delegate,
14434 ) -> ProjectSnoozeCreateCall<'a, C> {
14435 self._delegate = Some(new_value);
14436 self
14437 }
14438
14439 /// Set any additional parameter of the query string used in the request.
14440 /// It should be used to set parameters which are not yet available through their own
14441 /// setters.
14442 ///
14443 /// Please note that this method must not be used to set any of the known parameters
14444 /// which have their own setter method. If done anyway, the request will fail.
14445 ///
14446 /// # Additional Parameters
14447 ///
14448 /// * *$.xgafv* (query-string) - V1 error format.
14449 /// * *access_token* (query-string) - OAuth access token.
14450 /// * *alt* (query-string) - Data format for response.
14451 /// * *callback* (query-string) - JSONP
14452 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14453 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14454 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14455 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14456 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14457 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14458 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14459 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnoozeCreateCall<'a, C>
14460 where
14461 T: AsRef<str>,
14462 {
14463 self._additional_params
14464 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14465 self
14466 }
14467
14468 /// Identifies the authorization scope for the method you are building.
14469 ///
14470 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14471 /// [`Scope::CloudPlatform`].
14472 ///
14473 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14474 /// tokens for more than one scope.
14475 ///
14476 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14477 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14478 /// sufficient, a read-write scope will do as well.
14479 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnoozeCreateCall<'a, C>
14480 where
14481 St: AsRef<str>,
14482 {
14483 self._scopes.insert(String::from(scope.as_ref()));
14484 self
14485 }
14486 /// Identifies the authorization scope(s) for the method you are building.
14487 ///
14488 /// See [`Self::add_scope()`] for details.
14489 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnoozeCreateCall<'a, C>
14490 where
14491 I: IntoIterator<Item = St>,
14492 St: AsRef<str>,
14493 {
14494 self._scopes
14495 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14496 self
14497 }
14498
14499 /// Removes all scopes, and no default scope will be used either.
14500 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14501 /// for details).
14502 pub fn clear_scopes(mut self) -> ProjectSnoozeCreateCall<'a, C> {
14503 self._scopes.clear();
14504 self
14505 }
14506}
14507
14508/// Retrieves a Snooze by name.
14509///
14510/// A builder for the *snoozes.get* method supported by a *project* resource.
14511/// It is not used directly, but through a [`ProjectMethods`] instance.
14512///
14513/// # Example
14514///
14515/// Instantiate a resource method builder
14516///
14517/// ```test_harness,no_run
14518/// # extern crate hyper;
14519/// # extern crate hyper_rustls;
14520/// # extern crate google_monitoring3 as monitoring3;
14521/// # async fn dox() {
14522/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14523///
14524/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14525/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14526/// # secret,
14527/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14528/// # ).build().await.unwrap();
14529///
14530/// # let client = hyper_util::client::legacy::Client::builder(
14531/// # hyper_util::rt::TokioExecutor::new()
14532/// # )
14533/// # .build(
14534/// # hyper_rustls::HttpsConnectorBuilder::new()
14535/// # .with_native_roots()
14536/// # .unwrap()
14537/// # .https_or_http()
14538/// # .enable_http1()
14539/// # .build()
14540/// # );
14541/// # let mut hub = Monitoring::new(client, auth);
14542/// // You can configure optional parameters by calling the respective setters at will, and
14543/// // execute the final call using `doit()`.
14544/// // Values shown here are possibly random and not representative !
14545/// let result = hub.projects().snoozes_get("name")
14546/// .doit().await;
14547/// # }
14548/// ```
14549pub struct ProjectSnoozeGetCall<'a, C>
14550where
14551 C: 'a,
14552{
14553 hub: &'a Monitoring<C>,
14554 _name: String,
14555 _delegate: Option<&'a mut dyn common::Delegate>,
14556 _additional_params: HashMap<String, String>,
14557 _scopes: BTreeSet<String>,
14558}
14559
14560impl<'a, C> common::CallBuilder for ProjectSnoozeGetCall<'a, C> {}
14561
14562impl<'a, C> ProjectSnoozeGetCall<'a, C>
14563where
14564 C: common::Connector,
14565{
14566 /// Perform the operation you have build so far.
14567 pub async fn doit(mut self) -> common::Result<(common::Response, Snooze)> {
14568 use std::borrow::Cow;
14569 use std::io::{Read, Seek};
14570
14571 use common::{url::Params, ToParts};
14572 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14573
14574 let mut dd = common::DefaultDelegate;
14575 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14576 dlg.begin(common::MethodInfo {
14577 id: "monitoring.projects.snoozes.get",
14578 http_method: hyper::Method::GET,
14579 });
14580
14581 for &field in ["alt", "name"].iter() {
14582 if self._additional_params.contains_key(field) {
14583 dlg.finished(false);
14584 return Err(common::Error::FieldClash(field));
14585 }
14586 }
14587
14588 let mut params = Params::with_capacity(3 + self._additional_params.len());
14589 params.push("name", self._name);
14590
14591 params.extend(self._additional_params.iter());
14592
14593 params.push("alt", "json");
14594 let mut url = self.hub._base_url.clone() + "v3/{+name}";
14595 if self._scopes.is_empty() {
14596 self._scopes
14597 .insert(Scope::CloudPlatform.as_ref().to_string());
14598 }
14599
14600 #[allow(clippy::single_element_loop)]
14601 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14602 url = params.uri_replacement(url, param_name, find_this, true);
14603 }
14604 {
14605 let to_remove = ["name"];
14606 params.remove_params(&to_remove);
14607 }
14608
14609 let url = params.parse_with_url(&url);
14610
14611 loop {
14612 let token = match self
14613 .hub
14614 .auth
14615 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14616 .await
14617 {
14618 Ok(token) => token,
14619 Err(e) => match dlg.token(e) {
14620 Ok(token) => token,
14621 Err(e) => {
14622 dlg.finished(false);
14623 return Err(common::Error::MissingToken(e));
14624 }
14625 },
14626 };
14627 let mut req_result = {
14628 let client = &self.hub.client;
14629 dlg.pre_request();
14630 let mut req_builder = hyper::Request::builder()
14631 .method(hyper::Method::GET)
14632 .uri(url.as_str())
14633 .header(USER_AGENT, self.hub._user_agent.clone());
14634
14635 if let Some(token) = token.as_ref() {
14636 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14637 }
14638
14639 let request = req_builder
14640 .header(CONTENT_LENGTH, 0_u64)
14641 .body(common::to_body::<String>(None));
14642
14643 client.request(request.unwrap()).await
14644 };
14645
14646 match req_result {
14647 Err(err) => {
14648 if let common::Retry::After(d) = dlg.http_error(&err) {
14649 sleep(d).await;
14650 continue;
14651 }
14652 dlg.finished(false);
14653 return Err(common::Error::HttpError(err));
14654 }
14655 Ok(res) => {
14656 let (mut parts, body) = res.into_parts();
14657 let mut body = common::Body::new(body);
14658 if !parts.status.is_success() {
14659 let bytes = common::to_bytes(body).await.unwrap_or_default();
14660 let error = serde_json::from_str(&common::to_string(&bytes));
14661 let response = common::to_response(parts, bytes.into());
14662
14663 if let common::Retry::After(d) =
14664 dlg.http_failure(&response, error.as_ref().ok())
14665 {
14666 sleep(d).await;
14667 continue;
14668 }
14669
14670 dlg.finished(false);
14671
14672 return Err(match error {
14673 Ok(value) => common::Error::BadRequest(value),
14674 _ => common::Error::Failure(response),
14675 });
14676 }
14677 let response = {
14678 let bytes = common::to_bytes(body).await.unwrap_or_default();
14679 let encoded = common::to_string(&bytes);
14680 match serde_json::from_str(&encoded) {
14681 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14682 Err(error) => {
14683 dlg.response_json_decode_error(&encoded, &error);
14684 return Err(common::Error::JsonDecodeError(
14685 encoded.to_string(),
14686 error,
14687 ));
14688 }
14689 }
14690 };
14691
14692 dlg.finished(true);
14693 return Ok(response);
14694 }
14695 }
14696 }
14697 }
14698
14699 /// Required. The ID of the Snooze to retrieve. The format is: projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID]
14700 ///
14701 /// Sets the *name* path property to the given value.
14702 ///
14703 /// Even though the property as already been set when instantiating this call,
14704 /// we provide this method for API completeness.
14705 pub fn name(mut self, new_value: &str) -> ProjectSnoozeGetCall<'a, C> {
14706 self._name = new_value.to_string();
14707 self
14708 }
14709 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14710 /// while executing the actual API request.
14711 ///
14712 /// ````text
14713 /// It should be used to handle progress information, and to implement a certain level of resilience.
14714 /// ````
14715 ///
14716 /// Sets the *delegate* property to the given value.
14717 pub fn delegate(
14718 mut self,
14719 new_value: &'a mut dyn common::Delegate,
14720 ) -> ProjectSnoozeGetCall<'a, C> {
14721 self._delegate = Some(new_value);
14722 self
14723 }
14724
14725 /// Set any additional parameter of the query string used in the request.
14726 /// It should be used to set parameters which are not yet available through their own
14727 /// setters.
14728 ///
14729 /// Please note that this method must not be used to set any of the known parameters
14730 /// which have their own setter method. If done anyway, the request will fail.
14731 ///
14732 /// # Additional Parameters
14733 ///
14734 /// * *$.xgafv* (query-string) - V1 error format.
14735 /// * *access_token* (query-string) - OAuth access token.
14736 /// * *alt* (query-string) - Data format for response.
14737 /// * *callback* (query-string) - JSONP
14738 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14739 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14740 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14741 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14742 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14743 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14744 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14745 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnoozeGetCall<'a, C>
14746 where
14747 T: AsRef<str>,
14748 {
14749 self._additional_params
14750 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14751 self
14752 }
14753
14754 /// Identifies the authorization scope for the method you are building.
14755 ///
14756 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14757 /// [`Scope::CloudPlatform`].
14758 ///
14759 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14760 /// tokens for more than one scope.
14761 ///
14762 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14763 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14764 /// sufficient, a read-write scope will do as well.
14765 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnoozeGetCall<'a, C>
14766 where
14767 St: AsRef<str>,
14768 {
14769 self._scopes.insert(String::from(scope.as_ref()));
14770 self
14771 }
14772 /// Identifies the authorization scope(s) for the method you are building.
14773 ///
14774 /// See [`Self::add_scope()`] for details.
14775 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnoozeGetCall<'a, C>
14776 where
14777 I: IntoIterator<Item = St>,
14778 St: AsRef<str>,
14779 {
14780 self._scopes
14781 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14782 self
14783 }
14784
14785 /// Removes all scopes, and no default scope will be used either.
14786 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14787 /// for details).
14788 pub fn clear_scopes(mut self) -> ProjectSnoozeGetCall<'a, C> {
14789 self._scopes.clear();
14790 self
14791 }
14792}
14793
14794/// Lists the Snoozes associated with a project. Can optionally pass in filter, which specifies predicates to match Snoozes.
14795///
14796/// A builder for the *snoozes.list* method supported by a *project* resource.
14797/// It is not used directly, but through a [`ProjectMethods`] instance.
14798///
14799/// # Example
14800///
14801/// Instantiate a resource method builder
14802///
14803/// ```test_harness,no_run
14804/// # extern crate hyper;
14805/// # extern crate hyper_rustls;
14806/// # extern crate google_monitoring3 as monitoring3;
14807/// # async fn dox() {
14808/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14809///
14810/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14811/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14812/// # secret,
14813/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14814/// # ).build().await.unwrap();
14815///
14816/// # let client = hyper_util::client::legacy::Client::builder(
14817/// # hyper_util::rt::TokioExecutor::new()
14818/// # )
14819/// # .build(
14820/// # hyper_rustls::HttpsConnectorBuilder::new()
14821/// # .with_native_roots()
14822/// # .unwrap()
14823/// # .https_or_http()
14824/// # .enable_http1()
14825/// # .build()
14826/// # );
14827/// # let mut hub = Monitoring::new(client, auth);
14828/// // You can configure optional parameters by calling the respective setters at will, and
14829/// // execute the final call using `doit()`.
14830/// // Values shown here are possibly random and not representative !
14831/// let result = hub.projects().snoozes_list("parent")
14832/// .page_token("ipsum")
14833/// .page_size(-18)
14834/// .filter("sanctus")
14835/// .doit().await;
14836/// # }
14837/// ```
14838pub struct ProjectSnoozeListCall<'a, C>
14839where
14840 C: 'a,
14841{
14842 hub: &'a Monitoring<C>,
14843 _parent: String,
14844 _page_token: Option<String>,
14845 _page_size: Option<i32>,
14846 _filter: Option<String>,
14847 _delegate: Option<&'a mut dyn common::Delegate>,
14848 _additional_params: HashMap<String, String>,
14849 _scopes: BTreeSet<String>,
14850}
14851
14852impl<'a, C> common::CallBuilder for ProjectSnoozeListCall<'a, C> {}
14853
14854impl<'a, C> ProjectSnoozeListCall<'a, C>
14855where
14856 C: common::Connector,
14857{
14858 /// Perform the operation you have build so far.
14859 pub async fn doit(mut self) -> common::Result<(common::Response, ListSnoozesResponse)> {
14860 use std::borrow::Cow;
14861 use std::io::{Read, Seek};
14862
14863 use common::{url::Params, ToParts};
14864 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14865
14866 let mut dd = common::DefaultDelegate;
14867 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14868 dlg.begin(common::MethodInfo {
14869 id: "monitoring.projects.snoozes.list",
14870 http_method: hyper::Method::GET,
14871 });
14872
14873 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
14874 if self._additional_params.contains_key(field) {
14875 dlg.finished(false);
14876 return Err(common::Error::FieldClash(field));
14877 }
14878 }
14879
14880 let mut params = Params::with_capacity(6 + self._additional_params.len());
14881 params.push("parent", self._parent);
14882 if let Some(value) = self._page_token.as_ref() {
14883 params.push("pageToken", value);
14884 }
14885 if let Some(value) = self._page_size.as_ref() {
14886 params.push("pageSize", value.to_string());
14887 }
14888 if let Some(value) = self._filter.as_ref() {
14889 params.push("filter", value);
14890 }
14891
14892 params.extend(self._additional_params.iter());
14893
14894 params.push("alt", "json");
14895 let mut url = self.hub._base_url.clone() + "v3/{+parent}/snoozes";
14896 if self._scopes.is_empty() {
14897 self._scopes
14898 .insert(Scope::CloudPlatform.as_ref().to_string());
14899 }
14900
14901 #[allow(clippy::single_element_loop)]
14902 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14903 url = params.uri_replacement(url, param_name, find_this, true);
14904 }
14905 {
14906 let to_remove = ["parent"];
14907 params.remove_params(&to_remove);
14908 }
14909
14910 let url = params.parse_with_url(&url);
14911
14912 loop {
14913 let token = match self
14914 .hub
14915 .auth
14916 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14917 .await
14918 {
14919 Ok(token) => token,
14920 Err(e) => match dlg.token(e) {
14921 Ok(token) => token,
14922 Err(e) => {
14923 dlg.finished(false);
14924 return Err(common::Error::MissingToken(e));
14925 }
14926 },
14927 };
14928 let mut req_result = {
14929 let client = &self.hub.client;
14930 dlg.pre_request();
14931 let mut req_builder = hyper::Request::builder()
14932 .method(hyper::Method::GET)
14933 .uri(url.as_str())
14934 .header(USER_AGENT, self.hub._user_agent.clone());
14935
14936 if let Some(token) = token.as_ref() {
14937 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14938 }
14939
14940 let request = req_builder
14941 .header(CONTENT_LENGTH, 0_u64)
14942 .body(common::to_body::<String>(None));
14943
14944 client.request(request.unwrap()).await
14945 };
14946
14947 match req_result {
14948 Err(err) => {
14949 if let common::Retry::After(d) = dlg.http_error(&err) {
14950 sleep(d).await;
14951 continue;
14952 }
14953 dlg.finished(false);
14954 return Err(common::Error::HttpError(err));
14955 }
14956 Ok(res) => {
14957 let (mut parts, body) = res.into_parts();
14958 let mut body = common::Body::new(body);
14959 if !parts.status.is_success() {
14960 let bytes = common::to_bytes(body).await.unwrap_or_default();
14961 let error = serde_json::from_str(&common::to_string(&bytes));
14962 let response = common::to_response(parts, bytes.into());
14963
14964 if let common::Retry::After(d) =
14965 dlg.http_failure(&response, error.as_ref().ok())
14966 {
14967 sleep(d).await;
14968 continue;
14969 }
14970
14971 dlg.finished(false);
14972
14973 return Err(match error {
14974 Ok(value) => common::Error::BadRequest(value),
14975 _ => common::Error::Failure(response),
14976 });
14977 }
14978 let response = {
14979 let bytes = common::to_bytes(body).await.unwrap_or_default();
14980 let encoded = common::to_string(&bytes);
14981 match serde_json::from_str(&encoded) {
14982 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14983 Err(error) => {
14984 dlg.response_json_decode_error(&encoded, &error);
14985 return Err(common::Error::JsonDecodeError(
14986 encoded.to_string(),
14987 error,
14988 ));
14989 }
14990 }
14991 };
14992
14993 dlg.finished(true);
14994 return Ok(response);
14995 }
14996 }
14997 }
14998 }
14999
15000 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) whose Snoozes should be listed. The format is: projects/[PROJECT_ID_OR_NUMBER]
15001 ///
15002 /// Sets the *parent* path property to the given value.
15003 ///
15004 /// Even though the property as already been set when instantiating this call,
15005 /// we provide this method for API completeness.
15006 pub fn parent(mut self, new_value: &str) -> ProjectSnoozeListCall<'a, C> {
15007 self._parent = new_value.to_string();
15008 self
15009 }
15010 /// Optional. The next_page_token from a previous call to ListSnoozesRequest to get the next page of results.
15011 ///
15012 /// Sets the *page token* query property to the given value.
15013 pub fn page_token(mut self, new_value: &str) -> ProjectSnoozeListCall<'a, C> {
15014 self._page_token = Some(new_value.to_string());
15015 self
15016 }
15017 /// Optional. The maximum number of results to return for a single query. The server may further constrain the maximum number of results returned in a single page. The value should be in the range 1, 1000. If the value given is outside this range, the server will decide the number of results to be returned.
15018 ///
15019 /// Sets the *page size* query property to the given value.
15020 pub fn page_size(mut self, new_value: i32) -> ProjectSnoozeListCall<'a, C> {
15021 self._page_size = Some(new_value);
15022 self
15023 }
15024 /// Optional. Optional filter to restrict results to the given criteria. The following fields are supported. interval.start_time interval.end_timeFor example: ``` interval.start_time > "2022-03-11T00:00:00-08:00" AND interval.end_time < "2022-03-12T00:00:00-08:00" ```
15025 ///
15026 /// Sets the *filter* query property to the given value.
15027 pub fn filter(mut self, new_value: &str) -> ProjectSnoozeListCall<'a, C> {
15028 self._filter = Some(new_value.to_string());
15029 self
15030 }
15031 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15032 /// while executing the actual API request.
15033 ///
15034 /// ````text
15035 /// It should be used to handle progress information, and to implement a certain level of resilience.
15036 /// ````
15037 ///
15038 /// Sets the *delegate* property to the given value.
15039 pub fn delegate(
15040 mut self,
15041 new_value: &'a mut dyn common::Delegate,
15042 ) -> ProjectSnoozeListCall<'a, C> {
15043 self._delegate = Some(new_value);
15044 self
15045 }
15046
15047 /// Set any additional parameter of the query string used in the request.
15048 /// It should be used to set parameters which are not yet available through their own
15049 /// setters.
15050 ///
15051 /// Please note that this method must not be used to set any of the known parameters
15052 /// which have their own setter method. If done anyway, the request will fail.
15053 ///
15054 /// # Additional Parameters
15055 ///
15056 /// * *$.xgafv* (query-string) - V1 error format.
15057 /// * *access_token* (query-string) - OAuth access token.
15058 /// * *alt* (query-string) - Data format for response.
15059 /// * *callback* (query-string) - JSONP
15060 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15061 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15062 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15063 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15064 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15065 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15066 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15067 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnoozeListCall<'a, C>
15068 where
15069 T: AsRef<str>,
15070 {
15071 self._additional_params
15072 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15073 self
15074 }
15075
15076 /// Identifies the authorization scope for the method you are building.
15077 ///
15078 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15079 /// [`Scope::CloudPlatform`].
15080 ///
15081 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15082 /// tokens for more than one scope.
15083 ///
15084 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15085 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15086 /// sufficient, a read-write scope will do as well.
15087 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnoozeListCall<'a, C>
15088 where
15089 St: AsRef<str>,
15090 {
15091 self._scopes.insert(String::from(scope.as_ref()));
15092 self
15093 }
15094 /// Identifies the authorization scope(s) for the method you are building.
15095 ///
15096 /// See [`Self::add_scope()`] for details.
15097 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnoozeListCall<'a, C>
15098 where
15099 I: IntoIterator<Item = St>,
15100 St: AsRef<str>,
15101 {
15102 self._scopes
15103 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15104 self
15105 }
15106
15107 /// Removes all scopes, and no default scope will be used either.
15108 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15109 /// for details).
15110 pub fn clear_scopes(mut self) -> ProjectSnoozeListCall<'a, C> {
15111 self._scopes.clear();
15112 self
15113 }
15114}
15115
15116/// Updates a Snooze, identified by its name, with the parameters in the given Snooze object.
15117///
15118/// A builder for the *snoozes.patch* method supported by a *project* resource.
15119/// It is not used directly, but through a [`ProjectMethods`] instance.
15120///
15121/// # Example
15122///
15123/// Instantiate a resource method builder
15124///
15125/// ```test_harness,no_run
15126/// # extern crate hyper;
15127/// # extern crate hyper_rustls;
15128/// # extern crate google_monitoring3 as monitoring3;
15129/// use monitoring3::api::Snooze;
15130/// # async fn dox() {
15131/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15132///
15133/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15134/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15135/// # secret,
15136/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15137/// # ).build().await.unwrap();
15138///
15139/// # let client = hyper_util::client::legacy::Client::builder(
15140/// # hyper_util::rt::TokioExecutor::new()
15141/// # )
15142/// # .build(
15143/// # hyper_rustls::HttpsConnectorBuilder::new()
15144/// # .with_native_roots()
15145/// # .unwrap()
15146/// # .https_or_http()
15147/// # .enable_http1()
15148/// # .build()
15149/// # );
15150/// # let mut hub = Monitoring::new(client, auth);
15151/// // As the method needs a request, you would usually fill it with the desired information
15152/// // into the respective structure. Some of the parts shown here might not be applicable !
15153/// // Values shown here are possibly random and not representative !
15154/// let mut req = Snooze::default();
15155///
15156/// // You can configure optional parameters by calling the respective setters at will, and
15157/// // execute the final call using `doit()`.
15158/// // Values shown here are possibly random and not representative !
15159/// let result = hub.projects().snoozes_patch(req, "name")
15160/// .update_mask(FieldMask::new::<&str>(&[]))
15161/// .doit().await;
15162/// # }
15163/// ```
15164pub struct ProjectSnoozePatchCall<'a, C>
15165where
15166 C: 'a,
15167{
15168 hub: &'a Monitoring<C>,
15169 _request: Snooze,
15170 _name: String,
15171 _update_mask: Option<common::FieldMask>,
15172 _delegate: Option<&'a mut dyn common::Delegate>,
15173 _additional_params: HashMap<String, String>,
15174 _scopes: BTreeSet<String>,
15175}
15176
15177impl<'a, C> common::CallBuilder for ProjectSnoozePatchCall<'a, C> {}
15178
15179impl<'a, C> ProjectSnoozePatchCall<'a, C>
15180where
15181 C: common::Connector,
15182{
15183 /// Perform the operation you have build so far.
15184 pub async fn doit(mut self) -> common::Result<(common::Response, Snooze)> {
15185 use std::borrow::Cow;
15186 use std::io::{Read, Seek};
15187
15188 use common::{url::Params, ToParts};
15189 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15190
15191 let mut dd = common::DefaultDelegate;
15192 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15193 dlg.begin(common::MethodInfo {
15194 id: "monitoring.projects.snoozes.patch",
15195 http_method: hyper::Method::PATCH,
15196 });
15197
15198 for &field in ["alt", "name", "updateMask"].iter() {
15199 if self._additional_params.contains_key(field) {
15200 dlg.finished(false);
15201 return Err(common::Error::FieldClash(field));
15202 }
15203 }
15204
15205 let mut params = Params::with_capacity(5 + self._additional_params.len());
15206 params.push("name", self._name);
15207 if let Some(value) = self._update_mask.as_ref() {
15208 params.push("updateMask", value.to_string());
15209 }
15210
15211 params.extend(self._additional_params.iter());
15212
15213 params.push("alt", "json");
15214 let mut url = self.hub._base_url.clone() + "v3/{+name}";
15215 if self._scopes.is_empty() {
15216 self._scopes
15217 .insert(Scope::CloudPlatform.as_ref().to_string());
15218 }
15219
15220 #[allow(clippy::single_element_loop)]
15221 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15222 url = params.uri_replacement(url, param_name, find_this, true);
15223 }
15224 {
15225 let to_remove = ["name"];
15226 params.remove_params(&to_remove);
15227 }
15228
15229 let url = params.parse_with_url(&url);
15230
15231 let mut json_mime_type = mime::APPLICATION_JSON;
15232 let mut request_value_reader = {
15233 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15234 common::remove_json_null_values(&mut value);
15235 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15236 serde_json::to_writer(&mut dst, &value).unwrap();
15237 dst
15238 };
15239 let request_size = request_value_reader
15240 .seek(std::io::SeekFrom::End(0))
15241 .unwrap();
15242 request_value_reader
15243 .seek(std::io::SeekFrom::Start(0))
15244 .unwrap();
15245
15246 loop {
15247 let token = match self
15248 .hub
15249 .auth
15250 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15251 .await
15252 {
15253 Ok(token) => token,
15254 Err(e) => match dlg.token(e) {
15255 Ok(token) => token,
15256 Err(e) => {
15257 dlg.finished(false);
15258 return Err(common::Error::MissingToken(e));
15259 }
15260 },
15261 };
15262 request_value_reader
15263 .seek(std::io::SeekFrom::Start(0))
15264 .unwrap();
15265 let mut req_result = {
15266 let client = &self.hub.client;
15267 dlg.pre_request();
15268 let mut req_builder = hyper::Request::builder()
15269 .method(hyper::Method::PATCH)
15270 .uri(url.as_str())
15271 .header(USER_AGENT, self.hub._user_agent.clone());
15272
15273 if let Some(token) = token.as_ref() {
15274 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15275 }
15276
15277 let request = req_builder
15278 .header(CONTENT_TYPE, json_mime_type.to_string())
15279 .header(CONTENT_LENGTH, request_size as u64)
15280 .body(common::to_body(
15281 request_value_reader.get_ref().clone().into(),
15282 ));
15283
15284 client.request(request.unwrap()).await
15285 };
15286
15287 match req_result {
15288 Err(err) => {
15289 if let common::Retry::After(d) = dlg.http_error(&err) {
15290 sleep(d).await;
15291 continue;
15292 }
15293 dlg.finished(false);
15294 return Err(common::Error::HttpError(err));
15295 }
15296 Ok(res) => {
15297 let (mut parts, body) = res.into_parts();
15298 let mut body = common::Body::new(body);
15299 if !parts.status.is_success() {
15300 let bytes = common::to_bytes(body).await.unwrap_or_default();
15301 let error = serde_json::from_str(&common::to_string(&bytes));
15302 let response = common::to_response(parts, bytes.into());
15303
15304 if let common::Retry::After(d) =
15305 dlg.http_failure(&response, error.as_ref().ok())
15306 {
15307 sleep(d).await;
15308 continue;
15309 }
15310
15311 dlg.finished(false);
15312
15313 return Err(match error {
15314 Ok(value) => common::Error::BadRequest(value),
15315 _ => common::Error::Failure(response),
15316 });
15317 }
15318 let response = {
15319 let bytes = common::to_bytes(body).await.unwrap_or_default();
15320 let encoded = common::to_string(&bytes);
15321 match serde_json::from_str(&encoded) {
15322 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15323 Err(error) => {
15324 dlg.response_json_decode_error(&encoded, &error);
15325 return Err(common::Error::JsonDecodeError(
15326 encoded.to_string(),
15327 error,
15328 ));
15329 }
15330 }
15331 };
15332
15333 dlg.finished(true);
15334 return Ok(response);
15335 }
15336 }
15337 }
15338 }
15339
15340 ///
15341 /// Sets the *request* property to the given value.
15342 ///
15343 /// Even though the property as already been set when instantiating this call,
15344 /// we provide this method for API completeness.
15345 pub fn request(mut self, new_value: Snooze) -> ProjectSnoozePatchCall<'a, C> {
15346 self._request = new_value;
15347 self
15348 }
15349 /// Required. Identifier. The name of the Snooze. The format is: projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID] The ID of the Snooze will be generated by the system.
15350 ///
15351 /// Sets the *name* path property to the given value.
15352 ///
15353 /// Even though the property as already been set when instantiating this call,
15354 /// we provide this method for API completeness.
15355 pub fn name(mut self, new_value: &str) -> ProjectSnoozePatchCall<'a, C> {
15356 self._name = new_value.to_string();
15357 self
15358 }
15359 /// Required. The fields to update.For each field listed in update_mask: If the Snooze object supplied in the UpdateSnoozeRequest has a value for that field, the value of the field in the existing Snooze will be set to the value of the field in the supplied Snooze. If the field does not have a value in the supplied Snooze, the field in the existing Snooze is set to its default value.Fields not listed retain their existing value.The following are the field names that are accepted in update_mask: display_name interval.start_time interval.end_timeThat said, the start time and end time of the Snooze determines which fields can legally be updated. Before attempting an update, users should consult the documentation for UpdateSnoozeRequest, which talks about which fields can be updated.
15360 ///
15361 /// Sets the *update mask* query property to the given value.
15362 pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectSnoozePatchCall<'a, C> {
15363 self._update_mask = Some(new_value);
15364 self
15365 }
15366 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15367 /// while executing the actual API request.
15368 ///
15369 /// ````text
15370 /// It should be used to handle progress information, and to implement a certain level of resilience.
15371 /// ````
15372 ///
15373 /// Sets the *delegate* property to the given value.
15374 pub fn delegate(
15375 mut self,
15376 new_value: &'a mut dyn common::Delegate,
15377 ) -> ProjectSnoozePatchCall<'a, C> {
15378 self._delegate = Some(new_value);
15379 self
15380 }
15381
15382 /// Set any additional parameter of the query string used in the request.
15383 /// It should be used to set parameters which are not yet available through their own
15384 /// setters.
15385 ///
15386 /// Please note that this method must not be used to set any of the known parameters
15387 /// which have their own setter method. If done anyway, the request will fail.
15388 ///
15389 /// # Additional Parameters
15390 ///
15391 /// * *$.xgafv* (query-string) - V1 error format.
15392 /// * *access_token* (query-string) - OAuth access token.
15393 /// * *alt* (query-string) - Data format for response.
15394 /// * *callback* (query-string) - JSONP
15395 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15396 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15397 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15398 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15399 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15400 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15401 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15402 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnoozePatchCall<'a, C>
15403 where
15404 T: AsRef<str>,
15405 {
15406 self._additional_params
15407 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15408 self
15409 }
15410
15411 /// Identifies the authorization scope for the method you are building.
15412 ///
15413 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15414 /// [`Scope::CloudPlatform`].
15415 ///
15416 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15417 /// tokens for more than one scope.
15418 ///
15419 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15420 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15421 /// sufficient, a read-write scope will do as well.
15422 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnoozePatchCall<'a, C>
15423 where
15424 St: AsRef<str>,
15425 {
15426 self._scopes.insert(String::from(scope.as_ref()));
15427 self
15428 }
15429 /// Identifies the authorization scope(s) for the method you are building.
15430 ///
15431 /// See [`Self::add_scope()`] for details.
15432 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnoozePatchCall<'a, C>
15433 where
15434 I: IntoIterator<Item = St>,
15435 St: AsRef<str>,
15436 {
15437 self._scopes
15438 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15439 self
15440 }
15441
15442 /// Removes all scopes, and no default scope will be used either.
15443 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15444 /// for details).
15445 pub fn clear_scopes(mut self) -> ProjectSnoozePatchCall<'a, C> {
15446 self._scopes.clear();
15447 self
15448 }
15449}
15450
15451/// Creates or adds data to one or more time series. The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response. This method does not support resource locations constraint of an organization policy (https://cloud.google.com/resource-manager/docs/organization-policy/defining-locations#setting_the_organization_policy).
15452///
15453/// A builder for the *timeSeries.create* method supported by a *project* resource.
15454/// It is not used directly, but through a [`ProjectMethods`] instance.
15455///
15456/// # Example
15457///
15458/// Instantiate a resource method builder
15459///
15460/// ```test_harness,no_run
15461/// # extern crate hyper;
15462/// # extern crate hyper_rustls;
15463/// # extern crate google_monitoring3 as monitoring3;
15464/// use monitoring3::api::CreateTimeSeriesRequest;
15465/// # async fn dox() {
15466/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15467///
15468/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15469/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15470/// # secret,
15471/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15472/// # ).build().await.unwrap();
15473///
15474/// # let client = hyper_util::client::legacy::Client::builder(
15475/// # hyper_util::rt::TokioExecutor::new()
15476/// # )
15477/// # .build(
15478/// # hyper_rustls::HttpsConnectorBuilder::new()
15479/// # .with_native_roots()
15480/// # .unwrap()
15481/// # .https_or_http()
15482/// # .enable_http1()
15483/// # .build()
15484/// # );
15485/// # let mut hub = Monitoring::new(client, auth);
15486/// // As the method needs a request, you would usually fill it with the desired information
15487/// // into the respective structure. Some of the parts shown here might not be applicable !
15488/// // Values shown here are possibly random and not representative !
15489/// let mut req = CreateTimeSeriesRequest::default();
15490///
15491/// // You can configure optional parameters by calling the respective setters at will, and
15492/// // execute the final call using `doit()`.
15493/// // Values shown here are possibly random and not representative !
15494/// let result = hub.projects().time_series_create(req, "name")
15495/// .doit().await;
15496/// # }
15497/// ```
15498pub struct ProjectTimeSeryCreateCall<'a, C>
15499where
15500 C: 'a,
15501{
15502 hub: &'a Monitoring<C>,
15503 _request: CreateTimeSeriesRequest,
15504 _name: String,
15505 _delegate: Option<&'a mut dyn common::Delegate>,
15506 _additional_params: HashMap<String, String>,
15507 _scopes: BTreeSet<String>,
15508}
15509
15510impl<'a, C> common::CallBuilder for ProjectTimeSeryCreateCall<'a, C> {}
15511
15512impl<'a, C> ProjectTimeSeryCreateCall<'a, C>
15513where
15514 C: common::Connector,
15515{
15516 /// Perform the operation you have build so far.
15517 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
15518 use std::borrow::Cow;
15519 use std::io::{Read, Seek};
15520
15521 use common::{url::Params, ToParts};
15522 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15523
15524 let mut dd = common::DefaultDelegate;
15525 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15526 dlg.begin(common::MethodInfo {
15527 id: "monitoring.projects.timeSeries.create",
15528 http_method: hyper::Method::POST,
15529 });
15530
15531 for &field in ["alt", "name"].iter() {
15532 if self._additional_params.contains_key(field) {
15533 dlg.finished(false);
15534 return Err(common::Error::FieldClash(field));
15535 }
15536 }
15537
15538 let mut params = Params::with_capacity(4 + self._additional_params.len());
15539 params.push("name", self._name);
15540
15541 params.extend(self._additional_params.iter());
15542
15543 params.push("alt", "json");
15544 let mut url = self.hub._base_url.clone() + "v3/{+name}/timeSeries";
15545 if self._scopes.is_empty() {
15546 self._scopes
15547 .insert(Scope::CloudPlatform.as_ref().to_string());
15548 }
15549
15550 #[allow(clippy::single_element_loop)]
15551 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15552 url = params.uri_replacement(url, param_name, find_this, true);
15553 }
15554 {
15555 let to_remove = ["name"];
15556 params.remove_params(&to_remove);
15557 }
15558
15559 let url = params.parse_with_url(&url);
15560
15561 let mut json_mime_type = mime::APPLICATION_JSON;
15562 let mut request_value_reader = {
15563 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15564 common::remove_json_null_values(&mut value);
15565 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15566 serde_json::to_writer(&mut dst, &value).unwrap();
15567 dst
15568 };
15569 let request_size = request_value_reader
15570 .seek(std::io::SeekFrom::End(0))
15571 .unwrap();
15572 request_value_reader
15573 .seek(std::io::SeekFrom::Start(0))
15574 .unwrap();
15575
15576 loop {
15577 let token = match self
15578 .hub
15579 .auth
15580 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15581 .await
15582 {
15583 Ok(token) => token,
15584 Err(e) => match dlg.token(e) {
15585 Ok(token) => token,
15586 Err(e) => {
15587 dlg.finished(false);
15588 return Err(common::Error::MissingToken(e));
15589 }
15590 },
15591 };
15592 request_value_reader
15593 .seek(std::io::SeekFrom::Start(0))
15594 .unwrap();
15595 let mut req_result = {
15596 let client = &self.hub.client;
15597 dlg.pre_request();
15598 let mut req_builder = hyper::Request::builder()
15599 .method(hyper::Method::POST)
15600 .uri(url.as_str())
15601 .header(USER_AGENT, self.hub._user_agent.clone());
15602
15603 if let Some(token) = token.as_ref() {
15604 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15605 }
15606
15607 let request = req_builder
15608 .header(CONTENT_TYPE, json_mime_type.to_string())
15609 .header(CONTENT_LENGTH, request_size as u64)
15610 .body(common::to_body(
15611 request_value_reader.get_ref().clone().into(),
15612 ));
15613
15614 client.request(request.unwrap()).await
15615 };
15616
15617 match req_result {
15618 Err(err) => {
15619 if let common::Retry::After(d) = dlg.http_error(&err) {
15620 sleep(d).await;
15621 continue;
15622 }
15623 dlg.finished(false);
15624 return Err(common::Error::HttpError(err));
15625 }
15626 Ok(res) => {
15627 let (mut parts, body) = res.into_parts();
15628 let mut body = common::Body::new(body);
15629 if !parts.status.is_success() {
15630 let bytes = common::to_bytes(body).await.unwrap_or_default();
15631 let error = serde_json::from_str(&common::to_string(&bytes));
15632 let response = common::to_response(parts, bytes.into());
15633
15634 if let common::Retry::After(d) =
15635 dlg.http_failure(&response, error.as_ref().ok())
15636 {
15637 sleep(d).await;
15638 continue;
15639 }
15640
15641 dlg.finished(false);
15642
15643 return Err(match error {
15644 Ok(value) => common::Error::BadRequest(value),
15645 _ => common::Error::Failure(response),
15646 });
15647 }
15648 let response = {
15649 let bytes = common::to_bytes(body).await.unwrap_or_default();
15650 let encoded = common::to_string(&bytes);
15651 match serde_json::from_str(&encoded) {
15652 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15653 Err(error) => {
15654 dlg.response_json_decode_error(&encoded, &error);
15655 return Err(common::Error::JsonDecodeError(
15656 encoded.to_string(),
15657 error,
15658 ));
15659 }
15660 }
15661 };
15662
15663 dlg.finished(true);
15664 return Ok(response);
15665 }
15666 }
15667 }
15668 }
15669
15670 ///
15671 /// Sets the *request* property to the given value.
15672 ///
15673 /// Even though the property as already been set when instantiating this call,
15674 /// we provide this method for API completeness.
15675 pub fn request(
15676 mut self,
15677 new_value: CreateTimeSeriesRequest,
15678 ) -> ProjectTimeSeryCreateCall<'a, C> {
15679 self._request = new_value;
15680 self
15681 }
15682 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
15683 ///
15684 /// Sets the *name* path property to the given value.
15685 ///
15686 /// Even though the property as already been set when instantiating this call,
15687 /// we provide this method for API completeness.
15688 pub fn name(mut self, new_value: &str) -> ProjectTimeSeryCreateCall<'a, C> {
15689 self._name = new_value.to_string();
15690 self
15691 }
15692 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15693 /// while executing the actual API request.
15694 ///
15695 /// ````text
15696 /// It should be used to handle progress information, and to implement a certain level of resilience.
15697 /// ````
15698 ///
15699 /// Sets the *delegate* property to the given value.
15700 pub fn delegate(
15701 mut self,
15702 new_value: &'a mut dyn common::Delegate,
15703 ) -> ProjectTimeSeryCreateCall<'a, C> {
15704 self._delegate = Some(new_value);
15705 self
15706 }
15707
15708 /// Set any additional parameter of the query string used in the request.
15709 /// It should be used to set parameters which are not yet available through their own
15710 /// setters.
15711 ///
15712 /// Please note that this method must not be used to set any of the known parameters
15713 /// which have their own setter method. If done anyway, the request will fail.
15714 ///
15715 /// # Additional Parameters
15716 ///
15717 /// * *$.xgafv* (query-string) - V1 error format.
15718 /// * *access_token* (query-string) - OAuth access token.
15719 /// * *alt* (query-string) - Data format for response.
15720 /// * *callback* (query-string) - JSONP
15721 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15722 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15723 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15724 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15725 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15726 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15727 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15728 pub fn param<T>(mut self, name: T, value: T) -> ProjectTimeSeryCreateCall<'a, C>
15729 where
15730 T: AsRef<str>,
15731 {
15732 self._additional_params
15733 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15734 self
15735 }
15736
15737 /// Identifies the authorization scope for the method you are building.
15738 ///
15739 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15740 /// [`Scope::CloudPlatform`].
15741 ///
15742 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15743 /// tokens for more than one scope.
15744 ///
15745 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15746 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15747 /// sufficient, a read-write scope will do as well.
15748 pub fn add_scope<St>(mut self, scope: St) -> ProjectTimeSeryCreateCall<'a, C>
15749 where
15750 St: AsRef<str>,
15751 {
15752 self._scopes.insert(String::from(scope.as_ref()));
15753 self
15754 }
15755 /// Identifies the authorization scope(s) for the method you are building.
15756 ///
15757 /// See [`Self::add_scope()`] for details.
15758 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTimeSeryCreateCall<'a, C>
15759 where
15760 I: IntoIterator<Item = St>,
15761 St: AsRef<str>,
15762 {
15763 self._scopes
15764 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15765 self
15766 }
15767
15768 /// Removes all scopes, and no default scope will be used either.
15769 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15770 /// for details).
15771 pub fn clear_scopes(mut self) -> ProjectTimeSeryCreateCall<'a, C> {
15772 self._scopes.clear();
15773 self
15774 }
15775}
15776
15777/// Creates or adds data to one or more service time series. A service time series is a time series for a metric from a Google Cloud service. The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response. This endpoint rejects writes to user-defined metrics. This method is only for use by Google Cloud services. Use projects.timeSeries.create instead.
15778///
15779/// A builder for the *timeSeries.createService* method supported by a *project* resource.
15780/// It is not used directly, but through a [`ProjectMethods`] instance.
15781///
15782/// # Example
15783///
15784/// Instantiate a resource method builder
15785///
15786/// ```test_harness,no_run
15787/// # extern crate hyper;
15788/// # extern crate hyper_rustls;
15789/// # extern crate google_monitoring3 as monitoring3;
15790/// use monitoring3::api::CreateTimeSeriesRequest;
15791/// # async fn dox() {
15792/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15793///
15794/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15795/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15796/// # secret,
15797/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15798/// # ).build().await.unwrap();
15799///
15800/// # let client = hyper_util::client::legacy::Client::builder(
15801/// # hyper_util::rt::TokioExecutor::new()
15802/// # )
15803/// # .build(
15804/// # hyper_rustls::HttpsConnectorBuilder::new()
15805/// # .with_native_roots()
15806/// # .unwrap()
15807/// # .https_or_http()
15808/// # .enable_http1()
15809/// # .build()
15810/// # );
15811/// # let mut hub = Monitoring::new(client, auth);
15812/// // As the method needs a request, you would usually fill it with the desired information
15813/// // into the respective structure. Some of the parts shown here might not be applicable !
15814/// // Values shown here are possibly random and not representative !
15815/// let mut req = CreateTimeSeriesRequest::default();
15816///
15817/// // You can configure optional parameters by calling the respective setters at will, and
15818/// // execute the final call using `doit()`.
15819/// // Values shown here are possibly random and not representative !
15820/// let result = hub.projects().time_series_create_service(req, "name")
15821/// .doit().await;
15822/// # }
15823/// ```
15824pub struct ProjectTimeSeryCreateServiceCall<'a, C>
15825where
15826 C: 'a,
15827{
15828 hub: &'a Monitoring<C>,
15829 _request: CreateTimeSeriesRequest,
15830 _name: String,
15831 _delegate: Option<&'a mut dyn common::Delegate>,
15832 _additional_params: HashMap<String, String>,
15833 _scopes: BTreeSet<String>,
15834}
15835
15836impl<'a, C> common::CallBuilder for ProjectTimeSeryCreateServiceCall<'a, C> {}
15837
15838impl<'a, C> ProjectTimeSeryCreateServiceCall<'a, C>
15839where
15840 C: common::Connector,
15841{
15842 /// Perform the operation you have build so far.
15843 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
15844 use std::borrow::Cow;
15845 use std::io::{Read, Seek};
15846
15847 use common::{url::Params, ToParts};
15848 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15849
15850 let mut dd = common::DefaultDelegate;
15851 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15852 dlg.begin(common::MethodInfo {
15853 id: "monitoring.projects.timeSeries.createService",
15854 http_method: hyper::Method::POST,
15855 });
15856
15857 for &field in ["alt", "name"].iter() {
15858 if self._additional_params.contains_key(field) {
15859 dlg.finished(false);
15860 return Err(common::Error::FieldClash(field));
15861 }
15862 }
15863
15864 let mut params = Params::with_capacity(4 + self._additional_params.len());
15865 params.push("name", self._name);
15866
15867 params.extend(self._additional_params.iter());
15868
15869 params.push("alt", "json");
15870 let mut url = self.hub._base_url.clone() + "v3/{+name}/timeSeries:createService";
15871 if self._scopes.is_empty() {
15872 self._scopes
15873 .insert(Scope::CloudPlatform.as_ref().to_string());
15874 }
15875
15876 #[allow(clippy::single_element_loop)]
15877 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15878 url = params.uri_replacement(url, param_name, find_this, true);
15879 }
15880 {
15881 let to_remove = ["name"];
15882 params.remove_params(&to_remove);
15883 }
15884
15885 let url = params.parse_with_url(&url);
15886
15887 let mut json_mime_type = mime::APPLICATION_JSON;
15888 let mut request_value_reader = {
15889 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15890 common::remove_json_null_values(&mut value);
15891 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15892 serde_json::to_writer(&mut dst, &value).unwrap();
15893 dst
15894 };
15895 let request_size = request_value_reader
15896 .seek(std::io::SeekFrom::End(0))
15897 .unwrap();
15898 request_value_reader
15899 .seek(std::io::SeekFrom::Start(0))
15900 .unwrap();
15901
15902 loop {
15903 let token = match self
15904 .hub
15905 .auth
15906 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15907 .await
15908 {
15909 Ok(token) => token,
15910 Err(e) => match dlg.token(e) {
15911 Ok(token) => token,
15912 Err(e) => {
15913 dlg.finished(false);
15914 return Err(common::Error::MissingToken(e));
15915 }
15916 },
15917 };
15918 request_value_reader
15919 .seek(std::io::SeekFrom::Start(0))
15920 .unwrap();
15921 let mut req_result = {
15922 let client = &self.hub.client;
15923 dlg.pre_request();
15924 let mut req_builder = hyper::Request::builder()
15925 .method(hyper::Method::POST)
15926 .uri(url.as_str())
15927 .header(USER_AGENT, self.hub._user_agent.clone());
15928
15929 if let Some(token) = token.as_ref() {
15930 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15931 }
15932
15933 let request = req_builder
15934 .header(CONTENT_TYPE, json_mime_type.to_string())
15935 .header(CONTENT_LENGTH, request_size as u64)
15936 .body(common::to_body(
15937 request_value_reader.get_ref().clone().into(),
15938 ));
15939
15940 client.request(request.unwrap()).await
15941 };
15942
15943 match req_result {
15944 Err(err) => {
15945 if let common::Retry::After(d) = dlg.http_error(&err) {
15946 sleep(d).await;
15947 continue;
15948 }
15949 dlg.finished(false);
15950 return Err(common::Error::HttpError(err));
15951 }
15952 Ok(res) => {
15953 let (mut parts, body) = res.into_parts();
15954 let mut body = common::Body::new(body);
15955 if !parts.status.is_success() {
15956 let bytes = common::to_bytes(body).await.unwrap_or_default();
15957 let error = serde_json::from_str(&common::to_string(&bytes));
15958 let response = common::to_response(parts, bytes.into());
15959
15960 if let common::Retry::After(d) =
15961 dlg.http_failure(&response, error.as_ref().ok())
15962 {
15963 sleep(d).await;
15964 continue;
15965 }
15966
15967 dlg.finished(false);
15968
15969 return Err(match error {
15970 Ok(value) => common::Error::BadRequest(value),
15971 _ => common::Error::Failure(response),
15972 });
15973 }
15974 let response = {
15975 let bytes = common::to_bytes(body).await.unwrap_or_default();
15976 let encoded = common::to_string(&bytes);
15977 match serde_json::from_str(&encoded) {
15978 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15979 Err(error) => {
15980 dlg.response_json_decode_error(&encoded, &error);
15981 return Err(common::Error::JsonDecodeError(
15982 encoded.to_string(),
15983 error,
15984 ));
15985 }
15986 }
15987 };
15988
15989 dlg.finished(true);
15990 return Ok(response);
15991 }
15992 }
15993 }
15994 }
15995
15996 ///
15997 /// Sets the *request* property to the given value.
15998 ///
15999 /// Even though the property as already been set when instantiating this call,
16000 /// we provide this method for API completeness.
16001 pub fn request(
16002 mut self,
16003 new_value: CreateTimeSeriesRequest,
16004 ) -> ProjectTimeSeryCreateServiceCall<'a, C> {
16005 self._request = new_value;
16006 self
16007 }
16008 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
16009 ///
16010 /// Sets the *name* path property to the given value.
16011 ///
16012 /// Even though the property as already been set when instantiating this call,
16013 /// we provide this method for API completeness.
16014 pub fn name(mut self, new_value: &str) -> ProjectTimeSeryCreateServiceCall<'a, C> {
16015 self._name = new_value.to_string();
16016 self
16017 }
16018 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16019 /// while executing the actual API request.
16020 ///
16021 /// ````text
16022 /// It should be used to handle progress information, and to implement a certain level of resilience.
16023 /// ````
16024 ///
16025 /// Sets the *delegate* property to the given value.
16026 pub fn delegate(
16027 mut self,
16028 new_value: &'a mut dyn common::Delegate,
16029 ) -> ProjectTimeSeryCreateServiceCall<'a, C> {
16030 self._delegate = Some(new_value);
16031 self
16032 }
16033
16034 /// Set any additional parameter of the query string used in the request.
16035 /// It should be used to set parameters which are not yet available through their own
16036 /// setters.
16037 ///
16038 /// Please note that this method must not be used to set any of the known parameters
16039 /// which have their own setter method. If done anyway, the request will fail.
16040 ///
16041 /// # Additional Parameters
16042 ///
16043 /// * *$.xgafv* (query-string) - V1 error format.
16044 /// * *access_token* (query-string) - OAuth access token.
16045 /// * *alt* (query-string) - Data format for response.
16046 /// * *callback* (query-string) - JSONP
16047 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16048 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16049 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16050 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16051 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16052 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16053 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16054 pub fn param<T>(mut self, name: T, value: T) -> ProjectTimeSeryCreateServiceCall<'a, C>
16055 where
16056 T: AsRef<str>,
16057 {
16058 self._additional_params
16059 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16060 self
16061 }
16062
16063 /// Identifies the authorization scope for the method you are building.
16064 ///
16065 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16066 /// [`Scope::CloudPlatform`].
16067 ///
16068 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16069 /// tokens for more than one scope.
16070 ///
16071 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16072 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16073 /// sufficient, a read-write scope will do as well.
16074 pub fn add_scope<St>(mut self, scope: St) -> ProjectTimeSeryCreateServiceCall<'a, C>
16075 where
16076 St: AsRef<str>,
16077 {
16078 self._scopes.insert(String::from(scope.as_ref()));
16079 self
16080 }
16081 /// Identifies the authorization scope(s) for the method you are building.
16082 ///
16083 /// See [`Self::add_scope()`] for details.
16084 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTimeSeryCreateServiceCall<'a, C>
16085 where
16086 I: IntoIterator<Item = St>,
16087 St: AsRef<str>,
16088 {
16089 self._scopes
16090 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16091 self
16092 }
16093
16094 /// Removes all scopes, and no default scope will be used either.
16095 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16096 /// for details).
16097 pub fn clear_scopes(mut self) -> ProjectTimeSeryCreateServiceCall<'a, C> {
16098 self._scopes.clear();
16099 self
16100 }
16101}
16102
16103/// Lists time series that match a filter.
16104///
16105/// A builder for the *timeSeries.list* method supported by a *project* resource.
16106/// It is not used directly, but through a [`ProjectMethods`] instance.
16107///
16108/// # Example
16109///
16110/// Instantiate a resource method builder
16111///
16112/// ```test_harness,no_run
16113/// # extern crate hyper;
16114/// # extern crate hyper_rustls;
16115/// # extern crate google_monitoring3 as monitoring3;
16116/// # async fn dox() {
16117/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16118///
16119/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16120/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16121/// # secret,
16122/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16123/// # ).build().await.unwrap();
16124///
16125/// # let client = hyper_util::client::legacy::Client::builder(
16126/// # hyper_util::rt::TokioExecutor::new()
16127/// # )
16128/// # .build(
16129/// # hyper_rustls::HttpsConnectorBuilder::new()
16130/// # .with_native_roots()
16131/// # .unwrap()
16132/// # .https_or_http()
16133/// # .enable_http1()
16134/// # .build()
16135/// # );
16136/// # let mut hub = Monitoring::new(client, auth);
16137/// // You can configure optional parameters by calling the respective setters at will, and
16138/// // execute the final call using `doit()`.
16139/// // Values shown here are possibly random and not representative !
16140/// let result = hub.projects().time_series_list("name")
16141/// .view("dolores")
16142/// .secondary_aggregation_per_series_aligner("dolores")
16143/// .add_secondary_aggregation_group_by_fields("et")
16144/// .secondary_aggregation_cross_series_reducer("sed")
16145/// .secondary_aggregation_alignment_period(chrono::Duration::seconds(2189267))
16146/// .page_token("elitr")
16147/// .page_size(-80)
16148/// .order_by("no")
16149/// .interval_start_time(chrono::Utc::now())
16150/// .interval_end_time(chrono::Utc::now())
16151/// .filter("nonumy")
16152/// .aggregation_per_series_aligner("At")
16153/// .add_aggregation_group_by_fields("sadipscing")
16154/// .aggregation_cross_series_reducer("aliquyam")
16155/// .aggregation_alignment_period(chrono::Duration::seconds(4245441))
16156/// .doit().await;
16157/// # }
16158/// ```
16159pub struct ProjectTimeSeryListCall<'a, C>
16160where
16161 C: 'a,
16162{
16163 hub: &'a Monitoring<C>,
16164 _name: String,
16165 _view: Option<String>,
16166 _secondary_aggregation_per_series_aligner: Option<String>,
16167 _secondary_aggregation_group_by_fields: Vec<String>,
16168 _secondary_aggregation_cross_series_reducer: Option<String>,
16169 _secondary_aggregation_alignment_period: Option<chrono::Duration>,
16170 _page_token: Option<String>,
16171 _page_size: Option<i32>,
16172 _order_by: Option<String>,
16173 _interval_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
16174 _interval_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
16175 _filter: Option<String>,
16176 _aggregation_per_series_aligner: Option<String>,
16177 _aggregation_group_by_fields: Vec<String>,
16178 _aggregation_cross_series_reducer: Option<String>,
16179 _aggregation_alignment_period: Option<chrono::Duration>,
16180 _delegate: Option<&'a mut dyn common::Delegate>,
16181 _additional_params: HashMap<String, String>,
16182 _scopes: BTreeSet<String>,
16183}
16184
16185impl<'a, C> common::CallBuilder for ProjectTimeSeryListCall<'a, C> {}
16186
16187impl<'a, C> ProjectTimeSeryListCall<'a, C>
16188where
16189 C: common::Connector,
16190{
16191 /// Perform the operation you have build so far.
16192 pub async fn doit(mut self) -> common::Result<(common::Response, ListTimeSeriesResponse)> {
16193 use std::borrow::Cow;
16194 use std::io::{Read, Seek};
16195
16196 use common::{url::Params, ToParts};
16197 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16198
16199 let mut dd = common::DefaultDelegate;
16200 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16201 dlg.begin(common::MethodInfo {
16202 id: "monitoring.projects.timeSeries.list",
16203 http_method: hyper::Method::GET,
16204 });
16205
16206 for &field in [
16207 "alt",
16208 "name",
16209 "view",
16210 "secondaryAggregation.perSeriesAligner",
16211 "secondaryAggregation.groupByFields",
16212 "secondaryAggregation.crossSeriesReducer",
16213 "secondaryAggregation.alignmentPeriod",
16214 "pageToken",
16215 "pageSize",
16216 "orderBy",
16217 "interval.startTime",
16218 "interval.endTime",
16219 "filter",
16220 "aggregation.perSeriesAligner",
16221 "aggregation.groupByFields",
16222 "aggregation.crossSeriesReducer",
16223 "aggregation.alignmentPeriod",
16224 ]
16225 .iter()
16226 {
16227 if self._additional_params.contains_key(field) {
16228 dlg.finished(false);
16229 return Err(common::Error::FieldClash(field));
16230 }
16231 }
16232
16233 let mut params = Params::with_capacity(18 + self._additional_params.len());
16234 params.push("name", self._name);
16235 if let Some(value) = self._view.as_ref() {
16236 params.push("view", value);
16237 }
16238 if let Some(value) = self._secondary_aggregation_per_series_aligner.as_ref() {
16239 params.push("secondaryAggregation.perSeriesAligner", value);
16240 }
16241 if !self._secondary_aggregation_group_by_fields.is_empty() {
16242 for f in self._secondary_aggregation_group_by_fields.iter() {
16243 params.push("secondaryAggregation.groupByFields", f);
16244 }
16245 }
16246 if let Some(value) = self._secondary_aggregation_cross_series_reducer.as_ref() {
16247 params.push("secondaryAggregation.crossSeriesReducer", value);
16248 }
16249 if let Some(value) = self._secondary_aggregation_alignment_period.as_ref() {
16250 params.push(
16251 "secondaryAggregation.alignmentPeriod",
16252 common::serde::duration::to_string(&value),
16253 );
16254 }
16255 if let Some(value) = self._page_token.as_ref() {
16256 params.push("pageToken", value);
16257 }
16258 if let Some(value) = self._page_size.as_ref() {
16259 params.push("pageSize", value.to_string());
16260 }
16261 if let Some(value) = self._order_by.as_ref() {
16262 params.push("orderBy", value);
16263 }
16264 if let Some(value) = self._interval_start_time.as_ref() {
16265 params.push(
16266 "interval.startTime",
16267 common::serde::datetime_to_string(&value),
16268 );
16269 }
16270 if let Some(value) = self._interval_end_time.as_ref() {
16271 params.push(
16272 "interval.endTime",
16273 common::serde::datetime_to_string(&value),
16274 );
16275 }
16276 if let Some(value) = self._filter.as_ref() {
16277 params.push("filter", value);
16278 }
16279 if let Some(value) = self._aggregation_per_series_aligner.as_ref() {
16280 params.push("aggregation.perSeriesAligner", value);
16281 }
16282 if !self._aggregation_group_by_fields.is_empty() {
16283 for f in self._aggregation_group_by_fields.iter() {
16284 params.push("aggregation.groupByFields", f);
16285 }
16286 }
16287 if let Some(value) = self._aggregation_cross_series_reducer.as_ref() {
16288 params.push("aggregation.crossSeriesReducer", value);
16289 }
16290 if let Some(value) = self._aggregation_alignment_period.as_ref() {
16291 params.push(
16292 "aggregation.alignmentPeriod",
16293 common::serde::duration::to_string(&value),
16294 );
16295 }
16296
16297 params.extend(self._additional_params.iter());
16298
16299 params.push("alt", "json");
16300 let mut url = self.hub._base_url.clone() + "v3/{+name}/timeSeries";
16301 if self._scopes.is_empty() {
16302 self._scopes
16303 .insert(Scope::CloudPlatform.as_ref().to_string());
16304 }
16305
16306 #[allow(clippy::single_element_loop)]
16307 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16308 url = params.uri_replacement(url, param_name, find_this, true);
16309 }
16310 {
16311 let to_remove = ["name"];
16312 params.remove_params(&to_remove);
16313 }
16314
16315 let url = params.parse_with_url(&url);
16316
16317 loop {
16318 let token = match self
16319 .hub
16320 .auth
16321 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16322 .await
16323 {
16324 Ok(token) => token,
16325 Err(e) => match dlg.token(e) {
16326 Ok(token) => token,
16327 Err(e) => {
16328 dlg.finished(false);
16329 return Err(common::Error::MissingToken(e));
16330 }
16331 },
16332 };
16333 let mut req_result = {
16334 let client = &self.hub.client;
16335 dlg.pre_request();
16336 let mut req_builder = hyper::Request::builder()
16337 .method(hyper::Method::GET)
16338 .uri(url.as_str())
16339 .header(USER_AGENT, self.hub._user_agent.clone());
16340
16341 if let Some(token) = token.as_ref() {
16342 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16343 }
16344
16345 let request = req_builder
16346 .header(CONTENT_LENGTH, 0_u64)
16347 .body(common::to_body::<String>(None));
16348
16349 client.request(request.unwrap()).await
16350 };
16351
16352 match req_result {
16353 Err(err) => {
16354 if let common::Retry::After(d) = dlg.http_error(&err) {
16355 sleep(d).await;
16356 continue;
16357 }
16358 dlg.finished(false);
16359 return Err(common::Error::HttpError(err));
16360 }
16361 Ok(res) => {
16362 let (mut parts, body) = res.into_parts();
16363 let mut body = common::Body::new(body);
16364 if !parts.status.is_success() {
16365 let bytes = common::to_bytes(body).await.unwrap_or_default();
16366 let error = serde_json::from_str(&common::to_string(&bytes));
16367 let response = common::to_response(parts, bytes.into());
16368
16369 if let common::Retry::After(d) =
16370 dlg.http_failure(&response, error.as_ref().ok())
16371 {
16372 sleep(d).await;
16373 continue;
16374 }
16375
16376 dlg.finished(false);
16377
16378 return Err(match error {
16379 Ok(value) => common::Error::BadRequest(value),
16380 _ => common::Error::Failure(response),
16381 });
16382 }
16383 let response = {
16384 let bytes = common::to_bytes(body).await.unwrap_or_default();
16385 let encoded = common::to_string(&bytes);
16386 match serde_json::from_str(&encoded) {
16387 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16388 Err(error) => {
16389 dlg.response_json_decode_error(&encoded, &error);
16390 return Err(common::Error::JsonDecodeError(
16391 encoded.to_string(),
16392 error,
16393 ));
16394 }
16395 }
16396 };
16397
16398 dlg.finished(true);
16399 return Ok(response);
16400 }
16401 }
16402 }
16403 }
16404
16405 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name), organization or folder on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]
16406 ///
16407 /// Sets the *name* path property to the given value.
16408 ///
16409 /// Even though the property as already been set when instantiating this call,
16410 /// we provide this method for API completeness.
16411 pub fn name(mut self, new_value: &str) -> ProjectTimeSeryListCall<'a, C> {
16412 self._name = new_value.to_string();
16413 self
16414 }
16415 /// Required. Specifies which information is returned about the time series.
16416 ///
16417 /// Sets the *view* query property to the given value.
16418 pub fn view(mut self, new_value: &str) -> ProjectTimeSeryListCall<'a, C> {
16419 self._view = Some(new_value.to_string());
16420 self
16421 }
16422 /// An Aligner describes how to bring the data points in a single time series into temporal alignment. Except for ALIGN_NONE, all alignments cause all the data points in an alignment_period to be mathematically grouped together, resulting in a single data point for each alignment_period with end timestamp at the end of the period.Not all alignment operations may be applied to all time series. The valid choices depend on the metric_kind and value_type of the original time series. Alignment can change the metric_kind or the value_type of the time series.Time series data must be aligned in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified and not equal to ALIGN_NONE and alignment_period must be specified; otherwise, an error is returned.
16423 ///
16424 /// Sets the *secondary aggregation.per series aligner* query property to the given value.
16425 pub fn secondary_aggregation_per_series_aligner(
16426 mut self,
16427 new_value: &str,
16428 ) -> ProjectTimeSeryListCall<'a, C> {
16429 self._secondary_aggregation_per_series_aligner = Some(new_value.to_string());
16430 self
16431 }
16432 /// The set of fields to preserve when cross_series_reducer is specified. The group_by_fields determine how the time series are partitioned into subsets prior to applying the aggregation operation. Each subset contains time series that have the same value for each of the grouping fields. Each individual time series is a member of exactly one subset. The cross_series_reducer is applied to each subset of time series. It is not possible to reduce across different resource types, so this field implicitly contains resource.type. Fields not specified in group_by_fields are aggregated away. If group_by_fields is not specified and all the time series have the same resource type, then the time series are aggregated into a single output time series. If cross_series_reducer is not defined, this field is ignored.
16433 ///
16434 /// Append the given value to the *secondary aggregation.group by fields* query property.
16435 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
16436 pub fn add_secondary_aggregation_group_by_fields(
16437 mut self,
16438 new_value: &str,
16439 ) -> ProjectTimeSeryListCall<'a, C> {
16440 self._secondary_aggregation_group_by_fields
16441 .push(new_value.to_string());
16442 self
16443 }
16444 /// The reduction operation to be used to combine time series into a single time series, where the value of each data point in the resulting series is a function of all the already aligned values in the input time series.Not all reducer operations can be applied to all time series. The valid choices depend on the metric_kind and the value_type of the original time series. Reduction can yield a time series with a different metric_kind or value_type than the input time series.Time series data must first be aligned (see per_series_aligner) in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified, and must not be ALIGN_NONE. An alignment_period must also be specified; otherwise, an error is returned.
16445 ///
16446 /// Sets the *secondary aggregation.cross series reducer* query property to the given value.
16447 pub fn secondary_aggregation_cross_series_reducer(
16448 mut self,
16449 new_value: &str,
16450 ) -> ProjectTimeSeryListCall<'a, C> {
16451 self._secondary_aggregation_cross_series_reducer = Some(new_value.to_string());
16452 self
16453 }
16454 /// The alignment_period specifies a time interval, in seconds, that is used to divide the data in all the time series into consistent blocks of time. This will be done before the per-series aligner can be applied to the data.The value must be at least 60 seconds. If a per-series aligner other than ALIGN_NONE is specified, this field is required or an error is returned. If no per-series aligner is specified, or the aligner ALIGN_NONE is specified, then this field is ignored.The maximum value of the alignment_period is 104 weeks (2 years) for charts, and 90,000 seconds (25 hours) for alerting policies.
16455 ///
16456 /// Sets the *secondary aggregation.alignment period* query property to the given value.
16457 pub fn secondary_aggregation_alignment_period(
16458 mut self,
16459 new_value: chrono::Duration,
16460 ) -> ProjectTimeSeryListCall<'a, C> {
16461 self._secondary_aggregation_alignment_period = Some(new_value);
16462 self
16463 }
16464 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
16465 ///
16466 /// Sets the *page token* query property to the given value.
16467 pub fn page_token(mut self, new_value: &str) -> ProjectTimeSeryListCall<'a, C> {
16468 self._page_token = Some(new_value.to_string());
16469 self
16470 }
16471 /// A positive number that is the maximum number of results to return. If page_size is empty or more than 100,000 results, the effective page_size is 100,000 results. If view is set to FULL, this is the maximum number of Points returned. If view is set to HEADERS, this is the maximum number of TimeSeries returned.
16472 ///
16473 /// Sets the *page size* query property to the given value.
16474 pub fn page_size(mut self, new_value: i32) -> ProjectTimeSeryListCall<'a, C> {
16475 self._page_size = Some(new_value);
16476 self
16477 }
16478 /// Unsupported: must be left blank. The points in each time series are currently returned in reverse time order (most recent to oldest).
16479 ///
16480 /// Sets the *order by* query property to the given value.
16481 pub fn order_by(mut self, new_value: &str) -> ProjectTimeSeryListCall<'a, C> {
16482 self._order_by = Some(new_value.to_string());
16483 self
16484 }
16485 /// Optional. The beginning of the time interval. The default value for the start time is the end time. The start time must not be later than the end time.
16486 ///
16487 /// Sets the *interval.start time* query property to the given value.
16488 pub fn interval_start_time(
16489 mut self,
16490 new_value: chrono::DateTime<chrono::offset::Utc>,
16491 ) -> ProjectTimeSeryListCall<'a, C> {
16492 self._interval_start_time = Some(new_value);
16493 self
16494 }
16495 /// Required. The end of the time interval.
16496 ///
16497 /// Sets the *interval.end time* query property to the given value.
16498 pub fn interval_end_time(
16499 mut self,
16500 new_value: chrono::DateTime<chrono::offset::Utc>,
16501 ) -> ProjectTimeSeryListCall<'a, C> {
16502 self._interval_end_time = Some(new_value);
16503 self
16504 }
16505 /// Required. A monitoring filter (https://cloud.google.com/monitoring/api/v3/filters) that specifies which time series should be returned. The filter must specify a single metric type, and can additionally specify metric labels and other information. For example: metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND metric.labels.instance_name = "my-instance-name"
16506 ///
16507 /// Sets the *filter* query property to the given value.
16508 pub fn filter(mut self, new_value: &str) -> ProjectTimeSeryListCall<'a, C> {
16509 self._filter = Some(new_value.to_string());
16510 self
16511 }
16512 /// An Aligner describes how to bring the data points in a single time series into temporal alignment. Except for ALIGN_NONE, all alignments cause all the data points in an alignment_period to be mathematically grouped together, resulting in a single data point for each alignment_period with end timestamp at the end of the period.Not all alignment operations may be applied to all time series. The valid choices depend on the metric_kind and value_type of the original time series. Alignment can change the metric_kind or the value_type of the time series.Time series data must be aligned in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified and not equal to ALIGN_NONE and alignment_period must be specified; otherwise, an error is returned.
16513 ///
16514 /// Sets the *aggregation.per series aligner* query property to the given value.
16515 pub fn aggregation_per_series_aligner(
16516 mut self,
16517 new_value: &str,
16518 ) -> ProjectTimeSeryListCall<'a, C> {
16519 self._aggregation_per_series_aligner = Some(new_value.to_string());
16520 self
16521 }
16522 /// The set of fields to preserve when cross_series_reducer is specified. The group_by_fields determine how the time series are partitioned into subsets prior to applying the aggregation operation. Each subset contains time series that have the same value for each of the grouping fields. Each individual time series is a member of exactly one subset. The cross_series_reducer is applied to each subset of time series. It is not possible to reduce across different resource types, so this field implicitly contains resource.type. Fields not specified in group_by_fields are aggregated away. If group_by_fields is not specified and all the time series have the same resource type, then the time series are aggregated into a single output time series. If cross_series_reducer is not defined, this field is ignored.
16523 ///
16524 /// Append the given value to the *aggregation.group by fields* query property.
16525 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
16526 pub fn add_aggregation_group_by_fields(
16527 mut self,
16528 new_value: &str,
16529 ) -> ProjectTimeSeryListCall<'a, C> {
16530 self._aggregation_group_by_fields
16531 .push(new_value.to_string());
16532 self
16533 }
16534 /// The reduction operation to be used to combine time series into a single time series, where the value of each data point in the resulting series is a function of all the already aligned values in the input time series.Not all reducer operations can be applied to all time series. The valid choices depend on the metric_kind and the value_type of the original time series. Reduction can yield a time series with a different metric_kind or value_type than the input time series.Time series data must first be aligned (see per_series_aligner) in order to perform cross-time series reduction. If cross_series_reducer is specified, then per_series_aligner must be specified, and must not be ALIGN_NONE. An alignment_period must also be specified; otherwise, an error is returned.
16535 ///
16536 /// Sets the *aggregation.cross series reducer* query property to the given value.
16537 pub fn aggregation_cross_series_reducer(
16538 mut self,
16539 new_value: &str,
16540 ) -> ProjectTimeSeryListCall<'a, C> {
16541 self._aggregation_cross_series_reducer = Some(new_value.to_string());
16542 self
16543 }
16544 /// The alignment_period specifies a time interval, in seconds, that is used to divide the data in all the time series into consistent blocks of time. This will be done before the per-series aligner can be applied to the data.The value must be at least 60 seconds. If a per-series aligner other than ALIGN_NONE is specified, this field is required or an error is returned. If no per-series aligner is specified, or the aligner ALIGN_NONE is specified, then this field is ignored.The maximum value of the alignment_period is 104 weeks (2 years) for charts, and 90,000 seconds (25 hours) for alerting policies.
16545 ///
16546 /// Sets the *aggregation.alignment period* query property to the given value.
16547 pub fn aggregation_alignment_period(
16548 mut self,
16549 new_value: chrono::Duration,
16550 ) -> ProjectTimeSeryListCall<'a, C> {
16551 self._aggregation_alignment_period = Some(new_value);
16552 self
16553 }
16554 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16555 /// while executing the actual API request.
16556 ///
16557 /// ````text
16558 /// It should be used to handle progress information, and to implement a certain level of resilience.
16559 /// ````
16560 ///
16561 /// Sets the *delegate* property to the given value.
16562 pub fn delegate(
16563 mut self,
16564 new_value: &'a mut dyn common::Delegate,
16565 ) -> ProjectTimeSeryListCall<'a, C> {
16566 self._delegate = Some(new_value);
16567 self
16568 }
16569
16570 /// Set any additional parameter of the query string used in the request.
16571 /// It should be used to set parameters which are not yet available through their own
16572 /// setters.
16573 ///
16574 /// Please note that this method must not be used to set any of the known parameters
16575 /// which have their own setter method. If done anyway, the request will fail.
16576 ///
16577 /// # Additional Parameters
16578 ///
16579 /// * *$.xgafv* (query-string) - V1 error format.
16580 /// * *access_token* (query-string) - OAuth access token.
16581 /// * *alt* (query-string) - Data format for response.
16582 /// * *callback* (query-string) - JSONP
16583 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16584 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16585 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16586 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16587 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16588 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16589 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16590 pub fn param<T>(mut self, name: T, value: T) -> ProjectTimeSeryListCall<'a, C>
16591 where
16592 T: AsRef<str>,
16593 {
16594 self._additional_params
16595 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16596 self
16597 }
16598
16599 /// Identifies the authorization scope for the method you are building.
16600 ///
16601 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16602 /// [`Scope::CloudPlatform`].
16603 ///
16604 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16605 /// tokens for more than one scope.
16606 ///
16607 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16608 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16609 /// sufficient, a read-write scope will do as well.
16610 pub fn add_scope<St>(mut self, scope: St) -> ProjectTimeSeryListCall<'a, C>
16611 where
16612 St: AsRef<str>,
16613 {
16614 self._scopes.insert(String::from(scope.as_ref()));
16615 self
16616 }
16617 /// Identifies the authorization scope(s) for the method you are building.
16618 ///
16619 /// See [`Self::add_scope()`] for details.
16620 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTimeSeryListCall<'a, C>
16621 where
16622 I: IntoIterator<Item = St>,
16623 St: AsRef<str>,
16624 {
16625 self._scopes
16626 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16627 self
16628 }
16629
16630 /// Removes all scopes, and no default scope will be used either.
16631 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16632 /// for details).
16633 pub fn clear_scopes(mut self) -> ProjectTimeSeryListCall<'a, C> {
16634 self._scopes.clear();
16635 self
16636 }
16637}
16638
16639/// Queries time series using Monitoring Query Language.
16640///
16641/// A builder for the *timeSeries.query* method supported by a *project* resource.
16642/// It is not used directly, but through a [`ProjectMethods`] instance.
16643///
16644/// # Example
16645///
16646/// Instantiate a resource method builder
16647///
16648/// ```test_harness,no_run
16649/// # extern crate hyper;
16650/// # extern crate hyper_rustls;
16651/// # extern crate google_monitoring3 as monitoring3;
16652/// use monitoring3::api::QueryTimeSeriesRequest;
16653/// # async fn dox() {
16654/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16655///
16656/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16657/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16658/// # secret,
16659/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16660/// # ).build().await.unwrap();
16661///
16662/// # let client = hyper_util::client::legacy::Client::builder(
16663/// # hyper_util::rt::TokioExecutor::new()
16664/// # )
16665/// # .build(
16666/// # hyper_rustls::HttpsConnectorBuilder::new()
16667/// # .with_native_roots()
16668/// # .unwrap()
16669/// # .https_or_http()
16670/// # .enable_http1()
16671/// # .build()
16672/// # );
16673/// # let mut hub = Monitoring::new(client, auth);
16674/// // As the method needs a request, you would usually fill it with the desired information
16675/// // into the respective structure. Some of the parts shown here might not be applicable !
16676/// // Values shown here are possibly random and not representative !
16677/// let mut req = QueryTimeSeriesRequest::default();
16678///
16679/// // You can configure optional parameters by calling the respective setters at will, and
16680/// // execute the final call using `doit()`.
16681/// // Values shown here are possibly random and not representative !
16682/// let result = hub.projects().time_series_query(req, "name")
16683/// .doit().await;
16684/// # }
16685/// ```
16686pub struct ProjectTimeSeryQueryCall<'a, C>
16687where
16688 C: 'a,
16689{
16690 hub: &'a Monitoring<C>,
16691 _request: QueryTimeSeriesRequest,
16692 _name: String,
16693 _delegate: Option<&'a mut dyn common::Delegate>,
16694 _additional_params: HashMap<String, String>,
16695 _scopes: BTreeSet<String>,
16696}
16697
16698impl<'a, C> common::CallBuilder for ProjectTimeSeryQueryCall<'a, C> {}
16699
16700impl<'a, C> ProjectTimeSeryQueryCall<'a, C>
16701where
16702 C: common::Connector,
16703{
16704 /// Perform the operation you have build so far.
16705 pub async fn doit(mut self) -> common::Result<(common::Response, QueryTimeSeriesResponse)> {
16706 use std::borrow::Cow;
16707 use std::io::{Read, Seek};
16708
16709 use common::{url::Params, ToParts};
16710 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16711
16712 let mut dd = common::DefaultDelegate;
16713 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16714 dlg.begin(common::MethodInfo {
16715 id: "monitoring.projects.timeSeries.query",
16716 http_method: hyper::Method::POST,
16717 });
16718
16719 for &field in ["alt", "name"].iter() {
16720 if self._additional_params.contains_key(field) {
16721 dlg.finished(false);
16722 return Err(common::Error::FieldClash(field));
16723 }
16724 }
16725
16726 let mut params = Params::with_capacity(4 + self._additional_params.len());
16727 params.push("name", self._name);
16728
16729 params.extend(self._additional_params.iter());
16730
16731 params.push("alt", "json");
16732 let mut url = self.hub._base_url.clone() + "v3/{+name}/timeSeries:query";
16733 if self._scopes.is_empty() {
16734 self._scopes
16735 .insert(Scope::CloudPlatform.as_ref().to_string());
16736 }
16737
16738 #[allow(clippy::single_element_loop)]
16739 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16740 url = params.uri_replacement(url, param_name, find_this, true);
16741 }
16742 {
16743 let to_remove = ["name"];
16744 params.remove_params(&to_remove);
16745 }
16746
16747 let url = params.parse_with_url(&url);
16748
16749 let mut json_mime_type = mime::APPLICATION_JSON;
16750 let mut request_value_reader = {
16751 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16752 common::remove_json_null_values(&mut value);
16753 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16754 serde_json::to_writer(&mut dst, &value).unwrap();
16755 dst
16756 };
16757 let request_size = request_value_reader
16758 .seek(std::io::SeekFrom::End(0))
16759 .unwrap();
16760 request_value_reader
16761 .seek(std::io::SeekFrom::Start(0))
16762 .unwrap();
16763
16764 loop {
16765 let token = match self
16766 .hub
16767 .auth
16768 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16769 .await
16770 {
16771 Ok(token) => token,
16772 Err(e) => match dlg.token(e) {
16773 Ok(token) => token,
16774 Err(e) => {
16775 dlg.finished(false);
16776 return Err(common::Error::MissingToken(e));
16777 }
16778 },
16779 };
16780 request_value_reader
16781 .seek(std::io::SeekFrom::Start(0))
16782 .unwrap();
16783 let mut req_result = {
16784 let client = &self.hub.client;
16785 dlg.pre_request();
16786 let mut req_builder = hyper::Request::builder()
16787 .method(hyper::Method::POST)
16788 .uri(url.as_str())
16789 .header(USER_AGENT, self.hub._user_agent.clone());
16790
16791 if let Some(token) = token.as_ref() {
16792 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16793 }
16794
16795 let request = req_builder
16796 .header(CONTENT_TYPE, json_mime_type.to_string())
16797 .header(CONTENT_LENGTH, request_size as u64)
16798 .body(common::to_body(
16799 request_value_reader.get_ref().clone().into(),
16800 ));
16801
16802 client.request(request.unwrap()).await
16803 };
16804
16805 match req_result {
16806 Err(err) => {
16807 if let common::Retry::After(d) = dlg.http_error(&err) {
16808 sleep(d).await;
16809 continue;
16810 }
16811 dlg.finished(false);
16812 return Err(common::Error::HttpError(err));
16813 }
16814 Ok(res) => {
16815 let (mut parts, body) = res.into_parts();
16816 let mut body = common::Body::new(body);
16817 if !parts.status.is_success() {
16818 let bytes = common::to_bytes(body).await.unwrap_or_default();
16819 let error = serde_json::from_str(&common::to_string(&bytes));
16820 let response = common::to_response(parts, bytes.into());
16821
16822 if let common::Retry::After(d) =
16823 dlg.http_failure(&response, error.as_ref().ok())
16824 {
16825 sleep(d).await;
16826 continue;
16827 }
16828
16829 dlg.finished(false);
16830
16831 return Err(match error {
16832 Ok(value) => common::Error::BadRequest(value),
16833 _ => common::Error::Failure(response),
16834 });
16835 }
16836 let response = {
16837 let bytes = common::to_bytes(body).await.unwrap_or_default();
16838 let encoded = common::to_string(&bytes);
16839 match serde_json::from_str(&encoded) {
16840 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16841 Err(error) => {
16842 dlg.response_json_decode_error(&encoded, &error);
16843 return Err(common::Error::JsonDecodeError(
16844 encoded.to_string(),
16845 error,
16846 ));
16847 }
16848 }
16849 };
16850
16851 dlg.finished(true);
16852 return Ok(response);
16853 }
16854 }
16855 }
16856 }
16857
16858 ///
16859 /// Sets the *request* property to the given value.
16860 ///
16861 /// Even though the property as already been set when instantiating this call,
16862 /// we provide this method for API completeness.
16863 pub fn request(mut self, new_value: QueryTimeSeriesRequest) -> ProjectTimeSeryQueryCall<'a, C> {
16864 self._request = new_value;
16865 self
16866 }
16867 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) on which to execute the request. The format is: projects/[PROJECT_ID_OR_NUMBER]
16868 ///
16869 /// Sets the *name* path property to the given value.
16870 ///
16871 /// Even though the property as already been set when instantiating this call,
16872 /// we provide this method for API completeness.
16873 pub fn name(mut self, new_value: &str) -> ProjectTimeSeryQueryCall<'a, C> {
16874 self._name = new_value.to_string();
16875 self
16876 }
16877 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16878 /// while executing the actual API request.
16879 ///
16880 /// ````text
16881 /// It should be used to handle progress information, and to implement a certain level of resilience.
16882 /// ````
16883 ///
16884 /// Sets the *delegate* property to the given value.
16885 pub fn delegate(
16886 mut self,
16887 new_value: &'a mut dyn common::Delegate,
16888 ) -> ProjectTimeSeryQueryCall<'a, C> {
16889 self._delegate = Some(new_value);
16890 self
16891 }
16892
16893 /// Set any additional parameter of the query string used in the request.
16894 /// It should be used to set parameters which are not yet available through their own
16895 /// setters.
16896 ///
16897 /// Please note that this method must not be used to set any of the known parameters
16898 /// which have their own setter method. If done anyway, the request will fail.
16899 ///
16900 /// # Additional Parameters
16901 ///
16902 /// * *$.xgafv* (query-string) - V1 error format.
16903 /// * *access_token* (query-string) - OAuth access token.
16904 /// * *alt* (query-string) - Data format for response.
16905 /// * *callback* (query-string) - JSONP
16906 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16907 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16908 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16909 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16910 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16911 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16912 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16913 pub fn param<T>(mut self, name: T, value: T) -> ProjectTimeSeryQueryCall<'a, C>
16914 where
16915 T: AsRef<str>,
16916 {
16917 self._additional_params
16918 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16919 self
16920 }
16921
16922 /// Identifies the authorization scope for the method you are building.
16923 ///
16924 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16925 /// [`Scope::CloudPlatform`].
16926 ///
16927 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16928 /// tokens for more than one scope.
16929 ///
16930 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16931 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16932 /// sufficient, a read-write scope will do as well.
16933 pub fn add_scope<St>(mut self, scope: St) -> ProjectTimeSeryQueryCall<'a, C>
16934 where
16935 St: AsRef<str>,
16936 {
16937 self._scopes.insert(String::from(scope.as_ref()));
16938 self
16939 }
16940 /// Identifies the authorization scope(s) for the method you are building.
16941 ///
16942 /// See [`Self::add_scope()`] for details.
16943 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTimeSeryQueryCall<'a, C>
16944 where
16945 I: IntoIterator<Item = St>,
16946 St: AsRef<str>,
16947 {
16948 self._scopes
16949 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16950 self
16951 }
16952
16953 /// Removes all scopes, and no default scope will be used either.
16954 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16955 /// for details).
16956 pub fn clear_scopes(mut self) -> ProjectTimeSeryQueryCall<'a, C> {
16957 self._scopes.clear();
16958 self
16959 }
16960}
16961
16962/// Creates a new Uptime check configuration.
16963///
16964/// A builder for the *uptimeCheckConfigs.create* method supported by a *project* resource.
16965/// It is not used directly, but through a [`ProjectMethods`] instance.
16966///
16967/// # Example
16968///
16969/// Instantiate a resource method builder
16970///
16971/// ```test_harness,no_run
16972/// # extern crate hyper;
16973/// # extern crate hyper_rustls;
16974/// # extern crate google_monitoring3 as monitoring3;
16975/// use monitoring3::api::UptimeCheckConfig;
16976/// # async fn dox() {
16977/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16978///
16979/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16980/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16981/// # secret,
16982/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16983/// # ).build().await.unwrap();
16984///
16985/// # let client = hyper_util::client::legacy::Client::builder(
16986/// # hyper_util::rt::TokioExecutor::new()
16987/// # )
16988/// # .build(
16989/// # hyper_rustls::HttpsConnectorBuilder::new()
16990/// # .with_native_roots()
16991/// # .unwrap()
16992/// # .https_or_http()
16993/// # .enable_http1()
16994/// # .build()
16995/// # );
16996/// # let mut hub = Monitoring::new(client, auth);
16997/// // As the method needs a request, you would usually fill it with the desired information
16998/// // into the respective structure. Some of the parts shown here might not be applicable !
16999/// // Values shown here are possibly random and not representative !
17000/// let mut req = UptimeCheckConfig::default();
17001///
17002/// // You can configure optional parameters by calling the respective setters at will, and
17003/// // execute the final call using `doit()`.
17004/// // Values shown here are possibly random and not representative !
17005/// let result = hub.projects().uptime_check_configs_create(req, "parent")
17006/// .doit().await;
17007/// # }
17008/// ```
17009pub struct ProjectUptimeCheckConfigCreateCall<'a, C>
17010where
17011 C: 'a,
17012{
17013 hub: &'a Monitoring<C>,
17014 _request: UptimeCheckConfig,
17015 _parent: String,
17016 _delegate: Option<&'a mut dyn common::Delegate>,
17017 _additional_params: HashMap<String, String>,
17018 _scopes: BTreeSet<String>,
17019}
17020
17021impl<'a, C> common::CallBuilder for ProjectUptimeCheckConfigCreateCall<'a, C> {}
17022
17023impl<'a, C> ProjectUptimeCheckConfigCreateCall<'a, C>
17024where
17025 C: common::Connector,
17026{
17027 /// Perform the operation you have build so far.
17028 pub async fn doit(mut self) -> common::Result<(common::Response, UptimeCheckConfig)> {
17029 use std::borrow::Cow;
17030 use std::io::{Read, Seek};
17031
17032 use common::{url::Params, ToParts};
17033 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17034
17035 let mut dd = common::DefaultDelegate;
17036 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17037 dlg.begin(common::MethodInfo {
17038 id: "monitoring.projects.uptimeCheckConfigs.create",
17039 http_method: hyper::Method::POST,
17040 });
17041
17042 for &field in ["alt", "parent"].iter() {
17043 if self._additional_params.contains_key(field) {
17044 dlg.finished(false);
17045 return Err(common::Error::FieldClash(field));
17046 }
17047 }
17048
17049 let mut params = Params::with_capacity(4 + self._additional_params.len());
17050 params.push("parent", self._parent);
17051
17052 params.extend(self._additional_params.iter());
17053
17054 params.push("alt", "json");
17055 let mut url = self.hub._base_url.clone() + "v3/{+parent}/uptimeCheckConfigs";
17056 if self._scopes.is_empty() {
17057 self._scopes
17058 .insert(Scope::CloudPlatform.as_ref().to_string());
17059 }
17060
17061 #[allow(clippy::single_element_loop)]
17062 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17063 url = params.uri_replacement(url, param_name, find_this, true);
17064 }
17065 {
17066 let to_remove = ["parent"];
17067 params.remove_params(&to_remove);
17068 }
17069
17070 let url = params.parse_with_url(&url);
17071
17072 let mut json_mime_type = mime::APPLICATION_JSON;
17073 let mut request_value_reader = {
17074 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17075 common::remove_json_null_values(&mut value);
17076 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17077 serde_json::to_writer(&mut dst, &value).unwrap();
17078 dst
17079 };
17080 let request_size = request_value_reader
17081 .seek(std::io::SeekFrom::End(0))
17082 .unwrap();
17083 request_value_reader
17084 .seek(std::io::SeekFrom::Start(0))
17085 .unwrap();
17086
17087 loop {
17088 let token = match self
17089 .hub
17090 .auth
17091 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17092 .await
17093 {
17094 Ok(token) => token,
17095 Err(e) => match dlg.token(e) {
17096 Ok(token) => token,
17097 Err(e) => {
17098 dlg.finished(false);
17099 return Err(common::Error::MissingToken(e));
17100 }
17101 },
17102 };
17103 request_value_reader
17104 .seek(std::io::SeekFrom::Start(0))
17105 .unwrap();
17106 let mut req_result = {
17107 let client = &self.hub.client;
17108 dlg.pre_request();
17109 let mut req_builder = hyper::Request::builder()
17110 .method(hyper::Method::POST)
17111 .uri(url.as_str())
17112 .header(USER_AGENT, self.hub._user_agent.clone());
17113
17114 if let Some(token) = token.as_ref() {
17115 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17116 }
17117
17118 let request = req_builder
17119 .header(CONTENT_TYPE, json_mime_type.to_string())
17120 .header(CONTENT_LENGTH, request_size as u64)
17121 .body(common::to_body(
17122 request_value_reader.get_ref().clone().into(),
17123 ));
17124
17125 client.request(request.unwrap()).await
17126 };
17127
17128 match req_result {
17129 Err(err) => {
17130 if let common::Retry::After(d) = dlg.http_error(&err) {
17131 sleep(d).await;
17132 continue;
17133 }
17134 dlg.finished(false);
17135 return Err(common::Error::HttpError(err));
17136 }
17137 Ok(res) => {
17138 let (mut parts, body) = res.into_parts();
17139 let mut body = common::Body::new(body);
17140 if !parts.status.is_success() {
17141 let bytes = common::to_bytes(body).await.unwrap_or_default();
17142 let error = serde_json::from_str(&common::to_string(&bytes));
17143 let response = common::to_response(parts, bytes.into());
17144
17145 if let common::Retry::After(d) =
17146 dlg.http_failure(&response, error.as_ref().ok())
17147 {
17148 sleep(d).await;
17149 continue;
17150 }
17151
17152 dlg.finished(false);
17153
17154 return Err(match error {
17155 Ok(value) => common::Error::BadRequest(value),
17156 _ => common::Error::Failure(response),
17157 });
17158 }
17159 let response = {
17160 let bytes = common::to_bytes(body).await.unwrap_or_default();
17161 let encoded = common::to_string(&bytes);
17162 match serde_json::from_str(&encoded) {
17163 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17164 Err(error) => {
17165 dlg.response_json_decode_error(&encoded, &error);
17166 return Err(common::Error::JsonDecodeError(
17167 encoded.to_string(),
17168 error,
17169 ));
17170 }
17171 }
17172 };
17173
17174 dlg.finished(true);
17175 return Ok(response);
17176 }
17177 }
17178 }
17179 }
17180
17181 ///
17182 /// Sets the *request* property to the given value.
17183 ///
17184 /// Even though the property as already been set when instantiating this call,
17185 /// we provide this method for API completeness.
17186 pub fn request(
17187 mut self,
17188 new_value: UptimeCheckConfig,
17189 ) -> ProjectUptimeCheckConfigCreateCall<'a, C> {
17190 self._request = new_value;
17191 self
17192 }
17193 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) in which to create the Uptime check. The format is: projects/[PROJECT_ID_OR_NUMBER]
17194 ///
17195 /// Sets the *parent* path property to the given value.
17196 ///
17197 /// Even though the property as already been set when instantiating this call,
17198 /// we provide this method for API completeness.
17199 pub fn parent(mut self, new_value: &str) -> ProjectUptimeCheckConfigCreateCall<'a, C> {
17200 self._parent = new_value.to_string();
17201 self
17202 }
17203 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17204 /// while executing the actual API request.
17205 ///
17206 /// ````text
17207 /// It should be used to handle progress information, and to implement a certain level of resilience.
17208 /// ````
17209 ///
17210 /// Sets the *delegate* property to the given value.
17211 pub fn delegate(
17212 mut self,
17213 new_value: &'a mut dyn common::Delegate,
17214 ) -> ProjectUptimeCheckConfigCreateCall<'a, C> {
17215 self._delegate = Some(new_value);
17216 self
17217 }
17218
17219 /// Set any additional parameter of the query string used in the request.
17220 /// It should be used to set parameters which are not yet available through their own
17221 /// setters.
17222 ///
17223 /// Please note that this method must not be used to set any of the known parameters
17224 /// which have their own setter method. If done anyway, the request will fail.
17225 ///
17226 /// # Additional Parameters
17227 ///
17228 /// * *$.xgafv* (query-string) - V1 error format.
17229 /// * *access_token* (query-string) - OAuth access token.
17230 /// * *alt* (query-string) - Data format for response.
17231 /// * *callback* (query-string) - JSONP
17232 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17233 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17234 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17235 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17236 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17237 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17238 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17239 pub fn param<T>(mut self, name: T, value: T) -> ProjectUptimeCheckConfigCreateCall<'a, C>
17240 where
17241 T: AsRef<str>,
17242 {
17243 self._additional_params
17244 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17245 self
17246 }
17247
17248 /// Identifies the authorization scope for the method you are building.
17249 ///
17250 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17251 /// [`Scope::CloudPlatform`].
17252 ///
17253 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17254 /// tokens for more than one scope.
17255 ///
17256 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17257 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17258 /// sufficient, a read-write scope will do as well.
17259 pub fn add_scope<St>(mut self, scope: St) -> ProjectUptimeCheckConfigCreateCall<'a, C>
17260 where
17261 St: AsRef<str>,
17262 {
17263 self._scopes.insert(String::from(scope.as_ref()));
17264 self
17265 }
17266 /// Identifies the authorization scope(s) for the method you are building.
17267 ///
17268 /// See [`Self::add_scope()`] for details.
17269 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUptimeCheckConfigCreateCall<'a, C>
17270 where
17271 I: IntoIterator<Item = St>,
17272 St: AsRef<str>,
17273 {
17274 self._scopes
17275 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17276 self
17277 }
17278
17279 /// Removes all scopes, and no default scope will be used either.
17280 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17281 /// for details).
17282 pub fn clear_scopes(mut self) -> ProjectUptimeCheckConfigCreateCall<'a, C> {
17283 self._scopes.clear();
17284 self
17285 }
17286}
17287
17288/// Deletes an Uptime check configuration. Note that this method will fail if the Uptime check configuration is referenced by an alert policy or other dependent configs that would be rendered invalid by the deletion.
17289///
17290/// A builder for the *uptimeCheckConfigs.delete* method supported by a *project* resource.
17291/// It is not used directly, but through a [`ProjectMethods`] instance.
17292///
17293/// # Example
17294///
17295/// Instantiate a resource method builder
17296///
17297/// ```test_harness,no_run
17298/// # extern crate hyper;
17299/// # extern crate hyper_rustls;
17300/// # extern crate google_monitoring3 as monitoring3;
17301/// # async fn dox() {
17302/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17303///
17304/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17305/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17306/// # secret,
17307/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17308/// # ).build().await.unwrap();
17309///
17310/// # let client = hyper_util::client::legacy::Client::builder(
17311/// # hyper_util::rt::TokioExecutor::new()
17312/// # )
17313/// # .build(
17314/// # hyper_rustls::HttpsConnectorBuilder::new()
17315/// # .with_native_roots()
17316/// # .unwrap()
17317/// # .https_or_http()
17318/// # .enable_http1()
17319/// # .build()
17320/// # );
17321/// # let mut hub = Monitoring::new(client, auth);
17322/// // You can configure optional parameters by calling the respective setters at will, and
17323/// // execute the final call using `doit()`.
17324/// // Values shown here are possibly random and not representative !
17325/// let result = hub.projects().uptime_check_configs_delete("name")
17326/// .doit().await;
17327/// # }
17328/// ```
17329pub struct ProjectUptimeCheckConfigDeleteCall<'a, C>
17330where
17331 C: 'a,
17332{
17333 hub: &'a Monitoring<C>,
17334 _name: String,
17335 _delegate: Option<&'a mut dyn common::Delegate>,
17336 _additional_params: HashMap<String, String>,
17337 _scopes: BTreeSet<String>,
17338}
17339
17340impl<'a, C> common::CallBuilder for ProjectUptimeCheckConfigDeleteCall<'a, C> {}
17341
17342impl<'a, C> ProjectUptimeCheckConfigDeleteCall<'a, C>
17343where
17344 C: common::Connector,
17345{
17346 /// Perform the operation you have build so far.
17347 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
17348 use std::borrow::Cow;
17349 use std::io::{Read, Seek};
17350
17351 use common::{url::Params, ToParts};
17352 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17353
17354 let mut dd = common::DefaultDelegate;
17355 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17356 dlg.begin(common::MethodInfo {
17357 id: "monitoring.projects.uptimeCheckConfigs.delete",
17358 http_method: hyper::Method::DELETE,
17359 });
17360
17361 for &field in ["alt", "name"].iter() {
17362 if self._additional_params.contains_key(field) {
17363 dlg.finished(false);
17364 return Err(common::Error::FieldClash(field));
17365 }
17366 }
17367
17368 let mut params = Params::with_capacity(3 + self._additional_params.len());
17369 params.push("name", self._name);
17370
17371 params.extend(self._additional_params.iter());
17372
17373 params.push("alt", "json");
17374 let mut url = self.hub._base_url.clone() + "v3/{+name}";
17375 if self._scopes.is_empty() {
17376 self._scopes
17377 .insert(Scope::CloudPlatform.as_ref().to_string());
17378 }
17379
17380 #[allow(clippy::single_element_loop)]
17381 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17382 url = params.uri_replacement(url, param_name, find_this, true);
17383 }
17384 {
17385 let to_remove = ["name"];
17386 params.remove_params(&to_remove);
17387 }
17388
17389 let url = params.parse_with_url(&url);
17390
17391 loop {
17392 let token = match self
17393 .hub
17394 .auth
17395 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17396 .await
17397 {
17398 Ok(token) => token,
17399 Err(e) => match dlg.token(e) {
17400 Ok(token) => token,
17401 Err(e) => {
17402 dlg.finished(false);
17403 return Err(common::Error::MissingToken(e));
17404 }
17405 },
17406 };
17407 let mut req_result = {
17408 let client = &self.hub.client;
17409 dlg.pre_request();
17410 let mut req_builder = hyper::Request::builder()
17411 .method(hyper::Method::DELETE)
17412 .uri(url.as_str())
17413 .header(USER_AGENT, self.hub._user_agent.clone());
17414
17415 if let Some(token) = token.as_ref() {
17416 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17417 }
17418
17419 let request = req_builder
17420 .header(CONTENT_LENGTH, 0_u64)
17421 .body(common::to_body::<String>(None));
17422
17423 client.request(request.unwrap()).await
17424 };
17425
17426 match req_result {
17427 Err(err) => {
17428 if let common::Retry::After(d) = dlg.http_error(&err) {
17429 sleep(d).await;
17430 continue;
17431 }
17432 dlg.finished(false);
17433 return Err(common::Error::HttpError(err));
17434 }
17435 Ok(res) => {
17436 let (mut parts, body) = res.into_parts();
17437 let mut body = common::Body::new(body);
17438 if !parts.status.is_success() {
17439 let bytes = common::to_bytes(body).await.unwrap_or_default();
17440 let error = serde_json::from_str(&common::to_string(&bytes));
17441 let response = common::to_response(parts, bytes.into());
17442
17443 if let common::Retry::After(d) =
17444 dlg.http_failure(&response, error.as_ref().ok())
17445 {
17446 sleep(d).await;
17447 continue;
17448 }
17449
17450 dlg.finished(false);
17451
17452 return Err(match error {
17453 Ok(value) => common::Error::BadRequest(value),
17454 _ => common::Error::Failure(response),
17455 });
17456 }
17457 let response = {
17458 let bytes = common::to_bytes(body).await.unwrap_or_default();
17459 let encoded = common::to_string(&bytes);
17460 match serde_json::from_str(&encoded) {
17461 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17462 Err(error) => {
17463 dlg.response_json_decode_error(&encoded, &error);
17464 return Err(common::Error::JsonDecodeError(
17465 encoded.to_string(),
17466 error,
17467 ));
17468 }
17469 }
17470 };
17471
17472 dlg.finished(true);
17473 return Ok(response);
17474 }
17475 }
17476 }
17477 }
17478
17479 /// Required. The Uptime check configuration to delete. The format is: projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID]
17480 ///
17481 /// Sets the *name* path property to the given value.
17482 ///
17483 /// Even though the property as already been set when instantiating this call,
17484 /// we provide this method for API completeness.
17485 pub fn name(mut self, new_value: &str) -> ProjectUptimeCheckConfigDeleteCall<'a, C> {
17486 self._name = new_value.to_string();
17487 self
17488 }
17489 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17490 /// while executing the actual API request.
17491 ///
17492 /// ````text
17493 /// It should be used to handle progress information, and to implement a certain level of resilience.
17494 /// ````
17495 ///
17496 /// Sets the *delegate* property to the given value.
17497 pub fn delegate(
17498 mut self,
17499 new_value: &'a mut dyn common::Delegate,
17500 ) -> ProjectUptimeCheckConfigDeleteCall<'a, C> {
17501 self._delegate = Some(new_value);
17502 self
17503 }
17504
17505 /// Set any additional parameter of the query string used in the request.
17506 /// It should be used to set parameters which are not yet available through their own
17507 /// setters.
17508 ///
17509 /// Please note that this method must not be used to set any of the known parameters
17510 /// which have their own setter method. If done anyway, the request will fail.
17511 ///
17512 /// # Additional Parameters
17513 ///
17514 /// * *$.xgafv* (query-string) - V1 error format.
17515 /// * *access_token* (query-string) - OAuth access token.
17516 /// * *alt* (query-string) - Data format for response.
17517 /// * *callback* (query-string) - JSONP
17518 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17519 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17520 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17521 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17522 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17523 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17524 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17525 pub fn param<T>(mut self, name: T, value: T) -> ProjectUptimeCheckConfigDeleteCall<'a, C>
17526 where
17527 T: AsRef<str>,
17528 {
17529 self._additional_params
17530 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17531 self
17532 }
17533
17534 /// Identifies the authorization scope for the method you are building.
17535 ///
17536 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17537 /// [`Scope::CloudPlatform`].
17538 ///
17539 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17540 /// tokens for more than one scope.
17541 ///
17542 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17543 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17544 /// sufficient, a read-write scope will do as well.
17545 pub fn add_scope<St>(mut self, scope: St) -> ProjectUptimeCheckConfigDeleteCall<'a, C>
17546 where
17547 St: AsRef<str>,
17548 {
17549 self._scopes.insert(String::from(scope.as_ref()));
17550 self
17551 }
17552 /// Identifies the authorization scope(s) for the method you are building.
17553 ///
17554 /// See [`Self::add_scope()`] for details.
17555 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUptimeCheckConfigDeleteCall<'a, C>
17556 where
17557 I: IntoIterator<Item = St>,
17558 St: AsRef<str>,
17559 {
17560 self._scopes
17561 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17562 self
17563 }
17564
17565 /// Removes all scopes, and no default scope will be used either.
17566 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17567 /// for details).
17568 pub fn clear_scopes(mut self) -> ProjectUptimeCheckConfigDeleteCall<'a, C> {
17569 self._scopes.clear();
17570 self
17571 }
17572}
17573
17574/// Gets a single Uptime check configuration.
17575///
17576/// A builder for the *uptimeCheckConfigs.get* method supported by a *project* resource.
17577/// It is not used directly, but through a [`ProjectMethods`] instance.
17578///
17579/// # Example
17580///
17581/// Instantiate a resource method builder
17582///
17583/// ```test_harness,no_run
17584/// # extern crate hyper;
17585/// # extern crate hyper_rustls;
17586/// # extern crate google_monitoring3 as monitoring3;
17587/// # async fn dox() {
17588/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17589///
17590/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17591/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17592/// # secret,
17593/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17594/// # ).build().await.unwrap();
17595///
17596/// # let client = hyper_util::client::legacy::Client::builder(
17597/// # hyper_util::rt::TokioExecutor::new()
17598/// # )
17599/// # .build(
17600/// # hyper_rustls::HttpsConnectorBuilder::new()
17601/// # .with_native_roots()
17602/// # .unwrap()
17603/// # .https_or_http()
17604/// # .enable_http1()
17605/// # .build()
17606/// # );
17607/// # let mut hub = Monitoring::new(client, auth);
17608/// // You can configure optional parameters by calling the respective setters at will, and
17609/// // execute the final call using `doit()`.
17610/// // Values shown here are possibly random and not representative !
17611/// let result = hub.projects().uptime_check_configs_get("name")
17612/// .doit().await;
17613/// # }
17614/// ```
17615pub struct ProjectUptimeCheckConfigGetCall<'a, C>
17616where
17617 C: 'a,
17618{
17619 hub: &'a Monitoring<C>,
17620 _name: String,
17621 _delegate: Option<&'a mut dyn common::Delegate>,
17622 _additional_params: HashMap<String, String>,
17623 _scopes: BTreeSet<String>,
17624}
17625
17626impl<'a, C> common::CallBuilder for ProjectUptimeCheckConfigGetCall<'a, C> {}
17627
17628impl<'a, C> ProjectUptimeCheckConfigGetCall<'a, C>
17629where
17630 C: common::Connector,
17631{
17632 /// Perform the operation you have build so far.
17633 pub async fn doit(mut self) -> common::Result<(common::Response, UptimeCheckConfig)> {
17634 use std::borrow::Cow;
17635 use std::io::{Read, Seek};
17636
17637 use common::{url::Params, ToParts};
17638 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17639
17640 let mut dd = common::DefaultDelegate;
17641 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17642 dlg.begin(common::MethodInfo {
17643 id: "monitoring.projects.uptimeCheckConfigs.get",
17644 http_method: hyper::Method::GET,
17645 });
17646
17647 for &field in ["alt", "name"].iter() {
17648 if self._additional_params.contains_key(field) {
17649 dlg.finished(false);
17650 return Err(common::Error::FieldClash(field));
17651 }
17652 }
17653
17654 let mut params = Params::with_capacity(3 + self._additional_params.len());
17655 params.push("name", self._name);
17656
17657 params.extend(self._additional_params.iter());
17658
17659 params.push("alt", "json");
17660 let mut url = self.hub._base_url.clone() + "v3/{+name}";
17661 if self._scopes.is_empty() {
17662 self._scopes
17663 .insert(Scope::CloudPlatform.as_ref().to_string());
17664 }
17665
17666 #[allow(clippy::single_element_loop)]
17667 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17668 url = params.uri_replacement(url, param_name, find_this, true);
17669 }
17670 {
17671 let to_remove = ["name"];
17672 params.remove_params(&to_remove);
17673 }
17674
17675 let url = params.parse_with_url(&url);
17676
17677 loop {
17678 let token = match self
17679 .hub
17680 .auth
17681 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17682 .await
17683 {
17684 Ok(token) => token,
17685 Err(e) => match dlg.token(e) {
17686 Ok(token) => token,
17687 Err(e) => {
17688 dlg.finished(false);
17689 return Err(common::Error::MissingToken(e));
17690 }
17691 },
17692 };
17693 let mut req_result = {
17694 let client = &self.hub.client;
17695 dlg.pre_request();
17696 let mut req_builder = hyper::Request::builder()
17697 .method(hyper::Method::GET)
17698 .uri(url.as_str())
17699 .header(USER_AGENT, self.hub._user_agent.clone());
17700
17701 if let Some(token) = token.as_ref() {
17702 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17703 }
17704
17705 let request = req_builder
17706 .header(CONTENT_LENGTH, 0_u64)
17707 .body(common::to_body::<String>(None));
17708
17709 client.request(request.unwrap()).await
17710 };
17711
17712 match req_result {
17713 Err(err) => {
17714 if let common::Retry::After(d) = dlg.http_error(&err) {
17715 sleep(d).await;
17716 continue;
17717 }
17718 dlg.finished(false);
17719 return Err(common::Error::HttpError(err));
17720 }
17721 Ok(res) => {
17722 let (mut parts, body) = res.into_parts();
17723 let mut body = common::Body::new(body);
17724 if !parts.status.is_success() {
17725 let bytes = common::to_bytes(body).await.unwrap_or_default();
17726 let error = serde_json::from_str(&common::to_string(&bytes));
17727 let response = common::to_response(parts, bytes.into());
17728
17729 if let common::Retry::After(d) =
17730 dlg.http_failure(&response, error.as_ref().ok())
17731 {
17732 sleep(d).await;
17733 continue;
17734 }
17735
17736 dlg.finished(false);
17737
17738 return Err(match error {
17739 Ok(value) => common::Error::BadRequest(value),
17740 _ => common::Error::Failure(response),
17741 });
17742 }
17743 let response = {
17744 let bytes = common::to_bytes(body).await.unwrap_or_default();
17745 let encoded = common::to_string(&bytes);
17746 match serde_json::from_str(&encoded) {
17747 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17748 Err(error) => {
17749 dlg.response_json_decode_error(&encoded, &error);
17750 return Err(common::Error::JsonDecodeError(
17751 encoded.to_string(),
17752 error,
17753 ));
17754 }
17755 }
17756 };
17757
17758 dlg.finished(true);
17759 return Ok(response);
17760 }
17761 }
17762 }
17763 }
17764
17765 /// Required. The Uptime check configuration to retrieve. The format is: projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID]
17766 ///
17767 /// Sets the *name* path property to the given value.
17768 ///
17769 /// Even though the property as already been set when instantiating this call,
17770 /// we provide this method for API completeness.
17771 pub fn name(mut self, new_value: &str) -> ProjectUptimeCheckConfigGetCall<'a, C> {
17772 self._name = new_value.to_string();
17773 self
17774 }
17775 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17776 /// while executing the actual API request.
17777 ///
17778 /// ````text
17779 /// It should be used to handle progress information, and to implement a certain level of resilience.
17780 /// ````
17781 ///
17782 /// Sets the *delegate* property to the given value.
17783 pub fn delegate(
17784 mut self,
17785 new_value: &'a mut dyn common::Delegate,
17786 ) -> ProjectUptimeCheckConfigGetCall<'a, C> {
17787 self._delegate = Some(new_value);
17788 self
17789 }
17790
17791 /// Set any additional parameter of the query string used in the request.
17792 /// It should be used to set parameters which are not yet available through their own
17793 /// setters.
17794 ///
17795 /// Please note that this method must not be used to set any of the known parameters
17796 /// which have their own setter method. If done anyway, the request will fail.
17797 ///
17798 /// # Additional Parameters
17799 ///
17800 /// * *$.xgafv* (query-string) - V1 error format.
17801 /// * *access_token* (query-string) - OAuth access token.
17802 /// * *alt* (query-string) - Data format for response.
17803 /// * *callback* (query-string) - JSONP
17804 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17805 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17806 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17807 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17808 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17809 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17810 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17811 pub fn param<T>(mut self, name: T, value: T) -> ProjectUptimeCheckConfigGetCall<'a, C>
17812 where
17813 T: AsRef<str>,
17814 {
17815 self._additional_params
17816 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17817 self
17818 }
17819
17820 /// Identifies the authorization scope for the method you are building.
17821 ///
17822 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17823 /// [`Scope::CloudPlatform`].
17824 ///
17825 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17826 /// tokens for more than one scope.
17827 ///
17828 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17829 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17830 /// sufficient, a read-write scope will do as well.
17831 pub fn add_scope<St>(mut self, scope: St) -> ProjectUptimeCheckConfigGetCall<'a, C>
17832 where
17833 St: AsRef<str>,
17834 {
17835 self._scopes.insert(String::from(scope.as_ref()));
17836 self
17837 }
17838 /// Identifies the authorization scope(s) for the method you are building.
17839 ///
17840 /// See [`Self::add_scope()`] for details.
17841 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUptimeCheckConfigGetCall<'a, C>
17842 where
17843 I: IntoIterator<Item = St>,
17844 St: AsRef<str>,
17845 {
17846 self._scopes
17847 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17848 self
17849 }
17850
17851 /// Removes all scopes, and no default scope will be used either.
17852 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17853 /// for details).
17854 pub fn clear_scopes(mut self) -> ProjectUptimeCheckConfigGetCall<'a, C> {
17855 self._scopes.clear();
17856 self
17857 }
17858}
17859
17860/// Lists the existing valid Uptime check configurations for the project (leaving out any invalid configurations).
17861///
17862/// A builder for the *uptimeCheckConfigs.list* method supported by a *project* resource.
17863/// It is not used directly, but through a [`ProjectMethods`] instance.
17864///
17865/// # Example
17866///
17867/// Instantiate a resource method builder
17868///
17869/// ```test_harness,no_run
17870/// # extern crate hyper;
17871/// # extern crate hyper_rustls;
17872/// # extern crate google_monitoring3 as monitoring3;
17873/// # async fn dox() {
17874/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17875///
17876/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17877/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17878/// # secret,
17879/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17880/// # ).build().await.unwrap();
17881///
17882/// # let client = hyper_util::client::legacy::Client::builder(
17883/// # hyper_util::rt::TokioExecutor::new()
17884/// # )
17885/// # .build(
17886/// # hyper_rustls::HttpsConnectorBuilder::new()
17887/// # .with_native_roots()
17888/// # .unwrap()
17889/// # .https_or_http()
17890/// # .enable_http1()
17891/// # .build()
17892/// # );
17893/// # let mut hub = Monitoring::new(client, auth);
17894/// // You can configure optional parameters by calling the respective setters at will, and
17895/// // execute the final call using `doit()`.
17896/// // Values shown here are possibly random and not representative !
17897/// let result = hub.projects().uptime_check_configs_list("parent")
17898/// .page_token("et")
17899/// .page_size(-10)
17900/// .filter("consetetur")
17901/// .doit().await;
17902/// # }
17903/// ```
17904pub struct ProjectUptimeCheckConfigListCall<'a, C>
17905where
17906 C: 'a,
17907{
17908 hub: &'a Monitoring<C>,
17909 _parent: String,
17910 _page_token: Option<String>,
17911 _page_size: Option<i32>,
17912 _filter: Option<String>,
17913 _delegate: Option<&'a mut dyn common::Delegate>,
17914 _additional_params: HashMap<String, String>,
17915 _scopes: BTreeSet<String>,
17916}
17917
17918impl<'a, C> common::CallBuilder for ProjectUptimeCheckConfigListCall<'a, C> {}
17919
17920impl<'a, C> ProjectUptimeCheckConfigListCall<'a, C>
17921where
17922 C: common::Connector,
17923{
17924 /// Perform the operation you have build so far.
17925 pub async fn doit(
17926 mut self,
17927 ) -> common::Result<(common::Response, ListUptimeCheckConfigsResponse)> {
17928 use std::borrow::Cow;
17929 use std::io::{Read, Seek};
17930
17931 use common::{url::Params, ToParts};
17932 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17933
17934 let mut dd = common::DefaultDelegate;
17935 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17936 dlg.begin(common::MethodInfo {
17937 id: "monitoring.projects.uptimeCheckConfigs.list",
17938 http_method: hyper::Method::GET,
17939 });
17940
17941 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
17942 if self._additional_params.contains_key(field) {
17943 dlg.finished(false);
17944 return Err(common::Error::FieldClash(field));
17945 }
17946 }
17947
17948 let mut params = Params::with_capacity(6 + self._additional_params.len());
17949 params.push("parent", self._parent);
17950 if let Some(value) = self._page_token.as_ref() {
17951 params.push("pageToken", value);
17952 }
17953 if let Some(value) = self._page_size.as_ref() {
17954 params.push("pageSize", value.to_string());
17955 }
17956 if let Some(value) = self._filter.as_ref() {
17957 params.push("filter", value);
17958 }
17959
17960 params.extend(self._additional_params.iter());
17961
17962 params.push("alt", "json");
17963 let mut url = self.hub._base_url.clone() + "v3/{+parent}/uptimeCheckConfigs";
17964 if self._scopes.is_empty() {
17965 self._scopes
17966 .insert(Scope::CloudPlatform.as_ref().to_string());
17967 }
17968
17969 #[allow(clippy::single_element_loop)]
17970 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17971 url = params.uri_replacement(url, param_name, find_this, true);
17972 }
17973 {
17974 let to_remove = ["parent"];
17975 params.remove_params(&to_remove);
17976 }
17977
17978 let url = params.parse_with_url(&url);
17979
17980 loop {
17981 let token = match self
17982 .hub
17983 .auth
17984 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17985 .await
17986 {
17987 Ok(token) => token,
17988 Err(e) => match dlg.token(e) {
17989 Ok(token) => token,
17990 Err(e) => {
17991 dlg.finished(false);
17992 return Err(common::Error::MissingToken(e));
17993 }
17994 },
17995 };
17996 let mut req_result = {
17997 let client = &self.hub.client;
17998 dlg.pre_request();
17999 let mut req_builder = hyper::Request::builder()
18000 .method(hyper::Method::GET)
18001 .uri(url.as_str())
18002 .header(USER_AGENT, self.hub._user_agent.clone());
18003
18004 if let Some(token) = token.as_ref() {
18005 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18006 }
18007
18008 let request = req_builder
18009 .header(CONTENT_LENGTH, 0_u64)
18010 .body(common::to_body::<String>(None));
18011
18012 client.request(request.unwrap()).await
18013 };
18014
18015 match req_result {
18016 Err(err) => {
18017 if let common::Retry::After(d) = dlg.http_error(&err) {
18018 sleep(d).await;
18019 continue;
18020 }
18021 dlg.finished(false);
18022 return Err(common::Error::HttpError(err));
18023 }
18024 Ok(res) => {
18025 let (mut parts, body) = res.into_parts();
18026 let mut body = common::Body::new(body);
18027 if !parts.status.is_success() {
18028 let bytes = common::to_bytes(body).await.unwrap_or_default();
18029 let error = serde_json::from_str(&common::to_string(&bytes));
18030 let response = common::to_response(parts, bytes.into());
18031
18032 if let common::Retry::After(d) =
18033 dlg.http_failure(&response, error.as_ref().ok())
18034 {
18035 sleep(d).await;
18036 continue;
18037 }
18038
18039 dlg.finished(false);
18040
18041 return Err(match error {
18042 Ok(value) => common::Error::BadRequest(value),
18043 _ => common::Error::Failure(response),
18044 });
18045 }
18046 let response = {
18047 let bytes = common::to_bytes(body).await.unwrap_or_default();
18048 let encoded = common::to_string(&bytes);
18049 match serde_json::from_str(&encoded) {
18050 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18051 Err(error) => {
18052 dlg.response_json_decode_error(&encoded, &error);
18053 return Err(common::Error::JsonDecodeError(
18054 encoded.to_string(),
18055 error,
18056 ));
18057 }
18058 }
18059 };
18060
18061 dlg.finished(true);
18062 return Ok(response);
18063 }
18064 }
18065 }
18066 }
18067
18068 /// Required. The project (https://cloud.google.com/monitoring/api/v3#project_name) whose Uptime check configurations are listed. The format is: projects/[PROJECT_ID_OR_NUMBER]
18069 ///
18070 /// Sets the *parent* path property to the given value.
18071 ///
18072 /// Even though the property as already been set when instantiating this call,
18073 /// we provide this method for API completeness.
18074 pub fn parent(mut self, new_value: &str) -> ProjectUptimeCheckConfigListCall<'a, C> {
18075 self._parent = new_value.to_string();
18076 self
18077 }
18078 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return more results from the previous method call.
18079 ///
18080 /// Sets the *page token* query property to the given value.
18081 pub fn page_token(mut self, new_value: &str) -> ProjectUptimeCheckConfigListCall<'a, C> {
18082 self._page_token = Some(new_value.to_string());
18083 self
18084 }
18085 /// The maximum number of results to return in a single response. The server may further constrain the maximum number of results returned in a single page. If the page_size is <=0, the server will decide the number of results to be returned.
18086 ///
18087 /// Sets the *page size* query property to the given value.
18088 pub fn page_size(mut self, new_value: i32) -> ProjectUptimeCheckConfigListCall<'a, C> {
18089 self._page_size = Some(new_value);
18090 self
18091 }
18092 /// If provided, this field specifies the criteria that must be met by uptime checks to be included in the response.For more details, see Filtering syntax (https://cloud.google.com/monitoring/api/v3/sorting-and-filtering#filter_syntax).
18093 ///
18094 /// Sets the *filter* query property to the given value.
18095 pub fn filter(mut self, new_value: &str) -> ProjectUptimeCheckConfigListCall<'a, C> {
18096 self._filter = Some(new_value.to_string());
18097 self
18098 }
18099 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18100 /// while executing the actual API request.
18101 ///
18102 /// ````text
18103 /// It should be used to handle progress information, and to implement a certain level of resilience.
18104 /// ````
18105 ///
18106 /// Sets the *delegate* property to the given value.
18107 pub fn delegate(
18108 mut self,
18109 new_value: &'a mut dyn common::Delegate,
18110 ) -> ProjectUptimeCheckConfigListCall<'a, C> {
18111 self._delegate = Some(new_value);
18112 self
18113 }
18114
18115 /// Set any additional parameter of the query string used in the request.
18116 /// It should be used to set parameters which are not yet available through their own
18117 /// setters.
18118 ///
18119 /// Please note that this method must not be used to set any of the known parameters
18120 /// which have their own setter method. If done anyway, the request will fail.
18121 ///
18122 /// # Additional Parameters
18123 ///
18124 /// * *$.xgafv* (query-string) - V1 error format.
18125 /// * *access_token* (query-string) - OAuth access token.
18126 /// * *alt* (query-string) - Data format for response.
18127 /// * *callback* (query-string) - JSONP
18128 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18129 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18130 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18131 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18132 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18133 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18134 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18135 pub fn param<T>(mut self, name: T, value: T) -> ProjectUptimeCheckConfigListCall<'a, C>
18136 where
18137 T: AsRef<str>,
18138 {
18139 self._additional_params
18140 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18141 self
18142 }
18143
18144 /// Identifies the authorization scope for the method you are building.
18145 ///
18146 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18147 /// [`Scope::CloudPlatform`].
18148 ///
18149 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18150 /// tokens for more than one scope.
18151 ///
18152 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18153 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18154 /// sufficient, a read-write scope will do as well.
18155 pub fn add_scope<St>(mut self, scope: St) -> ProjectUptimeCheckConfigListCall<'a, C>
18156 where
18157 St: AsRef<str>,
18158 {
18159 self._scopes.insert(String::from(scope.as_ref()));
18160 self
18161 }
18162 /// Identifies the authorization scope(s) for the method you are building.
18163 ///
18164 /// See [`Self::add_scope()`] for details.
18165 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUptimeCheckConfigListCall<'a, C>
18166 where
18167 I: IntoIterator<Item = St>,
18168 St: AsRef<str>,
18169 {
18170 self._scopes
18171 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18172 self
18173 }
18174
18175 /// Removes all scopes, and no default scope will be used either.
18176 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18177 /// for details).
18178 pub fn clear_scopes(mut self) -> ProjectUptimeCheckConfigListCall<'a, C> {
18179 self._scopes.clear();
18180 self
18181 }
18182}
18183
18184/// Updates an Uptime check configuration. You can either replace the entire configuration with a new one or replace only certain fields in the current configuration by specifying the fields to be updated via updateMask. Returns the updated configuration.
18185///
18186/// A builder for the *uptimeCheckConfigs.patch* method supported by a *project* resource.
18187/// It is not used directly, but through a [`ProjectMethods`] instance.
18188///
18189/// # Example
18190///
18191/// Instantiate a resource method builder
18192///
18193/// ```test_harness,no_run
18194/// # extern crate hyper;
18195/// # extern crate hyper_rustls;
18196/// # extern crate google_monitoring3 as monitoring3;
18197/// use monitoring3::api::UptimeCheckConfig;
18198/// # async fn dox() {
18199/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18200///
18201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18202/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18203/// # secret,
18204/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18205/// # ).build().await.unwrap();
18206///
18207/// # let client = hyper_util::client::legacy::Client::builder(
18208/// # hyper_util::rt::TokioExecutor::new()
18209/// # )
18210/// # .build(
18211/// # hyper_rustls::HttpsConnectorBuilder::new()
18212/// # .with_native_roots()
18213/// # .unwrap()
18214/// # .https_or_http()
18215/// # .enable_http1()
18216/// # .build()
18217/// # );
18218/// # let mut hub = Monitoring::new(client, auth);
18219/// // As the method needs a request, you would usually fill it with the desired information
18220/// // into the respective structure. Some of the parts shown here might not be applicable !
18221/// // Values shown here are possibly random and not representative !
18222/// let mut req = UptimeCheckConfig::default();
18223///
18224/// // You can configure optional parameters by calling the respective setters at will, and
18225/// // execute the final call using `doit()`.
18226/// // Values shown here are possibly random and not representative !
18227/// let result = hub.projects().uptime_check_configs_patch(req, "name")
18228/// .update_mask(FieldMask::new::<&str>(&[]))
18229/// .doit().await;
18230/// # }
18231/// ```
18232pub struct ProjectUptimeCheckConfigPatchCall<'a, C>
18233where
18234 C: 'a,
18235{
18236 hub: &'a Monitoring<C>,
18237 _request: UptimeCheckConfig,
18238 _name: String,
18239 _update_mask: Option<common::FieldMask>,
18240 _delegate: Option<&'a mut dyn common::Delegate>,
18241 _additional_params: HashMap<String, String>,
18242 _scopes: BTreeSet<String>,
18243}
18244
18245impl<'a, C> common::CallBuilder for ProjectUptimeCheckConfigPatchCall<'a, C> {}
18246
18247impl<'a, C> ProjectUptimeCheckConfigPatchCall<'a, C>
18248where
18249 C: common::Connector,
18250{
18251 /// Perform the operation you have build so far.
18252 pub async fn doit(mut self) -> common::Result<(common::Response, UptimeCheckConfig)> {
18253 use std::borrow::Cow;
18254 use std::io::{Read, Seek};
18255
18256 use common::{url::Params, ToParts};
18257 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18258
18259 let mut dd = common::DefaultDelegate;
18260 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18261 dlg.begin(common::MethodInfo {
18262 id: "monitoring.projects.uptimeCheckConfigs.patch",
18263 http_method: hyper::Method::PATCH,
18264 });
18265
18266 for &field in ["alt", "name", "updateMask"].iter() {
18267 if self._additional_params.contains_key(field) {
18268 dlg.finished(false);
18269 return Err(common::Error::FieldClash(field));
18270 }
18271 }
18272
18273 let mut params = Params::with_capacity(5 + self._additional_params.len());
18274 params.push("name", self._name);
18275 if let Some(value) = self._update_mask.as_ref() {
18276 params.push("updateMask", value.to_string());
18277 }
18278
18279 params.extend(self._additional_params.iter());
18280
18281 params.push("alt", "json");
18282 let mut url = self.hub._base_url.clone() + "v3/{+name}";
18283 if self._scopes.is_empty() {
18284 self._scopes
18285 .insert(Scope::CloudPlatform.as_ref().to_string());
18286 }
18287
18288 #[allow(clippy::single_element_loop)]
18289 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18290 url = params.uri_replacement(url, param_name, find_this, true);
18291 }
18292 {
18293 let to_remove = ["name"];
18294 params.remove_params(&to_remove);
18295 }
18296
18297 let url = params.parse_with_url(&url);
18298
18299 let mut json_mime_type = mime::APPLICATION_JSON;
18300 let mut request_value_reader = {
18301 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18302 common::remove_json_null_values(&mut value);
18303 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18304 serde_json::to_writer(&mut dst, &value).unwrap();
18305 dst
18306 };
18307 let request_size = request_value_reader
18308 .seek(std::io::SeekFrom::End(0))
18309 .unwrap();
18310 request_value_reader
18311 .seek(std::io::SeekFrom::Start(0))
18312 .unwrap();
18313
18314 loop {
18315 let token = match self
18316 .hub
18317 .auth
18318 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18319 .await
18320 {
18321 Ok(token) => token,
18322 Err(e) => match dlg.token(e) {
18323 Ok(token) => token,
18324 Err(e) => {
18325 dlg.finished(false);
18326 return Err(common::Error::MissingToken(e));
18327 }
18328 },
18329 };
18330 request_value_reader
18331 .seek(std::io::SeekFrom::Start(0))
18332 .unwrap();
18333 let mut req_result = {
18334 let client = &self.hub.client;
18335 dlg.pre_request();
18336 let mut req_builder = hyper::Request::builder()
18337 .method(hyper::Method::PATCH)
18338 .uri(url.as_str())
18339 .header(USER_AGENT, self.hub._user_agent.clone());
18340
18341 if let Some(token) = token.as_ref() {
18342 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18343 }
18344
18345 let request = req_builder
18346 .header(CONTENT_TYPE, json_mime_type.to_string())
18347 .header(CONTENT_LENGTH, request_size as u64)
18348 .body(common::to_body(
18349 request_value_reader.get_ref().clone().into(),
18350 ));
18351
18352 client.request(request.unwrap()).await
18353 };
18354
18355 match req_result {
18356 Err(err) => {
18357 if let common::Retry::After(d) = dlg.http_error(&err) {
18358 sleep(d).await;
18359 continue;
18360 }
18361 dlg.finished(false);
18362 return Err(common::Error::HttpError(err));
18363 }
18364 Ok(res) => {
18365 let (mut parts, body) = res.into_parts();
18366 let mut body = common::Body::new(body);
18367 if !parts.status.is_success() {
18368 let bytes = common::to_bytes(body).await.unwrap_or_default();
18369 let error = serde_json::from_str(&common::to_string(&bytes));
18370 let response = common::to_response(parts, bytes.into());
18371
18372 if let common::Retry::After(d) =
18373 dlg.http_failure(&response, error.as_ref().ok())
18374 {
18375 sleep(d).await;
18376 continue;
18377 }
18378
18379 dlg.finished(false);
18380
18381 return Err(match error {
18382 Ok(value) => common::Error::BadRequest(value),
18383 _ => common::Error::Failure(response),
18384 });
18385 }
18386 let response = {
18387 let bytes = common::to_bytes(body).await.unwrap_or_default();
18388 let encoded = common::to_string(&bytes);
18389 match serde_json::from_str(&encoded) {
18390 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18391 Err(error) => {
18392 dlg.response_json_decode_error(&encoded, &error);
18393 return Err(common::Error::JsonDecodeError(
18394 encoded.to_string(),
18395 error,
18396 ));
18397 }
18398 }
18399 };
18400
18401 dlg.finished(true);
18402 return Ok(response);
18403 }
18404 }
18405 }
18406 }
18407
18408 ///
18409 /// Sets the *request* property to the given value.
18410 ///
18411 /// Even though the property as already been set when instantiating this call,
18412 /// we provide this method for API completeness.
18413 pub fn request(
18414 mut self,
18415 new_value: UptimeCheckConfig,
18416 ) -> ProjectUptimeCheckConfigPatchCall<'a, C> {
18417 self._request = new_value;
18418 self
18419 }
18420 /// Identifier. A unique resource name for this Uptime check configuration. The format is: projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] [PROJECT_ID_OR_NUMBER] is the Workspace host project associated with the Uptime check.This field should be omitted when creating the Uptime check configuration; on create, the resource name is assigned by the server and included in the response.
18421 ///
18422 /// Sets the *name* path property to the given value.
18423 ///
18424 /// Even though the property as already been set when instantiating this call,
18425 /// we provide this method for API completeness.
18426 pub fn name(mut self, new_value: &str) -> ProjectUptimeCheckConfigPatchCall<'a, C> {
18427 self._name = new_value.to_string();
18428 self
18429 }
18430 /// Optional. If present, only the listed fields in the current Uptime check configuration are updated with values from the new configuration. If this field is empty, then the current configuration is completely replaced with the new configuration.
18431 ///
18432 /// Sets the *update mask* query property to the given value.
18433 pub fn update_mask(
18434 mut self,
18435 new_value: common::FieldMask,
18436 ) -> ProjectUptimeCheckConfigPatchCall<'a, C> {
18437 self._update_mask = Some(new_value);
18438 self
18439 }
18440 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18441 /// while executing the actual API request.
18442 ///
18443 /// ````text
18444 /// It should be used to handle progress information, and to implement a certain level of resilience.
18445 /// ````
18446 ///
18447 /// Sets the *delegate* property to the given value.
18448 pub fn delegate(
18449 mut self,
18450 new_value: &'a mut dyn common::Delegate,
18451 ) -> ProjectUptimeCheckConfigPatchCall<'a, C> {
18452 self._delegate = Some(new_value);
18453 self
18454 }
18455
18456 /// Set any additional parameter of the query string used in the request.
18457 /// It should be used to set parameters which are not yet available through their own
18458 /// setters.
18459 ///
18460 /// Please note that this method must not be used to set any of the known parameters
18461 /// which have their own setter method. If done anyway, the request will fail.
18462 ///
18463 /// # Additional Parameters
18464 ///
18465 /// * *$.xgafv* (query-string) - V1 error format.
18466 /// * *access_token* (query-string) - OAuth access token.
18467 /// * *alt* (query-string) - Data format for response.
18468 /// * *callback* (query-string) - JSONP
18469 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18470 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18471 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18472 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18473 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18474 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18475 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18476 pub fn param<T>(mut self, name: T, value: T) -> ProjectUptimeCheckConfigPatchCall<'a, C>
18477 where
18478 T: AsRef<str>,
18479 {
18480 self._additional_params
18481 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18482 self
18483 }
18484
18485 /// Identifies the authorization scope for the method you are building.
18486 ///
18487 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18488 /// [`Scope::CloudPlatform`].
18489 ///
18490 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18491 /// tokens for more than one scope.
18492 ///
18493 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18494 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18495 /// sufficient, a read-write scope will do as well.
18496 pub fn add_scope<St>(mut self, scope: St) -> ProjectUptimeCheckConfigPatchCall<'a, C>
18497 where
18498 St: AsRef<str>,
18499 {
18500 self._scopes.insert(String::from(scope.as_ref()));
18501 self
18502 }
18503 /// Identifies the authorization scope(s) for the method you are building.
18504 ///
18505 /// See [`Self::add_scope()`] for details.
18506 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUptimeCheckConfigPatchCall<'a, C>
18507 where
18508 I: IntoIterator<Item = St>,
18509 St: AsRef<str>,
18510 {
18511 self._scopes
18512 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18513 self
18514 }
18515
18516 /// Removes all scopes, and no default scope will be used either.
18517 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18518 /// for details).
18519 pub fn clear_scopes(mut self) -> ProjectUptimeCheckConfigPatchCall<'a, C> {
18520 self._scopes.clear();
18521 self
18522 }
18523}
18524
18525/// Create a ServiceLevelObjective for the given Service.
18526///
18527/// A builder for the *serviceLevelObjectives.create* method supported by a *service* resource.
18528/// It is not used directly, but through a [`ServiceMethods`] instance.
18529///
18530/// # Example
18531///
18532/// Instantiate a resource method builder
18533///
18534/// ```test_harness,no_run
18535/// # extern crate hyper;
18536/// # extern crate hyper_rustls;
18537/// # extern crate google_monitoring3 as monitoring3;
18538/// use monitoring3::api::ServiceLevelObjective;
18539/// # async fn dox() {
18540/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18541///
18542/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18544/// # secret,
18545/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18546/// # ).build().await.unwrap();
18547///
18548/// # let client = hyper_util::client::legacy::Client::builder(
18549/// # hyper_util::rt::TokioExecutor::new()
18550/// # )
18551/// # .build(
18552/// # hyper_rustls::HttpsConnectorBuilder::new()
18553/// # .with_native_roots()
18554/// # .unwrap()
18555/// # .https_or_http()
18556/// # .enable_http1()
18557/// # .build()
18558/// # );
18559/// # let mut hub = Monitoring::new(client, auth);
18560/// // As the method needs a request, you would usually fill it with the desired information
18561/// // into the respective structure. Some of the parts shown here might not be applicable !
18562/// // Values shown here are possibly random and not representative !
18563/// let mut req = ServiceLevelObjective::default();
18564///
18565/// // You can configure optional parameters by calling the respective setters at will, and
18566/// // execute the final call using `doit()`.
18567/// // Values shown here are possibly random and not representative !
18568/// let result = hub.services().service_level_objectives_create(req, "parent")
18569/// .service_level_objective_id("est")
18570/// .doit().await;
18571/// # }
18572/// ```
18573pub struct ServiceServiceLevelObjectiveCreateCall<'a, C>
18574where
18575 C: 'a,
18576{
18577 hub: &'a Monitoring<C>,
18578 _request: ServiceLevelObjective,
18579 _parent: String,
18580 _service_level_objective_id: Option<String>,
18581 _delegate: Option<&'a mut dyn common::Delegate>,
18582 _additional_params: HashMap<String, String>,
18583 _scopes: BTreeSet<String>,
18584}
18585
18586impl<'a, C> common::CallBuilder for ServiceServiceLevelObjectiveCreateCall<'a, C> {}
18587
18588impl<'a, C> ServiceServiceLevelObjectiveCreateCall<'a, C>
18589where
18590 C: common::Connector,
18591{
18592 /// Perform the operation you have build so far.
18593 pub async fn doit(mut self) -> common::Result<(common::Response, ServiceLevelObjective)> {
18594 use std::borrow::Cow;
18595 use std::io::{Read, Seek};
18596
18597 use common::{url::Params, ToParts};
18598 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18599
18600 let mut dd = common::DefaultDelegate;
18601 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18602 dlg.begin(common::MethodInfo {
18603 id: "monitoring.services.serviceLevelObjectives.create",
18604 http_method: hyper::Method::POST,
18605 });
18606
18607 for &field in ["alt", "parent", "serviceLevelObjectiveId"].iter() {
18608 if self._additional_params.contains_key(field) {
18609 dlg.finished(false);
18610 return Err(common::Error::FieldClash(field));
18611 }
18612 }
18613
18614 let mut params = Params::with_capacity(5 + self._additional_params.len());
18615 params.push("parent", self._parent);
18616 if let Some(value) = self._service_level_objective_id.as_ref() {
18617 params.push("serviceLevelObjectiveId", value);
18618 }
18619
18620 params.extend(self._additional_params.iter());
18621
18622 params.push("alt", "json");
18623 let mut url = self.hub._base_url.clone() + "v3/{+parent}/serviceLevelObjectives";
18624 if self._scopes.is_empty() {
18625 self._scopes
18626 .insert(Scope::CloudPlatform.as_ref().to_string());
18627 }
18628
18629 #[allow(clippy::single_element_loop)]
18630 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18631 url = params.uri_replacement(url, param_name, find_this, true);
18632 }
18633 {
18634 let to_remove = ["parent"];
18635 params.remove_params(&to_remove);
18636 }
18637
18638 let url = params.parse_with_url(&url);
18639
18640 let mut json_mime_type = mime::APPLICATION_JSON;
18641 let mut request_value_reader = {
18642 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18643 common::remove_json_null_values(&mut value);
18644 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18645 serde_json::to_writer(&mut dst, &value).unwrap();
18646 dst
18647 };
18648 let request_size = request_value_reader
18649 .seek(std::io::SeekFrom::End(0))
18650 .unwrap();
18651 request_value_reader
18652 .seek(std::io::SeekFrom::Start(0))
18653 .unwrap();
18654
18655 loop {
18656 let token = match self
18657 .hub
18658 .auth
18659 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18660 .await
18661 {
18662 Ok(token) => token,
18663 Err(e) => match dlg.token(e) {
18664 Ok(token) => token,
18665 Err(e) => {
18666 dlg.finished(false);
18667 return Err(common::Error::MissingToken(e));
18668 }
18669 },
18670 };
18671 request_value_reader
18672 .seek(std::io::SeekFrom::Start(0))
18673 .unwrap();
18674 let mut req_result = {
18675 let client = &self.hub.client;
18676 dlg.pre_request();
18677 let mut req_builder = hyper::Request::builder()
18678 .method(hyper::Method::POST)
18679 .uri(url.as_str())
18680 .header(USER_AGENT, self.hub._user_agent.clone());
18681
18682 if let Some(token) = token.as_ref() {
18683 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18684 }
18685
18686 let request = req_builder
18687 .header(CONTENT_TYPE, json_mime_type.to_string())
18688 .header(CONTENT_LENGTH, request_size as u64)
18689 .body(common::to_body(
18690 request_value_reader.get_ref().clone().into(),
18691 ));
18692
18693 client.request(request.unwrap()).await
18694 };
18695
18696 match req_result {
18697 Err(err) => {
18698 if let common::Retry::After(d) = dlg.http_error(&err) {
18699 sleep(d).await;
18700 continue;
18701 }
18702 dlg.finished(false);
18703 return Err(common::Error::HttpError(err));
18704 }
18705 Ok(res) => {
18706 let (mut parts, body) = res.into_parts();
18707 let mut body = common::Body::new(body);
18708 if !parts.status.is_success() {
18709 let bytes = common::to_bytes(body).await.unwrap_or_default();
18710 let error = serde_json::from_str(&common::to_string(&bytes));
18711 let response = common::to_response(parts, bytes.into());
18712
18713 if let common::Retry::After(d) =
18714 dlg.http_failure(&response, error.as_ref().ok())
18715 {
18716 sleep(d).await;
18717 continue;
18718 }
18719
18720 dlg.finished(false);
18721
18722 return Err(match error {
18723 Ok(value) => common::Error::BadRequest(value),
18724 _ => common::Error::Failure(response),
18725 });
18726 }
18727 let response = {
18728 let bytes = common::to_bytes(body).await.unwrap_or_default();
18729 let encoded = common::to_string(&bytes);
18730 match serde_json::from_str(&encoded) {
18731 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18732 Err(error) => {
18733 dlg.response_json_decode_error(&encoded, &error);
18734 return Err(common::Error::JsonDecodeError(
18735 encoded.to_string(),
18736 error,
18737 ));
18738 }
18739 }
18740 };
18741
18742 dlg.finished(true);
18743 return Ok(response);
18744 }
18745 }
18746 }
18747 }
18748
18749 ///
18750 /// Sets the *request* property to the given value.
18751 ///
18752 /// Even though the property as already been set when instantiating this call,
18753 /// we provide this method for API completeness.
18754 pub fn request(
18755 mut self,
18756 new_value: ServiceLevelObjective,
18757 ) -> ServiceServiceLevelObjectiveCreateCall<'a, C> {
18758 self._request = new_value;
18759 self
18760 }
18761 /// Required. Resource name of the parent Service. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
18762 ///
18763 /// Sets the *parent* path property to the given value.
18764 ///
18765 /// Even though the property as already been set when instantiating this call,
18766 /// we provide this method for API completeness.
18767 pub fn parent(mut self, new_value: &str) -> ServiceServiceLevelObjectiveCreateCall<'a, C> {
18768 self._parent = new_value.to_string();
18769 self
18770 }
18771 /// Optional. The ServiceLevelObjective id to use for this ServiceLevelObjective. If omitted, an id will be generated instead. Must match the pattern ^[a-zA-Z0-9-_:.]+$
18772 ///
18773 /// Sets the *service level objective id* query property to the given value.
18774 pub fn service_level_objective_id(
18775 mut self,
18776 new_value: &str,
18777 ) -> ServiceServiceLevelObjectiveCreateCall<'a, C> {
18778 self._service_level_objective_id = Some(new_value.to_string());
18779 self
18780 }
18781 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18782 /// while executing the actual API request.
18783 ///
18784 /// ````text
18785 /// It should be used to handle progress information, and to implement a certain level of resilience.
18786 /// ````
18787 ///
18788 /// Sets the *delegate* property to the given value.
18789 pub fn delegate(
18790 mut self,
18791 new_value: &'a mut dyn common::Delegate,
18792 ) -> ServiceServiceLevelObjectiveCreateCall<'a, C> {
18793 self._delegate = Some(new_value);
18794 self
18795 }
18796
18797 /// Set any additional parameter of the query string used in the request.
18798 /// It should be used to set parameters which are not yet available through their own
18799 /// setters.
18800 ///
18801 /// Please note that this method must not be used to set any of the known parameters
18802 /// which have their own setter method. If done anyway, the request will fail.
18803 ///
18804 /// # Additional Parameters
18805 ///
18806 /// * *$.xgafv* (query-string) - V1 error format.
18807 /// * *access_token* (query-string) - OAuth access token.
18808 /// * *alt* (query-string) - Data format for response.
18809 /// * *callback* (query-string) - JSONP
18810 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18811 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18812 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18813 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18814 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18815 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18816 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18817 pub fn param<T>(mut self, name: T, value: T) -> ServiceServiceLevelObjectiveCreateCall<'a, C>
18818 where
18819 T: AsRef<str>,
18820 {
18821 self._additional_params
18822 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18823 self
18824 }
18825
18826 /// Identifies the authorization scope for the method you are building.
18827 ///
18828 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18829 /// [`Scope::CloudPlatform`].
18830 ///
18831 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18832 /// tokens for more than one scope.
18833 ///
18834 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18835 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18836 /// sufficient, a read-write scope will do as well.
18837 pub fn add_scope<St>(mut self, scope: St) -> ServiceServiceLevelObjectiveCreateCall<'a, C>
18838 where
18839 St: AsRef<str>,
18840 {
18841 self._scopes.insert(String::from(scope.as_ref()));
18842 self
18843 }
18844 /// Identifies the authorization scope(s) for the method you are building.
18845 ///
18846 /// See [`Self::add_scope()`] for details.
18847 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceServiceLevelObjectiveCreateCall<'a, C>
18848 where
18849 I: IntoIterator<Item = St>,
18850 St: AsRef<str>,
18851 {
18852 self._scopes
18853 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18854 self
18855 }
18856
18857 /// Removes all scopes, and no default scope will be used either.
18858 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18859 /// for details).
18860 pub fn clear_scopes(mut self) -> ServiceServiceLevelObjectiveCreateCall<'a, C> {
18861 self._scopes.clear();
18862 self
18863 }
18864}
18865
18866/// Delete the given ServiceLevelObjective.
18867///
18868/// A builder for the *serviceLevelObjectives.delete* method supported by a *service* resource.
18869/// It is not used directly, but through a [`ServiceMethods`] instance.
18870///
18871/// # Example
18872///
18873/// Instantiate a resource method builder
18874///
18875/// ```test_harness,no_run
18876/// # extern crate hyper;
18877/// # extern crate hyper_rustls;
18878/// # extern crate google_monitoring3 as monitoring3;
18879/// # async fn dox() {
18880/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18881///
18882/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18883/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18884/// # secret,
18885/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18886/// # ).build().await.unwrap();
18887///
18888/// # let client = hyper_util::client::legacy::Client::builder(
18889/// # hyper_util::rt::TokioExecutor::new()
18890/// # )
18891/// # .build(
18892/// # hyper_rustls::HttpsConnectorBuilder::new()
18893/// # .with_native_roots()
18894/// # .unwrap()
18895/// # .https_or_http()
18896/// # .enable_http1()
18897/// # .build()
18898/// # );
18899/// # let mut hub = Monitoring::new(client, auth);
18900/// // You can configure optional parameters by calling the respective setters at will, and
18901/// // execute the final call using `doit()`.
18902/// // Values shown here are possibly random and not representative !
18903/// let result = hub.services().service_level_objectives_delete("name")
18904/// .doit().await;
18905/// # }
18906/// ```
18907pub struct ServiceServiceLevelObjectiveDeleteCall<'a, C>
18908where
18909 C: 'a,
18910{
18911 hub: &'a Monitoring<C>,
18912 _name: String,
18913 _delegate: Option<&'a mut dyn common::Delegate>,
18914 _additional_params: HashMap<String, String>,
18915 _scopes: BTreeSet<String>,
18916}
18917
18918impl<'a, C> common::CallBuilder for ServiceServiceLevelObjectiveDeleteCall<'a, C> {}
18919
18920impl<'a, C> ServiceServiceLevelObjectiveDeleteCall<'a, C>
18921where
18922 C: common::Connector,
18923{
18924 /// Perform the operation you have build so far.
18925 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
18926 use std::borrow::Cow;
18927 use std::io::{Read, Seek};
18928
18929 use common::{url::Params, ToParts};
18930 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18931
18932 let mut dd = common::DefaultDelegate;
18933 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18934 dlg.begin(common::MethodInfo {
18935 id: "monitoring.services.serviceLevelObjectives.delete",
18936 http_method: hyper::Method::DELETE,
18937 });
18938
18939 for &field in ["alt", "name"].iter() {
18940 if self._additional_params.contains_key(field) {
18941 dlg.finished(false);
18942 return Err(common::Error::FieldClash(field));
18943 }
18944 }
18945
18946 let mut params = Params::with_capacity(3 + self._additional_params.len());
18947 params.push("name", self._name);
18948
18949 params.extend(self._additional_params.iter());
18950
18951 params.push("alt", "json");
18952 let mut url = self.hub._base_url.clone() + "v3/{+name}";
18953 if self._scopes.is_empty() {
18954 self._scopes
18955 .insert(Scope::CloudPlatform.as_ref().to_string());
18956 }
18957
18958 #[allow(clippy::single_element_loop)]
18959 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18960 url = params.uri_replacement(url, param_name, find_this, true);
18961 }
18962 {
18963 let to_remove = ["name"];
18964 params.remove_params(&to_remove);
18965 }
18966
18967 let url = params.parse_with_url(&url);
18968
18969 loop {
18970 let token = match self
18971 .hub
18972 .auth
18973 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18974 .await
18975 {
18976 Ok(token) => token,
18977 Err(e) => match dlg.token(e) {
18978 Ok(token) => token,
18979 Err(e) => {
18980 dlg.finished(false);
18981 return Err(common::Error::MissingToken(e));
18982 }
18983 },
18984 };
18985 let mut req_result = {
18986 let client = &self.hub.client;
18987 dlg.pre_request();
18988 let mut req_builder = hyper::Request::builder()
18989 .method(hyper::Method::DELETE)
18990 .uri(url.as_str())
18991 .header(USER_AGENT, self.hub._user_agent.clone());
18992
18993 if let Some(token) = token.as_ref() {
18994 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18995 }
18996
18997 let request = req_builder
18998 .header(CONTENT_LENGTH, 0_u64)
18999 .body(common::to_body::<String>(None));
19000
19001 client.request(request.unwrap()).await
19002 };
19003
19004 match req_result {
19005 Err(err) => {
19006 if let common::Retry::After(d) = dlg.http_error(&err) {
19007 sleep(d).await;
19008 continue;
19009 }
19010 dlg.finished(false);
19011 return Err(common::Error::HttpError(err));
19012 }
19013 Ok(res) => {
19014 let (mut parts, body) = res.into_parts();
19015 let mut body = common::Body::new(body);
19016 if !parts.status.is_success() {
19017 let bytes = common::to_bytes(body).await.unwrap_or_default();
19018 let error = serde_json::from_str(&common::to_string(&bytes));
19019 let response = common::to_response(parts, bytes.into());
19020
19021 if let common::Retry::After(d) =
19022 dlg.http_failure(&response, error.as_ref().ok())
19023 {
19024 sleep(d).await;
19025 continue;
19026 }
19027
19028 dlg.finished(false);
19029
19030 return Err(match error {
19031 Ok(value) => common::Error::BadRequest(value),
19032 _ => common::Error::Failure(response),
19033 });
19034 }
19035 let response = {
19036 let bytes = common::to_bytes(body).await.unwrap_or_default();
19037 let encoded = common::to_string(&bytes);
19038 match serde_json::from_str(&encoded) {
19039 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19040 Err(error) => {
19041 dlg.response_json_decode_error(&encoded, &error);
19042 return Err(common::Error::JsonDecodeError(
19043 encoded.to_string(),
19044 error,
19045 ));
19046 }
19047 }
19048 };
19049
19050 dlg.finished(true);
19051 return Ok(response);
19052 }
19053 }
19054 }
19055 }
19056
19057 /// Required. Resource name of the ServiceLevelObjective to delete. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
19058 ///
19059 /// Sets the *name* path property to the given value.
19060 ///
19061 /// Even though the property as already been set when instantiating this call,
19062 /// we provide this method for API completeness.
19063 pub fn name(mut self, new_value: &str) -> ServiceServiceLevelObjectiveDeleteCall<'a, C> {
19064 self._name = new_value.to_string();
19065 self
19066 }
19067 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19068 /// while executing the actual API request.
19069 ///
19070 /// ````text
19071 /// It should be used to handle progress information, and to implement a certain level of resilience.
19072 /// ````
19073 ///
19074 /// Sets the *delegate* property to the given value.
19075 pub fn delegate(
19076 mut self,
19077 new_value: &'a mut dyn common::Delegate,
19078 ) -> ServiceServiceLevelObjectiveDeleteCall<'a, C> {
19079 self._delegate = Some(new_value);
19080 self
19081 }
19082
19083 /// Set any additional parameter of the query string used in the request.
19084 /// It should be used to set parameters which are not yet available through their own
19085 /// setters.
19086 ///
19087 /// Please note that this method must not be used to set any of the known parameters
19088 /// which have their own setter method. If done anyway, the request will fail.
19089 ///
19090 /// # Additional Parameters
19091 ///
19092 /// * *$.xgafv* (query-string) - V1 error format.
19093 /// * *access_token* (query-string) - OAuth access token.
19094 /// * *alt* (query-string) - Data format for response.
19095 /// * *callback* (query-string) - JSONP
19096 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19097 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19098 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19099 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19100 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19101 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19102 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19103 pub fn param<T>(mut self, name: T, value: T) -> ServiceServiceLevelObjectiveDeleteCall<'a, C>
19104 where
19105 T: AsRef<str>,
19106 {
19107 self._additional_params
19108 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19109 self
19110 }
19111
19112 /// Identifies the authorization scope for the method you are building.
19113 ///
19114 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19115 /// [`Scope::CloudPlatform`].
19116 ///
19117 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19118 /// tokens for more than one scope.
19119 ///
19120 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19121 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19122 /// sufficient, a read-write scope will do as well.
19123 pub fn add_scope<St>(mut self, scope: St) -> ServiceServiceLevelObjectiveDeleteCall<'a, C>
19124 where
19125 St: AsRef<str>,
19126 {
19127 self._scopes.insert(String::from(scope.as_ref()));
19128 self
19129 }
19130 /// Identifies the authorization scope(s) for the method you are building.
19131 ///
19132 /// See [`Self::add_scope()`] for details.
19133 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceServiceLevelObjectiveDeleteCall<'a, C>
19134 where
19135 I: IntoIterator<Item = St>,
19136 St: AsRef<str>,
19137 {
19138 self._scopes
19139 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19140 self
19141 }
19142
19143 /// Removes all scopes, and no default scope will be used either.
19144 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19145 /// for details).
19146 pub fn clear_scopes(mut self) -> ServiceServiceLevelObjectiveDeleteCall<'a, C> {
19147 self._scopes.clear();
19148 self
19149 }
19150}
19151
19152/// Get a ServiceLevelObjective by name.
19153///
19154/// A builder for the *serviceLevelObjectives.get* method supported by a *service* resource.
19155/// It is not used directly, but through a [`ServiceMethods`] instance.
19156///
19157/// # Example
19158///
19159/// Instantiate a resource method builder
19160///
19161/// ```test_harness,no_run
19162/// # extern crate hyper;
19163/// # extern crate hyper_rustls;
19164/// # extern crate google_monitoring3 as monitoring3;
19165/// # async fn dox() {
19166/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19167///
19168/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19169/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19170/// # secret,
19171/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19172/// # ).build().await.unwrap();
19173///
19174/// # let client = hyper_util::client::legacy::Client::builder(
19175/// # hyper_util::rt::TokioExecutor::new()
19176/// # )
19177/// # .build(
19178/// # hyper_rustls::HttpsConnectorBuilder::new()
19179/// # .with_native_roots()
19180/// # .unwrap()
19181/// # .https_or_http()
19182/// # .enable_http1()
19183/// # .build()
19184/// # );
19185/// # let mut hub = Monitoring::new(client, auth);
19186/// // You can configure optional parameters by calling the respective setters at will, and
19187/// // execute the final call using `doit()`.
19188/// // Values shown here are possibly random and not representative !
19189/// let result = hub.services().service_level_objectives_get("name")
19190/// .view("duo")
19191/// .doit().await;
19192/// # }
19193/// ```
19194pub struct ServiceServiceLevelObjectiveGetCall<'a, C>
19195where
19196 C: 'a,
19197{
19198 hub: &'a Monitoring<C>,
19199 _name: String,
19200 _view: Option<String>,
19201 _delegate: Option<&'a mut dyn common::Delegate>,
19202 _additional_params: HashMap<String, String>,
19203 _scopes: BTreeSet<String>,
19204}
19205
19206impl<'a, C> common::CallBuilder for ServiceServiceLevelObjectiveGetCall<'a, C> {}
19207
19208impl<'a, C> ServiceServiceLevelObjectiveGetCall<'a, C>
19209where
19210 C: common::Connector,
19211{
19212 /// Perform the operation you have build so far.
19213 pub async fn doit(mut self) -> common::Result<(common::Response, ServiceLevelObjective)> {
19214 use std::borrow::Cow;
19215 use std::io::{Read, Seek};
19216
19217 use common::{url::Params, ToParts};
19218 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19219
19220 let mut dd = common::DefaultDelegate;
19221 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19222 dlg.begin(common::MethodInfo {
19223 id: "monitoring.services.serviceLevelObjectives.get",
19224 http_method: hyper::Method::GET,
19225 });
19226
19227 for &field in ["alt", "name", "view"].iter() {
19228 if self._additional_params.contains_key(field) {
19229 dlg.finished(false);
19230 return Err(common::Error::FieldClash(field));
19231 }
19232 }
19233
19234 let mut params = Params::with_capacity(4 + self._additional_params.len());
19235 params.push("name", self._name);
19236 if let Some(value) = self._view.as_ref() {
19237 params.push("view", value);
19238 }
19239
19240 params.extend(self._additional_params.iter());
19241
19242 params.push("alt", "json");
19243 let mut url = self.hub._base_url.clone() + "v3/{+name}";
19244 if self._scopes.is_empty() {
19245 self._scopes
19246 .insert(Scope::CloudPlatform.as_ref().to_string());
19247 }
19248
19249 #[allow(clippy::single_element_loop)]
19250 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19251 url = params.uri_replacement(url, param_name, find_this, true);
19252 }
19253 {
19254 let to_remove = ["name"];
19255 params.remove_params(&to_remove);
19256 }
19257
19258 let url = params.parse_with_url(&url);
19259
19260 loop {
19261 let token = match self
19262 .hub
19263 .auth
19264 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19265 .await
19266 {
19267 Ok(token) => token,
19268 Err(e) => match dlg.token(e) {
19269 Ok(token) => token,
19270 Err(e) => {
19271 dlg.finished(false);
19272 return Err(common::Error::MissingToken(e));
19273 }
19274 },
19275 };
19276 let mut req_result = {
19277 let client = &self.hub.client;
19278 dlg.pre_request();
19279 let mut req_builder = hyper::Request::builder()
19280 .method(hyper::Method::GET)
19281 .uri(url.as_str())
19282 .header(USER_AGENT, self.hub._user_agent.clone());
19283
19284 if let Some(token) = token.as_ref() {
19285 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19286 }
19287
19288 let request = req_builder
19289 .header(CONTENT_LENGTH, 0_u64)
19290 .body(common::to_body::<String>(None));
19291
19292 client.request(request.unwrap()).await
19293 };
19294
19295 match req_result {
19296 Err(err) => {
19297 if let common::Retry::After(d) = dlg.http_error(&err) {
19298 sleep(d).await;
19299 continue;
19300 }
19301 dlg.finished(false);
19302 return Err(common::Error::HttpError(err));
19303 }
19304 Ok(res) => {
19305 let (mut parts, body) = res.into_parts();
19306 let mut body = common::Body::new(body);
19307 if !parts.status.is_success() {
19308 let bytes = common::to_bytes(body).await.unwrap_or_default();
19309 let error = serde_json::from_str(&common::to_string(&bytes));
19310 let response = common::to_response(parts, bytes.into());
19311
19312 if let common::Retry::After(d) =
19313 dlg.http_failure(&response, error.as_ref().ok())
19314 {
19315 sleep(d).await;
19316 continue;
19317 }
19318
19319 dlg.finished(false);
19320
19321 return Err(match error {
19322 Ok(value) => common::Error::BadRequest(value),
19323 _ => common::Error::Failure(response),
19324 });
19325 }
19326 let response = {
19327 let bytes = common::to_bytes(body).await.unwrap_or_default();
19328 let encoded = common::to_string(&bytes);
19329 match serde_json::from_str(&encoded) {
19330 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19331 Err(error) => {
19332 dlg.response_json_decode_error(&encoded, &error);
19333 return Err(common::Error::JsonDecodeError(
19334 encoded.to_string(),
19335 error,
19336 ));
19337 }
19338 }
19339 };
19340
19341 dlg.finished(true);
19342 return Ok(response);
19343 }
19344 }
19345 }
19346 }
19347
19348 /// Required. Resource name of the ServiceLevelObjective to get. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
19349 ///
19350 /// Sets the *name* path property to the given value.
19351 ///
19352 /// Even though the property as already been set when instantiating this call,
19353 /// we provide this method for API completeness.
19354 pub fn name(mut self, new_value: &str) -> ServiceServiceLevelObjectiveGetCall<'a, C> {
19355 self._name = new_value.to_string();
19356 self
19357 }
19358 /// View of the ServiceLevelObjective to return. If DEFAULT, return the ServiceLevelObjective as originally defined. If EXPLICIT and the ServiceLevelObjective is defined in terms of a BasicSli, replace the BasicSli with a RequestBasedSli spelling out how the SLI is computed.
19359 ///
19360 /// Sets the *view* query property to the given value.
19361 pub fn view(mut self, new_value: &str) -> ServiceServiceLevelObjectiveGetCall<'a, C> {
19362 self._view = Some(new_value.to_string());
19363 self
19364 }
19365 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19366 /// while executing the actual API request.
19367 ///
19368 /// ````text
19369 /// It should be used to handle progress information, and to implement a certain level of resilience.
19370 /// ````
19371 ///
19372 /// Sets the *delegate* property to the given value.
19373 pub fn delegate(
19374 mut self,
19375 new_value: &'a mut dyn common::Delegate,
19376 ) -> ServiceServiceLevelObjectiveGetCall<'a, C> {
19377 self._delegate = Some(new_value);
19378 self
19379 }
19380
19381 /// Set any additional parameter of the query string used in the request.
19382 /// It should be used to set parameters which are not yet available through their own
19383 /// setters.
19384 ///
19385 /// Please note that this method must not be used to set any of the known parameters
19386 /// which have their own setter method. If done anyway, the request will fail.
19387 ///
19388 /// # Additional Parameters
19389 ///
19390 /// * *$.xgafv* (query-string) - V1 error format.
19391 /// * *access_token* (query-string) - OAuth access token.
19392 /// * *alt* (query-string) - Data format for response.
19393 /// * *callback* (query-string) - JSONP
19394 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19395 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19396 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19397 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19398 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19399 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19400 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19401 pub fn param<T>(mut self, name: T, value: T) -> ServiceServiceLevelObjectiveGetCall<'a, C>
19402 where
19403 T: AsRef<str>,
19404 {
19405 self._additional_params
19406 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19407 self
19408 }
19409
19410 /// Identifies the authorization scope for the method you are building.
19411 ///
19412 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19413 /// [`Scope::CloudPlatform`].
19414 ///
19415 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19416 /// tokens for more than one scope.
19417 ///
19418 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19419 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19420 /// sufficient, a read-write scope will do as well.
19421 pub fn add_scope<St>(mut self, scope: St) -> ServiceServiceLevelObjectiveGetCall<'a, C>
19422 where
19423 St: AsRef<str>,
19424 {
19425 self._scopes.insert(String::from(scope.as_ref()));
19426 self
19427 }
19428 /// Identifies the authorization scope(s) for the method you are building.
19429 ///
19430 /// See [`Self::add_scope()`] for details.
19431 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceServiceLevelObjectiveGetCall<'a, C>
19432 where
19433 I: IntoIterator<Item = St>,
19434 St: AsRef<str>,
19435 {
19436 self._scopes
19437 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19438 self
19439 }
19440
19441 /// Removes all scopes, and no default scope will be used either.
19442 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19443 /// for details).
19444 pub fn clear_scopes(mut self) -> ServiceServiceLevelObjectiveGetCall<'a, C> {
19445 self._scopes.clear();
19446 self
19447 }
19448}
19449
19450/// List the ServiceLevelObjectives for the given Service.
19451///
19452/// A builder for the *serviceLevelObjectives.list* method supported by a *service* resource.
19453/// It is not used directly, but through a [`ServiceMethods`] instance.
19454///
19455/// # Example
19456///
19457/// Instantiate a resource method builder
19458///
19459/// ```test_harness,no_run
19460/// # extern crate hyper;
19461/// # extern crate hyper_rustls;
19462/// # extern crate google_monitoring3 as monitoring3;
19463/// # async fn dox() {
19464/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19465///
19466/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19467/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19468/// # secret,
19469/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19470/// # ).build().await.unwrap();
19471///
19472/// # let client = hyper_util::client::legacy::Client::builder(
19473/// # hyper_util::rt::TokioExecutor::new()
19474/// # )
19475/// # .build(
19476/// # hyper_rustls::HttpsConnectorBuilder::new()
19477/// # .with_native_roots()
19478/// # .unwrap()
19479/// # .https_or_http()
19480/// # .enable_http1()
19481/// # .build()
19482/// # );
19483/// # let mut hub = Monitoring::new(client, auth);
19484/// // You can configure optional parameters by calling the respective setters at will, and
19485/// // execute the final call using `doit()`.
19486/// // Values shown here are possibly random and not representative !
19487/// let result = hub.services().service_level_objectives_list("parent")
19488/// .view("est")
19489/// .page_token("sit")
19490/// .page_size(-93)
19491/// .filter("eos")
19492/// .doit().await;
19493/// # }
19494/// ```
19495pub struct ServiceServiceLevelObjectiveListCall<'a, C>
19496where
19497 C: 'a,
19498{
19499 hub: &'a Monitoring<C>,
19500 _parent: String,
19501 _view: Option<String>,
19502 _page_token: Option<String>,
19503 _page_size: Option<i32>,
19504 _filter: Option<String>,
19505 _delegate: Option<&'a mut dyn common::Delegate>,
19506 _additional_params: HashMap<String, String>,
19507 _scopes: BTreeSet<String>,
19508}
19509
19510impl<'a, C> common::CallBuilder for ServiceServiceLevelObjectiveListCall<'a, C> {}
19511
19512impl<'a, C> ServiceServiceLevelObjectiveListCall<'a, C>
19513where
19514 C: common::Connector,
19515{
19516 /// Perform the operation you have build so far.
19517 pub async fn doit(
19518 mut self,
19519 ) -> common::Result<(common::Response, ListServiceLevelObjectivesResponse)> {
19520 use std::borrow::Cow;
19521 use std::io::{Read, Seek};
19522
19523 use common::{url::Params, ToParts};
19524 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19525
19526 let mut dd = common::DefaultDelegate;
19527 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19528 dlg.begin(common::MethodInfo {
19529 id: "monitoring.services.serviceLevelObjectives.list",
19530 http_method: hyper::Method::GET,
19531 });
19532
19533 for &field in ["alt", "parent", "view", "pageToken", "pageSize", "filter"].iter() {
19534 if self._additional_params.contains_key(field) {
19535 dlg.finished(false);
19536 return Err(common::Error::FieldClash(field));
19537 }
19538 }
19539
19540 let mut params = Params::with_capacity(7 + self._additional_params.len());
19541 params.push("parent", self._parent);
19542 if let Some(value) = self._view.as_ref() {
19543 params.push("view", value);
19544 }
19545 if let Some(value) = self._page_token.as_ref() {
19546 params.push("pageToken", value);
19547 }
19548 if let Some(value) = self._page_size.as_ref() {
19549 params.push("pageSize", value.to_string());
19550 }
19551 if let Some(value) = self._filter.as_ref() {
19552 params.push("filter", value);
19553 }
19554
19555 params.extend(self._additional_params.iter());
19556
19557 params.push("alt", "json");
19558 let mut url = self.hub._base_url.clone() + "v3/{+parent}/serviceLevelObjectives";
19559 if self._scopes.is_empty() {
19560 self._scopes
19561 .insert(Scope::CloudPlatform.as_ref().to_string());
19562 }
19563
19564 #[allow(clippy::single_element_loop)]
19565 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19566 url = params.uri_replacement(url, param_name, find_this, true);
19567 }
19568 {
19569 let to_remove = ["parent"];
19570 params.remove_params(&to_remove);
19571 }
19572
19573 let url = params.parse_with_url(&url);
19574
19575 loop {
19576 let token = match self
19577 .hub
19578 .auth
19579 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19580 .await
19581 {
19582 Ok(token) => token,
19583 Err(e) => match dlg.token(e) {
19584 Ok(token) => token,
19585 Err(e) => {
19586 dlg.finished(false);
19587 return Err(common::Error::MissingToken(e));
19588 }
19589 },
19590 };
19591 let mut req_result = {
19592 let client = &self.hub.client;
19593 dlg.pre_request();
19594 let mut req_builder = hyper::Request::builder()
19595 .method(hyper::Method::GET)
19596 .uri(url.as_str())
19597 .header(USER_AGENT, self.hub._user_agent.clone());
19598
19599 if let Some(token) = token.as_ref() {
19600 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19601 }
19602
19603 let request = req_builder
19604 .header(CONTENT_LENGTH, 0_u64)
19605 .body(common::to_body::<String>(None));
19606
19607 client.request(request.unwrap()).await
19608 };
19609
19610 match req_result {
19611 Err(err) => {
19612 if let common::Retry::After(d) = dlg.http_error(&err) {
19613 sleep(d).await;
19614 continue;
19615 }
19616 dlg.finished(false);
19617 return Err(common::Error::HttpError(err));
19618 }
19619 Ok(res) => {
19620 let (mut parts, body) = res.into_parts();
19621 let mut body = common::Body::new(body);
19622 if !parts.status.is_success() {
19623 let bytes = common::to_bytes(body).await.unwrap_or_default();
19624 let error = serde_json::from_str(&common::to_string(&bytes));
19625 let response = common::to_response(parts, bytes.into());
19626
19627 if let common::Retry::After(d) =
19628 dlg.http_failure(&response, error.as_ref().ok())
19629 {
19630 sleep(d).await;
19631 continue;
19632 }
19633
19634 dlg.finished(false);
19635
19636 return Err(match error {
19637 Ok(value) => common::Error::BadRequest(value),
19638 _ => common::Error::Failure(response),
19639 });
19640 }
19641 let response = {
19642 let bytes = common::to_bytes(body).await.unwrap_or_default();
19643 let encoded = common::to_string(&bytes);
19644 match serde_json::from_str(&encoded) {
19645 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19646 Err(error) => {
19647 dlg.response_json_decode_error(&encoded, &error);
19648 return Err(common::Error::JsonDecodeError(
19649 encoded.to_string(),
19650 error,
19651 ));
19652 }
19653 }
19654 };
19655
19656 dlg.finished(true);
19657 return Ok(response);
19658 }
19659 }
19660 }
19661 }
19662
19663 /// Required. Resource name of the parent containing the listed SLOs, either a project or a Monitoring Metrics Scope. The formats are: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] workspaces/[HOST_PROJECT_ID_OR_NUMBER]/services/-
19664 ///
19665 /// Sets the *parent* path property to the given value.
19666 ///
19667 /// Even though the property as already been set when instantiating this call,
19668 /// we provide this method for API completeness.
19669 pub fn parent(mut self, new_value: &str) -> ServiceServiceLevelObjectiveListCall<'a, C> {
19670 self._parent = new_value.to_string();
19671 self
19672 }
19673 /// View of the ServiceLevelObjectives to return. If DEFAULT, return each ServiceLevelObjective as originally defined. If EXPLICIT and the ServiceLevelObjective is defined in terms of a BasicSli, replace the BasicSli with a RequestBasedSli spelling out how the SLI is computed.
19674 ///
19675 /// Sets the *view* query property to the given value.
19676 pub fn view(mut self, new_value: &str) -> ServiceServiceLevelObjectiveListCall<'a, C> {
19677 self._view = Some(new_value.to_string());
19678 self
19679 }
19680 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
19681 ///
19682 /// Sets the *page token* query property to the given value.
19683 pub fn page_token(mut self, new_value: &str) -> ServiceServiceLevelObjectiveListCall<'a, C> {
19684 self._page_token = Some(new_value.to_string());
19685 self
19686 }
19687 /// A non-negative number that is the maximum number of results to return. When 0, use default page size.
19688 ///
19689 /// Sets the *page size* query property to the given value.
19690 pub fn page_size(mut self, new_value: i32) -> ServiceServiceLevelObjectiveListCall<'a, C> {
19691 self._page_size = Some(new_value);
19692 self
19693 }
19694 /// A filter specifying what ServiceLevelObjectives to return.
19695 ///
19696 /// Sets the *filter* query property to the given value.
19697 pub fn filter(mut self, new_value: &str) -> ServiceServiceLevelObjectiveListCall<'a, C> {
19698 self._filter = Some(new_value.to_string());
19699 self
19700 }
19701 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19702 /// while executing the actual API request.
19703 ///
19704 /// ````text
19705 /// It should be used to handle progress information, and to implement a certain level of resilience.
19706 /// ````
19707 ///
19708 /// Sets the *delegate* property to the given value.
19709 pub fn delegate(
19710 mut self,
19711 new_value: &'a mut dyn common::Delegate,
19712 ) -> ServiceServiceLevelObjectiveListCall<'a, C> {
19713 self._delegate = Some(new_value);
19714 self
19715 }
19716
19717 /// Set any additional parameter of the query string used in the request.
19718 /// It should be used to set parameters which are not yet available through their own
19719 /// setters.
19720 ///
19721 /// Please note that this method must not be used to set any of the known parameters
19722 /// which have their own setter method. If done anyway, the request will fail.
19723 ///
19724 /// # Additional Parameters
19725 ///
19726 /// * *$.xgafv* (query-string) - V1 error format.
19727 /// * *access_token* (query-string) - OAuth access token.
19728 /// * *alt* (query-string) - Data format for response.
19729 /// * *callback* (query-string) - JSONP
19730 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19731 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19732 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19733 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19734 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19735 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19736 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19737 pub fn param<T>(mut self, name: T, value: T) -> ServiceServiceLevelObjectiveListCall<'a, C>
19738 where
19739 T: AsRef<str>,
19740 {
19741 self._additional_params
19742 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19743 self
19744 }
19745
19746 /// Identifies the authorization scope for the method you are building.
19747 ///
19748 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19749 /// [`Scope::CloudPlatform`].
19750 ///
19751 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19752 /// tokens for more than one scope.
19753 ///
19754 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19755 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19756 /// sufficient, a read-write scope will do as well.
19757 pub fn add_scope<St>(mut self, scope: St) -> ServiceServiceLevelObjectiveListCall<'a, C>
19758 where
19759 St: AsRef<str>,
19760 {
19761 self._scopes.insert(String::from(scope.as_ref()));
19762 self
19763 }
19764 /// Identifies the authorization scope(s) for the method you are building.
19765 ///
19766 /// See [`Self::add_scope()`] for details.
19767 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceServiceLevelObjectiveListCall<'a, C>
19768 where
19769 I: IntoIterator<Item = St>,
19770 St: AsRef<str>,
19771 {
19772 self._scopes
19773 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19774 self
19775 }
19776
19777 /// Removes all scopes, and no default scope will be used either.
19778 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19779 /// for details).
19780 pub fn clear_scopes(mut self) -> ServiceServiceLevelObjectiveListCall<'a, C> {
19781 self._scopes.clear();
19782 self
19783 }
19784}
19785
19786/// Update the given ServiceLevelObjective.
19787///
19788/// A builder for the *serviceLevelObjectives.patch* method supported by a *service* resource.
19789/// It is not used directly, but through a [`ServiceMethods`] instance.
19790///
19791/// # Example
19792///
19793/// Instantiate a resource method builder
19794///
19795/// ```test_harness,no_run
19796/// # extern crate hyper;
19797/// # extern crate hyper_rustls;
19798/// # extern crate google_monitoring3 as monitoring3;
19799/// use monitoring3::api::ServiceLevelObjective;
19800/// # async fn dox() {
19801/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19802///
19803/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19804/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19805/// # secret,
19806/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19807/// # ).build().await.unwrap();
19808///
19809/// # let client = hyper_util::client::legacy::Client::builder(
19810/// # hyper_util::rt::TokioExecutor::new()
19811/// # )
19812/// # .build(
19813/// # hyper_rustls::HttpsConnectorBuilder::new()
19814/// # .with_native_roots()
19815/// # .unwrap()
19816/// # .https_or_http()
19817/// # .enable_http1()
19818/// # .build()
19819/// # );
19820/// # let mut hub = Monitoring::new(client, auth);
19821/// // As the method needs a request, you would usually fill it with the desired information
19822/// // into the respective structure. Some of the parts shown here might not be applicable !
19823/// // Values shown here are possibly random and not representative !
19824/// let mut req = ServiceLevelObjective::default();
19825///
19826/// // You can configure optional parameters by calling the respective setters at will, and
19827/// // execute the final call using `doit()`.
19828/// // Values shown here are possibly random and not representative !
19829/// let result = hub.services().service_level_objectives_patch(req, "name")
19830/// .update_mask(FieldMask::new::<&str>(&[]))
19831/// .doit().await;
19832/// # }
19833/// ```
19834pub struct ServiceServiceLevelObjectivePatchCall<'a, C>
19835where
19836 C: 'a,
19837{
19838 hub: &'a Monitoring<C>,
19839 _request: ServiceLevelObjective,
19840 _name: String,
19841 _update_mask: Option<common::FieldMask>,
19842 _delegate: Option<&'a mut dyn common::Delegate>,
19843 _additional_params: HashMap<String, String>,
19844 _scopes: BTreeSet<String>,
19845}
19846
19847impl<'a, C> common::CallBuilder for ServiceServiceLevelObjectivePatchCall<'a, C> {}
19848
19849impl<'a, C> ServiceServiceLevelObjectivePatchCall<'a, C>
19850where
19851 C: common::Connector,
19852{
19853 /// Perform the operation you have build so far.
19854 pub async fn doit(mut self) -> common::Result<(common::Response, ServiceLevelObjective)> {
19855 use std::borrow::Cow;
19856 use std::io::{Read, Seek};
19857
19858 use common::{url::Params, ToParts};
19859 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19860
19861 let mut dd = common::DefaultDelegate;
19862 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19863 dlg.begin(common::MethodInfo {
19864 id: "monitoring.services.serviceLevelObjectives.patch",
19865 http_method: hyper::Method::PATCH,
19866 });
19867
19868 for &field in ["alt", "name", "updateMask"].iter() {
19869 if self._additional_params.contains_key(field) {
19870 dlg.finished(false);
19871 return Err(common::Error::FieldClash(field));
19872 }
19873 }
19874
19875 let mut params = Params::with_capacity(5 + self._additional_params.len());
19876 params.push("name", self._name);
19877 if let Some(value) = self._update_mask.as_ref() {
19878 params.push("updateMask", value.to_string());
19879 }
19880
19881 params.extend(self._additional_params.iter());
19882
19883 params.push("alt", "json");
19884 let mut url = self.hub._base_url.clone() + "v3/{+name}";
19885 if self._scopes.is_empty() {
19886 self._scopes
19887 .insert(Scope::CloudPlatform.as_ref().to_string());
19888 }
19889
19890 #[allow(clippy::single_element_loop)]
19891 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19892 url = params.uri_replacement(url, param_name, find_this, true);
19893 }
19894 {
19895 let to_remove = ["name"];
19896 params.remove_params(&to_remove);
19897 }
19898
19899 let url = params.parse_with_url(&url);
19900
19901 let mut json_mime_type = mime::APPLICATION_JSON;
19902 let mut request_value_reader = {
19903 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19904 common::remove_json_null_values(&mut value);
19905 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19906 serde_json::to_writer(&mut dst, &value).unwrap();
19907 dst
19908 };
19909 let request_size = request_value_reader
19910 .seek(std::io::SeekFrom::End(0))
19911 .unwrap();
19912 request_value_reader
19913 .seek(std::io::SeekFrom::Start(0))
19914 .unwrap();
19915
19916 loop {
19917 let token = match self
19918 .hub
19919 .auth
19920 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19921 .await
19922 {
19923 Ok(token) => token,
19924 Err(e) => match dlg.token(e) {
19925 Ok(token) => token,
19926 Err(e) => {
19927 dlg.finished(false);
19928 return Err(common::Error::MissingToken(e));
19929 }
19930 },
19931 };
19932 request_value_reader
19933 .seek(std::io::SeekFrom::Start(0))
19934 .unwrap();
19935 let mut req_result = {
19936 let client = &self.hub.client;
19937 dlg.pre_request();
19938 let mut req_builder = hyper::Request::builder()
19939 .method(hyper::Method::PATCH)
19940 .uri(url.as_str())
19941 .header(USER_AGENT, self.hub._user_agent.clone());
19942
19943 if let Some(token) = token.as_ref() {
19944 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19945 }
19946
19947 let request = req_builder
19948 .header(CONTENT_TYPE, json_mime_type.to_string())
19949 .header(CONTENT_LENGTH, request_size as u64)
19950 .body(common::to_body(
19951 request_value_reader.get_ref().clone().into(),
19952 ));
19953
19954 client.request(request.unwrap()).await
19955 };
19956
19957 match req_result {
19958 Err(err) => {
19959 if let common::Retry::After(d) = dlg.http_error(&err) {
19960 sleep(d).await;
19961 continue;
19962 }
19963 dlg.finished(false);
19964 return Err(common::Error::HttpError(err));
19965 }
19966 Ok(res) => {
19967 let (mut parts, body) = res.into_parts();
19968 let mut body = common::Body::new(body);
19969 if !parts.status.is_success() {
19970 let bytes = common::to_bytes(body).await.unwrap_or_default();
19971 let error = serde_json::from_str(&common::to_string(&bytes));
19972 let response = common::to_response(parts, bytes.into());
19973
19974 if let common::Retry::After(d) =
19975 dlg.http_failure(&response, error.as_ref().ok())
19976 {
19977 sleep(d).await;
19978 continue;
19979 }
19980
19981 dlg.finished(false);
19982
19983 return Err(match error {
19984 Ok(value) => common::Error::BadRequest(value),
19985 _ => common::Error::Failure(response),
19986 });
19987 }
19988 let response = {
19989 let bytes = common::to_bytes(body).await.unwrap_or_default();
19990 let encoded = common::to_string(&bytes);
19991 match serde_json::from_str(&encoded) {
19992 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19993 Err(error) => {
19994 dlg.response_json_decode_error(&encoded, &error);
19995 return Err(common::Error::JsonDecodeError(
19996 encoded.to_string(),
19997 error,
19998 ));
19999 }
20000 }
20001 };
20002
20003 dlg.finished(true);
20004 return Ok(response);
20005 }
20006 }
20007 }
20008 }
20009
20010 ///
20011 /// Sets the *request* property to the given value.
20012 ///
20013 /// Even though the property as already been set when instantiating this call,
20014 /// we provide this method for API completeness.
20015 pub fn request(
20016 mut self,
20017 new_value: ServiceLevelObjective,
20018 ) -> ServiceServiceLevelObjectivePatchCall<'a, C> {
20019 self._request = new_value;
20020 self
20021 }
20022 /// Identifier. Resource name for this ServiceLevelObjective. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
20023 ///
20024 /// Sets the *name* path property to the given value.
20025 ///
20026 /// Even though the property as already been set when instantiating this call,
20027 /// we provide this method for API completeness.
20028 pub fn name(mut self, new_value: &str) -> ServiceServiceLevelObjectivePatchCall<'a, C> {
20029 self._name = new_value.to_string();
20030 self
20031 }
20032 /// A set of field paths defining which fields to use for the update.
20033 ///
20034 /// Sets the *update mask* query property to the given value.
20035 pub fn update_mask(
20036 mut self,
20037 new_value: common::FieldMask,
20038 ) -> ServiceServiceLevelObjectivePatchCall<'a, C> {
20039 self._update_mask = Some(new_value);
20040 self
20041 }
20042 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20043 /// while executing the actual API request.
20044 ///
20045 /// ````text
20046 /// It should be used to handle progress information, and to implement a certain level of resilience.
20047 /// ````
20048 ///
20049 /// Sets the *delegate* property to the given value.
20050 pub fn delegate(
20051 mut self,
20052 new_value: &'a mut dyn common::Delegate,
20053 ) -> ServiceServiceLevelObjectivePatchCall<'a, C> {
20054 self._delegate = Some(new_value);
20055 self
20056 }
20057
20058 /// Set any additional parameter of the query string used in the request.
20059 /// It should be used to set parameters which are not yet available through their own
20060 /// setters.
20061 ///
20062 /// Please note that this method must not be used to set any of the known parameters
20063 /// which have their own setter method. If done anyway, the request will fail.
20064 ///
20065 /// # Additional Parameters
20066 ///
20067 /// * *$.xgafv* (query-string) - V1 error format.
20068 /// * *access_token* (query-string) - OAuth access token.
20069 /// * *alt* (query-string) - Data format for response.
20070 /// * *callback* (query-string) - JSONP
20071 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20072 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20073 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20074 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20075 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
20076 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20077 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20078 pub fn param<T>(mut self, name: T, value: T) -> ServiceServiceLevelObjectivePatchCall<'a, C>
20079 where
20080 T: AsRef<str>,
20081 {
20082 self._additional_params
20083 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20084 self
20085 }
20086
20087 /// Identifies the authorization scope for the method you are building.
20088 ///
20089 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20090 /// [`Scope::CloudPlatform`].
20091 ///
20092 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20093 /// tokens for more than one scope.
20094 ///
20095 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20096 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20097 /// sufficient, a read-write scope will do as well.
20098 pub fn add_scope<St>(mut self, scope: St) -> ServiceServiceLevelObjectivePatchCall<'a, C>
20099 where
20100 St: AsRef<str>,
20101 {
20102 self._scopes.insert(String::from(scope.as_ref()));
20103 self
20104 }
20105 /// Identifies the authorization scope(s) for the method you are building.
20106 ///
20107 /// See [`Self::add_scope()`] for details.
20108 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceServiceLevelObjectivePatchCall<'a, C>
20109 where
20110 I: IntoIterator<Item = St>,
20111 St: AsRef<str>,
20112 {
20113 self._scopes
20114 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20115 self
20116 }
20117
20118 /// Removes all scopes, and no default scope will be used either.
20119 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20120 /// for details).
20121 pub fn clear_scopes(mut self) -> ServiceServiceLevelObjectivePatchCall<'a, C> {
20122 self._scopes.clear();
20123 self
20124 }
20125}
20126
20127/// Create a Service.
20128///
20129/// A builder for the *create* method supported by a *service* resource.
20130/// It is not used directly, but through a [`ServiceMethods`] instance.
20131///
20132/// # Example
20133///
20134/// Instantiate a resource method builder
20135///
20136/// ```test_harness,no_run
20137/// # extern crate hyper;
20138/// # extern crate hyper_rustls;
20139/// # extern crate google_monitoring3 as monitoring3;
20140/// use monitoring3::api::Service;
20141/// # async fn dox() {
20142/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20143///
20144/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20145/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20146/// # secret,
20147/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20148/// # ).build().await.unwrap();
20149///
20150/// # let client = hyper_util::client::legacy::Client::builder(
20151/// # hyper_util::rt::TokioExecutor::new()
20152/// # )
20153/// # .build(
20154/// # hyper_rustls::HttpsConnectorBuilder::new()
20155/// # .with_native_roots()
20156/// # .unwrap()
20157/// # .https_or_http()
20158/// # .enable_http1()
20159/// # .build()
20160/// # );
20161/// # let mut hub = Monitoring::new(client, auth);
20162/// // As the method needs a request, you would usually fill it with the desired information
20163/// // into the respective structure. Some of the parts shown here might not be applicable !
20164/// // Values shown here are possibly random and not representative !
20165/// let mut req = Service::default();
20166///
20167/// // You can configure optional parameters by calling the respective setters at will, and
20168/// // execute the final call using `doit()`.
20169/// // Values shown here are possibly random and not representative !
20170/// let result = hub.services().create(req, "parent")
20171/// .service_id("Stet")
20172/// .doit().await;
20173/// # }
20174/// ```
20175pub struct ServiceCreateCall<'a, C>
20176where
20177 C: 'a,
20178{
20179 hub: &'a Monitoring<C>,
20180 _request: Service,
20181 _parent: String,
20182 _service_id: Option<String>,
20183 _delegate: Option<&'a mut dyn common::Delegate>,
20184 _additional_params: HashMap<String, String>,
20185 _scopes: BTreeSet<String>,
20186}
20187
20188impl<'a, C> common::CallBuilder for ServiceCreateCall<'a, C> {}
20189
20190impl<'a, C> ServiceCreateCall<'a, C>
20191where
20192 C: common::Connector,
20193{
20194 /// Perform the operation you have build so far.
20195 pub async fn doit(mut self) -> common::Result<(common::Response, Service)> {
20196 use std::borrow::Cow;
20197 use std::io::{Read, Seek};
20198
20199 use common::{url::Params, ToParts};
20200 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20201
20202 let mut dd = common::DefaultDelegate;
20203 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20204 dlg.begin(common::MethodInfo {
20205 id: "monitoring.services.create",
20206 http_method: hyper::Method::POST,
20207 });
20208
20209 for &field in ["alt", "parent", "serviceId"].iter() {
20210 if self._additional_params.contains_key(field) {
20211 dlg.finished(false);
20212 return Err(common::Error::FieldClash(field));
20213 }
20214 }
20215
20216 let mut params = Params::with_capacity(5 + self._additional_params.len());
20217 params.push("parent", self._parent);
20218 if let Some(value) = self._service_id.as_ref() {
20219 params.push("serviceId", value);
20220 }
20221
20222 params.extend(self._additional_params.iter());
20223
20224 params.push("alt", "json");
20225 let mut url = self.hub._base_url.clone() + "v3/{+parent}/services";
20226 if self._scopes.is_empty() {
20227 self._scopes
20228 .insert(Scope::CloudPlatform.as_ref().to_string());
20229 }
20230
20231 #[allow(clippy::single_element_loop)]
20232 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
20233 url = params.uri_replacement(url, param_name, find_this, true);
20234 }
20235 {
20236 let to_remove = ["parent"];
20237 params.remove_params(&to_remove);
20238 }
20239
20240 let url = params.parse_with_url(&url);
20241
20242 let mut json_mime_type = mime::APPLICATION_JSON;
20243 let mut request_value_reader = {
20244 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20245 common::remove_json_null_values(&mut value);
20246 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20247 serde_json::to_writer(&mut dst, &value).unwrap();
20248 dst
20249 };
20250 let request_size = request_value_reader
20251 .seek(std::io::SeekFrom::End(0))
20252 .unwrap();
20253 request_value_reader
20254 .seek(std::io::SeekFrom::Start(0))
20255 .unwrap();
20256
20257 loop {
20258 let token = match self
20259 .hub
20260 .auth
20261 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20262 .await
20263 {
20264 Ok(token) => token,
20265 Err(e) => match dlg.token(e) {
20266 Ok(token) => token,
20267 Err(e) => {
20268 dlg.finished(false);
20269 return Err(common::Error::MissingToken(e));
20270 }
20271 },
20272 };
20273 request_value_reader
20274 .seek(std::io::SeekFrom::Start(0))
20275 .unwrap();
20276 let mut req_result = {
20277 let client = &self.hub.client;
20278 dlg.pre_request();
20279 let mut req_builder = hyper::Request::builder()
20280 .method(hyper::Method::POST)
20281 .uri(url.as_str())
20282 .header(USER_AGENT, self.hub._user_agent.clone());
20283
20284 if let Some(token) = token.as_ref() {
20285 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20286 }
20287
20288 let request = req_builder
20289 .header(CONTENT_TYPE, json_mime_type.to_string())
20290 .header(CONTENT_LENGTH, request_size as u64)
20291 .body(common::to_body(
20292 request_value_reader.get_ref().clone().into(),
20293 ));
20294
20295 client.request(request.unwrap()).await
20296 };
20297
20298 match req_result {
20299 Err(err) => {
20300 if let common::Retry::After(d) = dlg.http_error(&err) {
20301 sleep(d).await;
20302 continue;
20303 }
20304 dlg.finished(false);
20305 return Err(common::Error::HttpError(err));
20306 }
20307 Ok(res) => {
20308 let (mut parts, body) = res.into_parts();
20309 let mut body = common::Body::new(body);
20310 if !parts.status.is_success() {
20311 let bytes = common::to_bytes(body).await.unwrap_or_default();
20312 let error = serde_json::from_str(&common::to_string(&bytes));
20313 let response = common::to_response(parts, bytes.into());
20314
20315 if let common::Retry::After(d) =
20316 dlg.http_failure(&response, error.as_ref().ok())
20317 {
20318 sleep(d).await;
20319 continue;
20320 }
20321
20322 dlg.finished(false);
20323
20324 return Err(match error {
20325 Ok(value) => common::Error::BadRequest(value),
20326 _ => common::Error::Failure(response),
20327 });
20328 }
20329 let response = {
20330 let bytes = common::to_bytes(body).await.unwrap_or_default();
20331 let encoded = common::to_string(&bytes);
20332 match serde_json::from_str(&encoded) {
20333 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20334 Err(error) => {
20335 dlg.response_json_decode_error(&encoded, &error);
20336 return Err(common::Error::JsonDecodeError(
20337 encoded.to_string(),
20338 error,
20339 ));
20340 }
20341 }
20342 };
20343
20344 dlg.finished(true);
20345 return Ok(response);
20346 }
20347 }
20348 }
20349 }
20350
20351 ///
20352 /// Sets the *request* property to the given value.
20353 ///
20354 /// Even though the property as already been set when instantiating this call,
20355 /// we provide this method for API completeness.
20356 pub fn request(mut self, new_value: Service) -> ServiceCreateCall<'a, C> {
20357 self._request = new_value;
20358 self
20359 }
20360 /// Required. Resource name (https://cloud.google.com/monitoring/api/v3#project_name) of the parent Metrics Scope. The format is: projects/[PROJECT_ID_OR_NUMBER]
20361 ///
20362 /// Sets the *parent* path property to the given value.
20363 ///
20364 /// Even though the property as already been set when instantiating this call,
20365 /// we provide this method for API completeness.
20366 pub fn parent(mut self, new_value: &str) -> ServiceCreateCall<'a, C> {
20367 self._parent = new_value.to_string();
20368 self
20369 }
20370 /// Optional. The Service id to use for this Service. If omitted, an id will be generated instead. Must match the pattern [a-z0-9\-]+
20371 ///
20372 /// Sets the *service id* query property to the given value.
20373 pub fn service_id(mut self, new_value: &str) -> ServiceCreateCall<'a, C> {
20374 self._service_id = Some(new_value.to_string());
20375 self
20376 }
20377 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20378 /// while executing the actual API request.
20379 ///
20380 /// ````text
20381 /// It should be used to handle progress information, and to implement a certain level of resilience.
20382 /// ````
20383 ///
20384 /// Sets the *delegate* property to the given value.
20385 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceCreateCall<'a, C> {
20386 self._delegate = Some(new_value);
20387 self
20388 }
20389
20390 /// Set any additional parameter of the query string used in the request.
20391 /// It should be used to set parameters which are not yet available through their own
20392 /// setters.
20393 ///
20394 /// Please note that this method must not be used to set any of the known parameters
20395 /// which have their own setter method. If done anyway, the request will fail.
20396 ///
20397 /// # Additional Parameters
20398 ///
20399 /// * *$.xgafv* (query-string) - V1 error format.
20400 /// * *access_token* (query-string) - OAuth access token.
20401 /// * *alt* (query-string) - Data format for response.
20402 /// * *callback* (query-string) - JSONP
20403 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20404 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20405 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20406 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20407 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
20408 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20409 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20410 pub fn param<T>(mut self, name: T, value: T) -> ServiceCreateCall<'a, C>
20411 where
20412 T: AsRef<str>,
20413 {
20414 self._additional_params
20415 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20416 self
20417 }
20418
20419 /// Identifies the authorization scope for the method you are building.
20420 ///
20421 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20422 /// [`Scope::CloudPlatform`].
20423 ///
20424 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20425 /// tokens for more than one scope.
20426 ///
20427 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20428 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20429 /// sufficient, a read-write scope will do as well.
20430 pub fn add_scope<St>(mut self, scope: St) -> ServiceCreateCall<'a, C>
20431 where
20432 St: AsRef<str>,
20433 {
20434 self._scopes.insert(String::from(scope.as_ref()));
20435 self
20436 }
20437 /// Identifies the authorization scope(s) for the method you are building.
20438 ///
20439 /// See [`Self::add_scope()`] for details.
20440 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceCreateCall<'a, C>
20441 where
20442 I: IntoIterator<Item = St>,
20443 St: AsRef<str>,
20444 {
20445 self._scopes
20446 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20447 self
20448 }
20449
20450 /// Removes all scopes, and no default scope will be used either.
20451 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20452 /// for details).
20453 pub fn clear_scopes(mut self) -> ServiceCreateCall<'a, C> {
20454 self._scopes.clear();
20455 self
20456 }
20457}
20458
20459/// Soft delete this Service.
20460///
20461/// A builder for the *delete* method supported by a *service* resource.
20462/// It is not used directly, but through a [`ServiceMethods`] instance.
20463///
20464/// # Example
20465///
20466/// Instantiate a resource method builder
20467///
20468/// ```test_harness,no_run
20469/// # extern crate hyper;
20470/// # extern crate hyper_rustls;
20471/// # extern crate google_monitoring3 as monitoring3;
20472/// # async fn dox() {
20473/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20474///
20475/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20476/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20477/// # secret,
20478/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20479/// # ).build().await.unwrap();
20480///
20481/// # let client = hyper_util::client::legacy::Client::builder(
20482/// # hyper_util::rt::TokioExecutor::new()
20483/// # )
20484/// # .build(
20485/// # hyper_rustls::HttpsConnectorBuilder::new()
20486/// # .with_native_roots()
20487/// # .unwrap()
20488/// # .https_or_http()
20489/// # .enable_http1()
20490/// # .build()
20491/// # );
20492/// # let mut hub = Monitoring::new(client, auth);
20493/// // You can configure optional parameters by calling the respective setters at will, and
20494/// // execute the final call using `doit()`.
20495/// // Values shown here are possibly random and not representative !
20496/// let result = hub.services().delete("name")
20497/// .doit().await;
20498/// # }
20499/// ```
20500pub struct ServiceDeleteCall<'a, C>
20501where
20502 C: 'a,
20503{
20504 hub: &'a Monitoring<C>,
20505 _name: String,
20506 _delegate: Option<&'a mut dyn common::Delegate>,
20507 _additional_params: HashMap<String, String>,
20508 _scopes: BTreeSet<String>,
20509}
20510
20511impl<'a, C> common::CallBuilder for ServiceDeleteCall<'a, C> {}
20512
20513impl<'a, C> ServiceDeleteCall<'a, C>
20514where
20515 C: common::Connector,
20516{
20517 /// Perform the operation you have build so far.
20518 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
20519 use std::borrow::Cow;
20520 use std::io::{Read, Seek};
20521
20522 use common::{url::Params, ToParts};
20523 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20524
20525 let mut dd = common::DefaultDelegate;
20526 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20527 dlg.begin(common::MethodInfo {
20528 id: "monitoring.services.delete",
20529 http_method: hyper::Method::DELETE,
20530 });
20531
20532 for &field in ["alt", "name"].iter() {
20533 if self._additional_params.contains_key(field) {
20534 dlg.finished(false);
20535 return Err(common::Error::FieldClash(field));
20536 }
20537 }
20538
20539 let mut params = Params::with_capacity(3 + self._additional_params.len());
20540 params.push("name", self._name);
20541
20542 params.extend(self._additional_params.iter());
20543
20544 params.push("alt", "json");
20545 let mut url = self.hub._base_url.clone() + "v3/{+name}";
20546 if self._scopes.is_empty() {
20547 self._scopes
20548 .insert(Scope::CloudPlatform.as_ref().to_string());
20549 }
20550
20551 #[allow(clippy::single_element_loop)]
20552 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20553 url = params.uri_replacement(url, param_name, find_this, true);
20554 }
20555 {
20556 let to_remove = ["name"];
20557 params.remove_params(&to_remove);
20558 }
20559
20560 let url = params.parse_with_url(&url);
20561
20562 loop {
20563 let token = match self
20564 .hub
20565 .auth
20566 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20567 .await
20568 {
20569 Ok(token) => token,
20570 Err(e) => match dlg.token(e) {
20571 Ok(token) => token,
20572 Err(e) => {
20573 dlg.finished(false);
20574 return Err(common::Error::MissingToken(e));
20575 }
20576 },
20577 };
20578 let mut req_result = {
20579 let client = &self.hub.client;
20580 dlg.pre_request();
20581 let mut req_builder = hyper::Request::builder()
20582 .method(hyper::Method::DELETE)
20583 .uri(url.as_str())
20584 .header(USER_AGENT, self.hub._user_agent.clone());
20585
20586 if let Some(token) = token.as_ref() {
20587 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20588 }
20589
20590 let request = req_builder
20591 .header(CONTENT_LENGTH, 0_u64)
20592 .body(common::to_body::<String>(None));
20593
20594 client.request(request.unwrap()).await
20595 };
20596
20597 match req_result {
20598 Err(err) => {
20599 if let common::Retry::After(d) = dlg.http_error(&err) {
20600 sleep(d).await;
20601 continue;
20602 }
20603 dlg.finished(false);
20604 return Err(common::Error::HttpError(err));
20605 }
20606 Ok(res) => {
20607 let (mut parts, body) = res.into_parts();
20608 let mut body = common::Body::new(body);
20609 if !parts.status.is_success() {
20610 let bytes = common::to_bytes(body).await.unwrap_or_default();
20611 let error = serde_json::from_str(&common::to_string(&bytes));
20612 let response = common::to_response(parts, bytes.into());
20613
20614 if let common::Retry::After(d) =
20615 dlg.http_failure(&response, error.as_ref().ok())
20616 {
20617 sleep(d).await;
20618 continue;
20619 }
20620
20621 dlg.finished(false);
20622
20623 return Err(match error {
20624 Ok(value) => common::Error::BadRequest(value),
20625 _ => common::Error::Failure(response),
20626 });
20627 }
20628 let response = {
20629 let bytes = common::to_bytes(body).await.unwrap_or_default();
20630 let encoded = common::to_string(&bytes);
20631 match serde_json::from_str(&encoded) {
20632 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20633 Err(error) => {
20634 dlg.response_json_decode_error(&encoded, &error);
20635 return Err(common::Error::JsonDecodeError(
20636 encoded.to_string(),
20637 error,
20638 ));
20639 }
20640 }
20641 };
20642
20643 dlg.finished(true);
20644 return Ok(response);
20645 }
20646 }
20647 }
20648 }
20649
20650 /// Required. Resource name of the Service to delete. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
20651 ///
20652 /// Sets the *name* path property to the given value.
20653 ///
20654 /// Even though the property as already been set when instantiating this call,
20655 /// we provide this method for API completeness.
20656 pub fn name(mut self, new_value: &str) -> ServiceDeleteCall<'a, C> {
20657 self._name = new_value.to_string();
20658 self
20659 }
20660 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20661 /// while executing the actual API request.
20662 ///
20663 /// ````text
20664 /// It should be used to handle progress information, and to implement a certain level of resilience.
20665 /// ````
20666 ///
20667 /// Sets the *delegate* property to the given value.
20668 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceDeleteCall<'a, C> {
20669 self._delegate = Some(new_value);
20670 self
20671 }
20672
20673 /// Set any additional parameter of the query string used in the request.
20674 /// It should be used to set parameters which are not yet available through their own
20675 /// setters.
20676 ///
20677 /// Please note that this method must not be used to set any of the known parameters
20678 /// which have their own setter method. If done anyway, the request will fail.
20679 ///
20680 /// # Additional Parameters
20681 ///
20682 /// * *$.xgafv* (query-string) - V1 error format.
20683 /// * *access_token* (query-string) - OAuth access token.
20684 /// * *alt* (query-string) - Data format for response.
20685 /// * *callback* (query-string) - JSONP
20686 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20687 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20688 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20689 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20690 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
20691 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20692 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20693 pub fn param<T>(mut self, name: T, value: T) -> ServiceDeleteCall<'a, C>
20694 where
20695 T: AsRef<str>,
20696 {
20697 self._additional_params
20698 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20699 self
20700 }
20701
20702 /// Identifies the authorization scope for the method you are building.
20703 ///
20704 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20705 /// [`Scope::CloudPlatform`].
20706 ///
20707 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20708 /// tokens for more than one scope.
20709 ///
20710 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20711 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20712 /// sufficient, a read-write scope will do as well.
20713 pub fn add_scope<St>(mut self, scope: St) -> ServiceDeleteCall<'a, C>
20714 where
20715 St: AsRef<str>,
20716 {
20717 self._scopes.insert(String::from(scope.as_ref()));
20718 self
20719 }
20720 /// Identifies the authorization scope(s) for the method you are building.
20721 ///
20722 /// See [`Self::add_scope()`] for details.
20723 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceDeleteCall<'a, C>
20724 where
20725 I: IntoIterator<Item = St>,
20726 St: AsRef<str>,
20727 {
20728 self._scopes
20729 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20730 self
20731 }
20732
20733 /// Removes all scopes, and no default scope will be used either.
20734 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20735 /// for details).
20736 pub fn clear_scopes(mut self) -> ServiceDeleteCall<'a, C> {
20737 self._scopes.clear();
20738 self
20739 }
20740}
20741
20742/// Get the named Service.
20743///
20744/// A builder for the *get* method supported by a *service* resource.
20745/// It is not used directly, but through a [`ServiceMethods`] instance.
20746///
20747/// # Example
20748///
20749/// Instantiate a resource method builder
20750///
20751/// ```test_harness,no_run
20752/// # extern crate hyper;
20753/// # extern crate hyper_rustls;
20754/// # extern crate google_monitoring3 as monitoring3;
20755/// # async fn dox() {
20756/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20757///
20758/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20759/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20760/// # secret,
20761/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20762/// # ).build().await.unwrap();
20763///
20764/// # let client = hyper_util::client::legacy::Client::builder(
20765/// # hyper_util::rt::TokioExecutor::new()
20766/// # )
20767/// # .build(
20768/// # hyper_rustls::HttpsConnectorBuilder::new()
20769/// # .with_native_roots()
20770/// # .unwrap()
20771/// # .https_or_http()
20772/// # .enable_http1()
20773/// # .build()
20774/// # );
20775/// # let mut hub = Monitoring::new(client, auth);
20776/// // You can configure optional parameters by calling the respective setters at will, and
20777/// // execute the final call using `doit()`.
20778/// // Values shown here are possibly random and not representative !
20779/// let result = hub.services().get("name")
20780/// .doit().await;
20781/// # }
20782/// ```
20783pub struct ServiceGetCall<'a, C>
20784where
20785 C: 'a,
20786{
20787 hub: &'a Monitoring<C>,
20788 _name: String,
20789 _delegate: Option<&'a mut dyn common::Delegate>,
20790 _additional_params: HashMap<String, String>,
20791 _scopes: BTreeSet<String>,
20792}
20793
20794impl<'a, C> common::CallBuilder for ServiceGetCall<'a, C> {}
20795
20796impl<'a, C> ServiceGetCall<'a, C>
20797where
20798 C: common::Connector,
20799{
20800 /// Perform the operation you have build so far.
20801 pub async fn doit(mut self) -> common::Result<(common::Response, Service)> {
20802 use std::borrow::Cow;
20803 use std::io::{Read, Seek};
20804
20805 use common::{url::Params, ToParts};
20806 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20807
20808 let mut dd = common::DefaultDelegate;
20809 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20810 dlg.begin(common::MethodInfo {
20811 id: "monitoring.services.get",
20812 http_method: hyper::Method::GET,
20813 });
20814
20815 for &field in ["alt", "name"].iter() {
20816 if self._additional_params.contains_key(field) {
20817 dlg.finished(false);
20818 return Err(common::Error::FieldClash(field));
20819 }
20820 }
20821
20822 let mut params = Params::with_capacity(3 + self._additional_params.len());
20823 params.push("name", self._name);
20824
20825 params.extend(self._additional_params.iter());
20826
20827 params.push("alt", "json");
20828 let mut url = self.hub._base_url.clone() + "v3/{+name}";
20829 if self._scopes.is_empty() {
20830 self._scopes
20831 .insert(Scope::CloudPlatform.as_ref().to_string());
20832 }
20833
20834 #[allow(clippy::single_element_loop)]
20835 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20836 url = params.uri_replacement(url, param_name, find_this, true);
20837 }
20838 {
20839 let to_remove = ["name"];
20840 params.remove_params(&to_remove);
20841 }
20842
20843 let url = params.parse_with_url(&url);
20844
20845 loop {
20846 let token = match self
20847 .hub
20848 .auth
20849 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20850 .await
20851 {
20852 Ok(token) => token,
20853 Err(e) => match dlg.token(e) {
20854 Ok(token) => token,
20855 Err(e) => {
20856 dlg.finished(false);
20857 return Err(common::Error::MissingToken(e));
20858 }
20859 },
20860 };
20861 let mut req_result = {
20862 let client = &self.hub.client;
20863 dlg.pre_request();
20864 let mut req_builder = hyper::Request::builder()
20865 .method(hyper::Method::GET)
20866 .uri(url.as_str())
20867 .header(USER_AGENT, self.hub._user_agent.clone());
20868
20869 if let Some(token) = token.as_ref() {
20870 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20871 }
20872
20873 let request = req_builder
20874 .header(CONTENT_LENGTH, 0_u64)
20875 .body(common::to_body::<String>(None));
20876
20877 client.request(request.unwrap()).await
20878 };
20879
20880 match req_result {
20881 Err(err) => {
20882 if let common::Retry::After(d) = dlg.http_error(&err) {
20883 sleep(d).await;
20884 continue;
20885 }
20886 dlg.finished(false);
20887 return Err(common::Error::HttpError(err));
20888 }
20889 Ok(res) => {
20890 let (mut parts, body) = res.into_parts();
20891 let mut body = common::Body::new(body);
20892 if !parts.status.is_success() {
20893 let bytes = common::to_bytes(body).await.unwrap_or_default();
20894 let error = serde_json::from_str(&common::to_string(&bytes));
20895 let response = common::to_response(parts, bytes.into());
20896
20897 if let common::Retry::After(d) =
20898 dlg.http_failure(&response, error.as_ref().ok())
20899 {
20900 sleep(d).await;
20901 continue;
20902 }
20903
20904 dlg.finished(false);
20905
20906 return Err(match error {
20907 Ok(value) => common::Error::BadRequest(value),
20908 _ => common::Error::Failure(response),
20909 });
20910 }
20911 let response = {
20912 let bytes = common::to_bytes(body).await.unwrap_or_default();
20913 let encoded = common::to_string(&bytes);
20914 match serde_json::from_str(&encoded) {
20915 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20916 Err(error) => {
20917 dlg.response_json_decode_error(&encoded, &error);
20918 return Err(common::Error::JsonDecodeError(
20919 encoded.to_string(),
20920 error,
20921 ));
20922 }
20923 }
20924 };
20925
20926 dlg.finished(true);
20927 return Ok(response);
20928 }
20929 }
20930 }
20931 }
20932
20933 /// Required. Resource name of the Service. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
20934 ///
20935 /// Sets the *name* path property to the given value.
20936 ///
20937 /// Even though the property as already been set when instantiating this call,
20938 /// we provide this method for API completeness.
20939 pub fn name(mut self, new_value: &str) -> ServiceGetCall<'a, C> {
20940 self._name = new_value.to_string();
20941 self
20942 }
20943 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20944 /// while executing the actual API request.
20945 ///
20946 /// ````text
20947 /// It should be used to handle progress information, and to implement a certain level of resilience.
20948 /// ````
20949 ///
20950 /// Sets the *delegate* property to the given value.
20951 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceGetCall<'a, C> {
20952 self._delegate = Some(new_value);
20953 self
20954 }
20955
20956 /// Set any additional parameter of the query string used in the request.
20957 /// It should be used to set parameters which are not yet available through their own
20958 /// setters.
20959 ///
20960 /// Please note that this method must not be used to set any of the known parameters
20961 /// which have their own setter method. If done anyway, the request will fail.
20962 ///
20963 /// # Additional Parameters
20964 ///
20965 /// * *$.xgafv* (query-string) - V1 error format.
20966 /// * *access_token* (query-string) - OAuth access token.
20967 /// * *alt* (query-string) - Data format for response.
20968 /// * *callback* (query-string) - JSONP
20969 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20970 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20971 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20972 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20973 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
20974 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20975 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20976 pub fn param<T>(mut self, name: T, value: T) -> ServiceGetCall<'a, C>
20977 where
20978 T: AsRef<str>,
20979 {
20980 self._additional_params
20981 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20982 self
20983 }
20984
20985 /// Identifies the authorization scope for the method you are building.
20986 ///
20987 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20988 /// [`Scope::CloudPlatform`].
20989 ///
20990 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20991 /// tokens for more than one scope.
20992 ///
20993 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20994 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20995 /// sufficient, a read-write scope will do as well.
20996 pub fn add_scope<St>(mut self, scope: St) -> ServiceGetCall<'a, C>
20997 where
20998 St: AsRef<str>,
20999 {
21000 self._scopes.insert(String::from(scope.as_ref()));
21001 self
21002 }
21003 /// Identifies the authorization scope(s) for the method you are building.
21004 ///
21005 /// See [`Self::add_scope()`] for details.
21006 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceGetCall<'a, C>
21007 where
21008 I: IntoIterator<Item = St>,
21009 St: AsRef<str>,
21010 {
21011 self._scopes
21012 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21013 self
21014 }
21015
21016 /// Removes all scopes, and no default scope will be used either.
21017 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21018 /// for details).
21019 pub fn clear_scopes(mut self) -> ServiceGetCall<'a, C> {
21020 self._scopes.clear();
21021 self
21022 }
21023}
21024
21025/// List Services for this Metrics Scope.
21026///
21027/// A builder for the *list* method supported by a *service* resource.
21028/// It is not used directly, but through a [`ServiceMethods`] instance.
21029///
21030/// # Example
21031///
21032/// Instantiate a resource method builder
21033///
21034/// ```test_harness,no_run
21035/// # extern crate hyper;
21036/// # extern crate hyper_rustls;
21037/// # extern crate google_monitoring3 as monitoring3;
21038/// # async fn dox() {
21039/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21040///
21041/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21042/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21043/// # secret,
21044/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21045/// # ).build().await.unwrap();
21046///
21047/// # let client = hyper_util::client::legacy::Client::builder(
21048/// # hyper_util::rt::TokioExecutor::new()
21049/// # )
21050/// # .build(
21051/// # hyper_rustls::HttpsConnectorBuilder::new()
21052/// # .with_native_roots()
21053/// # .unwrap()
21054/// # .https_or_http()
21055/// # .enable_http1()
21056/// # .build()
21057/// # );
21058/// # let mut hub = Monitoring::new(client, auth);
21059/// // You can configure optional parameters by calling the respective setters at will, and
21060/// // execute the final call using `doit()`.
21061/// // Values shown here are possibly random and not representative !
21062/// let result = hub.services().list("parent")
21063/// .page_token("sea")
21064/// .page_size(-74)
21065/// .filter("At")
21066/// .doit().await;
21067/// # }
21068/// ```
21069pub struct ServiceListCall<'a, C>
21070where
21071 C: 'a,
21072{
21073 hub: &'a Monitoring<C>,
21074 _parent: String,
21075 _page_token: Option<String>,
21076 _page_size: Option<i32>,
21077 _filter: Option<String>,
21078 _delegate: Option<&'a mut dyn common::Delegate>,
21079 _additional_params: HashMap<String, String>,
21080 _scopes: BTreeSet<String>,
21081}
21082
21083impl<'a, C> common::CallBuilder for ServiceListCall<'a, C> {}
21084
21085impl<'a, C> ServiceListCall<'a, C>
21086where
21087 C: common::Connector,
21088{
21089 /// Perform the operation you have build so far.
21090 pub async fn doit(mut self) -> common::Result<(common::Response, ListServicesResponse)> {
21091 use std::borrow::Cow;
21092 use std::io::{Read, Seek};
21093
21094 use common::{url::Params, ToParts};
21095 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21096
21097 let mut dd = common::DefaultDelegate;
21098 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21099 dlg.begin(common::MethodInfo {
21100 id: "monitoring.services.list",
21101 http_method: hyper::Method::GET,
21102 });
21103
21104 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
21105 if self._additional_params.contains_key(field) {
21106 dlg.finished(false);
21107 return Err(common::Error::FieldClash(field));
21108 }
21109 }
21110
21111 let mut params = Params::with_capacity(6 + self._additional_params.len());
21112 params.push("parent", self._parent);
21113 if let Some(value) = self._page_token.as_ref() {
21114 params.push("pageToken", value);
21115 }
21116 if let Some(value) = self._page_size.as_ref() {
21117 params.push("pageSize", value.to_string());
21118 }
21119 if let Some(value) = self._filter.as_ref() {
21120 params.push("filter", value);
21121 }
21122
21123 params.extend(self._additional_params.iter());
21124
21125 params.push("alt", "json");
21126 let mut url = self.hub._base_url.clone() + "v3/{+parent}/services";
21127 if self._scopes.is_empty() {
21128 self._scopes
21129 .insert(Scope::CloudPlatform.as_ref().to_string());
21130 }
21131
21132 #[allow(clippy::single_element_loop)]
21133 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21134 url = params.uri_replacement(url, param_name, find_this, true);
21135 }
21136 {
21137 let to_remove = ["parent"];
21138 params.remove_params(&to_remove);
21139 }
21140
21141 let url = params.parse_with_url(&url);
21142
21143 loop {
21144 let token = match self
21145 .hub
21146 .auth
21147 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21148 .await
21149 {
21150 Ok(token) => token,
21151 Err(e) => match dlg.token(e) {
21152 Ok(token) => token,
21153 Err(e) => {
21154 dlg.finished(false);
21155 return Err(common::Error::MissingToken(e));
21156 }
21157 },
21158 };
21159 let mut req_result = {
21160 let client = &self.hub.client;
21161 dlg.pre_request();
21162 let mut req_builder = hyper::Request::builder()
21163 .method(hyper::Method::GET)
21164 .uri(url.as_str())
21165 .header(USER_AGENT, self.hub._user_agent.clone());
21166
21167 if let Some(token) = token.as_ref() {
21168 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21169 }
21170
21171 let request = req_builder
21172 .header(CONTENT_LENGTH, 0_u64)
21173 .body(common::to_body::<String>(None));
21174
21175 client.request(request.unwrap()).await
21176 };
21177
21178 match req_result {
21179 Err(err) => {
21180 if let common::Retry::After(d) = dlg.http_error(&err) {
21181 sleep(d).await;
21182 continue;
21183 }
21184 dlg.finished(false);
21185 return Err(common::Error::HttpError(err));
21186 }
21187 Ok(res) => {
21188 let (mut parts, body) = res.into_parts();
21189 let mut body = common::Body::new(body);
21190 if !parts.status.is_success() {
21191 let bytes = common::to_bytes(body).await.unwrap_or_default();
21192 let error = serde_json::from_str(&common::to_string(&bytes));
21193 let response = common::to_response(parts, bytes.into());
21194
21195 if let common::Retry::After(d) =
21196 dlg.http_failure(&response, error.as_ref().ok())
21197 {
21198 sleep(d).await;
21199 continue;
21200 }
21201
21202 dlg.finished(false);
21203
21204 return Err(match error {
21205 Ok(value) => common::Error::BadRequest(value),
21206 _ => common::Error::Failure(response),
21207 });
21208 }
21209 let response = {
21210 let bytes = common::to_bytes(body).await.unwrap_or_default();
21211 let encoded = common::to_string(&bytes);
21212 match serde_json::from_str(&encoded) {
21213 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21214 Err(error) => {
21215 dlg.response_json_decode_error(&encoded, &error);
21216 return Err(common::Error::JsonDecodeError(
21217 encoded.to_string(),
21218 error,
21219 ));
21220 }
21221 }
21222 };
21223
21224 dlg.finished(true);
21225 return Ok(response);
21226 }
21227 }
21228 }
21229 }
21230
21231 /// Required. Resource name of the parent containing the listed services, either a project (https://cloud.google.com/monitoring/api/v3#project_name) or a Monitoring Metrics Scope. The formats are: projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER]
21232 ///
21233 /// Sets the *parent* path property to the given value.
21234 ///
21235 /// Even though the property as already been set when instantiating this call,
21236 /// we provide this method for API completeness.
21237 pub fn parent(mut self, new_value: &str) -> ServiceListCall<'a, C> {
21238 self._parent = new_value.to_string();
21239 self
21240 }
21241 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call.
21242 ///
21243 /// Sets the *page token* query property to the given value.
21244 pub fn page_token(mut self, new_value: &str) -> ServiceListCall<'a, C> {
21245 self._page_token = Some(new_value.to_string());
21246 self
21247 }
21248 /// A non-negative number that is the maximum number of results to return. When 0, use default page size.
21249 ///
21250 /// Sets the *page size* query property to the given value.
21251 pub fn page_size(mut self, new_value: i32) -> ServiceListCall<'a, C> {
21252 self._page_size = Some(new_value);
21253 self
21254 }
21255 /// A filter specifying what Services to return. The filter supports filtering on a particular service-identifier type or one of its attributes.To filter on a particular service-identifier type, the identifier_case refers to which option in the identifier field is populated. For example, the filter identifier_case = "CUSTOM" would match all services with a value for the custom field. Valid options include "CUSTOM", "APP_ENGINE", "MESH_ISTIO", and the other options listed at https://cloud.google.com/monitoring/api/ref_v3/rest/v3/services#ServiceTo filter on an attribute of a service-identifier type, apply the filter name by using the snake case of the service-identifier type and the attribute of that service-identifier type, and join the two with a period. For example, to filter by the meshUid field of the MeshIstio service-identifier type, you must filter on mesh_istio.mesh_uid = "123" to match all services with mesh UID "123". Service-identifier types and their attributes are described at https://cloud.google.com/monitoring/api/ref_v3/rest/v3/services#Service
21256 ///
21257 /// Sets the *filter* query property to the given value.
21258 pub fn filter(mut self, new_value: &str) -> ServiceListCall<'a, C> {
21259 self._filter = Some(new_value.to_string());
21260 self
21261 }
21262 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21263 /// while executing the actual API request.
21264 ///
21265 /// ````text
21266 /// It should be used to handle progress information, and to implement a certain level of resilience.
21267 /// ````
21268 ///
21269 /// Sets the *delegate* property to the given value.
21270 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceListCall<'a, C> {
21271 self._delegate = Some(new_value);
21272 self
21273 }
21274
21275 /// Set any additional parameter of the query string used in the request.
21276 /// It should be used to set parameters which are not yet available through their own
21277 /// setters.
21278 ///
21279 /// Please note that this method must not be used to set any of the known parameters
21280 /// which have their own setter method. If done anyway, the request will fail.
21281 ///
21282 /// # Additional Parameters
21283 ///
21284 /// * *$.xgafv* (query-string) - V1 error format.
21285 /// * *access_token* (query-string) - OAuth access token.
21286 /// * *alt* (query-string) - Data format for response.
21287 /// * *callback* (query-string) - JSONP
21288 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21289 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21290 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21291 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21292 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
21293 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21294 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21295 pub fn param<T>(mut self, name: T, value: T) -> ServiceListCall<'a, C>
21296 where
21297 T: AsRef<str>,
21298 {
21299 self._additional_params
21300 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21301 self
21302 }
21303
21304 /// Identifies the authorization scope for the method you are building.
21305 ///
21306 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21307 /// [`Scope::CloudPlatform`].
21308 ///
21309 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21310 /// tokens for more than one scope.
21311 ///
21312 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21313 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21314 /// sufficient, a read-write scope will do as well.
21315 pub fn add_scope<St>(mut self, scope: St) -> ServiceListCall<'a, C>
21316 where
21317 St: AsRef<str>,
21318 {
21319 self._scopes.insert(String::from(scope.as_ref()));
21320 self
21321 }
21322 /// Identifies the authorization scope(s) for the method you are building.
21323 ///
21324 /// See [`Self::add_scope()`] for details.
21325 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceListCall<'a, C>
21326 where
21327 I: IntoIterator<Item = St>,
21328 St: AsRef<str>,
21329 {
21330 self._scopes
21331 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21332 self
21333 }
21334
21335 /// Removes all scopes, and no default scope will be used either.
21336 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21337 /// for details).
21338 pub fn clear_scopes(mut self) -> ServiceListCall<'a, C> {
21339 self._scopes.clear();
21340 self
21341 }
21342}
21343
21344/// Update this Service.
21345///
21346/// A builder for the *patch* method supported by a *service* resource.
21347/// It is not used directly, but through a [`ServiceMethods`] instance.
21348///
21349/// # Example
21350///
21351/// Instantiate a resource method builder
21352///
21353/// ```test_harness,no_run
21354/// # extern crate hyper;
21355/// # extern crate hyper_rustls;
21356/// # extern crate google_monitoring3 as monitoring3;
21357/// use monitoring3::api::Service;
21358/// # async fn dox() {
21359/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21360///
21361/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21362/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21363/// # secret,
21364/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21365/// # ).build().await.unwrap();
21366///
21367/// # let client = hyper_util::client::legacy::Client::builder(
21368/// # hyper_util::rt::TokioExecutor::new()
21369/// # )
21370/// # .build(
21371/// # hyper_rustls::HttpsConnectorBuilder::new()
21372/// # .with_native_roots()
21373/// # .unwrap()
21374/// # .https_or_http()
21375/// # .enable_http1()
21376/// # .build()
21377/// # );
21378/// # let mut hub = Monitoring::new(client, auth);
21379/// // As the method needs a request, you would usually fill it with the desired information
21380/// // into the respective structure. Some of the parts shown here might not be applicable !
21381/// // Values shown here are possibly random and not representative !
21382/// let mut req = Service::default();
21383///
21384/// // You can configure optional parameters by calling the respective setters at will, and
21385/// // execute the final call using `doit()`.
21386/// // Values shown here are possibly random and not representative !
21387/// let result = hub.services().patch(req, "name")
21388/// .update_mask(FieldMask::new::<&str>(&[]))
21389/// .doit().await;
21390/// # }
21391/// ```
21392pub struct ServicePatchCall<'a, C>
21393where
21394 C: 'a,
21395{
21396 hub: &'a Monitoring<C>,
21397 _request: Service,
21398 _name: String,
21399 _update_mask: Option<common::FieldMask>,
21400 _delegate: Option<&'a mut dyn common::Delegate>,
21401 _additional_params: HashMap<String, String>,
21402 _scopes: BTreeSet<String>,
21403}
21404
21405impl<'a, C> common::CallBuilder for ServicePatchCall<'a, C> {}
21406
21407impl<'a, C> ServicePatchCall<'a, C>
21408where
21409 C: common::Connector,
21410{
21411 /// Perform the operation you have build so far.
21412 pub async fn doit(mut self) -> common::Result<(common::Response, Service)> {
21413 use std::borrow::Cow;
21414 use std::io::{Read, Seek};
21415
21416 use common::{url::Params, ToParts};
21417 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21418
21419 let mut dd = common::DefaultDelegate;
21420 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21421 dlg.begin(common::MethodInfo {
21422 id: "monitoring.services.patch",
21423 http_method: hyper::Method::PATCH,
21424 });
21425
21426 for &field in ["alt", "name", "updateMask"].iter() {
21427 if self._additional_params.contains_key(field) {
21428 dlg.finished(false);
21429 return Err(common::Error::FieldClash(field));
21430 }
21431 }
21432
21433 let mut params = Params::with_capacity(5 + self._additional_params.len());
21434 params.push("name", self._name);
21435 if let Some(value) = self._update_mask.as_ref() {
21436 params.push("updateMask", value.to_string());
21437 }
21438
21439 params.extend(self._additional_params.iter());
21440
21441 params.push("alt", "json");
21442 let mut url = self.hub._base_url.clone() + "v3/{+name}";
21443 if self._scopes.is_empty() {
21444 self._scopes
21445 .insert(Scope::CloudPlatform.as_ref().to_string());
21446 }
21447
21448 #[allow(clippy::single_element_loop)]
21449 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21450 url = params.uri_replacement(url, param_name, find_this, true);
21451 }
21452 {
21453 let to_remove = ["name"];
21454 params.remove_params(&to_remove);
21455 }
21456
21457 let url = params.parse_with_url(&url);
21458
21459 let mut json_mime_type = mime::APPLICATION_JSON;
21460 let mut request_value_reader = {
21461 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21462 common::remove_json_null_values(&mut value);
21463 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21464 serde_json::to_writer(&mut dst, &value).unwrap();
21465 dst
21466 };
21467 let request_size = request_value_reader
21468 .seek(std::io::SeekFrom::End(0))
21469 .unwrap();
21470 request_value_reader
21471 .seek(std::io::SeekFrom::Start(0))
21472 .unwrap();
21473
21474 loop {
21475 let token = match self
21476 .hub
21477 .auth
21478 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21479 .await
21480 {
21481 Ok(token) => token,
21482 Err(e) => match dlg.token(e) {
21483 Ok(token) => token,
21484 Err(e) => {
21485 dlg.finished(false);
21486 return Err(common::Error::MissingToken(e));
21487 }
21488 },
21489 };
21490 request_value_reader
21491 .seek(std::io::SeekFrom::Start(0))
21492 .unwrap();
21493 let mut req_result = {
21494 let client = &self.hub.client;
21495 dlg.pre_request();
21496 let mut req_builder = hyper::Request::builder()
21497 .method(hyper::Method::PATCH)
21498 .uri(url.as_str())
21499 .header(USER_AGENT, self.hub._user_agent.clone());
21500
21501 if let Some(token) = token.as_ref() {
21502 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21503 }
21504
21505 let request = req_builder
21506 .header(CONTENT_TYPE, json_mime_type.to_string())
21507 .header(CONTENT_LENGTH, request_size as u64)
21508 .body(common::to_body(
21509 request_value_reader.get_ref().clone().into(),
21510 ));
21511
21512 client.request(request.unwrap()).await
21513 };
21514
21515 match req_result {
21516 Err(err) => {
21517 if let common::Retry::After(d) = dlg.http_error(&err) {
21518 sleep(d).await;
21519 continue;
21520 }
21521 dlg.finished(false);
21522 return Err(common::Error::HttpError(err));
21523 }
21524 Ok(res) => {
21525 let (mut parts, body) = res.into_parts();
21526 let mut body = common::Body::new(body);
21527 if !parts.status.is_success() {
21528 let bytes = common::to_bytes(body).await.unwrap_or_default();
21529 let error = serde_json::from_str(&common::to_string(&bytes));
21530 let response = common::to_response(parts, bytes.into());
21531
21532 if let common::Retry::After(d) =
21533 dlg.http_failure(&response, error.as_ref().ok())
21534 {
21535 sleep(d).await;
21536 continue;
21537 }
21538
21539 dlg.finished(false);
21540
21541 return Err(match error {
21542 Ok(value) => common::Error::BadRequest(value),
21543 _ => common::Error::Failure(response),
21544 });
21545 }
21546 let response = {
21547 let bytes = common::to_bytes(body).await.unwrap_or_default();
21548 let encoded = common::to_string(&bytes);
21549 match serde_json::from_str(&encoded) {
21550 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21551 Err(error) => {
21552 dlg.response_json_decode_error(&encoded, &error);
21553 return Err(common::Error::JsonDecodeError(
21554 encoded.to_string(),
21555 error,
21556 ));
21557 }
21558 }
21559 };
21560
21561 dlg.finished(true);
21562 return Ok(response);
21563 }
21564 }
21565 }
21566 }
21567
21568 ///
21569 /// Sets the *request* property to the given value.
21570 ///
21571 /// Even though the property as already been set when instantiating this call,
21572 /// we provide this method for API completeness.
21573 pub fn request(mut self, new_value: Service) -> ServicePatchCall<'a, C> {
21574 self._request = new_value;
21575 self
21576 }
21577 /// Identifier. Resource name for this Service. The format is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
21578 ///
21579 /// Sets the *name* path property to the given value.
21580 ///
21581 /// Even though the property as already been set when instantiating this call,
21582 /// we provide this method for API completeness.
21583 pub fn name(mut self, new_value: &str) -> ServicePatchCall<'a, C> {
21584 self._name = new_value.to_string();
21585 self
21586 }
21587 /// A set of field paths defining which fields to use for the update.
21588 ///
21589 /// Sets the *update mask* query property to the given value.
21590 pub fn update_mask(mut self, new_value: common::FieldMask) -> ServicePatchCall<'a, C> {
21591 self._update_mask = Some(new_value);
21592 self
21593 }
21594 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21595 /// while executing the actual API request.
21596 ///
21597 /// ````text
21598 /// It should be used to handle progress information, and to implement a certain level of resilience.
21599 /// ````
21600 ///
21601 /// Sets the *delegate* property to the given value.
21602 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServicePatchCall<'a, C> {
21603 self._delegate = Some(new_value);
21604 self
21605 }
21606
21607 /// Set any additional parameter of the query string used in the request.
21608 /// It should be used to set parameters which are not yet available through their own
21609 /// setters.
21610 ///
21611 /// Please note that this method must not be used to set any of the known parameters
21612 /// which have their own setter method. If done anyway, the request will fail.
21613 ///
21614 /// # Additional Parameters
21615 ///
21616 /// * *$.xgafv* (query-string) - V1 error format.
21617 /// * *access_token* (query-string) - OAuth access token.
21618 /// * *alt* (query-string) - Data format for response.
21619 /// * *callback* (query-string) - JSONP
21620 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21621 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21622 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21623 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21624 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
21625 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21626 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21627 pub fn param<T>(mut self, name: T, value: T) -> ServicePatchCall<'a, C>
21628 where
21629 T: AsRef<str>,
21630 {
21631 self._additional_params
21632 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21633 self
21634 }
21635
21636 /// Identifies the authorization scope for the method you are building.
21637 ///
21638 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21639 /// [`Scope::CloudPlatform`].
21640 ///
21641 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21642 /// tokens for more than one scope.
21643 ///
21644 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21645 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21646 /// sufficient, a read-write scope will do as well.
21647 pub fn add_scope<St>(mut self, scope: St) -> ServicePatchCall<'a, C>
21648 where
21649 St: AsRef<str>,
21650 {
21651 self._scopes.insert(String::from(scope.as_ref()));
21652 self
21653 }
21654 /// Identifies the authorization scope(s) for the method you are building.
21655 ///
21656 /// See [`Self::add_scope()`] for details.
21657 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServicePatchCall<'a, C>
21658 where
21659 I: IntoIterator<Item = St>,
21660 St: AsRef<str>,
21661 {
21662 self._scopes
21663 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21664 self
21665 }
21666
21667 /// Removes all scopes, and no default scope will be used either.
21668 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21669 /// for details).
21670 pub fn clear_scopes(mut self) -> ServicePatchCall<'a, C> {
21671 self._scopes.clear();
21672 self
21673 }
21674}
21675
21676/// Returns the list of IP addresses that checkers run from.
21677///
21678/// A builder for the *list* method supported by a *uptimeCheckIp* resource.
21679/// It is not used directly, but through a [`UptimeCheckIpMethods`] instance.
21680///
21681/// # Example
21682///
21683/// Instantiate a resource method builder
21684///
21685/// ```test_harness,no_run
21686/// # extern crate hyper;
21687/// # extern crate hyper_rustls;
21688/// # extern crate google_monitoring3 as monitoring3;
21689/// # async fn dox() {
21690/// # use monitoring3::{Monitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21691///
21692/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21693/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21694/// # secret,
21695/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21696/// # ).build().await.unwrap();
21697///
21698/// # let client = hyper_util::client::legacy::Client::builder(
21699/// # hyper_util::rt::TokioExecutor::new()
21700/// # )
21701/// # .build(
21702/// # hyper_rustls::HttpsConnectorBuilder::new()
21703/// # .with_native_roots()
21704/// # .unwrap()
21705/// # .https_or_http()
21706/// # .enable_http1()
21707/// # .build()
21708/// # );
21709/// # let mut hub = Monitoring::new(client, auth);
21710/// // You can configure optional parameters by calling the respective setters at will, and
21711/// // execute the final call using `doit()`.
21712/// // Values shown here are possibly random and not representative !
21713/// let result = hub.uptime_check_ips().list()
21714/// .page_token("eirmod")
21715/// .page_size(-51)
21716/// .doit().await;
21717/// # }
21718/// ```
21719pub struct UptimeCheckIpListCall<'a, C>
21720where
21721 C: 'a,
21722{
21723 hub: &'a Monitoring<C>,
21724 _page_token: Option<String>,
21725 _page_size: Option<i32>,
21726 _delegate: Option<&'a mut dyn common::Delegate>,
21727 _additional_params: HashMap<String, String>,
21728 _scopes: BTreeSet<String>,
21729}
21730
21731impl<'a, C> common::CallBuilder for UptimeCheckIpListCall<'a, C> {}
21732
21733impl<'a, C> UptimeCheckIpListCall<'a, C>
21734where
21735 C: common::Connector,
21736{
21737 /// Perform the operation you have build so far.
21738 pub async fn doit(mut self) -> common::Result<(common::Response, ListUptimeCheckIpsResponse)> {
21739 use std::borrow::Cow;
21740 use std::io::{Read, Seek};
21741
21742 use common::{url::Params, ToParts};
21743 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21744
21745 let mut dd = common::DefaultDelegate;
21746 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21747 dlg.begin(common::MethodInfo {
21748 id: "monitoring.uptimeCheckIps.list",
21749 http_method: hyper::Method::GET,
21750 });
21751
21752 for &field in ["alt", "pageToken", "pageSize"].iter() {
21753 if self._additional_params.contains_key(field) {
21754 dlg.finished(false);
21755 return Err(common::Error::FieldClash(field));
21756 }
21757 }
21758
21759 let mut params = Params::with_capacity(4 + self._additional_params.len());
21760 if let Some(value) = self._page_token.as_ref() {
21761 params.push("pageToken", value);
21762 }
21763 if let Some(value) = self._page_size.as_ref() {
21764 params.push("pageSize", value.to_string());
21765 }
21766
21767 params.extend(self._additional_params.iter());
21768
21769 params.push("alt", "json");
21770 let mut url = self.hub._base_url.clone() + "v3/uptimeCheckIps";
21771 if self._scopes.is_empty() {
21772 self._scopes
21773 .insert(Scope::CloudPlatform.as_ref().to_string());
21774 }
21775
21776 let url = params.parse_with_url(&url);
21777
21778 loop {
21779 let token = match self
21780 .hub
21781 .auth
21782 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21783 .await
21784 {
21785 Ok(token) => token,
21786 Err(e) => match dlg.token(e) {
21787 Ok(token) => token,
21788 Err(e) => {
21789 dlg.finished(false);
21790 return Err(common::Error::MissingToken(e));
21791 }
21792 },
21793 };
21794 let mut req_result = {
21795 let client = &self.hub.client;
21796 dlg.pre_request();
21797 let mut req_builder = hyper::Request::builder()
21798 .method(hyper::Method::GET)
21799 .uri(url.as_str())
21800 .header(USER_AGENT, self.hub._user_agent.clone());
21801
21802 if let Some(token) = token.as_ref() {
21803 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21804 }
21805
21806 let request = req_builder
21807 .header(CONTENT_LENGTH, 0_u64)
21808 .body(common::to_body::<String>(None));
21809
21810 client.request(request.unwrap()).await
21811 };
21812
21813 match req_result {
21814 Err(err) => {
21815 if let common::Retry::After(d) = dlg.http_error(&err) {
21816 sleep(d).await;
21817 continue;
21818 }
21819 dlg.finished(false);
21820 return Err(common::Error::HttpError(err));
21821 }
21822 Ok(res) => {
21823 let (mut parts, body) = res.into_parts();
21824 let mut body = common::Body::new(body);
21825 if !parts.status.is_success() {
21826 let bytes = common::to_bytes(body).await.unwrap_or_default();
21827 let error = serde_json::from_str(&common::to_string(&bytes));
21828 let response = common::to_response(parts, bytes.into());
21829
21830 if let common::Retry::After(d) =
21831 dlg.http_failure(&response, error.as_ref().ok())
21832 {
21833 sleep(d).await;
21834 continue;
21835 }
21836
21837 dlg.finished(false);
21838
21839 return Err(match error {
21840 Ok(value) => common::Error::BadRequest(value),
21841 _ => common::Error::Failure(response),
21842 });
21843 }
21844 let response = {
21845 let bytes = common::to_bytes(body).await.unwrap_or_default();
21846 let encoded = common::to_string(&bytes);
21847 match serde_json::from_str(&encoded) {
21848 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21849 Err(error) => {
21850 dlg.response_json_decode_error(&encoded, &error);
21851 return Err(common::Error::JsonDecodeError(
21852 encoded.to_string(),
21853 error,
21854 ));
21855 }
21856 }
21857 };
21858
21859 dlg.finished(true);
21860 return Ok(response);
21861 }
21862 }
21863 }
21864 }
21865
21866 /// If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return more results from the previous method call. NOTE: this field is not yet implemented
21867 ///
21868 /// Sets the *page token* query property to the given value.
21869 pub fn page_token(mut self, new_value: &str) -> UptimeCheckIpListCall<'a, C> {
21870 self._page_token = Some(new_value.to_string());
21871 self
21872 }
21873 /// The maximum number of results to return in a single response. The server may further constrain the maximum number of results returned in a single page. If the page_size is <=0, the server will decide the number of results to be returned. NOTE: this field is not yet implemented
21874 ///
21875 /// Sets the *page size* query property to the given value.
21876 pub fn page_size(mut self, new_value: i32) -> UptimeCheckIpListCall<'a, C> {
21877 self._page_size = Some(new_value);
21878 self
21879 }
21880 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21881 /// while executing the actual API request.
21882 ///
21883 /// ````text
21884 /// It should be used to handle progress information, and to implement a certain level of resilience.
21885 /// ````
21886 ///
21887 /// Sets the *delegate* property to the given value.
21888 pub fn delegate(
21889 mut self,
21890 new_value: &'a mut dyn common::Delegate,
21891 ) -> UptimeCheckIpListCall<'a, C> {
21892 self._delegate = Some(new_value);
21893 self
21894 }
21895
21896 /// Set any additional parameter of the query string used in the request.
21897 /// It should be used to set parameters which are not yet available through their own
21898 /// setters.
21899 ///
21900 /// Please note that this method must not be used to set any of the known parameters
21901 /// which have their own setter method. If done anyway, the request will fail.
21902 ///
21903 /// # Additional Parameters
21904 ///
21905 /// * *$.xgafv* (query-string) - V1 error format.
21906 /// * *access_token* (query-string) - OAuth access token.
21907 /// * *alt* (query-string) - Data format for response.
21908 /// * *callback* (query-string) - JSONP
21909 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21910 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21911 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21912 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21913 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
21914 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21915 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21916 pub fn param<T>(mut self, name: T, value: T) -> UptimeCheckIpListCall<'a, C>
21917 where
21918 T: AsRef<str>,
21919 {
21920 self._additional_params
21921 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21922 self
21923 }
21924
21925 /// Identifies the authorization scope for the method you are building.
21926 ///
21927 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21928 /// [`Scope::CloudPlatform`].
21929 ///
21930 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21931 /// tokens for more than one scope.
21932 ///
21933 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21934 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21935 /// sufficient, a read-write scope will do as well.
21936 pub fn add_scope<St>(mut self, scope: St) -> UptimeCheckIpListCall<'a, C>
21937 where
21938 St: AsRef<str>,
21939 {
21940 self._scopes.insert(String::from(scope.as_ref()));
21941 self
21942 }
21943 /// Identifies the authorization scope(s) for the method you are building.
21944 ///
21945 /// See [`Self::add_scope()`] for details.
21946 pub fn add_scopes<I, St>(mut self, scopes: I) -> UptimeCheckIpListCall<'a, C>
21947 where
21948 I: IntoIterator<Item = St>,
21949 St: AsRef<str>,
21950 {
21951 self._scopes
21952 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21953 self
21954 }
21955
21956 /// Removes all scopes, and no default scope will be used either.
21957 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21958 /// for details).
21959 pub fn clear_scopes(mut self) -> UptimeCheckIpListCall<'a, C> {
21960 self._scopes.clear();
21961 self
21962 }
21963}