google_versionhistory1/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// ########
12// HUB ###
13// ######
14
15/// Central instance to access all VersionHistory related resource activities
16///
17/// # Examples
18///
19/// Instantiate a new hub
20///
21/// ```test_harness,no_run
22/// extern crate hyper;
23/// extern crate hyper_rustls;
24/// extern crate google_versionhistory1 as versionhistory1;
25/// use versionhistory1::{Result, Error};
26/// # async fn dox() {
27/// use versionhistory1::{VersionHistory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28///
29/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
30/// // `client_secret`, among other things.
31/// let secret: yup_oauth2::ApplicationSecret = Default::default();
32/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
33/// // unless you replace `None` with the desired Flow.
34/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
35/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
36/// // retrieve them from storage.
37/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
38/// secret,
39/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
40/// ).build().await.unwrap();
41///
42/// let client = hyper_util::client::legacy::Client::builder(
43/// hyper_util::rt::TokioExecutor::new()
44/// )
45/// .build(
46/// hyper_rustls::HttpsConnectorBuilder::new()
47/// .with_native_roots()
48/// .unwrap()
49/// .https_or_http()
50/// .enable_http1()
51/// .build()
52/// );
53/// let mut hub = VersionHistory::new(client, auth);
54/// // You can configure optional parameters by calling the respective setters at will, and
55/// // execute the final call using `doit()`.
56/// // Values shown here are possibly random and not representative !
57/// let result = hub.platforms().channels_versions_releases_list("parent")
58/// .page_token("duo")
59/// .page_size(-55)
60/// .order_by("gubergren")
61/// .filter("Lorem")
62/// .doit().await;
63///
64/// match result {
65/// Err(e) => match e {
66/// // The Error enum provides details about what exactly happened.
67/// // You can also just use its `Debug`, `Display` or `Error` traits
68/// Error::HttpError(_)
69/// |Error::Io(_)
70/// |Error::MissingAPIKey
71/// |Error::MissingToken(_)
72/// |Error::Cancelled
73/// |Error::UploadSizeLimitExceeded(_, _)
74/// |Error::Failure(_)
75/// |Error::BadRequest(_)
76/// |Error::FieldClash(_)
77/// |Error::JsonDecodeError(_, _) => println!("{}", e),
78/// },
79/// Ok(res) => println!("Success: {:?}", res),
80/// }
81/// # }
82/// ```
83#[derive(Clone)]
84pub struct VersionHistory<C> {
85 pub client: common::Client<C>,
86 pub auth: Box<dyn common::GetToken>,
87 _user_agent: String,
88 _base_url: String,
89 _root_url: String,
90}
91
92impl<C> common::Hub for VersionHistory<C> {}
93
94impl<'a, C> VersionHistory<C> {
95 pub fn new<A: 'static + common::GetToken>(
96 client: common::Client<C>,
97 auth: A,
98 ) -> VersionHistory<C> {
99 VersionHistory {
100 client,
101 auth: Box::new(auth),
102 _user_agent: "google-api-rust-client/6.0.0".to_string(),
103 _base_url: "https://versionhistory.googleapis.com/".to_string(),
104 _root_url: "https://versionhistory.googleapis.com/".to_string(),
105 }
106 }
107
108 pub fn platforms(&'a self) -> PlatformMethods<'a, C> {
109 PlatformMethods { hub: self }
110 }
111
112 /// Set the user-agent header field to use in all requests to the server.
113 /// It defaults to `google-api-rust-client/6.0.0`.
114 ///
115 /// Returns the previously set user-agent.
116 pub fn user_agent(&mut self, agent_name: String) -> String {
117 std::mem::replace(&mut self._user_agent, agent_name)
118 }
119
120 /// Set the base url to use in all requests to the server.
121 /// It defaults to `https://versionhistory.googleapis.com/`.
122 ///
123 /// Returns the previously set base url.
124 pub fn base_url(&mut self, new_base_url: String) -> String {
125 std::mem::replace(&mut self._base_url, new_base_url)
126 }
127
128 /// Set the root url to use in all requests to the server.
129 /// It defaults to `https://versionhistory.googleapis.com/`.
130 ///
131 /// Returns the previously set root url.
132 pub fn root_url(&mut self, new_root_url: String) -> String {
133 std::mem::replace(&mut self._root_url, new_root_url)
134 }
135}
136
137// ############
138// SCHEMAS ###
139// ##########
140/// Each Channel is owned by a Platform and owns a collection of versions. Possible Channels are listed in the Channel enum below. Not all Channels are available for every Platform (e.g. CANARY does not exist for LINUX).
141///
142/// This type is not used in any activity, and only used as *part* of another schema.
143///
144#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
145#[serde_with::serde_as]
146#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
147pub struct Channel {
148 /// Type of channel.
149 #[serde(rename = "channelType")]
150 pub channel_type: Option<String>,
151 /// Channel name. Format is "{product}/platforms/{platform}/channels/{channel}"
152 pub name: Option<String>,
153}
154
155impl common::Part for Channel {}
156
157/// Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive). The start must be less than or equal to the end. When the start equals the end, the interval is empty (matches no time). When both start and end are unspecified, the interval matches any time.
158///
159/// This type is not used in any activity, and only used as *part* of another schema.
160///
161#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
162#[serde_with::serde_as]
163#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
164pub struct Interval {
165 /// Optional. Exclusive end of the interval. If specified, a Timestamp matching this interval will have to be before the end.
166 #[serde(rename = "endTime")]
167 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
168 /// Optional. Inclusive start of the interval. If specified, a Timestamp matching this interval will have to be the same or after the start.
169 #[serde(rename = "startTime")]
170 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
171}
172
173impl common::Part for Interval {}
174
175/// Response message for ListChannels.
176///
177/// # Activities
178///
179/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
180/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
181///
182/// * [channels list platforms](PlatformChannelListCall) (response)
183#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
184#[serde_with::serde_as]
185#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
186pub struct ListChannelsResponse {
187 /// The list of channels.
188 pub channels: Option<Vec<Channel>>,
189 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
190 #[serde(rename = "nextPageToken")]
191 pub next_page_token: Option<String>,
192}
193
194impl common::ResponseResult for ListChannelsResponse {}
195
196/// Response message for ListPlatforms.
197///
198/// # Activities
199///
200/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
201/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
202///
203/// * [list platforms](PlatformListCall) (response)
204#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
205#[serde_with::serde_as]
206#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
207pub struct ListPlatformsResponse {
208 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
209 #[serde(rename = "nextPageToken")]
210 pub next_page_token: Option<String>,
211 /// The list of platforms.
212 pub platforms: Option<Vec<Platform>>,
213}
214
215impl common::ResponseResult for ListPlatformsResponse {}
216
217/// Response message for ListReleases.
218///
219/// # Activities
220///
221/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
222/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
223///
224/// * [channels versions releases list platforms](PlatformChannelVersionReleaseListCall) (response)
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct ListReleasesResponse {
229 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
230 #[serde(rename = "nextPageToken")]
231 pub next_page_token: Option<String>,
232 /// The list of releases.
233 pub releases: Option<Vec<Release>>,
234}
235
236impl common::ResponseResult for ListReleasesResponse {}
237
238/// Response message for ListVersions.
239///
240/// # Activities
241///
242/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
243/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
244///
245/// * [channels versions list platforms](PlatformChannelVersionListCall) (response)
246#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
247#[serde_with::serde_as]
248#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
249pub struct ListVersionsResponse {
250 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
251 #[serde(rename = "nextPageToken")]
252 pub next_page_token: Option<String>,
253 /// The list of versions.
254 pub versions: Option<Vec<Version>>,
255}
256
257impl common::ResponseResult for ListVersionsResponse {}
258
259/// Each Platform is owned by a Product and owns a collection of channels. Available platforms are listed in Platform enum below. Not all Channels are available for every Platform (e.g. CANARY does not exist for LINUX).
260///
261/// # Activities
262///
263/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
264/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
265///
266/// * [channels versions releases list platforms](PlatformChannelVersionReleaseListCall) (none)
267/// * [channels versions list platforms](PlatformChannelVersionListCall) (none)
268/// * [channels list platforms](PlatformChannelListCall) (none)
269/// * [list platforms](PlatformListCall) (none)
270#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
271#[serde_with::serde_as]
272#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
273pub struct Platform {
274 /// Platform name. Format is "{product}/platforms/{platform}"
275 pub name: Option<String>,
276 /// Type of platform.
277 #[serde(rename = "platformType")]
278 pub platform_type: Option<String>,
279}
280
281impl common::Resource for Platform {}
282
283/// A Release is owned by a Version. A Release contains information about the release(s) of its parent version. This includes when the release began and ended, as well as what percentage it was released at. If the version is released again, or if the serving percentage changes, it will create another release under the version.
284///
285/// This type is not used in any activity, and only used as *part* of another schema.
286///
287#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
288#[serde_with::serde_as]
289#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
290pub struct Release {
291 /// Rollout fraction. This fraction indicates the fraction of people that should receive this version in this release. If the fraction is not specified in ReleaseManager, the API will assume fraction is 1.
292 pub fraction: Option<f64>,
293 /// Rollout fraction group. Only fractions with the same fraction_group are statistically comparable: there may be non-fractional differences between different fraction groups.
294 #[serde(rename = "fractionGroup")]
295 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
296 pub fraction_group: Option<i64>,
297 /// Release name. Format is "{product}/platforms/{platform}/channels/{channel}/versions/{version}/releases/{release}"
298 pub name: Option<String>,
299 /// Whether or not the release was available for version pinning.
300 pub pinnable: Option<bool>,
301 /// Timestamp interval of when the release was live. If end_time is unspecified, the release is currently live.
302 pub serving: Option<Interval>,
303 /// String containing just the version number. e.g. "84.0.4147.38"
304 pub version: Option<String>,
305}
306
307impl common::Part for Release {}
308
309/// Each Version is owned by a Channel. A Version only displays the Version number (e.g. 84.0.4147.38). A Version owns a collection of releases.
310///
311/// This type is not used in any activity, and only used as *part* of another schema.
312///
313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
314#[serde_with::serde_as]
315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
316pub struct Version {
317 /// Version name. Format is "{product}/platforms/{platform}/channels/{channel}/versions/{version}" e.g. "chrome/platforms/win/channels/beta/versions/84.0.4147.38"
318 pub name: Option<String>,
319 /// String containing just the version number. e.g. "84.0.4147.38"
320 pub version: Option<String>,
321}
322
323impl common::Part for Version {}
324
325// ###################
326// MethodBuilders ###
327// #################
328
329/// A builder providing access to all methods supported on *platform* resources.
330/// It is not used directly, but through the [`VersionHistory`] hub.
331///
332/// # Example
333///
334/// Instantiate a resource builder
335///
336/// ```test_harness,no_run
337/// extern crate hyper;
338/// extern crate hyper_rustls;
339/// extern crate google_versionhistory1 as versionhistory1;
340///
341/// # async fn dox() {
342/// use versionhistory1::{VersionHistory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
343///
344/// let secret: yup_oauth2::ApplicationSecret = Default::default();
345/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
346/// secret,
347/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
348/// ).build().await.unwrap();
349///
350/// let client = hyper_util::client::legacy::Client::builder(
351/// hyper_util::rt::TokioExecutor::new()
352/// )
353/// .build(
354/// hyper_rustls::HttpsConnectorBuilder::new()
355/// .with_native_roots()
356/// .unwrap()
357/// .https_or_http()
358/// .enable_http1()
359/// .build()
360/// );
361/// let mut hub = VersionHistory::new(client, auth);
362/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
363/// // like `channels_list(...)`, `channels_versions_list(...)`, `channels_versions_releases_list(...)` and `list(...)`
364/// // to build up your call.
365/// let rb = hub.platforms();
366/// # }
367/// ```
368pub struct PlatformMethods<'a, C>
369where
370 C: 'a,
371{
372 hub: &'a VersionHistory<C>,
373}
374
375impl<'a, C> common::MethodsBuilder for PlatformMethods<'a, C> {}
376
377impl<'a, C> PlatformMethods<'a, C> {
378 /// Create a builder to help you perform the following task:
379 ///
380 /// Returns list of releases of the given version.
381 ///
382 /// # Arguments
383 ///
384 /// * `parent` - Required. The version, which owns this collection of releases. Format: {product}/platforms/{platform}/channels/{channel}/versions/{version}
385 pub fn channels_versions_releases_list(
386 &self,
387 parent: &str,
388 ) -> PlatformChannelVersionReleaseListCall<'a, C> {
389 PlatformChannelVersionReleaseListCall {
390 hub: self.hub,
391 _parent: parent.to_string(),
392 _page_token: Default::default(),
393 _page_size: Default::default(),
394 _order_by: Default::default(),
395 _filter: Default::default(),
396 _delegate: Default::default(),
397 _additional_params: Default::default(),
398 }
399 }
400
401 /// Create a builder to help you perform the following task:
402 ///
403 /// Returns list of version for the given platform/channel.
404 ///
405 /// # Arguments
406 ///
407 /// * `parent` - Required. The channel, which owns this collection of versions. Format: {product}/platforms/{platform}/channels/{channel}
408 pub fn channels_versions_list(&self, parent: &str) -> PlatformChannelVersionListCall<'a, C> {
409 PlatformChannelVersionListCall {
410 hub: self.hub,
411 _parent: parent.to_string(),
412 _page_token: Default::default(),
413 _page_size: Default::default(),
414 _order_by: Default::default(),
415 _filter: Default::default(),
416 _delegate: Default::default(),
417 _additional_params: Default::default(),
418 }
419 }
420
421 /// Create a builder to help you perform the following task:
422 ///
423 /// Returns list of channels that are available for a given platform.
424 ///
425 /// # Arguments
426 ///
427 /// * `parent` - Required. The platform, which owns this collection of channels. Format: {product}/platforms/{platform}
428 pub fn channels_list(&self, parent: &str) -> PlatformChannelListCall<'a, C> {
429 PlatformChannelListCall {
430 hub: self.hub,
431 _parent: parent.to_string(),
432 _page_token: Default::default(),
433 _page_size: Default::default(),
434 _delegate: Default::default(),
435 _additional_params: Default::default(),
436 }
437 }
438
439 /// Create a builder to help you perform the following task:
440 ///
441 /// Returns list of platforms that are available for a given product. The resource "product" has no resource name in its name.
442 ///
443 /// # Arguments
444 ///
445 /// * `parent` - Required. The product, which owns this collection of platforms. Format: {product}
446 pub fn list(&self, parent: &str) -> PlatformListCall<'a, C> {
447 PlatformListCall {
448 hub: self.hub,
449 _parent: parent.to_string(),
450 _page_token: Default::default(),
451 _page_size: Default::default(),
452 _delegate: Default::default(),
453 _additional_params: Default::default(),
454 }
455 }
456}
457
458// ###################
459// CallBuilders ###
460// #################
461
462/// Returns list of releases of the given version.
463///
464/// A builder for the *channels.versions.releases.list* method supported by a *platform* resource.
465/// It is not used directly, but through a [`PlatformMethods`] instance.
466///
467/// # Example
468///
469/// Instantiate a resource method builder
470///
471/// ```test_harness,no_run
472/// # extern crate hyper;
473/// # extern crate hyper_rustls;
474/// # extern crate google_versionhistory1 as versionhistory1;
475/// # async fn dox() {
476/// # use versionhistory1::{VersionHistory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
477///
478/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
479/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
480/// # secret,
481/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
482/// # ).build().await.unwrap();
483///
484/// # let client = hyper_util::client::legacy::Client::builder(
485/// # hyper_util::rt::TokioExecutor::new()
486/// # )
487/// # .build(
488/// # hyper_rustls::HttpsConnectorBuilder::new()
489/// # .with_native_roots()
490/// # .unwrap()
491/// # .https_or_http()
492/// # .enable_http1()
493/// # .build()
494/// # );
495/// # let mut hub = VersionHistory::new(client, auth);
496/// // You can configure optional parameters by calling the respective setters at will, and
497/// // execute the final call using `doit()`.
498/// // Values shown here are possibly random and not representative !
499/// let result = hub.platforms().channels_versions_releases_list("parent")
500/// .page_token("eos")
501/// .page_size(-4)
502/// .order_by("ea")
503/// .filter("ipsum")
504/// .doit().await;
505/// # }
506/// ```
507pub struct PlatformChannelVersionReleaseListCall<'a, C>
508where
509 C: 'a,
510{
511 hub: &'a VersionHistory<C>,
512 _parent: String,
513 _page_token: Option<String>,
514 _page_size: Option<i32>,
515 _order_by: Option<String>,
516 _filter: Option<String>,
517 _delegate: Option<&'a mut dyn common::Delegate>,
518 _additional_params: HashMap<String, String>,
519}
520
521impl<'a, C> common::CallBuilder for PlatformChannelVersionReleaseListCall<'a, C> {}
522
523impl<'a, C> PlatformChannelVersionReleaseListCall<'a, C>
524where
525 C: common::Connector,
526{
527 /// Perform the operation you have build so far.
528 pub async fn doit(mut self) -> common::Result<(common::Response, ListReleasesResponse)> {
529 use std::borrow::Cow;
530 use std::io::{Read, Seek};
531
532 use common::{url::Params, ToParts};
533 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
534
535 let mut dd = common::DefaultDelegate;
536 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
537 dlg.begin(common::MethodInfo {
538 id: "versionhistory.platforms.channels.versions.releases.list",
539 http_method: hyper::Method::GET,
540 });
541
542 for &field in [
543 "alt",
544 "parent",
545 "pageToken",
546 "pageSize",
547 "orderBy",
548 "filter",
549 ]
550 .iter()
551 {
552 if self._additional_params.contains_key(field) {
553 dlg.finished(false);
554 return Err(common::Error::FieldClash(field));
555 }
556 }
557
558 let mut params = Params::with_capacity(7 + self._additional_params.len());
559 params.push("parent", self._parent);
560 if let Some(value) = self._page_token.as_ref() {
561 params.push("pageToken", value);
562 }
563 if let Some(value) = self._page_size.as_ref() {
564 params.push("pageSize", value.to_string());
565 }
566 if let Some(value) = self._order_by.as_ref() {
567 params.push("orderBy", value);
568 }
569 if let Some(value) = self._filter.as_ref() {
570 params.push("filter", value);
571 }
572
573 params.extend(self._additional_params.iter());
574
575 params.push("alt", "json");
576 let mut url = self.hub._base_url.clone() + "v1/{+parent}/releases";
577
578 match dlg.api_key() {
579 Some(value) => params.push("key", value),
580 None => {
581 dlg.finished(false);
582 return Err(common::Error::MissingAPIKey);
583 }
584 }
585
586 #[allow(clippy::single_element_loop)]
587 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
588 url = params.uri_replacement(url, param_name, find_this, true);
589 }
590 {
591 let to_remove = ["parent"];
592 params.remove_params(&to_remove);
593 }
594
595 let url = params.parse_with_url(&url);
596
597 loop {
598 let mut req_result = {
599 let client = &self.hub.client;
600 dlg.pre_request();
601 let mut req_builder = hyper::Request::builder()
602 .method(hyper::Method::GET)
603 .uri(url.as_str())
604 .header(USER_AGENT, self.hub._user_agent.clone());
605
606 let request = req_builder
607 .header(CONTENT_LENGTH, 0_u64)
608 .body(common::to_body::<String>(None));
609
610 client.request(request.unwrap()).await
611 };
612
613 match req_result {
614 Err(err) => {
615 if let common::Retry::After(d) = dlg.http_error(&err) {
616 sleep(d).await;
617 continue;
618 }
619 dlg.finished(false);
620 return Err(common::Error::HttpError(err));
621 }
622 Ok(res) => {
623 let (mut parts, body) = res.into_parts();
624 let mut body = common::Body::new(body);
625 if !parts.status.is_success() {
626 let bytes = common::to_bytes(body).await.unwrap_or_default();
627 let error = serde_json::from_str(&common::to_string(&bytes));
628 let response = common::to_response(parts, bytes.into());
629
630 if let common::Retry::After(d) =
631 dlg.http_failure(&response, error.as_ref().ok())
632 {
633 sleep(d).await;
634 continue;
635 }
636
637 dlg.finished(false);
638
639 return Err(match error {
640 Ok(value) => common::Error::BadRequest(value),
641 _ => common::Error::Failure(response),
642 });
643 }
644 let response = {
645 let bytes = common::to_bytes(body).await.unwrap_or_default();
646 let encoded = common::to_string(&bytes);
647 match serde_json::from_str(&encoded) {
648 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
649 Err(error) => {
650 dlg.response_json_decode_error(&encoded, &error);
651 return Err(common::Error::JsonDecodeError(
652 encoded.to_string(),
653 error,
654 ));
655 }
656 }
657 };
658
659 dlg.finished(true);
660 return Ok(response);
661 }
662 }
663 }
664 }
665
666 /// Required. The version, which owns this collection of releases. Format: {product}/platforms/{platform}/channels/{channel}/versions/{version}
667 ///
668 /// Sets the *parent* path property to the given value.
669 ///
670 /// Even though the property as already been set when instantiating this call,
671 /// we provide this method for API completeness.
672 pub fn parent(mut self, new_value: &str) -> PlatformChannelVersionReleaseListCall<'a, C> {
673 self._parent = new_value.to_string();
674 self
675 }
676 /// Optional. A page token, received from a previous `ListReleases` call. Provide this to retrieve the subsequent page.
677 ///
678 /// Sets the *page token* query property to the given value.
679 pub fn page_token(mut self, new_value: &str) -> PlatformChannelVersionReleaseListCall<'a, C> {
680 self._page_token = Some(new_value.to_string());
681 self
682 }
683 /// Optional. Optional limit on the number of releases to include in the response. If unspecified, the server will pick an appropriate default.
684 ///
685 /// Sets the *page size* query property to the given value.
686 pub fn page_size(mut self, new_value: i32) -> PlatformChannelVersionReleaseListCall<'a, C> {
687 self._page_size = Some(new_value);
688 self
689 }
690 /// Optional. Ordering string. Valid order_by strings are "version", "name", "starttime", "endtime", "platform", "channel", and "fraction". Optionally, you can append "desc" or "asc" to specify the sorting order. Multiple order_by strings can be used in a comma separated list. Ordering by channel will sort by distance from the stable channel (not alphabetically). A list of channels sorted in this order is: stable, beta, dev, canary, and canary_asan. Sorting by name may cause unexpected behaviour as it is a naive string sort. For example, 1.0.0.8 will be before 1.0.0.10 in descending order. If order_by is not specified the response will be sorted by starttime in descending order. Ex) "...?order_by=starttime asc" Ex) "...?order_by=platform desc, channel, startime desc"
691 ///
692 /// Sets the *order by* query property to the given value.
693 pub fn order_by(mut self, new_value: &str) -> PlatformChannelVersionReleaseListCall<'a, C> {
694 self._order_by = Some(new_value.to_string());
695 self
696 }
697 /// Optional. Filter string. Format is a comma separated list of All comma separated filter clauses are conjoined with a logical "and". Valid field_names are "version", "name", "platform", "channel", "fraction" "starttime", and "endtime". Valid operators are "<", "<=", "=", ">=", and ">". Channel comparison is done by distance from stable. must be a valid channel when filtering by channel. Ex) stable < beta, beta < dev, canary < canary_asan. Version comparison is done numerically. Ex) 1.0.0.8 < 1.0.0.10. If version is not entirely written, the version will be appended with 0 for the missing fields. Ex) version > 80 becoms version > 80.0.0.0 When filtering by starttime or endtime, string must be in RFC 3339 date string format. Name and platform are filtered by string comparison. Ex) "...?filter=channel<=beta, version >= 80 Ex) "...?filter=version > 80, version < 81 Ex) "...?filter=starttime>2020-01-01T00:00:00Z
698 ///
699 /// Sets the *filter* query property to the given value.
700 pub fn filter(mut self, new_value: &str) -> PlatformChannelVersionReleaseListCall<'a, C> {
701 self._filter = Some(new_value.to_string());
702 self
703 }
704 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
705 /// while executing the actual API request.
706 ///
707 /// ````text
708 /// It should be used to handle progress information, and to implement a certain level of resilience.
709 /// ````
710 ///
711 /// Sets the *delegate* property to the given value.
712 pub fn delegate(
713 mut self,
714 new_value: &'a mut dyn common::Delegate,
715 ) -> PlatformChannelVersionReleaseListCall<'a, C> {
716 self._delegate = Some(new_value);
717 self
718 }
719
720 /// Set any additional parameter of the query string used in the request.
721 /// It should be used to set parameters which are not yet available through their own
722 /// setters.
723 ///
724 /// Please note that this method must not be used to set any of the known parameters
725 /// which have their own setter method. If done anyway, the request will fail.
726 ///
727 /// # Additional Parameters
728 ///
729 /// * *$.xgafv* (query-string) - V1 error format.
730 /// * *access_token* (query-string) - OAuth access token.
731 /// * *alt* (query-string) - Data format for response.
732 /// * *callback* (query-string) - JSONP
733 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
734 /// * *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.
735 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
736 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
737 /// * *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.
738 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
739 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
740 pub fn param<T>(mut self, name: T, value: T) -> PlatformChannelVersionReleaseListCall<'a, C>
741 where
742 T: AsRef<str>,
743 {
744 self._additional_params
745 .insert(name.as_ref().to_string(), value.as_ref().to_string());
746 self
747 }
748}
749
750/// Returns list of version for the given platform/channel.
751///
752/// A builder for the *channels.versions.list* method supported by a *platform* resource.
753/// It is not used directly, but through a [`PlatformMethods`] instance.
754///
755/// # Example
756///
757/// Instantiate a resource method builder
758///
759/// ```test_harness,no_run
760/// # extern crate hyper;
761/// # extern crate hyper_rustls;
762/// # extern crate google_versionhistory1 as versionhistory1;
763/// # async fn dox() {
764/// # use versionhistory1::{VersionHistory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
765///
766/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
767/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
768/// # secret,
769/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
770/// # ).build().await.unwrap();
771///
772/// # let client = hyper_util::client::legacy::Client::builder(
773/// # hyper_util::rt::TokioExecutor::new()
774/// # )
775/// # .build(
776/// # hyper_rustls::HttpsConnectorBuilder::new()
777/// # .with_native_roots()
778/// # .unwrap()
779/// # .https_or_http()
780/// # .enable_http1()
781/// # .build()
782/// # );
783/// # let mut hub = VersionHistory::new(client, auth);
784/// // You can configure optional parameters by calling the respective setters at will, and
785/// // execute the final call using `doit()`.
786/// // Values shown here are possibly random and not representative !
787/// let result = hub.platforms().channels_versions_list("parent")
788/// .page_token("amet")
789/// .page_size(-20)
790/// .order_by("ipsum")
791/// .filter("sed")
792/// .doit().await;
793/// # }
794/// ```
795pub struct PlatformChannelVersionListCall<'a, C>
796where
797 C: 'a,
798{
799 hub: &'a VersionHistory<C>,
800 _parent: String,
801 _page_token: Option<String>,
802 _page_size: Option<i32>,
803 _order_by: Option<String>,
804 _filter: Option<String>,
805 _delegate: Option<&'a mut dyn common::Delegate>,
806 _additional_params: HashMap<String, String>,
807}
808
809impl<'a, C> common::CallBuilder for PlatformChannelVersionListCall<'a, C> {}
810
811impl<'a, C> PlatformChannelVersionListCall<'a, C>
812where
813 C: common::Connector,
814{
815 /// Perform the operation you have build so far.
816 pub async fn doit(mut self) -> common::Result<(common::Response, ListVersionsResponse)> {
817 use std::borrow::Cow;
818 use std::io::{Read, Seek};
819
820 use common::{url::Params, ToParts};
821 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
822
823 let mut dd = common::DefaultDelegate;
824 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
825 dlg.begin(common::MethodInfo {
826 id: "versionhistory.platforms.channels.versions.list",
827 http_method: hyper::Method::GET,
828 });
829
830 for &field in [
831 "alt",
832 "parent",
833 "pageToken",
834 "pageSize",
835 "orderBy",
836 "filter",
837 ]
838 .iter()
839 {
840 if self._additional_params.contains_key(field) {
841 dlg.finished(false);
842 return Err(common::Error::FieldClash(field));
843 }
844 }
845
846 let mut params = Params::with_capacity(7 + self._additional_params.len());
847 params.push("parent", self._parent);
848 if let Some(value) = self._page_token.as_ref() {
849 params.push("pageToken", value);
850 }
851 if let Some(value) = self._page_size.as_ref() {
852 params.push("pageSize", value.to_string());
853 }
854 if let Some(value) = self._order_by.as_ref() {
855 params.push("orderBy", value);
856 }
857 if let Some(value) = self._filter.as_ref() {
858 params.push("filter", value);
859 }
860
861 params.extend(self._additional_params.iter());
862
863 params.push("alt", "json");
864 let mut url = self.hub._base_url.clone() + "v1/{+parent}/versions";
865
866 match dlg.api_key() {
867 Some(value) => params.push("key", value),
868 None => {
869 dlg.finished(false);
870 return Err(common::Error::MissingAPIKey);
871 }
872 }
873
874 #[allow(clippy::single_element_loop)]
875 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
876 url = params.uri_replacement(url, param_name, find_this, true);
877 }
878 {
879 let to_remove = ["parent"];
880 params.remove_params(&to_remove);
881 }
882
883 let url = params.parse_with_url(&url);
884
885 loop {
886 let mut req_result = {
887 let client = &self.hub.client;
888 dlg.pre_request();
889 let mut req_builder = hyper::Request::builder()
890 .method(hyper::Method::GET)
891 .uri(url.as_str())
892 .header(USER_AGENT, self.hub._user_agent.clone());
893
894 let request = req_builder
895 .header(CONTENT_LENGTH, 0_u64)
896 .body(common::to_body::<String>(None));
897
898 client.request(request.unwrap()).await
899 };
900
901 match req_result {
902 Err(err) => {
903 if let common::Retry::After(d) = dlg.http_error(&err) {
904 sleep(d).await;
905 continue;
906 }
907 dlg.finished(false);
908 return Err(common::Error::HttpError(err));
909 }
910 Ok(res) => {
911 let (mut parts, body) = res.into_parts();
912 let mut body = common::Body::new(body);
913 if !parts.status.is_success() {
914 let bytes = common::to_bytes(body).await.unwrap_or_default();
915 let error = serde_json::from_str(&common::to_string(&bytes));
916 let response = common::to_response(parts, bytes.into());
917
918 if let common::Retry::After(d) =
919 dlg.http_failure(&response, error.as_ref().ok())
920 {
921 sleep(d).await;
922 continue;
923 }
924
925 dlg.finished(false);
926
927 return Err(match error {
928 Ok(value) => common::Error::BadRequest(value),
929 _ => common::Error::Failure(response),
930 });
931 }
932 let response = {
933 let bytes = common::to_bytes(body).await.unwrap_or_default();
934 let encoded = common::to_string(&bytes);
935 match serde_json::from_str(&encoded) {
936 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
937 Err(error) => {
938 dlg.response_json_decode_error(&encoded, &error);
939 return Err(common::Error::JsonDecodeError(
940 encoded.to_string(),
941 error,
942 ));
943 }
944 }
945 };
946
947 dlg.finished(true);
948 return Ok(response);
949 }
950 }
951 }
952 }
953
954 /// Required. The channel, which owns this collection of versions. Format: {product}/platforms/{platform}/channels/{channel}
955 ///
956 /// Sets the *parent* path property to the given value.
957 ///
958 /// Even though the property as already been set when instantiating this call,
959 /// we provide this method for API completeness.
960 pub fn parent(mut self, new_value: &str) -> PlatformChannelVersionListCall<'a, C> {
961 self._parent = new_value.to_string();
962 self
963 }
964 /// Optional. A page token, received from a previous `ListVersions` call. Provide this to retrieve the subsequent page.
965 ///
966 /// Sets the *page token* query property to the given value.
967 pub fn page_token(mut self, new_value: &str) -> PlatformChannelVersionListCall<'a, C> {
968 self._page_token = Some(new_value.to_string());
969 self
970 }
971 /// Optional. Optional limit on the number of versions to include in the response. If unspecified, the server will pick an appropriate default.
972 ///
973 /// Sets the *page size* query property to the given value.
974 pub fn page_size(mut self, new_value: i32) -> PlatformChannelVersionListCall<'a, C> {
975 self._page_size = Some(new_value);
976 self
977 }
978 /// Optional. Ordering string. Valid order_by strings are "version", "name", "platform", and "channel". Optionally, you can append " desc" or " asc" to specify the sorting order. Multiple order_by strings can be used in a comma separated list. Ordering by channel will sort by distance from the stable channel (not alphabetically). A list of channels sorted in this order is: stable, beta, dev, canary, and canary_asan. Sorting by name may cause unexpected behaviour as it is a naive string sort. For example, 1.0.0.8 will be before 1.0.0.10 in descending order. If order_by is not specified the response will be sorted by version in descending order. Ex) "...?order_by=version asc" Ex) "...?order_by=platform desc, channel, version"
979 ///
980 /// Sets the *order by* query property to the given value.
981 pub fn order_by(mut self, new_value: &str) -> PlatformChannelVersionListCall<'a, C> {
982 self._order_by = Some(new_value.to_string());
983 self
984 }
985 /// Optional. Filter string. Format is a comma separated list of All comma separated filter clauses are conjoined with a logical "and". Valid field_names are "version", "name", "platform", and "channel". Valid operators are "<", "<=", "=", ">=", and ">". Channel comparison is done by distance from stable. Ex) stable < beta, beta < dev, canary < canary_asan. Version comparison is done numerically. If version is not entirely written, the version will be appended with 0 in missing fields. Ex) version > 80 becoms version > 80.0.0.0 Name and platform are filtered by string comparison. Ex) "...?filter=channel<=beta, version >= 80 Ex) "...?filter=version > 80, version < 81
986 ///
987 /// Sets the *filter* query property to the given value.
988 pub fn filter(mut self, new_value: &str) -> PlatformChannelVersionListCall<'a, C> {
989 self._filter = Some(new_value.to_string());
990 self
991 }
992 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
993 /// while executing the actual API request.
994 ///
995 /// ````text
996 /// It should be used to handle progress information, and to implement a certain level of resilience.
997 /// ````
998 ///
999 /// Sets the *delegate* property to the given value.
1000 pub fn delegate(
1001 mut self,
1002 new_value: &'a mut dyn common::Delegate,
1003 ) -> PlatformChannelVersionListCall<'a, C> {
1004 self._delegate = Some(new_value);
1005 self
1006 }
1007
1008 /// Set any additional parameter of the query string used in the request.
1009 /// It should be used to set parameters which are not yet available through their own
1010 /// setters.
1011 ///
1012 /// Please note that this method must not be used to set any of the known parameters
1013 /// which have their own setter method. If done anyway, the request will fail.
1014 ///
1015 /// # Additional Parameters
1016 ///
1017 /// * *$.xgafv* (query-string) - V1 error format.
1018 /// * *access_token* (query-string) - OAuth access token.
1019 /// * *alt* (query-string) - Data format for response.
1020 /// * *callback* (query-string) - JSONP
1021 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1022 /// * *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.
1023 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1024 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1025 /// * *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.
1026 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1027 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1028 pub fn param<T>(mut self, name: T, value: T) -> PlatformChannelVersionListCall<'a, C>
1029 where
1030 T: AsRef<str>,
1031 {
1032 self._additional_params
1033 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1034 self
1035 }
1036}
1037
1038/// Returns list of channels that are available for a given platform.
1039///
1040/// A builder for the *channels.list* method supported by a *platform* resource.
1041/// It is not used directly, but through a [`PlatformMethods`] instance.
1042///
1043/// # Example
1044///
1045/// Instantiate a resource method builder
1046///
1047/// ```test_harness,no_run
1048/// # extern crate hyper;
1049/// # extern crate hyper_rustls;
1050/// # extern crate google_versionhistory1 as versionhistory1;
1051/// # async fn dox() {
1052/// # use versionhistory1::{VersionHistory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1053///
1054/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1055/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1056/// # secret,
1057/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1058/// # ).build().await.unwrap();
1059///
1060/// # let client = hyper_util::client::legacy::Client::builder(
1061/// # hyper_util::rt::TokioExecutor::new()
1062/// # )
1063/// # .build(
1064/// # hyper_rustls::HttpsConnectorBuilder::new()
1065/// # .with_native_roots()
1066/// # .unwrap()
1067/// # .https_or_http()
1068/// # .enable_http1()
1069/// # .build()
1070/// # );
1071/// # let mut hub = VersionHistory::new(client, auth);
1072/// // You can configure optional parameters by calling the respective setters at will, and
1073/// // execute the final call using `doit()`.
1074/// // Values shown here are possibly random and not representative !
1075/// let result = hub.platforms().channels_list("parent")
1076/// .page_token("gubergren")
1077/// .page_size(-16)
1078/// .doit().await;
1079/// # }
1080/// ```
1081pub struct PlatformChannelListCall<'a, C>
1082where
1083 C: 'a,
1084{
1085 hub: &'a VersionHistory<C>,
1086 _parent: String,
1087 _page_token: Option<String>,
1088 _page_size: Option<i32>,
1089 _delegate: Option<&'a mut dyn common::Delegate>,
1090 _additional_params: HashMap<String, String>,
1091}
1092
1093impl<'a, C> common::CallBuilder for PlatformChannelListCall<'a, C> {}
1094
1095impl<'a, C> PlatformChannelListCall<'a, C>
1096where
1097 C: common::Connector,
1098{
1099 /// Perform the operation you have build so far.
1100 pub async fn doit(mut self) -> common::Result<(common::Response, ListChannelsResponse)> {
1101 use std::borrow::Cow;
1102 use std::io::{Read, Seek};
1103
1104 use common::{url::Params, ToParts};
1105 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1106
1107 let mut dd = common::DefaultDelegate;
1108 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1109 dlg.begin(common::MethodInfo {
1110 id: "versionhistory.platforms.channels.list",
1111 http_method: hyper::Method::GET,
1112 });
1113
1114 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
1115 if self._additional_params.contains_key(field) {
1116 dlg.finished(false);
1117 return Err(common::Error::FieldClash(field));
1118 }
1119 }
1120
1121 let mut params = Params::with_capacity(5 + self._additional_params.len());
1122 params.push("parent", self._parent);
1123 if let Some(value) = self._page_token.as_ref() {
1124 params.push("pageToken", value);
1125 }
1126 if let Some(value) = self._page_size.as_ref() {
1127 params.push("pageSize", value.to_string());
1128 }
1129
1130 params.extend(self._additional_params.iter());
1131
1132 params.push("alt", "json");
1133 let mut url = self.hub._base_url.clone() + "v1/{+parent}/channels";
1134
1135 match dlg.api_key() {
1136 Some(value) => params.push("key", value),
1137 None => {
1138 dlg.finished(false);
1139 return Err(common::Error::MissingAPIKey);
1140 }
1141 }
1142
1143 #[allow(clippy::single_element_loop)]
1144 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1145 url = params.uri_replacement(url, param_name, find_this, true);
1146 }
1147 {
1148 let to_remove = ["parent"];
1149 params.remove_params(&to_remove);
1150 }
1151
1152 let url = params.parse_with_url(&url);
1153
1154 loop {
1155 let mut req_result = {
1156 let client = &self.hub.client;
1157 dlg.pre_request();
1158 let mut req_builder = hyper::Request::builder()
1159 .method(hyper::Method::GET)
1160 .uri(url.as_str())
1161 .header(USER_AGENT, self.hub._user_agent.clone());
1162
1163 let request = req_builder
1164 .header(CONTENT_LENGTH, 0_u64)
1165 .body(common::to_body::<String>(None));
1166
1167 client.request(request.unwrap()).await
1168 };
1169
1170 match req_result {
1171 Err(err) => {
1172 if let common::Retry::After(d) = dlg.http_error(&err) {
1173 sleep(d).await;
1174 continue;
1175 }
1176 dlg.finished(false);
1177 return Err(common::Error::HttpError(err));
1178 }
1179 Ok(res) => {
1180 let (mut parts, body) = res.into_parts();
1181 let mut body = common::Body::new(body);
1182 if !parts.status.is_success() {
1183 let bytes = common::to_bytes(body).await.unwrap_or_default();
1184 let error = serde_json::from_str(&common::to_string(&bytes));
1185 let response = common::to_response(parts, bytes.into());
1186
1187 if let common::Retry::After(d) =
1188 dlg.http_failure(&response, error.as_ref().ok())
1189 {
1190 sleep(d).await;
1191 continue;
1192 }
1193
1194 dlg.finished(false);
1195
1196 return Err(match error {
1197 Ok(value) => common::Error::BadRequest(value),
1198 _ => common::Error::Failure(response),
1199 });
1200 }
1201 let response = {
1202 let bytes = common::to_bytes(body).await.unwrap_or_default();
1203 let encoded = common::to_string(&bytes);
1204 match serde_json::from_str(&encoded) {
1205 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1206 Err(error) => {
1207 dlg.response_json_decode_error(&encoded, &error);
1208 return Err(common::Error::JsonDecodeError(
1209 encoded.to_string(),
1210 error,
1211 ));
1212 }
1213 }
1214 };
1215
1216 dlg.finished(true);
1217 return Ok(response);
1218 }
1219 }
1220 }
1221 }
1222
1223 /// Required. The platform, which owns this collection of channels. Format: {product}/platforms/{platform}
1224 ///
1225 /// Sets the *parent* path property to the given value.
1226 ///
1227 /// Even though the property as already been set when instantiating this call,
1228 /// we provide this method for API completeness.
1229 pub fn parent(mut self, new_value: &str) -> PlatformChannelListCall<'a, C> {
1230 self._parent = new_value.to_string();
1231 self
1232 }
1233 /// Optional. A page token, received from a previous `ListChannels` call. Provide this to retrieve the subsequent page.
1234 ///
1235 /// Sets the *page token* query property to the given value.
1236 pub fn page_token(mut self, new_value: &str) -> PlatformChannelListCall<'a, C> {
1237 self._page_token = Some(new_value.to_string());
1238 self
1239 }
1240 /// Optional. Optional limit on the number of channels to include in the response. If unspecified, the server will pick an appropriate default.
1241 ///
1242 /// Sets the *page size* query property to the given value.
1243 pub fn page_size(mut self, new_value: i32) -> PlatformChannelListCall<'a, C> {
1244 self._page_size = Some(new_value);
1245 self
1246 }
1247 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1248 /// while executing the actual API request.
1249 ///
1250 /// ````text
1251 /// It should be used to handle progress information, and to implement a certain level of resilience.
1252 /// ````
1253 ///
1254 /// Sets the *delegate* property to the given value.
1255 pub fn delegate(
1256 mut self,
1257 new_value: &'a mut dyn common::Delegate,
1258 ) -> PlatformChannelListCall<'a, C> {
1259 self._delegate = Some(new_value);
1260 self
1261 }
1262
1263 /// Set any additional parameter of the query string used in the request.
1264 /// It should be used to set parameters which are not yet available through their own
1265 /// setters.
1266 ///
1267 /// Please note that this method must not be used to set any of the known parameters
1268 /// which have their own setter method. If done anyway, the request will fail.
1269 ///
1270 /// # Additional Parameters
1271 ///
1272 /// * *$.xgafv* (query-string) - V1 error format.
1273 /// * *access_token* (query-string) - OAuth access token.
1274 /// * *alt* (query-string) - Data format for response.
1275 /// * *callback* (query-string) - JSONP
1276 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1277 /// * *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.
1278 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1279 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1280 /// * *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.
1281 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1282 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1283 pub fn param<T>(mut self, name: T, value: T) -> PlatformChannelListCall<'a, C>
1284 where
1285 T: AsRef<str>,
1286 {
1287 self._additional_params
1288 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1289 self
1290 }
1291}
1292
1293/// Returns list of platforms that are available for a given product. The resource "product" has no resource name in its name.
1294///
1295/// A builder for the *list* method supported by a *platform* resource.
1296/// It is not used directly, but through a [`PlatformMethods`] instance.
1297///
1298/// # Example
1299///
1300/// Instantiate a resource method builder
1301///
1302/// ```test_harness,no_run
1303/// # extern crate hyper;
1304/// # extern crate hyper_rustls;
1305/// # extern crate google_versionhistory1 as versionhistory1;
1306/// # async fn dox() {
1307/// # use versionhistory1::{VersionHistory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1308///
1309/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1310/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1311/// # secret,
1312/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1313/// # ).build().await.unwrap();
1314///
1315/// # let client = hyper_util::client::legacy::Client::builder(
1316/// # hyper_util::rt::TokioExecutor::new()
1317/// # )
1318/// # .build(
1319/// # hyper_rustls::HttpsConnectorBuilder::new()
1320/// # .with_native_roots()
1321/// # .unwrap()
1322/// # .https_or_http()
1323/// # .enable_http1()
1324/// # .build()
1325/// # );
1326/// # let mut hub = VersionHistory::new(client, auth);
1327/// // You can configure optional parameters by calling the respective setters at will, and
1328/// // execute the final call using `doit()`.
1329/// // Values shown here are possibly random and not representative !
1330/// let result = hub.platforms().list("parent")
1331/// .page_token("ipsum")
1332/// .page_size(-50)
1333/// .doit().await;
1334/// # }
1335/// ```
1336pub struct PlatformListCall<'a, C>
1337where
1338 C: 'a,
1339{
1340 hub: &'a VersionHistory<C>,
1341 _parent: String,
1342 _page_token: Option<String>,
1343 _page_size: Option<i32>,
1344 _delegate: Option<&'a mut dyn common::Delegate>,
1345 _additional_params: HashMap<String, String>,
1346}
1347
1348impl<'a, C> common::CallBuilder for PlatformListCall<'a, C> {}
1349
1350impl<'a, C> PlatformListCall<'a, C>
1351where
1352 C: common::Connector,
1353{
1354 /// Perform the operation you have build so far.
1355 pub async fn doit(mut self) -> common::Result<(common::Response, ListPlatformsResponse)> {
1356 use std::borrow::Cow;
1357 use std::io::{Read, Seek};
1358
1359 use common::{url::Params, ToParts};
1360 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1361
1362 let mut dd = common::DefaultDelegate;
1363 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1364 dlg.begin(common::MethodInfo {
1365 id: "versionhistory.platforms.list",
1366 http_method: hyper::Method::GET,
1367 });
1368
1369 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
1370 if self._additional_params.contains_key(field) {
1371 dlg.finished(false);
1372 return Err(common::Error::FieldClash(field));
1373 }
1374 }
1375
1376 let mut params = Params::with_capacity(5 + self._additional_params.len());
1377 params.push("parent", self._parent);
1378 if let Some(value) = self._page_token.as_ref() {
1379 params.push("pageToken", value);
1380 }
1381 if let Some(value) = self._page_size.as_ref() {
1382 params.push("pageSize", value.to_string());
1383 }
1384
1385 params.extend(self._additional_params.iter());
1386
1387 params.push("alt", "json");
1388 let mut url = self.hub._base_url.clone() + "v1/{+parent}/platforms";
1389
1390 match dlg.api_key() {
1391 Some(value) => params.push("key", value),
1392 None => {
1393 dlg.finished(false);
1394 return Err(common::Error::MissingAPIKey);
1395 }
1396 }
1397
1398 #[allow(clippy::single_element_loop)]
1399 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1400 url = params.uri_replacement(url, param_name, find_this, true);
1401 }
1402 {
1403 let to_remove = ["parent"];
1404 params.remove_params(&to_remove);
1405 }
1406
1407 let url = params.parse_with_url(&url);
1408
1409 loop {
1410 let mut req_result = {
1411 let client = &self.hub.client;
1412 dlg.pre_request();
1413 let mut req_builder = hyper::Request::builder()
1414 .method(hyper::Method::GET)
1415 .uri(url.as_str())
1416 .header(USER_AGENT, self.hub._user_agent.clone());
1417
1418 let request = req_builder
1419 .header(CONTENT_LENGTH, 0_u64)
1420 .body(common::to_body::<String>(None));
1421
1422 client.request(request.unwrap()).await
1423 };
1424
1425 match req_result {
1426 Err(err) => {
1427 if let common::Retry::After(d) = dlg.http_error(&err) {
1428 sleep(d).await;
1429 continue;
1430 }
1431 dlg.finished(false);
1432 return Err(common::Error::HttpError(err));
1433 }
1434 Ok(res) => {
1435 let (mut parts, body) = res.into_parts();
1436 let mut body = common::Body::new(body);
1437 if !parts.status.is_success() {
1438 let bytes = common::to_bytes(body).await.unwrap_or_default();
1439 let error = serde_json::from_str(&common::to_string(&bytes));
1440 let response = common::to_response(parts, bytes.into());
1441
1442 if let common::Retry::After(d) =
1443 dlg.http_failure(&response, error.as_ref().ok())
1444 {
1445 sleep(d).await;
1446 continue;
1447 }
1448
1449 dlg.finished(false);
1450
1451 return Err(match error {
1452 Ok(value) => common::Error::BadRequest(value),
1453 _ => common::Error::Failure(response),
1454 });
1455 }
1456 let response = {
1457 let bytes = common::to_bytes(body).await.unwrap_or_default();
1458 let encoded = common::to_string(&bytes);
1459 match serde_json::from_str(&encoded) {
1460 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1461 Err(error) => {
1462 dlg.response_json_decode_error(&encoded, &error);
1463 return Err(common::Error::JsonDecodeError(
1464 encoded.to_string(),
1465 error,
1466 ));
1467 }
1468 }
1469 };
1470
1471 dlg.finished(true);
1472 return Ok(response);
1473 }
1474 }
1475 }
1476 }
1477
1478 /// Required. The product, which owns this collection of platforms. Format: {product}
1479 ///
1480 /// Sets the *parent* path property to the given value.
1481 ///
1482 /// Even though the property as already been set when instantiating this call,
1483 /// we provide this method for API completeness.
1484 pub fn parent(mut self, new_value: &str) -> PlatformListCall<'a, C> {
1485 self._parent = new_value.to_string();
1486 self
1487 }
1488 /// Optional. A page token, received from a previous `ListChannels` call. Provide this to retrieve the subsequent page.
1489 ///
1490 /// Sets the *page token* query property to the given value.
1491 pub fn page_token(mut self, new_value: &str) -> PlatformListCall<'a, C> {
1492 self._page_token = Some(new_value.to_string());
1493 self
1494 }
1495 /// Optional. Optional limit on the number of channels to include in the response. If unspecified, the server will pick an appropriate default.
1496 ///
1497 /// Sets the *page size* query property to the given value.
1498 pub fn page_size(mut self, new_value: i32) -> PlatformListCall<'a, C> {
1499 self._page_size = Some(new_value);
1500 self
1501 }
1502 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1503 /// while executing the actual API request.
1504 ///
1505 /// ````text
1506 /// It should be used to handle progress information, and to implement a certain level of resilience.
1507 /// ````
1508 ///
1509 /// Sets the *delegate* property to the given value.
1510 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PlatformListCall<'a, C> {
1511 self._delegate = Some(new_value);
1512 self
1513 }
1514
1515 /// Set any additional parameter of the query string used in the request.
1516 /// It should be used to set parameters which are not yet available through their own
1517 /// setters.
1518 ///
1519 /// Please note that this method must not be used to set any of the known parameters
1520 /// which have their own setter method. If done anyway, the request will fail.
1521 ///
1522 /// # Additional Parameters
1523 ///
1524 /// * *$.xgafv* (query-string) - V1 error format.
1525 /// * *access_token* (query-string) - OAuth access token.
1526 /// * *alt* (query-string) - Data format for response.
1527 /// * *callback* (query-string) - JSONP
1528 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1529 /// * *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.
1530 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1531 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1532 /// * *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.
1533 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1534 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1535 pub fn param<T>(mut self, name: T, value: T) -> PlatformListCall<'a, C>
1536 where
1537 T: AsRef<str>,
1538 {
1539 self._additional_params
1540 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1541 self
1542 }
1543}