google_cloudmonitoring2_beta2/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 /// View and manage your data across Google Cloud Platform services
17 CloudPlatform,
18
19 /// View and write monitoring data for all of your Google and third-party Cloud and API projects
20 Monitoring,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27 Scope::Monitoring => "https://www.googleapis.com/auth/monitoring",
28 }
29 }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34 fn default() -> Scope {
35 Scope::Monitoring
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all CloudMonitoring related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_cloudmonitoring2_beta2 as cloudmonitoring2_beta2;
53/// use cloudmonitoring2_beta2::api::ListMetricDescriptorsRequest;
54/// use cloudmonitoring2_beta2::{Result, Error};
55/// # async fn dox() {
56/// use cloudmonitoring2_beta2::{CloudMonitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67/// .with_native_roots()
68/// .unwrap()
69/// .https_only()
70/// .enable_http2()
71/// .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75/// secret,
76/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77/// yup_oauth2::client::CustomHyperClientBuilder::from(
78/// hyper_util::client::legacy::Client::builder(executor).build(connector),
79/// ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83/// hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86/// hyper_rustls::HttpsConnectorBuilder::new()
87/// .with_native_roots()
88/// .unwrap()
89/// .https_or_http()
90/// .enable_http2()
91/// .build()
92/// );
93/// let mut hub = CloudMonitoring::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = ListMetricDescriptorsRequest::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.metric_descriptors().list(req, "project")
103/// .query("takimata")
104/// .page_token("amet.")
105/// .count(-20)
106/// .doit().await;
107///
108/// match result {
109/// Err(e) => match e {
110/// // The Error enum provides details about what exactly happened.
111/// // You can also just use its `Debug`, `Display` or `Error` traits
112/// Error::HttpError(_)
113/// |Error::Io(_)
114/// |Error::MissingAPIKey
115/// |Error::MissingToken(_)
116/// |Error::Cancelled
117/// |Error::UploadSizeLimitExceeded(_, _)
118/// |Error::Failure(_)
119/// |Error::BadRequest(_)
120/// |Error::FieldClash(_)
121/// |Error::JsonDecodeError(_, _) => println!("{}", e),
122/// },
123/// Ok(res) => println!("Success: {:?}", res),
124/// }
125/// # }
126/// ```
127#[derive(Clone)]
128pub struct CloudMonitoring<C> {
129 pub client: common::Client<C>,
130 pub auth: Box<dyn common::GetToken>,
131 _user_agent: String,
132 _base_url: String,
133 _root_url: String,
134}
135
136impl<C> common::Hub for CloudMonitoring<C> {}
137
138impl<'a, C> CloudMonitoring<C> {
139 pub fn new<A: 'static + common::GetToken>(
140 client: common::Client<C>,
141 auth: A,
142 ) -> CloudMonitoring<C> {
143 CloudMonitoring {
144 client,
145 auth: Box::new(auth),
146 _user_agent: "google-api-rust-client/7.0.0".to_string(),
147 _base_url: "https://www.googleapis.com/cloudmonitoring/v2beta2/projects/".to_string(),
148 _root_url: "https://www.googleapis.com/".to_string(),
149 }
150 }
151
152 pub fn metric_descriptors(&'a self) -> MetricDescriptorMethods<'a, C> {
153 MetricDescriptorMethods { hub: self }
154 }
155 pub fn timeseries(&'a self) -> TimeseryMethods<'a, C> {
156 TimeseryMethods { hub: self }
157 }
158 pub fn timeseries_descriptors(&'a self) -> TimeseriesDescriptorMethods<'a, C> {
159 TimeseriesDescriptorMethods { hub: self }
160 }
161
162 /// Set the user-agent header field to use in all requests to the server.
163 /// It defaults to `google-api-rust-client/7.0.0`.
164 ///
165 /// Returns the previously set user-agent.
166 pub fn user_agent(&mut self, agent_name: String) -> String {
167 std::mem::replace(&mut self._user_agent, agent_name)
168 }
169
170 /// Set the base url to use in all requests to the server.
171 /// It defaults to `https://www.googleapis.com/cloudmonitoring/v2beta2/projects/`.
172 ///
173 /// Returns the previously set base url.
174 pub fn base_url(&mut self, new_base_url: String) -> String {
175 std::mem::replace(&mut self._base_url, new_base_url)
176 }
177
178 /// Set the root url to use in all requests to the server.
179 /// It defaults to `https://www.googleapis.com/`.
180 ///
181 /// Returns the previously set root url.
182 pub fn root_url(&mut self, new_root_url: String) -> String {
183 std::mem::replace(&mut self._root_url, new_root_url)
184 }
185}
186
187// ############
188// SCHEMAS ###
189// ##########
190/// The response of cloudmonitoring.metricDescriptors.delete.
191///
192/// # Activities
193///
194/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
195/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
196///
197/// * [delete metric descriptors](MetricDescriptorDeleteCall) (response)
198#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
199#[serde_with::serde_as]
200#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
201pub struct DeleteMetricDescriptorResponse {
202 /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#deleteMetricDescriptorResponse".
203 pub kind: Option<String>,
204}
205
206impl common::ResponseResult for DeleteMetricDescriptorResponse {}
207
208/// The request of cloudmonitoring.metricDescriptors.list.
209///
210/// # Activities
211///
212/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
213/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
214///
215/// * [list metric descriptors](MetricDescriptorListCall) (request)
216#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
217#[serde_with::serde_as]
218#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
219pub struct ListMetricDescriptorsRequest {
220 /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#listMetricDescriptorsRequest".
221 pub kind: Option<String>,
222}
223
224impl common::RequestValue for ListMetricDescriptorsRequest {}
225
226/// The response of cloudmonitoring.metricDescriptors.list.
227///
228/// # Activities
229///
230/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
231/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
232///
233/// * [list metric descriptors](MetricDescriptorListCall) (response)
234#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
235#[serde_with::serde_as]
236#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
237pub struct ListMetricDescriptorsResponse {
238 /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#listMetricDescriptorsResponse".
239 pub kind: Option<String>,
240 /// The returned metric descriptors.
241 pub metrics: Option<Vec<MetricDescriptor>>,
242 /// Pagination token. If present, indicates that additional results are available for retrieval. To access the results past the pagination limit, pass this value to the pageToken query parameter.
243 #[serde(rename = "nextPageToken")]
244 pub next_page_token: Option<String>,
245}
246
247impl common::ResponseResult for ListMetricDescriptorsResponse {}
248
249/// The request of cloudmonitoring.timeseriesDescriptors.list
250///
251/// # Activities
252///
253/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
254/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
255///
256/// * [list timeseries descriptors](TimeseriesDescriptorListCall) (request)
257#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
258#[serde_with::serde_as]
259#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
260pub struct ListTimeseriesDescriptorsRequest {
261 /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#listTimeseriesDescriptorsRequest".
262 pub kind: Option<String>,
263}
264
265impl common::RequestValue for ListTimeseriesDescriptorsRequest {}
266
267/// The response of cloudmonitoring.timeseriesDescriptors.list
268///
269/// # Activities
270///
271/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
272/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
273///
274/// * [list timeseries descriptors](TimeseriesDescriptorListCall) (response)
275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
276#[serde_with::serde_as]
277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
278pub struct ListTimeseriesDescriptorsResponse {
279 /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#listTimeseriesDescriptorsResponse".
280 pub kind: Option<String>,
281 /// Pagination token. If present, indicates that additional results are available for retrieval. To access the results past the pagination limit, set this value to the pageToken query parameter.
282 #[serde(rename = "nextPageToken")]
283 pub next_page_token: Option<String>,
284 /// The oldest timestamp of the interval of this query, as an RFC 3339 string.
285 pub oldest: Option<chrono::DateTime<chrono::offset::Utc>>,
286 /// The returned time series descriptors.
287 pub timeseries: Option<Vec<TimeseriesDescriptor>>,
288 /// The youngest timestamp of the interval of this query, as an RFC 3339 string.
289 pub youngest: Option<chrono::DateTime<chrono::offset::Utc>>,
290}
291
292impl common::ResponseResult for ListTimeseriesDescriptorsResponse {}
293
294/// The request of cloudmonitoring.timeseries.list
295///
296/// # Activities
297///
298/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
299/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
300///
301/// * [list timeseries](TimeseryListCall) (request)
302#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
303#[serde_with::serde_as]
304#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
305pub struct ListTimeseriesRequest {
306 /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#listTimeseriesRequest".
307 pub kind: Option<String>,
308}
309
310impl common::RequestValue for ListTimeseriesRequest {}
311
312/// The response of cloudmonitoring.timeseries.list
313///
314/// # Activities
315///
316/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
317/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
318///
319/// * [list timeseries](TimeseryListCall) (response)
320#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
321#[serde_with::serde_as]
322#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
323pub struct ListTimeseriesResponse {
324 /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#listTimeseriesResponse".
325 pub kind: Option<String>,
326 /// Pagination token. If present, indicates that additional results are available for retrieval. To access the results past the pagination limit, set the pageToken query parameter to this value. All of the points of a time series will be returned before returning any point of the subsequent time series.
327 #[serde(rename = "nextPageToken")]
328 pub next_page_token: Option<String>,
329 /// The oldest timestamp of the interval of this query as an RFC 3339 string.
330 pub oldest: Option<chrono::DateTime<chrono::offset::Utc>>,
331 /// The returned time series.
332 pub timeseries: Option<Vec<Timeseries>>,
333 /// The youngest timestamp of the interval of this query as an RFC 3339 string.
334 pub youngest: Option<chrono::DateTime<chrono::offset::Utc>>,
335}
336
337impl common::ResponseResult for ListTimeseriesResponse {}
338
339/// A metricDescriptor defines the name, label keys, and data type of a particular metric.
340///
341/// # Activities
342///
343/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
344/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
345///
346/// * [create metric descriptors](MetricDescriptorCreateCall) (request|response)
347/// * [delete metric descriptors](MetricDescriptorDeleteCall) (none)
348/// * [list metric descriptors](MetricDescriptorListCall) (none)
349#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
350#[serde_with::serde_as]
351#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
352pub struct MetricDescriptor {
353 /// Description of this metric.
354 pub description: Option<String>,
355 /// Labels defined for this metric.
356 pub labels: Option<Vec<MetricDescriptorLabelDescriptor>>,
357 /// The name of this metric.
358 pub name: Option<String>,
359 /// The project ID to which the metric belongs.
360 pub project: Option<String>,
361 /// Type description for this metric.
362 #[serde(rename = "typeDescriptor")]
363 pub type_descriptor: Option<MetricDescriptorTypeDescriptor>,
364}
365
366impl common::RequestValue for MetricDescriptor {}
367impl common::Resource for MetricDescriptor {}
368impl common::ResponseResult for MetricDescriptor {}
369
370/// A label in a metric is a description of this metric, including the key of this description (what the description is), and the value for this description.
371///
372/// This type is not used in any activity, and only used as *part* of another schema.
373///
374#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
375#[serde_with::serde_as]
376#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
377pub struct MetricDescriptorLabelDescriptor {
378 /// Label description.
379 pub description: Option<String>,
380 /// Label key.
381 pub key: Option<String>,
382}
383
384impl common::Part for MetricDescriptorLabelDescriptor {}
385
386/// A type in a metric contains information about how the metric is collected and what its data points look like.
387///
388/// This type is not used in any activity, and only used as *part* of another schema.
389///
390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
391#[serde_with::serde_as]
392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
393pub struct MetricDescriptorTypeDescriptor {
394 /// The method of collecting data for the metric. See Metric types.
395 #[serde(rename = "metricType")]
396 pub metric_type: Option<String>,
397 /// The data type of of individual points in the metric's time series. See Metric value types.
398 #[serde(rename = "valueType")]
399 pub value_type: Option<String>,
400}
401
402impl common::Part for MetricDescriptorTypeDescriptor {}
403
404/// Point is a single point in a time series. It consists of a start time, an end time, and a value.
405///
406/// This type is not used in any activity, and only used as *part* of another schema.
407///
408#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
409#[serde_with::serde_as]
410#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
411pub struct Point {
412 /// The value of this data point. Either "true" or "false".
413 #[serde(rename = "boolValue")]
414 pub bool_value: Option<bool>,
415 /// The value of this data point as a distribution. A distribution value can contain a list of buckets and/or an underflowBucket and an overflowBucket. The values of these points can be used to create a histogram.
416 #[serde(rename = "distributionValue")]
417 pub distribution_value: Option<PointDistribution>,
418 /// The value of this data point as a double-precision floating-point number.
419 #[serde(rename = "doubleValue")]
420 pub double_value: Option<f64>,
421 /// The interval [start, end] is the time period to which the point's value applies. For gauge metrics, whose values are instantaneous measurements, this interval should be empty (start should equal end). For cumulative metrics (of which deltas and rates are special cases), the interval should be non-empty. Both start and end are RFC 3339 strings.
422 pub end: Option<chrono::DateTime<chrono::offset::Utc>>,
423 /// The value of this data point as a 64-bit integer.
424 #[serde(rename = "int64Value")]
425 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
426 pub int64_value: Option<i64>,
427 /// The interval [start, end] is the time period to which the point's value applies. For gauge metrics, whose values are instantaneous measurements, this interval should be empty (start should equal end). For cumulative metrics (of which deltas and rates are special cases), the interval should be non-empty. Both start and end are RFC 3339 strings.
428 pub start: Option<chrono::DateTime<chrono::offset::Utc>>,
429 /// The value of this data point in string format.
430 #[serde(rename = "stringValue")]
431 pub string_value: Option<String>,
432}
433
434impl common::Part for Point {}
435
436/// Distribution data point value type. When writing distribution points, try to be consistent with the boundaries of your buckets. If you must modify the bucket boundaries, then do so by merging, partitioning, or appending rather than skewing them.
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 PointDistribution {
444 /// The finite buckets.
445 pub buckets: Option<Vec<PointDistributionBucket>>,
446 /// The overflow bucket.
447 #[serde(rename = "overflowBucket")]
448 pub overflow_bucket: Option<PointDistributionOverflowBucket>,
449 /// The underflow bucket.
450 #[serde(rename = "underflowBucket")]
451 pub underflow_bucket: Option<PointDistributionUnderflowBucket>,
452}
453
454impl common::Part for PointDistribution {}
455
456/// The histogram's bucket. Buckets that form the histogram of a distribution value. If the upper bound of a bucket, say U1, does not equal the lower bound of the next bucket, say L2, this means that there is no event in [U1, L2).
457///
458/// This type is not used in any activity, and only used as *part* of another schema.
459///
460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
461#[serde_with::serde_as]
462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
463pub struct PointDistributionBucket {
464 /// The number of events whose values are in the interval defined by this bucket.
465 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
466 pub count: Option<i64>,
467 /// The lower bound of the value interval of this bucket (inclusive).
468 #[serde(rename = "lowerBound")]
469 pub lower_bound: Option<f64>,
470 /// The upper bound of the value interval of this bucket (exclusive).
471 #[serde(rename = "upperBound")]
472 pub upper_bound: Option<f64>,
473}
474
475impl common::Part for PointDistributionBucket {}
476
477/// The overflow bucket is a special bucket that does not have the upperBound field; it includes all of the events that are no less than its lower bound.
478///
479/// This type is not used in any activity, and only used as *part* of another schema.
480///
481#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
482#[serde_with::serde_as]
483#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
484pub struct PointDistributionOverflowBucket {
485 /// The number of events whose values are in the interval defined by this bucket.
486 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
487 pub count: Option<i64>,
488 /// The lower bound of the value interval of this bucket (inclusive).
489 #[serde(rename = "lowerBound")]
490 pub lower_bound: Option<f64>,
491}
492
493impl common::Part for PointDistributionOverflowBucket {}
494
495/// The underflow bucket is a special bucket that does not have the lowerBound field; it includes all of the events that are less than its upper bound.
496///
497/// This type is not used in any activity, and only used as *part* of another schema.
498///
499#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
500#[serde_with::serde_as]
501#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
502pub struct PointDistributionUnderflowBucket {
503 /// The number of events whose values are in the interval defined by this bucket.
504 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
505 pub count: Option<i64>,
506 /// The upper bound of the value interval of this bucket (exclusive).
507 #[serde(rename = "upperBound")]
508 pub upper_bound: Option<f64>,
509}
510
511impl common::Part for PointDistributionUnderflowBucket {}
512
513/// The monitoring data is organized as metrics and stored as data points that are recorded over time. Each data point represents information like the CPU utilization of your virtual machine. A historical record of these data points is called a time series.
514///
515/// This type is not used in any activity, and only used as *part* of another schema.
516///
517#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
518#[serde_with::serde_as]
519#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
520pub struct Timeseries {
521 /// The data points of this time series. The points are listed in order of their end timestamp, from younger to older.
522 pub points: Option<Vec<Point>>,
523 /// The descriptor of this time series.
524 #[serde(rename = "timeseriesDesc")]
525 pub timeseries_desc: Option<TimeseriesDescriptor>,
526}
527
528impl common::Part for Timeseries {}
529
530/// TimeseriesDescriptor identifies a single time series.
531///
532/// # Activities
533///
534/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
535/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
536///
537/// * [list timeseries descriptors](TimeseriesDescriptorListCall) (none)
538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
539#[serde_with::serde_as]
540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
541pub struct TimeseriesDescriptor {
542 /// The label's name.
543 pub labels: Option<HashMap<String, String>>,
544 /// The name of the metric.
545 pub metric: Option<String>,
546 /// The Developers Console project number to which this time series belongs.
547 pub project: Option<String>,
548}
549
550impl common::Resource for TimeseriesDescriptor {}
551
552/// When writing time series, TimeseriesPoint should be used instead of Timeseries, to enforce single point for each time series in the timeseries.write request.
553///
554/// This type is not used in any activity, and only used as *part* of another schema.
555///
556#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
557#[serde_with::serde_as]
558#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
559pub struct TimeseriesPoint {
560 /// The data point in this time series snapshot.
561 pub point: Option<Point>,
562 /// The descriptor of this time series.
563 #[serde(rename = "timeseriesDesc")]
564 pub timeseries_desc: Option<TimeseriesDescriptor>,
565}
566
567impl common::Part for TimeseriesPoint {}
568
569/// The request of cloudmonitoring.timeseries.write
570///
571/// # Activities
572///
573/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
574/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
575///
576/// * [write timeseries](TimeseryWriteCall) (request)
577#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
578#[serde_with::serde_as]
579#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
580pub struct WriteTimeseriesRequest {
581 /// The label's name.
582 #[serde(rename = "commonLabels")]
583 pub common_labels: Option<HashMap<String, String>>,
584 /// Provide time series specific labels and the data points for each time series. The labels in timeseries and the common_labels should form a complete list of labels that required by the metric.
585 pub timeseries: Option<Vec<TimeseriesPoint>>,
586}
587
588impl common::RequestValue for WriteTimeseriesRequest {}
589
590/// The response of cloudmonitoring.timeseries.write
591///
592/// # Activities
593///
594/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
595/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
596///
597/// * [write timeseries](TimeseryWriteCall) (response)
598#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
599#[serde_with::serde_as]
600#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
601pub struct WriteTimeseriesResponse {
602 /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#writeTimeseriesResponse".
603 pub kind: Option<String>,
604}
605
606impl common::ResponseResult for WriteTimeseriesResponse {}
607
608// ###################
609// MethodBuilders ###
610// #################
611
612/// A builder providing access to all methods supported on *metricDescriptor* resources.
613/// It is not used directly, but through the [`CloudMonitoring`] hub.
614///
615/// # Example
616///
617/// Instantiate a resource builder
618///
619/// ```test_harness,no_run
620/// extern crate hyper;
621/// extern crate hyper_rustls;
622/// extern crate google_cloudmonitoring2_beta2 as cloudmonitoring2_beta2;
623///
624/// # async fn dox() {
625/// use cloudmonitoring2_beta2::{CloudMonitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
626///
627/// let secret: yup_oauth2::ApplicationSecret = Default::default();
628/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
629/// .with_native_roots()
630/// .unwrap()
631/// .https_only()
632/// .enable_http2()
633/// .build();
634///
635/// let executor = hyper_util::rt::TokioExecutor::new();
636/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
637/// secret,
638/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
639/// yup_oauth2::client::CustomHyperClientBuilder::from(
640/// hyper_util::client::legacy::Client::builder(executor).build(connector),
641/// ),
642/// ).build().await.unwrap();
643///
644/// let client = hyper_util::client::legacy::Client::builder(
645/// hyper_util::rt::TokioExecutor::new()
646/// )
647/// .build(
648/// hyper_rustls::HttpsConnectorBuilder::new()
649/// .with_native_roots()
650/// .unwrap()
651/// .https_or_http()
652/// .enable_http2()
653/// .build()
654/// );
655/// let mut hub = CloudMonitoring::new(client, auth);
656/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
657/// // like `create(...)`, `delete(...)` and `list(...)`
658/// // to build up your call.
659/// let rb = hub.metric_descriptors();
660/// # }
661/// ```
662pub struct MetricDescriptorMethods<'a, C>
663where
664 C: 'a,
665{
666 hub: &'a CloudMonitoring<C>,
667}
668
669impl<'a, C> common::MethodsBuilder for MetricDescriptorMethods<'a, C> {}
670
671impl<'a, C> MetricDescriptorMethods<'a, C> {
672 /// Create a builder to help you perform the following task:
673 ///
674 /// Create a new metric.
675 ///
676 /// # Arguments
677 ///
678 /// * `request` - No description provided.
679 /// * `project` - The project id. The value can be the numeric project ID or string-based project name.
680 pub fn create(
681 &self,
682 request: MetricDescriptor,
683 project: &str,
684 ) -> MetricDescriptorCreateCall<'a, C> {
685 MetricDescriptorCreateCall {
686 hub: self.hub,
687 _request: request,
688 _project: project.to_string(),
689 _delegate: Default::default(),
690 _additional_params: Default::default(),
691 _scopes: Default::default(),
692 }
693 }
694
695 /// Create a builder to help you perform the following task:
696 ///
697 /// Delete an existing metric.
698 ///
699 /// # Arguments
700 ///
701 /// * `project` - The project ID to which the metric belongs.
702 /// * `metric` - Name of the metric.
703 pub fn delete(&self, project: &str, metric: &str) -> MetricDescriptorDeleteCall<'a, C> {
704 MetricDescriptorDeleteCall {
705 hub: self.hub,
706 _project: project.to_string(),
707 _metric: metric.to_string(),
708 _delegate: Default::default(),
709 _additional_params: Default::default(),
710 _scopes: Default::default(),
711 }
712 }
713
714 /// Create a builder to help you perform the following task:
715 ///
716 /// List metric descriptors that match the query. If the query is not set, then all of the metric descriptors will be returned. Large responses will be paginated, use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.
717 ///
718 /// # Arguments
719 ///
720 /// * `request` - No description provided.
721 /// * `project` - The project id. The value can be the numeric project ID or string-based project name.
722 pub fn list(
723 &self,
724 request: ListMetricDescriptorsRequest,
725 project: &str,
726 ) -> MetricDescriptorListCall<'a, C> {
727 MetricDescriptorListCall {
728 hub: self.hub,
729 _request: request,
730 _project: project.to_string(),
731 _query: Default::default(),
732 _page_token: Default::default(),
733 _count: Default::default(),
734 _delegate: Default::default(),
735 _additional_params: Default::default(),
736 _scopes: Default::default(),
737 }
738 }
739}
740
741/// A builder providing access to all methods supported on *timesery* resources.
742/// It is not used directly, but through the [`CloudMonitoring`] hub.
743///
744/// # Example
745///
746/// Instantiate a resource builder
747///
748/// ```test_harness,no_run
749/// extern crate hyper;
750/// extern crate hyper_rustls;
751/// extern crate google_cloudmonitoring2_beta2 as cloudmonitoring2_beta2;
752///
753/// # async fn dox() {
754/// use cloudmonitoring2_beta2::{CloudMonitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
755///
756/// let secret: yup_oauth2::ApplicationSecret = Default::default();
757/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
758/// .with_native_roots()
759/// .unwrap()
760/// .https_only()
761/// .enable_http2()
762/// .build();
763///
764/// let executor = hyper_util::rt::TokioExecutor::new();
765/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
766/// secret,
767/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
768/// yup_oauth2::client::CustomHyperClientBuilder::from(
769/// hyper_util::client::legacy::Client::builder(executor).build(connector),
770/// ),
771/// ).build().await.unwrap();
772///
773/// let client = hyper_util::client::legacy::Client::builder(
774/// hyper_util::rt::TokioExecutor::new()
775/// )
776/// .build(
777/// hyper_rustls::HttpsConnectorBuilder::new()
778/// .with_native_roots()
779/// .unwrap()
780/// .https_or_http()
781/// .enable_http2()
782/// .build()
783/// );
784/// let mut hub = CloudMonitoring::new(client, auth);
785/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
786/// // like `list(...)` and `write(...)`
787/// // to build up your call.
788/// let rb = hub.timeseries();
789/// # }
790/// ```
791pub struct TimeseryMethods<'a, C>
792where
793 C: 'a,
794{
795 hub: &'a CloudMonitoring<C>,
796}
797
798impl<'a, C> common::MethodsBuilder for TimeseryMethods<'a, C> {}
799
800impl<'a, C> TimeseryMethods<'a, C> {
801 /// Create a builder to help you perform the following task:
802 ///
803 /// List the data points of the time series that match the metric and labels values and that have data points in the interval. Large responses are paginated; use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.
804 ///
805 /// # Arguments
806 ///
807 /// * `request` - No description provided.
808 /// * `project` - The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name.
809 /// * `metric` - Metric names are protocol-free URLs as listed in the Supported Metrics page. For example, compute.googleapis.com/instance/disk/read_ops_count.
810 /// * `youngest` - End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp.
811 pub fn list(
812 &self,
813 request: ListTimeseriesRequest,
814 project: &str,
815 metric: &str,
816 youngest: &str,
817 ) -> TimeseryListCall<'a, C> {
818 TimeseryListCall {
819 hub: self.hub,
820 _request: request,
821 _project: project.to_string(),
822 _metric: metric.to_string(),
823 _youngest: youngest.to_string(),
824 _window: Default::default(),
825 _timespan: Default::default(),
826 _page_token: Default::default(),
827 _oldest: Default::default(),
828 _labels: Default::default(),
829 _count: Default::default(),
830 _aggregator: Default::default(),
831 _delegate: Default::default(),
832 _additional_params: Default::default(),
833 _scopes: Default::default(),
834 }
835 }
836
837 /// Create a builder to help you perform the following task:
838 ///
839 /// Put data points to one or more time series for one or more metrics. If a time series does not exist, a new time series will be created. It is not allowed to write a time series point that is older than the existing youngest point of that time series. Points that are older than the existing youngest point of that time series will be discarded silently. Therefore, users should make sure that points of a time series are written sequentially in the order of their end time.
840 ///
841 /// # Arguments
842 ///
843 /// * `request` - No description provided.
844 /// * `project` - The project ID. The value can be the numeric project ID or string-based project name.
845 pub fn write(
846 &self,
847 request: WriteTimeseriesRequest,
848 project: &str,
849 ) -> TimeseryWriteCall<'a, C> {
850 TimeseryWriteCall {
851 hub: self.hub,
852 _request: request,
853 _project: project.to_string(),
854 _delegate: Default::default(),
855 _additional_params: Default::default(),
856 _scopes: Default::default(),
857 }
858 }
859}
860
861/// A builder providing access to all methods supported on *timeseriesDescriptor* resources.
862/// It is not used directly, but through the [`CloudMonitoring`] hub.
863///
864/// # Example
865///
866/// Instantiate a resource builder
867///
868/// ```test_harness,no_run
869/// extern crate hyper;
870/// extern crate hyper_rustls;
871/// extern crate google_cloudmonitoring2_beta2 as cloudmonitoring2_beta2;
872///
873/// # async fn dox() {
874/// use cloudmonitoring2_beta2::{CloudMonitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
875///
876/// let secret: yup_oauth2::ApplicationSecret = Default::default();
877/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
878/// .with_native_roots()
879/// .unwrap()
880/// .https_only()
881/// .enable_http2()
882/// .build();
883///
884/// let executor = hyper_util::rt::TokioExecutor::new();
885/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
886/// secret,
887/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
888/// yup_oauth2::client::CustomHyperClientBuilder::from(
889/// hyper_util::client::legacy::Client::builder(executor).build(connector),
890/// ),
891/// ).build().await.unwrap();
892///
893/// let client = hyper_util::client::legacy::Client::builder(
894/// hyper_util::rt::TokioExecutor::new()
895/// )
896/// .build(
897/// hyper_rustls::HttpsConnectorBuilder::new()
898/// .with_native_roots()
899/// .unwrap()
900/// .https_or_http()
901/// .enable_http2()
902/// .build()
903/// );
904/// let mut hub = CloudMonitoring::new(client, auth);
905/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
906/// // like `list(...)`
907/// // to build up your call.
908/// let rb = hub.timeseries_descriptors();
909/// # }
910/// ```
911pub struct TimeseriesDescriptorMethods<'a, C>
912where
913 C: 'a,
914{
915 hub: &'a CloudMonitoring<C>,
916}
917
918impl<'a, C> common::MethodsBuilder for TimeseriesDescriptorMethods<'a, C> {}
919
920impl<'a, C> TimeseriesDescriptorMethods<'a, C> {
921 /// Create a builder to help you perform the following task:
922 ///
923 /// List the descriptors of the time series that match the metric and labels values and that have data points in the interval. Large responses are paginated; use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.
924 ///
925 /// # Arguments
926 ///
927 /// * `request` - No description provided.
928 /// * `project` - The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name.
929 /// * `metric` - Metric names are protocol-free URLs as listed in the Supported Metrics page. For example, compute.googleapis.com/instance/disk/read_ops_count.
930 /// * `youngest` - End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp.
931 pub fn list(
932 &self,
933 request: ListTimeseriesDescriptorsRequest,
934 project: &str,
935 metric: &str,
936 youngest: &str,
937 ) -> TimeseriesDescriptorListCall<'a, C> {
938 TimeseriesDescriptorListCall {
939 hub: self.hub,
940 _request: request,
941 _project: project.to_string(),
942 _metric: metric.to_string(),
943 _youngest: youngest.to_string(),
944 _window: Default::default(),
945 _timespan: Default::default(),
946 _page_token: Default::default(),
947 _oldest: Default::default(),
948 _labels: Default::default(),
949 _count: Default::default(),
950 _aggregator: Default::default(),
951 _delegate: Default::default(),
952 _additional_params: Default::default(),
953 _scopes: Default::default(),
954 }
955 }
956}
957
958// ###################
959// CallBuilders ###
960// #################
961
962/// Create a new metric.
963///
964/// A builder for the *create* method supported by a *metricDescriptor* resource.
965/// It is not used directly, but through a [`MetricDescriptorMethods`] instance.
966///
967/// # Example
968///
969/// Instantiate a resource method builder
970///
971/// ```test_harness,no_run
972/// # extern crate hyper;
973/// # extern crate hyper_rustls;
974/// # extern crate google_cloudmonitoring2_beta2 as cloudmonitoring2_beta2;
975/// use cloudmonitoring2_beta2::api::MetricDescriptor;
976/// # async fn dox() {
977/// # use cloudmonitoring2_beta2::{CloudMonitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
978///
979/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
980/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
981/// # .with_native_roots()
982/// # .unwrap()
983/// # .https_only()
984/// # .enable_http2()
985/// # .build();
986///
987/// # let executor = hyper_util::rt::TokioExecutor::new();
988/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
989/// # secret,
990/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
991/// # yup_oauth2::client::CustomHyperClientBuilder::from(
992/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
993/// # ),
994/// # ).build().await.unwrap();
995///
996/// # let client = hyper_util::client::legacy::Client::builder(
997/// # hyper_util::rt::TokioExecutor::new()
998/// # )
999/// # .build(
1000/// # hyper_rustls::HttpsConnectorBuilder::new()
1001/// # .with_native_roots()
1002/// # .unwrap()
1003/// # .https_or_http()
1004/// # .enable_http2()
1005/// # .build()
1006/// # );
1007/// # let mut hub = CloudMonitoring::new(client, auth);
1008/// // As the method needs a request, you would usually fill it with the desired information
1009/// // into the respective structure. Some of the parts shown here might not be applicable !
1010/// // Values shown here are possibly random and not representative !
1011/// let mut req = MetricDescriptor::default();
1012///
1013/// // You can configure optional parameters by calling the respective setters at will, and
1014/// // execute the final call using `doit()`.
1015/// // Values shown here are possibly random and not representative !
1016/// let result = hub.metric_descriptors().create(req, "project")
1017/// .doit().await;
1018/// # }
1019/// ```
1020pub struct MetricDescriptorCreateCall<'a, C>
1021where
1022 C: 'a,
1023{
1024 hub: &'a CloudMonitoring<C>,
1025 _request: MetricDescriptor,
1026 _project: String,
1027 _delegate: Option<&'a mut dyn common::Delegate>,
1028 _additional_params: HashMap<String, String>,
1029 _scopes: BTreeSet<String>,
1030}
1031
1032impl<'a, C> common::CallBuilder for MetricDescriptorCreateCall<'a, C> {}
1033
1034impl<'a, C> MetricDescriptorCreateCall<'a, C>
1035where
1036 C: common::Connector,
1037{
1038 /// Perform the operation you have build so far.
1039 pub async fn doit(mut self) -> common::Result<(common::Response, MetricDescriptor)> {
1040 use std::borrow::Cow;
1041 use std::io::{Read, Seek};
1042
1043 use common::{url::Params, ToParts};
1044 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1045
1046 let mut dd = common::DefaultDelegate;
1047 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1048 dlg.begin(common::MethodInfo {
1049 id: "cloudmonitoring.metricDescriptors.create",
1050 http_method: hyper::Method::POST,
1051 });
1052
1053 for &field in ["alt", "project"].iter() {
1054 if self._additional_params.contains_key(field) {
1055 dlg.finished(false);
1056 return Err(common::Error::FieldClash(field));
1057 }
1058 }
1059
1060 let mut params = Params::with_capacity(4 + self._additional_params.len());
1061 params.push("project", self._project);
1062
1063 params.extend(self._additional_params.iter());
1064
1065 params.push("alt", "json");
1066 let mut url = self.hub._base_url.clone() + "{project}/metricDescriptors";
1067 if self._scopes.is_empty() {
1068 self._scopes
1069 .insert(Scope::CloudPlatform.as_ref().to_string());
1070 }
1071
1072 #[allow(clippy::single_element_loop)]
1073 for &(find_this, param_name) in [("{project}", "project")].iter() {
1074 url = params.uri_replacement(url, param_name, find_this, false);
1075 }
1076 {
1077 let to_remove = ["project"];
1078 params.remove_params(&to_remove);
1079 }
1080
1081 let url = params.parse_with_url(&url);
1082
1083 let mut json_mime_type = mime::APPLICATION_JSON;
1084 let mut request_value_reader = {
1085 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1086 common::remove_json_null_values(&mut value);
1087 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1088 serde_json::to_writer(&mut dst, &value).unwrap();
1089 dst
1090 };
1091 let request_size = request_value_reader
1092 .seek(std::io::SeekFrom::End(0))
1093 .unwrap();
1094 request_value_reader
1095 .seek(std::io::SeekFrom::Start(0))
1096 .unwrap();
1097
1098 loop {
1099 let token = match self
1100 .hub
1101 .auth
1102 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1103 .await
1104 {
1105 Ok(token) => token,
1106 Err(e) => match dlg.token(e) {
1107 Ok(token) => token,
1108 Err(e) => {
1109 dlg.finished(false);
1110 return Err(common::Error::MissingToken(e));
1111 }
1112 },
1113 };
1114 request_value_reader
1115 .seek(std::io::SeekFrom::Start(0))
1116 .unwrap();
1117 let mut req_result = {
1118 let client = &self.hub.client;
1119 dlg.pre_request();
1120 let mut req_builder = hyper::Request::builder()
1121 .method(hyper::Method::POST)
1122 .uri(url.as_str())
1123 .header(USER_AGENT, self.hub._user_agent.clone());
1124
1125 if let Some(token) = token.as_ref() {
1126 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1127 }
1128
1129 let request = req_builder
1130 .header(CONTENT_TYPE, json_mime_type.to_string())
1131 .header(CONTENT_LENGTH, request_size as u64)
1132 .body(common::to_body(
1133 request_value_reader.get_ref().clone().into(),
1134 ));
1135
1136 client.request(request.unwrap()).await
1137 };
1138
1139 match req_result {
1140 Err(err) => {
1141 if let common::Retry::After(d) = dlg.http_error(&err) {
1142 sleep(d).await;
1143 continue;
1144 }
1145 dlg.finished(false);
1146 return Err(common::Error::HttpError(err));
1147 }
1148 Ok(res) => {
1149 let (mut parts, body) = res.into_parts();
1150 let mut body = common::Body::new(body);
1151 if !parts.status.is_success() {
1152 let bytes = common::to_bytes(body).await.unwrap_or_default();
1153 let error = serde_json::from_str(&common::to_string(&bytes));
1154 let response = common::to_response(parts, bytes.into());
1155
1156 if let common::Retry::After(d) =
1157 dlg.http_failure(&response, error.as_ref().ok())
1158 {
1159 sleep(d).await;
1160 continue;
1161 }
1162
1163 dlg.finished(false);
1164
1165 return Err(match error {
1166 Ok(value) => common::Error::BadRequest(value),
1167 _ => common::Error::Failure(response),
1168 });
1169 }
1170 let response = {
1171 let bytes = common::to_bytes(body).await.unwrap_or_default();
1172 let encoded = common::to_string(&bytes);
1173 match serde_json::from_str(&encoded) {
1174 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1175 Err(error) => {
1176 dlg.response_json_decode_error(&encoded, &error);
1177 return Err(common::Error::JsonDecodeError(
1178 encoded.to_string(),
1179 error,
1180 ));
1181 }
1182 }
1183 };
1184
1185 dlg.finished(true);
1186 return Ok(response);
1187 }
1188 }
1189 }
1190 }
1191
1192 ///
1193 /// Sets the *request* property to the given value.
1194 ///
1195 /// Even though the property as already been set when instantiating this call,
1196 /// we provide this method for API completeness.
1197 pub fn request(mut self, new_value: MetricDescriptor) -> MetricDescriptorCreateCall<'a, C> {
1198 self._request = new_value;
1199 self
1200 }
1201 /// The project id. The value can be the numeric project ID or string-based project name.
1202 ///
1203 /// Sets the *project* path property to the given value.
1204 ///
1205 /// Even though the property as already been set when instantiating this call,
1206 /// we provide this method for API completeness.
1207 pub fn project(mut self, new_value: &str) -> MetricDescriptorCreateCall<'a, C> {
1208 self._project = new_value.to_string();
1209 self
1210 }
1211 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1212 /// while executing the actual API request.
1213 ///
1214 /// ````text
1215 /// It should be used to handle progress information, and to implement a certain level of resilience.
1216 /// ````
1217 ///
1218 /// Sets the *delegate* property to the given value.
1219 pub fn delegate(
1220 mut self,
1221 new_value: &'a mut dyn common::Delegate,
1222 ) -> MetricDescriptorCreateCall<'a, C> {
1223 self._delegate = Some(new_value);
1224 self
1225 }
1226
1227 /// Set any additional parameter of the query string used in the request.
1228 /// It should be used to set parameters which are not yet available through their own
1229 /// setters.
1230 ///
1231 /// Please note that this method must not be used to set any of the known parameters
1232 /// which have their own setter method. If done anyway, the request will fail.
1233 ///
1234 /// # Additional Parameters
1235 ///
1236 /// * *alt* (query-string) - Data format for the response.
1237 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1238 /// * *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.
1239 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1240 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1241 /// * *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. Overrides userIp if both are provided.
1242 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1243 pub fn param<T>(mut self, name: T, value: T) -> MetricDescriptorCreateCall<'a, C>
1244 where
1245 T: AsRef<str>,
1246 {
1247 self._additional_params
1248 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1249 self
1250 }
1251
1252 /// Identifies the authorization scope for the method you are building.
1253 ///
1254 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1255 /// [`Scope::CloudPlatform`].
1256 ///
1257 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1258 /// tokens for more than one scope.
1259 ///
1260 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1261 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1262 /// sufficient, a read-write scope will do as well.
1263 pub fn add_scope<St>(mut self, scope: St) -> MetricDescriptorCreateCall<'a, C>
1264 where
1265 St: AsRef<str>,
1266 {
1267 self._scopes.insert(String::from(scope.as_ref()));
1268 self
1269 }
1270 /// Identifies the authorization scope(s) for the method you are building.
1271 ///
1272 /// See [`Self::add_scope()`] for details.
1273 pub fn add_scopes<I, St>(mut self, scopes: I) -> MetricDescriptorCreateCall<'a, C>
1274 where
1275 I: IntoIterator<Item = St>,
1276 St: AsRef<str>,
1277 {
1278 self._scopes
1279 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1280 self
1281 }
1282
1283 /// Removes all scopes, and no default scope will be used either.
1284 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1285 /// for details).
1286 pub fn clear_scopes(mut self) -> MetricDescriptorCreateCall<'a, C> {
1287 self._scopes.clear();
1288 self
1289 }
1290}
1291
1292/// Delete an existing metric.
1293///
1294/// A builder for the *delete* method supported by a *metricDescriptor* resource.
1295/// It is not used directly, but through a [`MetricDescriptorMethods`] instance.
1296///
1297/// # Example
1298///
1299/// Instantiate a resource method builder
1300///
1301/// ```test_harness,no_run
1302/// # extern crate hyper;
1303/// # extern crate hyper_rustls;
1304/// # extern crate google_cloudmonitoring2_beta2 as cloudmonitoring2_beta2;
1305/// # async fn dox() {
1306/// # use cloudmonitoring2_beta2::{CloudMonitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1307///
1308/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1309/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1310/// # .with_native_roots()
1311/// # .unwrap()
1312/// # .https_only()
1313/// # .enable_http2()
1314/// # .build();
1315///
1316/// # let executor = hyper_util::rt::TokioExecutor::new();
1317/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1318/// # secret,
1319/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1320/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1321/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1322/// # ),
1323/// # ).build().await.unwrap();
1324///
1325/// # let client = hyper_util::client::legacy::Client::builder(
1326/// # hyper_util::rt::TokioExecutor::new()
1327/// # )
1328/// # .build(
1329/// # hyper_rustls::HttpsConnectorBuilder::new()
1330/// # .with_native_roots()
1331/// # .unwrap()
1332/// # .https_or_http()
1333/// # .enable_http2()
1334/// # .build()
1335/// # );
1336/// # let mut hub = CloudMonitoring::new(client, auth);
1337/// // You can configure optional parameters by calling the respective setters at will, and
1338/// // execute the final call using `doit()`.
1339/// // Values shown here are possibly random and not representative !
1340/// let result = hub.metric_descriptors().delete("project", "metric")
1341/// .doit().await;
1342/// # }
1343/// ```
1344pub struct MetricDescriptorDeleteCall<'a, C>
1345where
1346 C: 'a,
1347{
1348 hub: &'a CloudMonitoring<C>,
1349 _project: String,
1350 _metric: String,
1351 _delegate: Option<&'a mut dyn common::Delegate>,
1352 _additional_params: HashMap<String, String>,
1353 _scopes: BTreeSet<String>,
1354}
1355
1356impl<'a, C> common::CallBuilder for MetricDescriptorDeleteCall<'a, C> {}
1357
1358impl<'a, C> MetricDescriptorDeleteCall<'a, C>
1359where
1360 C: common::Connector,
1361{
1362 /// Perform the operation you have build so far.
1363 pub async fn doit(
1364 mut self,
1365 ) -> common::Result<(common::Response, DeleteMetricDescriptorResponse)> {
1366 use std::borrow::Cow;
1367 use std::io::{Read, Seek};
1368
1369 use common::{url::Params, ToParts};
1370 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1371
1372 let mut dd = common::DefaultDelegate;
1373 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1374 dlg.begin(common::MethodInfo {
1375 id: "cloudmonitoring.metricDescriptors.delete",
1376 http_method: hyper::Method::DELETE,
1377 });
1378
1379 for &field in ["alt", "project", "metric"].iter() {
1380 if self._additional_params.contains_key(field) {
1381 dlg.finished(false);
1382 return Err(common::Error::FieldClash(field));
1383 }
1384 }
1385
1386 let mut params = Params::with_capacity(4 + self._additional_params.len());
1387 params.push("project", self._project);
1388 params.push("metric", self._metric);
1389
1390 params.extend(self._additional_params.iter());
1391
1392 params.push("alt", "json");
1393 let mut url = self.hub._base_url.clone() + "{project}/metricDescriptors/{metric}";
1394 if self._scopes.is_empty() {
1395 self._scopes
1396 .insert(Scope::CloudPlatform.as_ref().to_string());
1397 }
1398
1399 #[allow(clippy::single_element_loop)]
1400 for &(find_this, param_name) in [("{project}", "project"), ("{metric}", "metric")].iter() {
1401 url = params.uri_replacement(url, param_name, find_this, false);
1402 }
1403 {
1404 let to_remove = ["metric", "project"];
1405 params.remove_params(&to_remove);
1406 }
1407
1408 let url = params.parse_with_url(&url);
1409
1410 loop {
1411 let token = match self
1412 .hub
1413 .auth
1414 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1415 .await
1416 {
1417 Ok(token) => token,
1418 Err(e) => match dlg.token(e) {
1419 Ok(token) => token,
1420 Err(e) => {
1421 dlg.finished(false);
1422 return Err(common::Error::MissingToken(e));
1423 }
1424 },
1425 };
1426 let mut req_result = {
1427 let client = &self.hub.client;
1428 dlg.pre_request();
1429 let mut req_builder = hyper::Request::builder()
1430 .method(hyper::Method::DELETE)
1431 .uri(url.as_str())
1432 .header(USER_AGENT, self.hub._user_agent.clone());
1433
1434 if let Some(token) = token.as_ref() {
1435 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1436 }
1437
1438 let request = req_builder
1439 .header(CONTENT_LENGTH, 0_u64)
1440 .body(common::to_body::<String>(None));
1441
1442 client.request(request.unwrap()).await
1443 };
1444
1445 match req_result {
1446 Err(err) => {
1447 if let common::Retry::After(d) = dlg.http_error(&err) {
1448 sleep(d).await;
1449 continue;
1450 }
1451 dlg.finished(false);
1452 return Err(common::Error::HttpError(err));
1453 }
1454 Ok(res) => {
1455 let (mut parts, body) = res.into_parts();
1456 let mut body = common::Body::new(body);
1457 if !parts.status.is_success() {
1458 let bytes = common::to_bytes(body).await.unwrap_or_default();
1459 let error = serde_json::from_str(&common::to_string(&bytes));
1460 let response = common::to_response(parts, bytes.into());
1461
1462 if let common::Retry::After(d) =
1463 dlg.http_failure(&response, error.as_ref().ok())
1464 {
1465 sleep(d).await;
1466 continue;
1467 }
1468
1469 dlg.finished(false);
1470
1471 return Err(match error {
1472 Ok(value) => common::Error::BadRequest(value),
1473 _ => common::Error::Failure(response),
1474 });
1475 }
1476 let response = {
1477 let bytes = common::to_bytes(body).await.unwrap_or_default();
1478 let encoded = common::to_string(&bytes);
1479 match serde_json::from_str(&encoded) {
1480 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1481 Err(error) => {
1482 dlg.response_json_decode_error(&encoded, &error);
1483 return Err(common::Error::JsonDecodeError(
1484 encoded.to_string(),
1485 error,
1486 ));
1487 }
1488 }
1489 };
1490
1491 dlg.finished(true);
1492 return Ok(response);
1493 }
1494 }
1495 }
1496 }
1497
1498 /// The project ID to which the metric belongs.
1499 ///
1500 /// Sets the *project* path property to the given value.
1501 ///
1502 /// Even though the property as already been set when instantiating this call,
1503 /// we provide this method for API completeness.
1504 pub fn project(mut self, new_value: &str) -> MetricDescriptorDeleteCall<'a, C> {
1505 self._project = new_value.to_string();
1506 self
1507 }
1508 /// Name of the metric.
1509 ///
1510 /// Sets the *metric* path property to the given value.
1511 ///
1512 /// Even though the property as already been set when instantiating this call,
1513 /// we provide this method for API completeness.
1514 pub fn metric(mut self, new_value: &str) -> MetricDescriptorDeleteCall<'a, C> {
1515 self._metric = new_value.to_string();
1516 self
1517 }
1518 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1519 /// while executing the actual API request.
1520 ///
1521 /// ````text
1522 /// It should be used to handle progress information, and to implement a certain level of resilience.
1523 /// ````
1524 ///
1525 /// Sets the *delegate* property to the given value.
1526 pub fn delegate(
1527 mut self,
1528 new_value: &'a mut dyn common::Delegate,
1529 ) -> MetricDescriptorDeleteCall<'a, C> {
1530 self._delegate = Some(new_value);
1531 self
1532 }
1533
1534 /// Set any additional parameter of the query string used in the request.
1535 /// It should be used to set parameters which are not yet available through their own
1536 /// setters.
1537 ///
1538 /// Please note that this method must not be used to set any of the known parameters
1539 /// which have their own setter method. If done anyway, the request will fail.
1540 ///
1541 /// # Additional Parameters
1542 ///
1543 /// * *alt* (query-string) - Data format for the response.
1544 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1545 /// * *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.
1546 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1547 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1548 /// * *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. Overrides userIp if both are provided.
1549 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1550 pub fn param<T>(mut self, name: T, value: T) -> MetricDescriptorDeleteCall<'a, C>
1551 where
1552 T: AsRef<str>,
1553 {
1554 self._additional_params
1555 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1556 self
1557 }
1558
1559 /// Identifies the authorization scope for the method you are building.
1560 ///
1561 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1562 /// [`Scope::CloudPlatform`].
1563 ///
1564 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1565 /// tokens for more than one scope.
1566 ///
1567 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1568 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1569 /// sufficient, a read-write scope will do as well.
1570 pub fn add_scope<St>(mut self, scope: St) -> MetricDescriptorDeleteCall<'a, C>
1571 where
1572 St: AsRef<str>,
1573 {
1574 self._scopes.insert(String::from(scope.as_ref()));
1575 self
1576 }
1577 /// Identifies the authorization scope(s) for the method you are building.
1578 ///
1579 /// See [`Self::add_scope()`] for details.
1580 pub fn add_scopes<I, St>(mut self, scopes: I) -> MetricDescriptorDeleteCall<'a, C>
1581 where
1582 I: IntoIterator<Item = St>,
1583 St: AsRef<str>,
1584 {
1585 self._scopes
1586 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1587 self
1588 }
1589
1590 /// Removes all scopes, and no default scope will be used either.
1591 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1592 /// for details).
1593 pub fn clear_scopes(mut self) -> MetricDescriptorDeleteCall<'a, C> {
1594 self._scopes.clear();
1595 self
1596 }
1597}
1598
1599/// List metric descriptors that match the query. If the query is not set, then all of the metric descriptors will be returned. Large responses will be paginated, use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.
1600///
1601/// A builder for the *list* method supported by a *metricDescriptor* resource.
1602/// It is not used directly, but through a [`MetricDescriptorMethods`] instance.
1603///
1604/// # Example
1605///
1606/// Instantiate a resource method builder
1607///
1608/// ```test_harness,no_run
1609/// # extern crate hyper;
1610/// # extern crate hyper_rustls;
1611/// # extern crate google_cloudmonitoring2_beta2 as cloudmonitoring2_beta2;
1612/// use cloudmonitoring2_beta2::api::ListMetricDescriptorsRequest;
1613/// # async fn dox() {
1614/// # use cloudmonitoring2_beta2::{CloudMonitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1615///
1616/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1617/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1618/// # .with_native_roots()
1619/// # .unwrap()
1620/// # .https_only()
1621/// # .enable_http2()
1622/// # .build();
1623///
1624/// # let executor = hyper_util::rt::TokioExecutor::new();
1625/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1626/// # secret,
1627/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1628/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1629/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1630/// # ),
1631/// # ).build().await.unwrap();
1632///
1633/// # let client = hyper_util::client::legacy::Client::builder(
1634/// # hyper_util::rt::TokioExecutor::new()
1635/// # )
1636/// # .build(
1637/// # hyper_rustls::HttpsConnectorBuilder::new()
1638/// # .with_native_roots()
1639/// # .unwrap()
1640/// # .https_or_http()
1641/// # .enable_http2()
1642/// # .build()
1643/// # );
1644/// # let mut hub = CloudMonitoring::new(client, auth);
1645/// // As the method needs a request, you would usually fill it with the desired information
1646/// // into the respective structure. Some of the parts shown here might not be applicable !
1647/// // Values shown here are possibly random and not representative !
1648/// let mut req = ListMetricDescriptorsRequest::default();
1649///
1650/// // You can configure optional parameters by calling the respective setters at will, and
1651/// // execute the final call using `doit()`.
1652/// // Values shown here are possibly random and not representative !
1653/// let result = hub.metric_descriptors().list(req, "project")
1654/// .query("eos")
1655/// .page_token("dolor")
1656/// .count(-17)
1657/// .doit().await;
1658/// # }
1659/// ```
1660pub struct MetricDescriptorListCall<'a, C>
1661where
1662 C: 'a,
1663{
1664 hub: &'a CloudMonitoring<C>,
1665 _request: ListMetricDescriptorsRequest,
1666 _project: String,
1667 _query: Option<String>,
1668 _page_token: Option<String>,
1669 _count: Option<i32>,
1670 _delegate: Option<&'a mut dyn common::Delegate>,
1671 _additional_params: HashMap<String, String>,
1672 _scopes: BTreeSet<String>,
1673}
1674
1675impl<'a, C> common::CallBuilder for MetricDescriptorListCall<'a, C> {}
1676
1677impl<'a, C> MetricDescriptorListCall<'a, C>
1678where
1679 C: common::Connector,
1680{
1681 /// Perform the operation you have build so far.
1682 pub async fn doit(
1683 mut self,
1684 ) -> common::Result<(common::Response, ListMetricDescriptorsResponse)> {
1685 use std::borrow::Cow;
1686 use std::io::{Read, Seek};
1687
1688 use common::{url::Params, ToParts};
1689 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1690
1691 let mut dd = common::DefaultDelegate;
1692 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1693 dlg.begin(common::MethodInfo {
1694 id: "cloudmonitoring.metricDescriptors.list",
1695 http_method: hyper::Method::GET,
1696 });
1697
1698 for &field in ["alt", "project", "query", "pageToken", "count"].iter() {
1699 if self._additional_params.contains_key(field) {
1700 dlg.finished(false);
1701 return Err(common::Error::FieldClash(field));
1702 }
1703 }
1704
1705 let mut params = Params::with_capacity(7 + self._additional_params.len());
1706 params.push("project", self._project);
1707 if let Some(value) = self._query.as_ref() {
1708 params.push("query", value);
1709 }
1710 if let Some(value) = self._page_token.as_ref() {
1711 params.push("pageToken", value);
1712 }
1713 if let Some(value) = self._count.as_ref() {
1714 params.push("count", value.to_string());
1715 }
1716
1717 params.extend(self._additional_params.iter());
1718
1719 params.push("alt", "json");
1720 let mut url = self.hub._base_url.clone() + "{project}/metricDescriptors";
1721 if self._scopes.is_empty() {
1722 self._scopes
1723 .insert(Scope::CloudPlatform.as_ref().to_string());
1724 }
1725
1726 #[allow(clippy::single_element_loop)]
1727 for &(find_this, param_name) in [("{project}", "project")].iter() {
1728 url = params.uri_replacement(url, param_name, find_this, false);
1729 }
1730 {
1731 let to_remove = ["project"];
1732 params.remove_params(&to_remove);
1733 }
1734
1735 let url = params.parse_with_url(&url);
1736
1737 let mut json_mime_type = mime::APPLICATION_JSON;
1738 let mut request_value_reader = {
1739 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1740 common::remove_json_null_values(&mut value);
1741 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1742 serde_json::to_writer(&mut dst, &value).unwrap();
1743 dst
1744 };
1745 let request_size = request_value_reader
1746 .seek(std::io::SeekFrom::End(0))
1747 .unwrap();
1748 request_value_reader
1749 .seek(std::io::SeekFrom::Start(0))
1750 .unwrap();
1751
1752 loop {
1753 let token = match self
1754 .hub
1755 .auth
1756 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1757 .await
1758 {
1759 Ok(token) => token,
1760 Err(e) => match dlg.token(e) {
1761 Ok(token) => token,
1762 Err(e) => {
1763 dlg.finished(false);
1764 return Err(common::Error::MissingToken(e));
1765 }
1766 },
1767 };
1768 request_value_reader
1769 .seek(std::io::SeekFrom::Start(0))
1770 .unwrap();
1771 let mut req_result = {
1772 let client = &self.hub.client;
1773 dlg.pre_request();
1774 let mut req_builder = hyper::Request::builder()
1775 .method(hyper::Method::GET)
1776 .uri(url.as_str())
1777 .header(USER_AGENT, self.hub._user_agent.clone());
1778
1779 if let Some(token) = token.as_ref() {
1780 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1781 }
1782
1783 let request = req_builder
1784 .header(CONTENT_TYPE, json_mime_type.to_string())
1785 .header(CONTENT_LENGTH, request_size as u64)
1786 .body(common::to_body(
1787 request_value_reader.get_ref().clone().into(),
1788 ));
1789
1790 client.request(request.unwrap()).await
1791 };
1792
1793 match req_result {
1794 Err(err) => {
1795 if let common::Retry::After(d) = dlg.http_error(&err) {
1796 sleep(d).await;
1797 continue;
1798 }
1799 dlg.finished(false);
1800 return Err(common::Error::HttpError(err));
1801 }
1802 Ok(res) => {
1803 let (mut parts, body) = res.into_parts();
1804 let mut body = common::Body::new(body);
1805 if !parts.status.is_success() {
1806 let bytes = common::to_bytes(body).await.unwrap_or_default();
1807 let error = serde_json::from_str(&common::to_string(&bytes));
1808 let response = common::to_response(parts, bytes.into());
1809
1810 if let common::Retry::After(d) =
1811 dlg.http_failure(&response, error.as_ref().ok())
1812 {
1813 sleep(d).await;
1814 continue;
1815 }
1816
1817 dlg.finished(false);
1818
1819 return Err(match error {
1820 Ok(value) => common::Error::BadRequest(value),
1821 _ => common::Error::Failure(response),
1822 });
1823 }
1824 let response = {
1825 let bytes = common::to_bytes(body).await.unwrap_or_default();
1826 let encoded = common::to_string(&bytes);
1827 match serde_json::from_str(&encoded) {
1828 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1829 Err(error) => {
1830 dlg.response_json_decode_error(&encoded, &error);
1831 return Err(common::Error::JsonDecodeError(
1832 encoded.to_string(),
1833 error,
1834 ));
1835 }
1836 }
1837 };
1838
1839 dlg.finished(true);
1840 return Ok(response);
1841 }
1842 }
1843 }
1844 }
1845
1846 ///
1847 /// Sets the *request* property to the given value.
1848 ///
1849 /// Even though the property as already been set when instantiating this call,
1850 /// we provide this method for API completeness.
1851 pub fn request(
1852 mut self,
1853 new_value: ListMetricDescriptorsRequest,
1854 ) -> MetricDescriptorListCall<'a, C> {
1855 self._request = new_value;
1856 self
1857 }
1858 /// The project id. The value can be the numeric project ID or string-based project name.
1859 ///
1860 /// Sets the *project* path property to the given value.
1861 ///
1862 /// Even though the property as already been set when instantiating this call,
1863 /// we provide this method for API completeness.
1864 pub fn project(mut self, new_value: &str) -> MetricDescriptorListCall<'a, C> {
1865 self._project = new_value.to_string();
1866 self
1867 }
1868 /// The query used to search against existing metrics. Separate keywords with a space; the service joins all keywords with AND, meaning that all keywords must match for a metric to be returned. If this field is omitted, all metrics are returned. If an empty string is passed with this field, no metrics are returned.
1869 ///
1870 /// Sets the *query* query property to the given value.
1871 pub fn query(mut self, new_value: &str) -> MetricDescriptorListCall<'a, C> {
1872 self._query = Some(new_value.to_string());
1873 self
1874 }
1875 /// The pagination token, which is used to page through large result sets. Set this value to the value of the nextPageToken to retrieve the next page of results.
1876 ///
1877 /// Sets the *page token* query property to the given value.
1878 pub fn page_token(mut self, new_value: &str) -> MetricDescriptorListCall<'a, C> {
1879 self._page_token = Some(new_value.to_string());
1880 self
1881 }
1882 /// Maximum number of metric descriptors per page. Used for pagination. If not specified, count = 100.
1883 ///
1884 /// Sets the *count* query property to the given value.
1885 pub fn count(mut self, new_value: i32) -> MetricDescriptorListCall<'a, C> {
1886 self._count = Some(new_value);
1887 self
1888 }
1889 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1890 /// while executing the actual API request.
1891 ///
1892 /// ````text
1893 /// It should be used to handle progress information, and to implement a certain level of resilience.
1894 /// ````
1895 ///
1896 /// Sets the *delegate* property to the given value.
1897 pub fn delegate(
1898 mut self,
1899 new_value: &'a mut dyn common::Delegate,
1900 ) -> MetricDescriptorListCall<'a, C> {
1901 self._delegate = Some(new_value);
1902 self
1903 }
1904
1905 /// Set any additional parameter of the query string used in the request.
1906 /// It should be used to set parameters which are not yet available through their own
1907 /// setters.
1908 ///
1909 /// Please note that this method must not be used to set any of the known parameters
1910 /// which have their own setter method. If done anyway, the request will fail.
1911 ///
1912 /// # Additional Parameters
1913 ///
1914 /// * *alt* (query-string) - Data format for the response.
1915 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1916 /// * *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.
1917 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1918 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1919 /// * *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. Overrides userIp if both are provided.
1920 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1921 pub fn param<T>(mut self, name: T, value: T) -> MetricDescriptorListCall<'a, C>
1922 where
1923 T: AsRef<str>,
1924 {
1925 self._additional_params
1926 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1927 self
1928 }
1929
1930 /// Identifies the authorization scope for the method you are building.
1931 ///
1932 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1933 /// [`Scope::CloudPlatform`].
1934 ///
1935 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1936 /// tokens for more than one scope.
1937 ///
1938 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1939 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1940 /// sufficient, a read-write scope will do as well.
1941 pub fn add_scope<St>(mut self, scope: St) -> MetricDescriptorListCall<'a, C>
1942 where
1943 St: AsRef<str>,
1944 {
1945 self._scopes.insert(String::from(scope.as_ref()));
1946 self
1947 }
1948 /// Identifies the authorization scope(s) for the method you are building.
1949 ///
1950 /// See [`Self::add_scope()`] for details.
1951 pub fn add_scopes<I, St>(mut self, scopes: I) -> MetricDescriptorListCall<'a, C>
1952 where
1953 I: IntoIterator<Item = St>,
1954 St: AsRef<str>,
1955 {
1956 self._scopes
1957 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1958 self
1959 }
1960
1961 /// Removes all scopes, and no default scope will be used either.
1962 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1963 /// for details).
1964 pub fn clear_scopes(mut self) -> MetricDescriptorListCall<'a, C> {
1965 self._scopes.clear();
1966 self
1967 }
1968}
1969
1970/// List the data points of the time series that match the metric and labels values and that have data points in the interval. Large responses are paginated; use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.
1971///
1972/// A builder for the *list* method supported by a *timesery* resource.
1973/// It is not used directly, but through a [`TimeseryMethods`] instance.
1974///
1975/// # Example
1976///
1977/// Instantiate a resource method builder
1978///
1979/// ```test_harness,no_run
1980/// # extern crate hyper;
1981/// # extern crate hyper_rustls;
1982/// # extern crate google_cloudmonitoring2_beta2 as cloudmonitoring2_beta2;
1983/// use cloudmonitoring2_beta2::api::ListTimeseriesRequest;
1984/// # async fn dox() {
1985/// # use cloudmonitoring2_beta2::{CloudMonitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1986///
1987/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1988/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1989/// # .with_native_roots()
1990/// # .unwrap()
1991/// # .https_only()
1992/// # .enable_http2()
1993/// # .build();
1994///
1995/// # let executor = hyper_util::rt::TokioExecutor::new();
1996/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1997/// # secret,
1998/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1999/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2000/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2001/// # ),
2002/// # ).build().await.unwrap();
2003///
2004/// # let client = hyper_util::client::legacy::Client::builder(
2005/// # hyper_util::rt::TokioExecutor::new()
2006/// # )
2007/// # .build(
2008/// # hyper_rustls::HttpsConnectorBuilder::new()
2009/// # .with_native_roots()
2010/// # .unwrap()
2011/// # .https_or_http()
2012/// # .enable_http2()
2013/// # .build()
2014/// # );
2015/// # let mut hub = CloudMonitoring::new(client, auth);
2016/// // As the method needs a request, you would usually fill it with the desired information
2017/// // into the respective structure. Some of the parts shown here might not be applicable !
2018/// // Values shown here are possibly random and not representative !
2019/// let mut req = ListTimeseriesRequest::default();
2020///
2021/// // You can configure optional parameters by calling the respective setters at will, and
2022/// // execute the final call using `doit()`.
2023/// // Values shown here are possibly random and not representative !
2024/// let result = hub.timeseries().list(req, "project", "metric", "youngest")
2025/// .window("duo")
2026/// .timespan("ipsum")
2027/// .page_token("sed")
2028/// .oldest("ut")
2029/// .add_labels("gubergren")
2030/// .count(-16)
2031/// .aggregator("est")
2032/// .doit().await;
2033/// # }
2034/// ```
2035pub struct TimeseryListCall<'a, C>
2036where
2037 C: 'a,
2038{
2039 hub: &'a CloudMonitoring<C>,
2040 _request: ListTimeseriesRequest,
2041 _project: String,
2042 _metric: String,
2043 _youngest: String,
2044 _window: Option<String>,
2045 _timespan: Option<String>,
2046 _page_token: Option<String>,
2047 _oldest: Option<String>,
2048 _labels: Vec<String>,
2049 _count: Option<i32>,
2050 _aggregator: Option<String>,
2051 _delegate: Option<&'a mut dyn common::Delegate>,
2052 _additional_params: HashMap<String, String>,
2053 _scopes: BTreeSet<String>,
2054}
2055
2056impl<'a, C> common::CallBuilder for TimeseryListCall<'a, C> {}
2057
2058impl<'a, C> TimeseryListCall<'a, C>
2059where
2060 C: common::Connector,
2061{
2062 /// Perform the operation you have build so far.
2063 pub async fn doit(mut self) -> common::Result<(common::Response, ListTimeseriesResponse)> {
2064 use std::borrow::Cow;
2065 use std::io::{Read, Seek};
2066
2067 use common::{url::Params, ToParts};
2068 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2069
2070 let mut dd = common::DefaultDelegate;
2071 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2072 dlg.begin(common::MethodInfo {
2073 id: "cloudmonitoring.timeseries.list",
2074 http_method: hyper::Method::GET,
2075 });
2076
2077 for &field in [
2078 "alt",
2079 "project",
2080 "metric",
2081 "youngest",
2082 "window",
2083 "timespan",
2084 "pageToken",
2085 "oldest",
2086 "labels",
2087 "count",
2088 "aggregator",
2089 ]
2090 .iter()
2091 {
2092 if self._additional_params.contains_key(field) {
2093 dlg.finished(false);
2094 return Err(common::Error::FieldClash(field));
2095 }
2096 }
2097
2098 let mut params = Params::with_capacity(13 + self._additional_params.len());
2099 params.push("project", self._project);
2100 params.push("metric", self._metric);
2101 params.push("youngest", self._youngest);
2102 if let Some(value) = self._window.as_ref() {
2103 params.push("window", value);
2104 }
2105 if let Some(value) = self._timespan.as_ref() {
2106 params.push("timespan", value);
2107 }
2108 if let Some(value) = self._page_token.as_ref() {
2109 params.push("pageToken", value);
2110 }
2111 if let Some(value) = self._oldest.as_ref() {
2112 params.push("oldest", value);
2113 }
2114 if !self._labels.is_empty() {
2115 for f in self._labels.iter() {
2116 params.push("labels", f);
2117 }
2118 }
2119 if let Some(value) = self._count.as_ref() {
2120 params.push("count", value.to_string());
2121 }
2122 if let Some(value) = self._aggregator.as_ref() {
2123 params.push("aggregator", value);
2124 }
2125
2126 params.extend(self._additional_params.iter());
2127
2128 params.push("alt", "json");
2129 let mut url = self.hub._base_url.clone() + "{project}/timeseries/{metric}";
2130 if self._scopes.is_empty() {
2131 self._scopes
2132 .insert(Scope::CloudPlatform.as_ref().to_string());
2133 }
2134
2135 #[allow(clippy::single_element_loop)]
2136 for &(find_this, param_name) in [("{project}", "project"), ("{metric}", "metric")].iter() {
2137 url = params.uri_replacement(url, param_name, find_this, false);
2138 }
2139 {
2140 let to_remove = ["metric", "project"];
2141 params.remove_params(&to_remove);
2142 }
2143
2144 let url = params.parse_with_url(&url);
2145
2146 let mut json_mime_type = mime::APPLICATION_JSON;
2147 let mut request_value_reader = {
2148 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2149 common::remove_json_null_values(&mut value);
2150 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2151 serde_json::to_writer(&mut dst, &value).unwrap();
2152 dst
2153 };
2154 let request_size = request_value_reader
2155 .seek(std::io::SeekFrom::End(0))
2156 .unwrap();
2157 request_value_reader
2158 .seek(std::io::SeekFrom::Start(0))
2159 .unwrap();
2160
2161 loop {
2162 let token = match self
2163 .hub
2164 .auth
2165 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2166 .await
2167 {
2168 Ok(token) => token,
2169 Err(e) => match dlg.token(e) {
2170 Ok(token) => token,
2171 Err(e) => {
2172 dlg.finished(false);
2173 return Err(common::Error::MissingToken(e));
2174 }
2175 },
2176 };
2177 request_value_reader
2178 .seek(std::io::SeekFrom::Start(0))
2179 .unwrap();
2180 let mut req_result = {
2181 let client = &self.hub.client;
2182 dlg.pre_request();
2183 let mut req_builder = hyper::Request::builder()
2184 .method(hyper::Method::GET)
2185 .uri(url.as_str())
2186 .header(USER_AGENT, self.hub._user_agent.clone());
2187
2188 if let Some(token) = token.as_ref() {
2189 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2190 }
2191
2192 let request = req_builder
2193 .header(CONTENT_TYPE, json_mime_type.to_string())
2194 .header(CONTENT_LENGTH, request_size as u64)
2195 .body(common::to_body(
2196 request_value_reader.get_ref().clone().into(),
2197 ));
2198
2199 client.request(request.unwrap()).await
2200 };
2201
2202 match req_result {
2203 Err(err) => {
2204 if let common::Retry::After(d) = dlg.http_error(&err) {
2205 sleep(d).await;
2206 continue;
2207 }
2208 dlg.finished(false);
2209 return Err(common::Error::HttpError(err));
2210 }
2211 Ok(res) => {
2212 let (mut parts, body) = res.into_parts();
2213 let mut body = common::Body::new(body);
2214 if !parts.status.is_success() {
2215 let bytes = common::to_bytes(body).await.unwrap_or_default();
2216 let error = serde_json::from_str(&common::to_string(&bytes));
2217 let response = common::to_response(parts, bytes.into());
2218
2219 if let common::Retry::After(d) =
2220 dlg.http_failure(&response, error.as_ref().ok())
2221 {
2222 sleep(d).await;
2223 continue;
2224 }
2225
2226 dlg.finished(false);
2227
2228 return Err(match error {
2229 Ok(value) => common::Error::BadRequest(value),
2230 _ => common::Error::Failure(response),
2231 });
2232 }
2233 let response = {
2234 let bytes = common::to_bytes(body).await.unwrap_or_default();
2235 let encoded = common::to_string(&bytes);
2236 match serde_json::from_str(&encoded) {
2237 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2238 Err(error) => {
2239 dlg.response_json_decode_error(&encoded, &error);
2240 return Err(common::Error::JsonDecodeError(
2241 encoded.to_string(),
2242 error,
2243 ));
2244 }
2245 }
2246 };
2247
2248 dlg.finished(true);
2249 return Ok(response);
2250 }
2251 }
2252 }
2253 }
2254
2255 ///
2256 /// Sets the *request* property to the given value.
2257 ///
2258 /// Even though the property as already been set when instantiating this call,
2259 /// we provide this method for API completeness.
2260 pub fn request(mut self, new_value: ListTimeseriesRequest) -> TimeseryListCall<'a, C> {
2261 self._request = new_value;
2262 self
2263 }
2264 /// The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name.
2265 ///
2266 /// Sets the *project* path property to the given value.
2267 ///
2268 /// Even though the property as already been set when instantiating this call,
2269 /// we provide this method for API completeness.
2270 pub fn project(mut self, new_value: &str) -> TimeseryListCall<'a, C> {
2271 self._project = new_value.to_string();
2272 self
2273 }
2274 /// Metric names are protocol-free URLs as listed in the Supported Metrics page. For example, compute.googleapis.com/instance/disk/read_ops_count.
2275 ///
2276 /// Sets the *metric* path property to the given value.
2277 ///
2278 /// Even though the property as already been set when instantiating this call,
2279 /// we provide this method for API completeness.
2280 pub fn metric(mut self, new_value: &str) -> TimeseryListCall<'a, C> {
2281 self._metric = new_value.to_string();
2282 self
2283 }
2284 /// End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp.
2285 ///
2286 /// Sets the *youngest* query property to the given value.
2287 ///
2288 /// Even though the property as already been set when instantiating this call,
2289 /// we provide this method for API completeness.
2290 pub fn youngest(mut self, new_value: &str) -> TimeseryListCall<'a, C> {
2291 self._youngest = new_value.to_string();
2292 self
2293 }
2294 /// The sampling window. At most one data point will be returned for each window in the requested time interval. This parameter is only valid for non-cumulative metric types. Units:
2295 /// - m: minute
2296 /// - h: hour
2297 /// - d: day
2298 /// - w: week Examples: 3m, 4w. Only one unit is allowed, for example: 2w3d is not allowed; you should use 17d instead.
2299 ///
2300 /// Sets the *window* query property to the given value.
2301 pub fn window(mut self, new_value: &str) -> TimeseryListCall<'a, C> {
2302 self._window = Some(new_value.to_string());
2303 self
2304 }
2305 /// Length of the time interval to query, which is an alternative way to declare the interval: (youngest - timespan, youngest]. The timespan and oldest parameters should not be used together. Units:
2306 /// - s: second
2307 /// - m: minute
2308 /// - h: hour
2309 /// - d: day
2310 /// - w: week Examples: 2s, 3m, 4w. Only one unit is allowed, for example: 2w3d is not allowed; you should use 17d instead.
2311 ///
2312 /// If neither oldest nor timespan is specified, the default time interval will be (youngest - 4 hours, youngest].
2313 ///
2314 /// Sets the *timespan* query property to the given value.
2315 pub fn timespan(mut self, new_value: &str) -> TimeseryListCall<'a, C> {
2316 self._timespan = Some(new_value.to_string());
2317 self
2318 }
2319 /// The pagination token, which is used to page through large result sets. Set this value to the value of the nextPageToken to retrieve the next page of results.
2320 ///
2321 /// Sets the *page token* query property to the given value.
2322 pub fn page_token(mut self, new_value: &str) -> TimeseryListCall<'a, C> {
2323 self._page_token = Some(new_value.to_string());
2324 self
2325 }
2326 /// Start of the time interval (exclusive), which is expressed as an RFC 3339 timestamp. If neither oldest nor timespan is specified, the default time interval will be (youngest - 4 hours, youngest]
2327 ///
2328 /// Sets the *oldest* query property to the given value.
2329 pub fn oldest(mut self, new_value: &str) -> TimeseryListCall<'a, C> {
2330 self._oldest = Some(new_value.to_string());
2331 self
2332 }
2333 /// A collection of labels for the matching time series, which are represented as:
2334 /// - key==value: key equals the value
2335 /// - key=~value: key regex matches the value
2336 /// - key!=value: key does not equal the value
2337 /// - key!~value: key regex does not match the value For example, to list all of the time series descriptors for the region us-central1, you could specify:
2338 /// label=cloud.googleapis.com%2Flocation=~us-central1.*
2339 ///
2340 /// Append the given value to the *labels* query property.
2341 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
2342 pub fn add_labels(mut self, new_value: &str) -> TimeseryListCall<'a, C> {
2343 self._labels.push(new_value.to_string());
2344 self
2345 }
2346 /// Maximum number of data points per page, which is used for pagination of results.
2347 ///
2348 /// Sets the *count* query property to the given value.
2349 pub fn count(mut self, new_value: i32) -> TimeseryListCall<'a, C> {
2350 self._count = Some(new_value);
2351 self
2352 }
2353 /// The aggregation function that will reduce the data points in each window to a single point. This parameter is only valid for non-cumulative metrics with a value type of INT64 or DOUBLE.
2354 ///
2355 /// Sets the *aggregator* query property to the given value.
2356 pub fn aggregator(mut self, new_value: &str) -> TimeseryListCall<'a, C> {
2357 self._aggregator = Some(new_value.to_string());
2358 self
2359 }
2360 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2361 /// while executing the actual API request.
2362 ///
2363 /// ````text
2364 /// It should be used to handle progress information, and to implement a certain level of resilience.
2365 /// ````
2366 ///
2367 /// Sets the *delegate* property to the given value.
2368 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TimeseryListCall<'a, C> {
2369 self._delegate = Some(new_value);
2370 self
2371 }
2372
2373 /// Set any additional parameter of the query string used in the request.
2374 /// It should be used to set parameters which are not yet available through their own
2375 /// setters.
2376 ///
2377 /// Please note that this method must not be used to set any of the known parameters
2378 /// which have their own setter method. If done anyway, the request will fail.
2379 ///
2380 /// # Additional Parameters
2381 ///
2382 /// * *alt* (query-string) - Data format for the response.
2383 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2384 /// * *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.
2385 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2386 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2387 /// * *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. Overrides userIp if both are provided.
2388 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2389 pub fn param<T>(mut self, name: T, value: T) -> TimeseryListCall<'a, C>
2390 where
2391 T: AsRef<str>,
2392 {
2393 self._additional_params
2394 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2395 self
2396 }
2397
2398 /// Identifies the authorization scope for the method you are building.
2399 ///
2400 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2401 /// [`Scope::CloudPlatform`].
2402 ///
2403 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2404 /// tokens for more than one scope.
2405 ///
2406 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2407 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2408 /// sufficient, a read-write scope will do as well.
2409 pub fn add_scope<St>(mut self, scope: St) -> TimeseryListCall<'a, C>
2410 where
2411 St: AsRef<str>,
2412 {
2413 self._scopes.insert(String::from(scope.as_ref()));
2414 self
2415 }
2416 /// Identifies the authorization scope(s) for the method you are building.
2417 ///
2418 /// See [`Self::add_scope()`] for details.
2419 pub fn add_scopes<I, St>(mut self, scopes: I) -> TimeseryListCall<'a, C>
2420 where
2421 I: IntoIterator<Item = St>,
2422 St: AsRef<str>,
2423 {
2424 self._scopes
2425 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2426 self
2427 }
2428
2429 /// Removes all scopes, and no default scope will be used either.
2430 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2431 /// for details).
2432 pub fn clear_scopes(mut self) -> TimeseryListCall<'a, C> {
2433 self._scopes.clear();
2434 self
2435 }
2436}
2437
2438/// Put data points to one or more time series for one or more metrics. If a time series does not exist, a new time series will be created. It is not allowed to write a time series point that is older than the existing youngest point of that time series. Points that are older than the existing youngest point of that time series will be discarded silently. Therefore, users should make sure that points of a time series are written sequentially in the order of their end time.
2439///
2440/// A builder for the *write* method supported by a *timesery* resource.
2441/// It is not used directly, but through a [`TimeseryMethods`] instance.
2442///
2443/// # Example
2444///
2445/// Instantiate a resource method builder
2446///
2447/// ```test_harness,no_run
2448/// # extern crate hyper;
2449/// # extern crate hyper_rustls;
2450/// # extern crate google_cloudmonitoring2_beta2 as cloudmonitoring2_beta2;
2451/// use cloudmonitoring2_beta2::api::WriteTimeseriesRequest;
2452/// # async fn dox() {
2453/// # use cloudmonitoring2_beta2::{CloudMonitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2454///
2455/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2456/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2457/// # .with_native_roots()
2458/// # .unwrap()
2459/// # .https_only()
2460/// # .enable_http2()
2461/// # .build();
2462///
2463/// # let executor = hyper_util::rt::TokioExecutor::new();
2464/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2465/// # secret,
2466/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2467/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2468/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2469/// # ),
2470/// # ).build().await.unwrap();
2471///
2472/// # let client = hyper_util::client::legacy::Client::builder(
2473/// # hyper_util::rt::TokioExecutor::new()
2474/// # )
2475/// # .build(
2476/// # hyper_rustls::HttpsConnectorBuilder::new()
2477/// # .with_native_roots()
2478/// # .unwrap()
2479/// # .https_or_http()
2480/// # .enable_http2()
2481/// # .build()
2482/// # );
2483/// # let mut hub = CloudMonitoring::new(client, auth);
2484/// // As the method needs a request, you would usually fill it with the desired information
2485/// // into the respective structure. Some of the parts shown here might not be applicable !
2486/// // Values shown here are possibly random and not representative !
2487/// let mut req = WriteTimeseriesRequest::default();
2488///
2489/// // You can configure optional parameters by calling the respective setters at will, and
2490/// // execute the final call using `doit()`.
2491/// // Values shown here are possibly random and not representative !
2492/// let result = hub.timeseries().write(req, "project")
2493/// .doit().await;
2494/// # }
2495/// ```
2496pub struct TimeseryWriteCall<'a, C>
2497where
2498 C: 'a,
2499{
2500 hub: &'a CloudMonitoring<C>,
2501 _request: WriteTimeseriesRequest,
2502 _project: String,
2503 _delegate: Option<&'a mut dyn common::Delegate>,
2504 _additional_params: HashMap<String, String>,
2505 _scopes: BTreeSet<String>,
2506}
2507
2508impl<'a, C> common::CallBuilder for TimeseryWriteCall<'a, C> {}
2509
2510impl<'a, C> TimeseryWriteCall<'a, C>
2511where
2512 C: common::Connector,
2513{
2514 /// Perform the operation you have build so far.
2515 pub async fn doit(mut self) -> common::Result<(common::Response, WriteTimeseriesResponse)> {
2516 use std::borrow::Cow;
2517 use std::io::{Read, Seek};
2518
2519 use common::{url::Params, ToParts};
2520 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2521
2522 let mut dd = common::DefaultDelegate;
2523 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2524 dlg.begin(common::MethodInfo {
2525 id: "cloudmonitoring.timeseries.write",
2526 http_method: hyper::Method::POST,
2527 });
2528
2529 for &field in ["alt", "project"].iter() {
2530 if self._additional_params.contains_key(field) {
2531 dlg.finished(false);
2532 return Err(common::Error::FieldClash(field));
2533 }
2534 }
2535
2536 let mut params = Params::with_capacity(4 + self._additional_params.len());
2537 params.push("project", self._project);
2538
2539 params.extend(self._additional_params.iter());
2540
2541 params.push("alt", "json");
2542 let mut url = self.hub._base_url.clone() + "{project}/timeseries:write";
2543 if self._scopes.is_empty() {
2544 self._scopes
2545 .insert(Scope::CloudPlatform.as_ref().to_string());
2546 }
2547
2548 #[allow(clippy::single_element_loop)]
2549 for &(find_this, param_name) in [("{project}", "project")].iter() {
2550 url = params.uri_replacement(url, param_name, find_this, false);
2551 }
2552 {
2553 let to_remove = ["project"];
2554 params.remove_params(&to_remove);
2555 }
2556
2557 let url = params.parse_with_url(&url);
2558
2559 let mut json_mime_type = mime::APPLICATION_JSON;
2560 let mut request_value_reader = {
2561 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2562 common::remove_json_null_values(&mut value);
2563 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2564 serde_json::to_writer(&mut dst, &value).unwrap();
2565 dst
2566 };
2567 let request_size = request_value_reader
2568 .seek(std::io::SeekFrom::End(0))
2569 .unwrap();
2570 request_value_reader
2571 .seek(std::io::SeekFrom::Start(0))
2572 .unwrap();
2573
2574 loop {
2575 let token = match self
2576 .hub
2577 .auth
2578 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2579 .await
2580 {
2581 Ok(token) => token,
2582 Err(e) => match dlg.token(e) {
2583 Ok(token) => token,
2584 Err(e) => {
2585 dlg.finished(false);
2586 return Err(common::Error::MissingToken(e));
2587 }
2588 },
2589 };
2590 request_value_reader
2591 .seek(std::io::SeekFrom::Start(0))
2592 .unwrap();
2593 let mut req_result = {
2594 let client = &self.hub.client;
2595 dlg.pre_request();
2596 let mut req_builder = hyper::Request::builder()
2597 .method(hyper::Method::POST)
2598 .uri(url.as_str())
2599 .header(USER_AGENT, self.hub._user_agent.clone());
2600
2601 if let Some(token) = token.as_ref() {
2602 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2603 }
2604
2605 let request = req_builder
2606 .header(CONTENT_TYPE, json_mime_type.to_string())
2607 .header(CONTENT_LENGTH, request_size as u64)
2608 .body(common::to_body(
2609 request_value_reader.get_ref().clone().into(),
2610 ));
2611
2612 client.request(request.unwrap()).await
2613 };
2614
2615 match req_result {
2616 Err(err) => {
2617 if let common::Retry::After(d) = dlg.http_error(&err) {
2618 sleep(d).await;
2619 continue;
2620 }
2621 dlg.finished(false);
2622 return Err(common::Error::HttpError(err));
2623 }
2624 Ok(res) => {
2625 let (mut parts, body) = res.into_parts();
2626 let mut body = common::Body::new(body);
2627 if !parts.status.is_success() {
2628 let bytes = common::to_bytes(body).await.unwrap_or_default();
2629 let error = serde_json::from_str(&common::to_string(&bytes));
2630 let response = common::to_response(parts, bytes.into());
2631
2632 if let common::Retry::After(d) =
2633 dlg.http_failure(&response, error.as_ref().ok())
2634 {
2635 sleep(d).await;
2636 continue;
2637 }
2638
2639 dlg.finished(false);
2640
2641 return Err(match error {
2642 Ok(value) => common::Error::BadRequest(value),
2643 _ => common::Error::Failure(response),
2644 });
2645 }
2646 let response = {
2647 let bytes = common::to_bytes(body).await.unwrap_or_default();
2648 let encoded = common::to_string(&bytes);
2649 match serde_json::from_str(&encoded) {
2650 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2651 Err(error) => {
2652 dlg.response_json_decode_error(&encoded, &error);
2653 return Err(common::Error::JsonDecodeError(
2654 encoded.to_string(),
2655 error,
2656 ));
2657 }
2658 }
2659 };
2660
2661 dlg.finished(true);
2662 return Ok(response);
2663 }
2664 }
2665 }
2666 }
2667
2668 ///
2669 /// Sets the *request* property to the given value.
2670 ///
2671 /// Even though the property as already been set when instantiating this call,
2672 /// we provide this method for API completeness.
2673 pub fn request(mut self, new_value: WriteTimeseriesRequest) -> TimeseryWriteCall<'a, C> {
2674 self._request = new_value;
2675 self
2676 }
2677 /// The project ID. The value can be the numeric project ID or string-based project name.
2678 ///
2679 /// Sets the *project* path property to the given value.
2680 ///
2681 /// Even though the property as already been set when instantiating this call,
2682 /// we provide this method for API completeness.
2683 pub fn project(mut self, new_value: &str) -> TimeseryWriteCall<'a, C> {
2684 self._project = new_value.to_string();
2685 self
2686 }
2687 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2688 /// while executing the actual API request.
2689 ///
2690 /// ````text
2691 /// It should be used to handle progress information, and to implement a certain level of resilience.
2692 /// ````
2693 ///
2694 /// Sets the *delegate* property to the given value.
2695 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TimeseryWriteCall<'a, C> {
2696 self._delegate = Some(new_value);
2697 self
2698 }
2699
2700 /// Set any additional parameter of the query string used in the request.
2701 /// It should be used to set parameters which are not yet available through their own
2702 /// setters.
2703 ///
2704 /// Please note that this method must not be used to set any of the known parameters
2705 /// which have their own setter method. If done anyway, the request will fail.
2706 ///
2707 /// # Additional Parameters
2708 ///
2709 /// * *alt* (query-string) - Data format for the response.
2710 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2711 /// * *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.
2712 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2713 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2714 /// * *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. Overrides userIp if both are provided.
2715 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2716 pub fn param<T>(mut self, name: T, value: T) -> TimeseryWriteCall<'a, C>
2717 where
2718 T: AsRef<str>,
2719 {
2720 self._additional_params
2721 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2722 self
2723 }
2724
2725 /// Identifies the authorization scope for the method you are building.
2726 ///
2727 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2728 /// [`Scope::CloudPlatform`].
2729 ///
2730 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2731 /// tokens for more than one scope.
2732 ///
2733 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2734 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2735 /// sufficient, a read-write scope will do as well.
2736 pub fn add_scope<St>(mut self, scope: St) -> TimeseryWriteCall<'a, C>
2737 where
2738 St: AsRef<str>,
2739 {
2740 self._scopes.insert(String::from(scope.as_ref()));
2741 self
2742 }
2743 /// Identifies the authorization scope(s) for the method you are building.
2744 ///
2745 /// See [`Self::add_scope()`] for details.
2746 pub fn add_scopes<I, St>(mut self, scopes: I) -> TimeseryWriteCall<'a, C>
2747 where
2748 I: IntoIterator<Item = St>,
2749 St: AsRef<str>,
2750 {
2751 self._scopes
2752 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2753 self
2754 }
2755
2756 /// Removes all scopes, and no default scope will be used either.
2757 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2758 /// for details).
2759 pub fn clear_scopes(mut self) -> TimeseryWriteCall<'a, C> {
2760 self._scopes.clear();
2761 self
2762 }
2763}
2764
2765/// List the descriptors of the time series that match the metric and labels values and that have data points in the interval. Large responses are paginated; use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.
2766///
2767/// A builder for the *list* method supported by a *timeseriesDescriptor* resource.
2768/// It is not used directly, but through a [`TimeseriesDescriptorMethods`] instance.
2769///
2770/// # Example
2771///
2772/// Instantiate a resource method builder
2773///
2774/// ```test_harness,no_run
2775/// # extern crate hyper;
2776/// # extern crate hyper_rustls;
2777/// # extern crate google_cloudmonitoring2_beta2 as cloudmonitoring2_beta2;
2778/// use cloudmonitoring2_beta2::api::ListTimeseriesDescriptorsRequest;
2779/// # async fn dox() {
2780/// # use cloudmonitoring2_beta2::{CloudMonitoring, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2781///
2782/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2783/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2784/// # .with_native_roots()
2785/// # .unwrap()
2786/// # .https_only()
2787/// # .enable_http2()
2788/// # .build();
2789///
2790/// # let executor = hyper_util::rt::TokioExecutor::new();
2791/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2792/// # secret,
2793/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2794/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2795/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2796/// # ),
2797/// # ).build().await.unwrap();
2798///
2799/// # let client = hyper_util::client::legacy::Client::builder(
2800/// # hyper_util::rt::TokioExecutor::new()
2801/// # )
2802/// # .build(
2803/// # hyper_rustls::HttpsConnectorBuilder::new()
2804/// # .with_native_roots()
2805/// # .unwrap()
2806/// # .https_or_http()
2807/// # .enable_http2()
2808/// # .build()
2809/// # );
2810/// # let mut hub = CloudMonitoring::new(client, auth);
2811/// // As the method needs a request, you would usually fill it with the desired information
2812/// // into the respective structure. Some of the parts shown here might not be applicable !
2813/// // Values shown here are possibly random and not representative !
2814/// let mut req = ListTimeseriesDescriptorsRequest::default();
2815///
2816/// // You can configure optional parameters by calling the respective setters at will, and
2817/// // execute the final call using `doit()`.
2818/// // Values shown here are possibly random and not representative !
2819/// let result = hub.timeseries_descriptors().list(req, "project", "metric", "youngest")
2820/// .window("ea")
2821/// .timespan("dolor")
2822/// .page_token("Lorem")
2823/// .oldest("eos")
2824/// .add_labels("labore")
2825/// .count(-43)
2826/// .aggregator("duo")
2827/// .doit().await;
2828/// # }
2829/// ```
2830pub struct TimeseriesDescriptorListCall<'a, C>
2831where
2832 C: 'a,
2833{
2834 hub: &'a CloudMonitoring<C>,
2835 _request: ListTimeseriesDescriptorsRequest,
2836 _project: String,
2837 _metric: String,
2838 _youngest: String,
2839 _window: Option<String>,
2840 _timespan: Option<String>,
2841 _page_token: Option<String>,
2842 _oldest: Option<String>,
2843 _labels: Vec<String>,
2844 _count: Option<i32>,
2845 _aggregator: Option<String>,
2846 _delegate: Option<&'a mut dyn common::Delegate>,
2847 _additional_params: HashMap<String, String>,
2848 _scopes: BTreeSet<String>,
2849}
2850
2851impl<'a, C> common::CallBuilder for TimeseriesDescriptorListCall<'a, C> {}
2852
2853impl<'a, C> TimeseriesDescriptorListCall<'a, C>
2854where
2855 C: common::Connector,
2856{
2857 /// Perform the operation you have build so far.
2858 pub async fn doit(
2859 mut self,
2860 ) -> common::Result<(common::Response, ListTimeseriesDescriptorsResponse)> {
2861 use std::borrow::Cow;
2862 use std::io::{Read, Seek};
2863
2864 use common::{url::Params, ToParts};
2865 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2866
2867 let mut dd = common::DefaultDelegate;
2868 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2869 dlg.begin(common::MethodInfo {
2870 id: "cloudmonitoring.timeseriesDescriptors.list",
2871 http_method: hyper::Method::GET,
2872 });
2873
2874 for &field in [
2875 "alt",
2876 "project",
2877 "metric",
2878 "youngest",
2879 "window",
2880 "timespan",
2881 "pageToken",
2882 "oldest",
2883 "labels",
2884 "count",
2885 "aggregator",
2886 ]
2887 .iter()
2888 {
2889 if self._additional_params.contains_key(field) {
2890 dlg.finished(false);
2891 return Err(common::Error::FieldClash(field));
2892 }
2893 }
2894
2895 let mut params = Params::with_capacity(13 + self._additional_params.len());
2896 params.push("project", self._project);
2897 params.push("metric", self._metric);
2898 params.push("youngest", self._youngest);
2899 if let Some(value) = self._window.as_ref() {
2900 params.push("window", value);
2901 }
2902 if let Some(value) = self._timespan.as_ref() {
2903 params.push("timespan", value);
2904 }
2905 if let Some(value) = self._page_token.as_ref() {
2906 params.push("pageToken", value);
2907 }
2908 if let Some(value) = self._oldest.as_ref() {
2909 params.push("oldest", value);
2910 }
2911 if !self._labels.is_empty() {
2912 for f in self._labels.iter() {
2913 params.push("labels", f);
2914 }
2915 }
2916 if let Some(value) = self._count.as_ref() {
2917 params.push("count", value.to_string());
2918 }
2919 if let Some(value) = self._aggregator.as_ref() {
2920 params.push("aggregator", value);
2921 }
2922
2923 params.extend(self._additional_params.iter());
2924
2925 params.push("alt", "json");
2926 let mut url = self.hub._base_url.clone() + "{project}/timeseriesDescriptors/{metric}";
2927 if self._scopes.is_empty() {
2928 self._scopes
2929 .insert(Scope::CloudPlatform.as_ref().to_string());
2930 }
2931
2932 #[allow(clippy::single_element_loop)]
2933 for &(find_this, param_name) in [("{project}", "project"), ("{metric}", "metric")].iter() {
2934 url = params.uri_replacement(url, param_name, find_this, false);
2935 }
2936 {
2937 let to_remove = ["metric", "project"];
2938 params.remove_params(&to_remove);
2939 }
2940
2941 let url = params.parse_with_url(&url);
2942
2943 let mut json_mime_type = mime::APPLICATION_JSON;
2944 let mut request_value_reader = {
2945 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2946 common::remove_json_null_values(&mut value);
2947 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2948 serde_json::to_writer(&mut dst, &value).unwrap();
2949 dst
2950 };
2951 let request_size = request_value_reader
2952 .seek(std::io::SeekFrom::End(0))
2953 .unwrap();
2954 request_value_reader
2955 .seek(std::io::SeekFrom::Start(0))
2956 .unwrap();
2957
2958 loop {
2959 let token = match self
2960 .hub
2961 .auth
2962 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2963 .await
2964 {
2965 Ok(token) => token,
2966 Err(e) => match dlg.token(e) {
2967 Ok(token) => token,
2968 Err(e) => {
2969 dlg.finished(false);
2970 return Err(common::Error::MissingToken(e));
2971 }
2972 },
2973 };
2974 request_value_reader
2975 .seek(std::io::SeekFrom::Start(0))
2976 .unwrap();
2977 let mut req_result = {
2978 let client = &self.hub.client;
2979 dlg.pre_request();
2980 let mut req_builder = hyper::Request::builder()
2981 .method(hyper::Method::GET)
2982 .uri(url.as_str())
2983 .header(USER_AGENT, self.hub._user_agent.clone());
2984
2985 if let Some(token) = token.as_ref() {
2986 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2987 }
2988
2989 let request = req_builder
2990 .header(CONTENT_TYPE, json_mime_type.to_string())
2991 .header(CONTENT_LENGTH, request_size as u64)
2992 .body(common::to_body(
2993 request_value_reader.get_ref().clone().into(),
2994 ));
2995
2996 client.request(request.unwrap()).await
2997 };
2998
2999 match req_result {
3000 Err(err) => {
3001 if let common::Retry::After(d) = dlg.http_error(&err) {
3002 sleep(d).await;
3003 continue;
3004 }
3005 dlg.finished(false);
3006 return Err(common::Error::HttpError(err));
3007 }
3008 Ok(res) => {
3009 let (mut parts, body) = res.into_parts();
3010 let mut body = common::Body::new(body);
3011 if !parts.status.is_success() {
3012 let bytes = common::to_bytes(body).await.unwrap_or_default();
3013 let error = serde_json::from_str(&common::to_string(&bytes));
3014 let response = common::to_response(parts, bytes.into());
3015
3016 if let common::Retry::After(d) =
3017 dlg.http_failure(&response, error.as_ref().ok())
3018 {
3019 sleep(d).await;
3020 continue;
3021 }
3022
3023 dlg.finished(false);
3024
3025 return Err(match error {
3026 Ok(value) => common::Error::BadRequest(value),
3027 _ => common::Error::Failure(response),
3028 });
3029 }
3030 let response = {
3031 let bytes = common::to_bytes(body).await.unwrap_or_default();
3032 let encoded = common::to_string(&bytes);
3033 match serde_json::from_str(&encoded) {
3034 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3035 Err(error) => {
3036 dlg.response_json_decode_error(&encoded, &error);
3037 return Err(common::Error::JsonDecodeError(
3038 encoded.to_string(),
3039 error,
3040 ));
3041 }
3042 }
3043 };
3044
3045 dlg.finished(true);
3046 return Ok(response);
3047 }
3048 }
3049 }
3050 }
3051
3052 ///
3053 /// Sets the *request* property to the given value.
3054 ///
3055 /// Even though the property as already been set when instantiating this call,
3056 /// we provide this method for API completeness.
3057 pub fn request(
3058 mut self,
3059 new_value: ListTimeseriesDescriptorsRequest,
3060 ) -> TimeseriesDescriptorListCall<'a, C> {
3061 self._request = new_value;
3062 self
3063 }
3064 /// The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name.
3065 ///
3066 /// Sets the *project* path property to the given value.
3067 ///
3068 /// Even though the property as already been set when instantiating this call,
3069 /// we provide this method for API completeness.
3070 pub fn project(mut self, new_value: &str) -> TimeseriesDescriptorListCall<'a, C> {
3071 self._project = new_value.to_string();
3072 self
3073 }
3074 /// Metric names are protocol-free URLs as listed in the Supported Metrics page. For example, compute.googleapis.com/instance/disk/read_ops_count.
3075 ///
3076 /// Sets the *metric* path property to the given value.
3077 ///
3078 /// Even though the property as already been set when instantiating this call,
3079 /// we provide this method for API completeness.
3080 pub fn metric(mut self, new_value: &str) -> TimeseriesDescriptorListCall<'a, C> {
3081 self._metric = new_value.to_string();
3082 self
3083 }
3084 /// End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp.
3085 ///
3086 /// Sets the *youngest* query property to the given value.
3087 ///
3088 /// Even though the property as already been set when instantiating this call,
3089 /// we provide this method for API completeness.
3090 pub fn youngest(mut self, new_value: &str) -> TimeseriesDescriptorListCall<'a, C> {
3091 self._youngest = new_value.to_string();
3092 self
3093 }
3094 /// The sampling window. At most one data point will be returned for each window in the requested time interval. This parameter is only valid for non-cumulative metric types. Units:
3095 /// - m: minute
3096 /// - h: hour
3097 /// - d: day
3098 /// - w: week Examples: 3m, 4w. Only one unit is allowed, for example: 2w3d is not allowed; you should use 17d instead.
3099 ///
3100 /// Sets the *window* query property to the given value.
3101 pub fn window(mut self, new_value: &str) -> TimeseriesDescriptorListCall<'a, C> {
3102 self._window = Some(new_value.to_string());
3103 self
3104 }
3105 /// Length of the time interval to query, which is an alternative way to declare the interval: (youngest - timespan, youngest]. The timespan and oldest parameters should not be used together. Units:
3106 /// - s: second
3107 /// - m: minute
3108 /// - h: hour
3109 /// - d: day
3110 /// - w: week Examples: 2s, 3m, 4w. Only one unit is allowed, for example: 2w3d is not allowed; you should use 17d instead.
3111 ///
3112 /// If neither oldest nor timespan is specified, the default time interval will be (youngest - 4 hours, youngest].
3113 ///
3114 /// Sets the *timespan* query property to the given value.
3115 pub fn timespan(mut self, new_value: &str) -> TimeseriesDescriptorListCall<'a, C> {
3116 self._timespan = Some(new_value.to_string());
3117 self
3118 }
3119 /// The pagination token, which is used to page through large result sets. Set this value to the value of the nextPageToken to retrieve the next page of results.
3120 ///
3121 /// Sets the *page token* query property to the given value.
3122 pub fn page_token(mut self, new_value: &str) -> TimeseriesDescriptorListCall<'a, C> {
3123 self._page_token = Some(new_value.to_string());
3124 self
3125 }
3126 /// Start of the time interval (exclusive), which is expressed as an RFC 3339 timestamp. If neither oldest nor timespan is specified, the default time interval will be (youngest - 4 hours, youngest]
3127 ///
3128 /// Sets the *oldest* query property to the given value.
3129 pub fn oldest(mut self, new_value: &str) -> TimeseriesDescriptorListCall<'a, C> {
3130 self._oldest = Some(new_value.to_string());
3131 self
3132 }
3133 /// A collection of labels for the matching time series, which are represented as:
3134 /// - key==value: key equals the value
3135 /// - key=~value: key regex matches the value
3136 /// - key!=value: key does not equal the value
3137 /// - key!~value: key regex does not match the value For example, to list all of the time series descriptors for the region us-central1, you could specify:
3138 /// label=cloud.googleapis.com%2Flocation=~us-central1.*
3139 ///
3140 /// Append the given value to the *labels* query property.
3141 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3142 pub fn add_labels(mut self, new_value: &str) -> TimeseriesDescriptorListCall<'a, C> {
3143 self._labels.push(new_value.to_string());
3144 self
3145 }
3146 /// Maximum number of time series descriptors per page. Used for pagination. If not specified, count = 100.
3147 ///
3148 /// Sets the *count* query property to the given value.
3149 pub fn count(mut self, new_value: i32) -> TimeseriesDescriptorListCall<'a, C> {
3150 self._count = Some(new_value);
3151 self
3152 }
3153 /// The aggregation function that will reduce the data points in each window to a single point. This parameter is only valid for non-cumulative metrics with a value type of INT64 or DOUBLE.
3154 ///
3155 /// Sets the *aggregator* query property to the given value.
3156 pub fn aggregator(mut self, new_value: &str) -> TimeseriesDescriptorListCall<'a, C> {
3157 self._aggregator = Some(new_value.to_string());
3158 self
3159 }
3160 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3161 /// while executing the actual API request.
3162 ///
3163 /// ````text
3164 /// It should be used to handle progress information, and to implement a certain level of resilience.
3165 /// ````
3166 ///
3167 /// Sets the *delegate* property to the given value.
3168 pub fn delegate(
3169 mut self,
3170 new_value: &'a mut dyn common::Delegate,
3171 ) -> TimeseriesDescriptorListCall<'a, C> {
3172 self._delegate = Some(new_value);
3173 self
3174 }
3175
3176 /// Set any additional parameter of the query string used in the request.
3177 /// It should be used to set parameters which are not yet available through their own
3178 /// setters.
3179 ///
3180 /// Please note that this method must not be used to set any of the known parameters
3181 /// which have their own setter method. If done anyway, the request will fail.
3182 ///
3183 /// # Additional Parameters
3184 ///
3185 /// * *alt* (query-string) - Data format for the response.
3186 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3187 /// * *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.
3188 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3189 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3190 /// * *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. Overrides userIp if both are provided.
3191 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3192 pub fn param<T>(mut self, name: T, value: T) -> TimeseriesDescriptorListCall<'a, C>
3193 where
3194 T: AsRef<str>,
3195 {
3196 self._additional_params
3197 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3198 self
3199 }
3200
3201 /// Identifies the authorization scope for the method you are building.
3202 ///
3203 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3204 /// [`Scope::CloudPlatform`].
3205 ///
3206 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3207 /// tokens for more than one scope.
3208 ///
3209 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3210 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3211 /// sufficient, a read-write scope will do as well.
3212 pub fn add_scope<St>(mut self, scope: St) -> TimeseriesDescriptorListCall<'a, C>
3213 where
3214 St: AsRef<str>,
3215 {
3216 self._scopes.insert(String::from(scope.as_ref()));
3217 self
3218 }
3219 /// Identifies the authorization scope(s) for the method you are building.
3220 ///
3221 /// See [`Self::add_scope()`] for details.
3222 pub fn add_scopes<I, St>(mut self, scopes: I) -> TimeseriesDescriptorListCall<'a, C>
3223 where
3224 I: IntoIterator<Item = St>,
3225 St: AsRef<str>,
3226 {
3227 self._scopes
3228 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3229 self
3230 }
3231
3232 /// Removes all scopes, and no default scope will be used either.
3233 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3234 /// for details).
3235 pub fn clear_scopes(mut self) -> TimeseriesDescriptorListCall<'a, C> {
3236 self._scopes.clear();
3237 self
3238 }
3239}