regen all APIs

This commit is contained in:
Sebastian Thiel
2023-01-25 14:56:25 +01:00
parent 3edefb7f01
commit 783e9188a6
1284 changed files with 1008155 additions and 716362 deletions

View File

@@ -1,19 +1,20 @@
use std::collections::HashMap;
use std::cell::RefCell;
use std::default::Default;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::error::Error as StdError;
use serde_json as json;
use std::io;
use std::fs;
use std::mem;
use std::thread::sleep;
use http::Uri;
use hyper::client::connect;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::time::sleep;
use tower_service;
use crate::client;
use serde::{Serialize, Deserialize};
use crate::{client, client::GetToken, client::serde_with};
// ##############
// UTILITIES ###
@@ -62,7 +63,7 @@ impl Default for Scope {
/// use std::fs;
/// # async fn dox() {
/// use std::default::Default;
/// use groupsmigration1::{GroupsMigration, oauth2, hyper, hyper_rustls};
/// use groupsmigration1::{GroupsMigration, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
/// // `client_secret`, among other things.
@@ -105,7 +106,7 @@ impl Default for Scope {
#[derive(Clone)]
pub struct GroupsMigration<S> {
pub client: hyper::Client<S, hyper::body::Body>,
pub auth: oauth2::authenticator::Authenticator<S>,
pub auth: Box<dyn client::GetToken>,
_user_agent: String,
_base_url: String,
_root_url: String,
@@ -115,11 +116,11 @@ impl<'a, S> client::Hub for GroupsMigration<S> {}
impl<'a, S> GroupsMigration<S> {
pub fn new(client: hyper::Client<S, hyper::body::Body>, authenticator: oauth2::authenticator::Authenticator<S>) -> GroupsMigration<S> {
pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> GroupsMigration<S> {
GroupsMigration {
client,
auth: authenticator,
_user_agent: "google-api-rust-client/4.0.1".to_string(),
auth: Box::new(auth),
_user_agent: "google-api-rust-client/5.0.2-beta-1".to_string(),
_base_url: "https://groupsmigration.googleapis.com/".to_string(),
_root_url: "https://groupsmigration.googleapis.com/".to_string(),
}
@@ -130,7 +131,7 @@ impl<'a, S> GroupsMigration<S> {
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/4.0.1`.
/// It defaults to `google-api-rust-client/5.0.2-beta-1`.
///
/// Returns the previously set user-agent.
pub fn user_agent(&mut self, agent_name: String) -> String {
@@ -167,12 +168,15 @@ impl<'a, S> GroupsMigration<S> {
///
/// * [insert archive](ArchiveInsertCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Groups {
/// The kind of insert resource this is.
pub kind: Option<String>,
/// The status of the insert request.
#[serde(rename="responseCode")]
pub response_code: Option<String>,
}
@@ -185,7 +189,7 @@ impl client::ResponseResult for Groups {}
// #################
/// A builder providing access to all methods supported on *archive* resources.
/// It is not used directly, but through the `GroupsMigration` hub.
/// It is not used directly, but through the [`GroupsMigration`] hub.
///
/// # Example
///
@@ -198,7 +202,7 @@ impl client::ResponseResult for Groups {}
///
/// # async fn dox() {
/// use std::default::Default;
/// use groupsmigration1::{GroupsMigration, oauth2, hyper, hyper_rustls};
/// use groupsmigration1::{GroupsMigration, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
@@ -251,7 +255,7 @@ impl<'a, S> ArchiveMethods<'a, S> {
/// Inserts a new mail into the archive of the Google group.
///
/// A builder for the *insert* method supported by a *archive* resource.
/// It is not used directly, but through a `ArchiveMethods` instance.
/// It is not used directly, but through a [`ArchiveMethods`] instance.
///
/// # Example
///
@@ -264,7 +268,7 @@ impl<'a, S> ArchiveMethods<'a, S> {
/// use std::fs;
/// # async fn dox() {
/// # use std::default::Default;
/// # use groupsmigration1::{GroupsMigration, oauth2, hyper, hyper_rustls};
/// # use groupsmigration1::{GroupsMigration, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
@@ -286,14 +290,14 @@ pub struct ArchiveInsertCall<'a, S>
_group_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ArchiveInsertCall<'a, S> {}
impl<'a, S> ArchiveInsertCall<'a, S>
where
S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
@@ -301,78 +305,63 @@ where
/// Perform the operation you have build so far.
async fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> client::Result<(hyper::Response<hyper::body::Body>, Groups)>
async fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response<hyper::body::Body>, Groups)>
where RS: client::ReadSeek {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::ToParts;
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "groupsmigration.archive.insert",
http_method: hyper::Method::POST });
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
params.push(("groupId", self._group_id.to_string()));
for &field in ["alt", "groupId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("groupId", self._group_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let (mut url, upload_type) =
if protocol == "simple" {
if protocol == client::UploadProtocol::Simple {
(self.hub._root_url.clone() + "upload/groups/v1/groups/{groupId}/archive", "multipart")
} else {
unreachable!()
};
params.push(("uploadType", upload_type.to_string()));
if self._scopes.len() == 0 {
self._scopes.insert(Scope::AppGroupMigration.as_ref().to_string(), ());
params.push("uploadType", upload_type);
if self._scopes.is_empty() {
self._scopes.insert(Scope::AppGroupMigration.as_ref().to_string());
}
for &(find_this, param_name) in [("{groupId}", "groupId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["groupId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
let to_remove = ["groupId"];
params.remove_params(&to_remove);
}
let url = url::Url::parse_with_params(&url, params).unwrap();
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
Ok(token) => token.clone(),
Err(err) => {
match dlg.token(&err) {
Some(token) => token,
None => {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(err))
return Err(client::Error::MissingToken(e));
}
}
}
@@ -380,11 +369,17 @@ where
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string())
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = if protocol == "simple" {
let request = if protocol == client::UploadProtocol::Simple {
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
reader.seek(io::SeekFrom::Start(0)).unwrap();
if size > 26214400 {
@@ -400,13 +395,13 @@ where
};
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
sleep(d).await;
continue;
}
dlg.finished(false);
@@ -422,7 +417,7 @@ where
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d);
sleep(d).await;
continue;
}
@@ -460,7 +455,7 @@ where
/// * *valid mime types*: 'message/rfc822'
pub async fn upload<RS>(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response<hyper::body::Body>, Groups)>
where RS: client::ReadSeek {
self.doit(stream, mime_type, "simple").await
self.doit(stream, mime_type, client::UploadProtocol::Simple).await
}
/// The group ID
@@ -476,7 +471,8 @@ where
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
/// ````text
/// It should be used to handle progress information, and to implement a certain level of resilience.````
///
/// Sets the *delegate* property to the given value.
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ArchiveInsertCall<'a, S> {
@@ -512,25 +508,36 @@ where
/// Identifies the authorization scope for the method you are building.
///
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
/// `Scope::AppGroupMigration`.
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
/// [`Scope::AppGroupMigration`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
/// function for details).
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T, St>(mut self, scope: T) -> ArchiveInsertCall<'a, S>
where T: Into<Option<St>>,
St: AsRef<str> {
match scope.into() {
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
None => None,
};
pub fn add_scope<St>(mut self, scope: St) -> ArchiveInsertCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ArchiveInsertCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ArchiveInsertCall<'a, S> {
self._scopes.clear();
self
}
}

View File

@@ -2,7 +2,7 @@
// This file was generated automatically from 'src/generator/templates/api/lib.rs.mako'
// DO NOT EDIT !
//! This documentation was generated from *Groups Migration* crate version *4.0.1+20220226*, where *20220226* is the exact revision of the *groupsmigration:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v4.0.1*.
//! This documentation was generated from *Groups Migration* crate version *5.0.2-beta-1+20230117*, where *20230117* is the exact revision of the *groupsmigration:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v5.0.2-beta-1*.
//!
//! Everything else about the *Groups Migration* *v1* API can be found at the
//! [official documentation site](https://developers.google.com/google-apps/groups-migration/).
@@ -82,7 +82,7 @@
//! use std::fs;
//! # async fn dox() {
//! use std::default::Default;
//! use groupsmigration1::{GroupsMigration, oauth2, hyper, hyper_rustls};
//! use groupsmigration1::{GroupsMigration, oauth2, hyper, hyper_rustls, chrono, FieldMask};
//!
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
//! // `client_secret`, among other things.
@@ -186,22 +186,17 @@
// This file was generated automatically from 'src/generator/templates/api/lib.rs.mako'
// DO NOT EDIT !
#[macro_use]
extern crate serde_derive;
// Re-export the hyper and hyper_rustls crate, they are required to build the hub
pub extern crate hyper;
pub extern crate hyper_rustls;
extern crate serde;
extern crate serde_json;
// Re-export the yup_oauth2 crate, that is required to call some methods of the hub and the client
pub extern crate yup_oauth2 as oauth2;
extern crate mime;
extern crate url;
pub use hyper;
pub use hyper_rustls;
pub extern crate google_apis_common as client;
pub use client::chrono;
pub mod api;
pub mod client;
// Re-export the hub type and some basic client structs
pub use api::GroupsMigration;
pub use client::{Result, Error, Delegate};
pub use client::{Result, Error, Delegate, FieldMask};
// Re-export the yup_oauth2 crate, that is required to call some methods of the hub and the client
#[cfg(feature = "yup-oauth2")]
pub use client::oauth2;