mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2025-12-31 00:21:44 +01:00
3096 lines
124 KiB
Rust
3096 lines
124 KiB
Rust
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
|
// DO NOT EDIT !
|
|
|
|
//! This documentation was generated from *Hangouts Chat* crate version *1.0.14+20200701*, where *20200701* is the exact revision of the *chat:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v1.0.14*.
|
|
//!
|
|
//! Everything else about the *Hangouts Chat* *v1* API can be found at the
|
|
//! [official documentation site](https://developers.google.com/hangouts/chat).
|
|
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/chat1).
|
|
//! # Features
|
|
//!
|
|
//! Handle the following *Resources* with ease from the central [hub](struct.HangoutsChat.html) ...
|
|
//!
|
|
//! * [spaces](struct.Space.html)
|
|
//! * [*get*](struct.SpaceGetCall.html), [*list*](struct.SpaceListCall.html), [*members get*](struct.SpaceMemberGetCall.html), [*members list*](struct.SpaceMemberListCall.html), [*messages create*](struct.SpaceMessageCreateCall.html), [*messages delete*](struct.SpaceMessageDeleteCall.html), [*messages get*](struct.SpaceMessageGetCall.html) and [*messages update*](struct.SpaceMessageUpdateCall.html)
|
|
//!
|
|
//!
|
|
//!
|
|
//!
|
|
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](http://byron.github.io/google-apis-rs).
|
|
//!
|
|
//! # Structure of this Library
|
|
//!
|
|
//! The API is structured into the following primary items:
|
|
//!
|
|
//! * **[Hub](struct.HangoutsChat.html)**
|
|
//! * a central object to maintain state and allow accessing all *Activities*
|
|
//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
|
|
//! allow access to individual [*Call Builders*](trait.CallBuilder.html)
|
|
//! * **[Resources](trait.Resource.html)**
|
|
//! * primary types that you can apply *Activities* to
|
|
//! * a collection of properties and *Parts*
|
|
//! * **[Parts](trait.Part.html)**
|
|
//! * a collection of properties
|
|
//! * never directly used in *Activities*
|
|
//! * **[Activities](trait.CallBuilder.html)**
|
|
//! * operations to apply to *Resources*
|
|
//!
|
|
//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
|
|
//!
|
|
//! Generally speaking, you can invoke *Activities* like this:
|
|
//!
|
|
//! ```Rust,ignore
|
|
//! let r = hub.resource().activity(...).doit()
|
|
//! ```
|
|
//!
|
|
//! Or specifically ...
|
|
//!
|
|
//! ```ignore
|
|
//! let r = hub.spaces().list(...).doit()
|
|
//! let r = hub.spaces().messages_get(...).doit()
|
|
//! let r = hub.spaces().get(...).doit()
|
|
//! let r = hub.spaces().messages_update(...).doit()
|
|
//! let r = hub.spaces().members_list(...).doit()
|
|
//! let r = hub.spaces().members_get(...).doit()
|
|
//! let r = hub.spaces().messages_delete(...).doit()
|
|
//! let r = hub.spaces().messages_create(...).doit()
|
|
//! ```
|
|
//!
|
|
//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
|
|
//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
|
|
//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
|
|
//! The `doit()` method performs the actual communication with the server and returns the respective result.
|
|
//!
|
|
//! # Usage
|
|
//!
|
|
//! ## Setting up your Project
|
|
//!
|
|
//! To use this library, you would put the following lines into your `Cargo.toml` file:
|
|
//!
|
|
//! ```toml
|
|
//! [dependencies]
|
|
//! google-chat1 = "*"
|
|
//! # This project intentionally uses an old version of Hyper. See
|
|
//! # https://github.com/Byron/google-apis-rs/issues/173 for more
|
|
//! # information.
|
|
//! hyper = "^0.10"
|
|
//! hyper-rustls = "^0.6"
|
|
//! serde = "^1.0"
|
|
//! serde_json = "^1.0"
|
|
//! yup-oauth2 = "^1.0"
|
|
//! ```
|
|
//!
|
|
//! ## A complete example
|
|
//!
|
|
//! ```test_harness,no_run
|
|
//! extern crate hyper;
|
|
//! extern crate hyper_rustls;
|
|
//! extern crate yup_oauth2 as oauth2;
|
|
//! extern crate google_chat1 as chat1;
|
|
//! use chat1::Message;
|
|
//! use chat1::{Result, Error};
|
|
//! # #[test] fn egal() {
|
|
//! use std::default::Default;
|
|
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
//! use chat1::HangoutsChat;
|
|
//!
|
|
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
//! // `client_secret`, among other things.
|
|
//! let secret: ApplicationSecret = Default::default();
|
|
//! // Instantiate the authenticator. It will choose a suitable authentication flow for you,
|
|
//! // unless you replace `None` with the desired Flow.
|
|
//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
|
|
//! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
|
|
//! // retrieve them from storage.
|
|
//! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
//! hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
//! <MemoryStorage as Default>::default(), None);
|
|
//! let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
//! // As the method needs a request, you would usually fill it with the desired information
|
|
//! // into the respective structure. Some of the parts shown here might not be applicable !
|
|
//! // Values shown here are possibly random and not representative !
|
|
//! let mut req = Message::default();
|
|
//!
|
|
//! // You can configure optional parameters by calling the respective setters at will, and
|
|
//! // execute the final call using `doit()`.
|
|
//! // Values shown here are possibly random and not representative !
|
|
//! let result = hub.spaces().messages_update(req, "name")
|
|
//! .update_mask("sed")
|
|
//! .doit();
|
|
//!
|
|
//! match result {
|
|
//! Err(e) => match e {
|
|
//! // The Error enum provides details about what exactly happened.
|
|
//! // You can also just use its `Debug`, `Display` or `Error` traits
|
|
//! Error::HttpError(_)
|
|
//! |Error::MissingAPIKey
|
|
//! |Error::MissingToken(_)
|
|
//! |Error::Cancelled
|
|
//! |Error::UploadSizeLimitExceeded(_, _)
|
|
//! |Error::Failure(_)
|
|
//! |Error::BadRequest(_)
|
|
//! |Error::FieldClash(_)
|
|
//! |Error::JsonDecodeError(_, _) => println!("{}", e),
|
|
//! },
|
|
//! Ok(res) => println!("Success: {:?}", res),
|
|
//! }
|
|
//! # }
|
|
//! ```
|
|
//! ## Handling Errors
|
|
//!
|
|
//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of
|
|
//! the doit() methods, or handed as possibly intermediate results to either the
|
|
//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
|
|
//!
|
|
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
|
//! makes the system potentially resilient to all kinds of errors.
|
|
//!
|
|
//! ## Uploads and Downloads
|
|
//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
|
|
//! read by you to obtain the media.
|
|
//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
|
|
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
|
|
//! this call: `.param("alt", "media")`.
|
|
//!
|
|
//! Methods supporting uploads can do so using up to 2 different protocols:
|
|
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
|
|
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
|
|
//!
|
|
//! ## Customization and Callbacks
|
|
//!
|
|
//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the
|
|
//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call.
|
|
//! Respective methods will be called to provide progress information, as well as determine whether the system should
|
|
//! retry on failure.
|
|
//!
|
|
//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
|
|
//!
|
|
//! ## Optional Parts in Server-Requests
|
|
//!
|
|
//! All structures provided by this library are made to be [encodable](trait.RequestValue.html) and
|
|
//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses
|
|
//! are valid.
|
|
//! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to
|
|
//! the server to indicate either the set parts of the request or the desired parts in the response.
|
|
//!
|
|
//! ## Builder Arguments
|
|
//!
|
|
//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
|
|
//! These will always take a single argument, for which the following statements are true.
|
|
//!
|
|
//! * [PODs][wiki-pod] are handed by copy
|
|
//! * strings are passed as `&str`
|
|
//! * [request values](trait.RequestValue.html) are moved
|
|
//!
|
|
//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
|
|
//!
|
|
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
|
|
//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
|
|
//! [google-go-api]: https://github.com/google/google-api-go-client
|
|
//!
|
|
//!
|
|
|
|
// Unused attributes happen thanks to defined, but unused structures
|
|
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
|
|
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
|
// unused imports in fully featured APIs. Same with unused_mut ... .
|
|
#![allow(unused_imports, unused_mut, dead_code)]
|
|
|
|
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
|
// DO NOT EDIT !
|
|
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
|
|
extern crate hyper;
|
|
extern crate serde;
|
|
extern crate serde_json;
|
|
extern crate yup_oauth2 as oauth2;
|
|
extern crate mime;
|
|
extern crate url;
|
|
|
|
mod cmn;
|
|
|
|
use std::collections::HashMap;
|
|
use std::cell::RefCell;
|
|
use std::borrow::BorrowMut;
|
|
use std::default::Default;
|
|
use std::collections::BTreeMap;
|
|
use serde_json as json;
|
|
use std::io;
|
|
use std::fs;
|
|
use std::mem;
|
|
use std::thread::sleep;
|
|
use std::time::Duration;
|
|
|
|
pub use cmn::*;
|
|
|
|
|
|
// ##############
|
|
// UTILITIES ###
|
|
// ############
|
|
|
|
|
|
|
|
|
|
// ########
|
|
// HUB ###
|
|
// ######
|
|
|
|
/// Central instance to access all HangoutsChat related resource activities
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// Instantiate a new hub
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_chat1 as chat1;
|
|
/// use chat1::Message;
|
|
/// use chat1::{Result, Error};
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use chat1::HangoutsChat;
|
|
///
|
|
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
/// // `client_secret`, among other things.
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
|
|
/// // unless you replace `None` with the desired Flow.
|
|
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
|
|
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
|
|
/// // retrieve them from storage.
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req = Message::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.spaces().messages_update(req, "name")
|
|
/// .update_mask("dolores")
|
|
/// .doit();
|
|
///
|
|
/// match result {
|
|
/// Err(e) => match e {
|
|
/// // The Error enum provides details about what exactly happened.
|
|
/// // You can also just use its `Debug`, `Display` or `Error` traits
|
|
/// Error::HttpError(_)
|
|
/// |Error::MissingAPIKey
|
|
/// |Error::MissingToken(_)
|
|
/// |Error::Cancelled
|
|
/// |Error::UploadSizeLimitExceeded(_, _)
|
|
/// |Error::Failure(_)
|
|
/// |Error::BadRequest(_)
|
|
/// |Error::FieldClash(_)
|
|
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
|
|
/// },
|
|
/// Ok(res) => println!("Success: {:?}", res),
|
|
/// }
|
|
/// # }
|
|
/// ```
|
|
pub struct HangoutsChat<C, A> {
|
|
client: RefCell<C>,
|
|
auth: RefCell<A>,
|
|
_user_agent: String,
|
|
_base_url: String,
|
|
_root_url: String,
|
|
}
|
|
|
|
impl<'a, C, A> Hub for HangoutsChat<C, A> {}
|
|
|
|
impl<'a, C, A> HangoutsChat<C, A>
|
|
where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
pub fn new(client: C, authenticator: A) -> HangoutsChat<C, A> {
|
|
HangoutsChat {
|
|
client: RefCell::new(client),
|
|
auth: RefCell::new(authenticator),
|
|
_user_agent: "google-api-rust-client/1.0.14".to_string(),
|
|
_base_url: "https://chat.googleapis.com/".to_string(),
|
|
_root_url: "https://chat.googleapis.com/".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn spaces(&'a self) -> SpaceMethods<'a, C, A> {
|
|
SpaceMethods { hub: &self }
|
|
}
|
|
|
|
/// Set the user-agent header field to use in all requests to the server.
|
|
/// It defaults to `google-api-rust-client/1.0.14`.
|
|
///
|
|
/// Returns the previously set user-agent.
|
|
pub fn user_agent(&mut self, agent_name: String) -> String {
|
|
mem::replace(&mut self._user_agent, agent_name)
|
|
}
|
|
|
|
/// Set the base url to use in all requests to the server.
|
|
/// It defaults to `https://chat.googleapis.com/`.
|
|
///
|
|
/// Returns the previously set base url.
|
|
pub fn base_url(&mut self, new_base_url: String) -> String {
|
|
mem::replace(&mut self._base_url, new_base_url)
|
|
}
|
|
|
|
/// Set the root url to use in all requests to the server.
|
|
/// It defaults to `https://chat.googleapis.com/`.
|
|
///
|
|
/// Returns the previously set root url.
|
|
pub fn root_url(&mut self, new_root_url: String) -> String {
|
|
mem::replace(&mut self._root_url, new_root_url)
|
|
}
|
|
}
|
|
|
|
|
|
// ############
|
|
// SCHEMAS ###
|
|
// ##########
|
|
/// A link that opens a new window.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct OpenLink {
|
|
/// The URL to open.
|
|
pub url: Option<String>,
|
|
}
|
|
|
|
impl Part for OpenLink {}
|
|
|
|
|
|
/// Parameters that a bot can use to configure how it's response is posted.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ActionResponse {
|
|
/// URL for users to auth or config. (Only for REQUEST_CONFIG response types.)
|
|
pub url: Option<String>,
|
|
/// The type of bot response.
|
|
#[serde(rename="type")]
|
|
pub type_: Option<String>,
|
|
}
|
|
|
|
impl Part for ActionResponse {}
|
|
|
|
|
|
/// A thread in Hangouts Chat.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Thread {
|
|
/// Resource name, in the form "spaces/*/threads/*".
|
|
///
|
|
/// Example: spaces/AAAAMpdlehY/threads/UMxbHmzDlr4
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
impl Part for Thread {}
|
|
|
|
|
|
/// A room or DM in Hangouts Chat.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [list spaces](struct.SpaceListCall.html) (none)
|
|
/// * [messages get spaces](struct.SpaceMessageGetCall.html) (none)
|
|
/// * [get spaces](struct.SpaceGetCall.html) (response)
|
|
/// * [messages update spaces](struct.SpaceMessageUpdateCall.html) (none)
|
|
/// * [members list spaces](struct.SpaceMemberListCall.html) (none)
|
|
/// * [members get spaces](struct.SpaceMemberGetCall.html) (none)
|
|
/// * [messages delete spaces](struct.SpaceMessageDeleteCall.html) (none)
|
|
/// * [messages create spaces](struct.SpaceMessageCreateCall.html) (none)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Space {
|
|
/// Output only. The display name (only if the space is a room).
|
|
/// Please note that this field might not be populated in direct messages
|
|
/// between humans.
|
|
#[serde(rename="displayName")]
|
|
pub display_name: Option<String>,
|
|
/// Whether the space is a DM between a bot and a single human.
|
|
#[serde(rename="singleUserBotDm")]
|
|
pub single_user_bot_dm: Option<bool>,
|
|
/// Whether the messages are threaded in this space.
|
|
pub threaded: Option<bool>,
|
|
/// Output only. The type of a space.
|
|
/// This is deprecated. Use `single_user_bot_dm` instead.
|
|
#[serde(rename="type")]
|
|
pub type_: Option<String>,
|
|
/// Resource name of the space, in the form "spaces/*".
|
|
///
|
|
/// Example: spaces/AAAAMpdlehYs
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
impl Resource for Space {}
|
|
impl ResponseResult for Space {}
|
|
|
|
|
|
/// A widget is a UI element that presents texts, images, etc.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct WidgetMarkup {
|
|
/// A list of buttons. Buttons is also oneof data and only one of these
|
|
/// fields should be set.
|
|
pub buttons: Option<Vec<Button>>,
|
|
/// Display a key value item in this widget.
|
|
#[serde(rename="keyValue")]
|
|
pub key_value: Option<KeyValue>,
|
|
/// Display an image in this widget.
|
|
pub image: Option<Image>,
|
|
/// Display a text paragraph in this widget.
|
|
#[serde(rename="textParagraph")]
|
|
pub text_paragraph: Option<TextParagraph>,
|
|
}
|
|
|
|
impl Part for WidgetMarkup {}
|
|
|
|
|
|
/// A section contains a collection of widgets that are rendered
|
|
/// (vertically) in the order that they are specified. Across all platforms,
|
|
/// cards have a narrow fixed width, so
|
|
/// there is currently no need for layout properties (e.g. float).
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Section {
|
|
/// A section must contain at least 1 widget.
|
|
pub widgets: Option<Vec<WidgetMarkup>>,
|
|
/// The header of the section, text formatted supported.
|
|
pub header: Option<String>,
|
|
}
|
|
|
|
impl Part for Section {}
|
|
|
|
|
|
/// A paragraph of text. Formatted text supported.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct TextParagraph {
|
|
/// no description provided
|
|
pub text: Option<String>,
|
|
}
|
|
|
|
impl Part for TextParagraph {}
|
|
|
|
|
|
/// A form action describes the behavior when the form is submitted.
|
|
/// For example, an Apps Script can be invoked to handle the form.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct FormAction {
|
|
/// The method name is used to identify which part of the form triggered the
|
|
/// form submission. This information is echoed back to the bot as part of
|
|
/// the card click event. The same method name can be used for several
|
|
/// elements that trigger a common behavior if desired.
|
|
#[serde(rename="actionMethodName")]
|
|
pub action_method_name: Option<String>,
|
|
/// List of action parameters.
|
|
pub parameters: Option<Vec<ActionParameter>>,
|
|
}
|
|
|
|
impl Part for FormAction {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CardHeader {
|
|
/// The image's type (e.g. square border or circular border).
|
|
#[serde(rename="imageStyle")]
|
|
pub image_style: Option<String>,
|
|
/// The URL of the image in the card header.
|
|
#[serde(rename="imageUrl")]
|
|
pub image_url: Option<String>,
|
|
/// The subtitle of the card header.
|
|
pub subtitle: Option<String>,
|
|
/// The title must be specified. The header has a fixed height: if both a
|
|
/// title and subtitle is specified, each will take up 1 line. If only the
|
|
/// title is specified, it will take up both lines.
|
|
pub title: Option<String>,
|
|
}
|
|
|
|
impl Part for CardHeader {}
|
|
|
|
|
|
/// A button. Can be a text button or an image button.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Button {
|
|
/// A button with image and onclick action.
|
|
#[serde(rename="imageButton")]
|
|
pub image_button: Option<ImageButton>,
|
|
/// A button with text and onclick action.
|
|
#[serde(rename="textButton")]
|
|
pub text_button: Option<TextButton>,
|
|
}
|
|
|
|
impl Part for Button {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [list spaces](struct.SpaceListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ListSpacesResponse {
|
|
/// Continuation token to retrieve the next page of results. It will be empty
|
|
/// for the last page of results. Tokens expire in an hour. An error is thrown
|
|
/// if an expired token is passed.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
/// List of spaces in the requested (or first) page.
|
|
pub spaces: Option<Vec<Space>>,
|
|
}
|
|
|
|
impl ResponseResult for ListSpacesResponse {}
|
|
|
|
|
|
/// List of string parameters to supply when the action method is invoked.
|
|
/// For example, consider three snooze buttons: snooze now, snooze 1 day,
|
|
/// snooze next week. You might use action method = snooze(), passing the
|
|
/// snooze type and snooze time in the list of string parameters.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ActionParameter {
|
|
/// The name of the parameter for the action script.
|
|
pub key: Option<String>,
|
|
/// The value of the parameter.
|
|
pub value: Option<String>,
|
|
}
|
|
|
|
impl Part for ActionParameter {}
|
|
|
|
|
|
/// A card action is
|
|
/// the action associated with the card. For an invoice card, a
|
|
/// typical action would be: delete invoice, email invoice or open the
|
|
/// invoice in browser.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CardAction {
|
|
/// The label used to be displayed in the action menu item.
|
|
#[serde(rename="actionLabel")]
|
|
pub action_label: Option<String>,
|
|
/// The onclick action for this action item.
|
|
#[serde(rename="onClick")]
|
|
pub on_click: Option<OnClick>,
|
|
}
|
|
|
|
impl Part for CardAction {}
|
|
|
|
|
|
/// A button with text and onclick action.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct TextButton {
|
|
/// The text of the button.
|
|
pub text: Option<String>,
|
|
/// The onclick action of the button.
|
|
#[serde(rename="onClick")]
|
|
pub on_click: Option<OnClick>,
|
|
}
|
|
|
|
impl Part for TextButton {}
|
|
|
|
|
|
/// An image button with an onclick action.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ImageButton {
|
|
/// The icon specified by a URL.
|
|
#[serde(rename="iconUrl")]
|
|
pub icon_url: Option<String>,
|
|
/// The name of this image_button which will be used for accessibility.
|
|
/// Default value will be provided if developers don't specify.
|
|
pub name: Option<String>,
|
|
/// The onclick action.
|
|
#[serde(rename="onClick")]
|
|
pub on_click: Option<OnClick>,
|
|
/// The icon specified by an enum that indices to an icon provided by Chat
|
|
/// API.
|
|
pub icon: Option<String>,
|
|
}
|
|
|
|
impl Part for ImageButton {}
|
|
|
|
|
|
/// An image that is specified by a URL and can have an onclick action.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Image {
|
|
/// The aspect ratio of this image (width/height). This field allows clients
|
|
/// to reserve the right height for the image while waiting for it to load.
|
|
/// It's not meant to override the native aspect ratio of the image.
|
|
/// If unset, the server fills it by prefetching the image.
|
|
#[serde(rename="aspectRatio")]
|
|
pub aspect_ratio: Option<f64>,
|
|
/// The URL of the image.
|
|
#[serde(rename="imageUrl")]
|
|
pub image_url: Option<String>,
|
|
/// The onclick action.
|
|
#[serde(rename="onClick")]
|
|
pub on_click: Option<OnClick>,
|
|
}
|
|
|
|
impl Part for Image {}
|
|
|
|
|
|
/// Represents a membership relation in Hangouts Chat.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [members get spaces](struct.SpaceMemberGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Membership {
|
|
/// Member details.
|
|
pub member: Option<User>,
|
|
/// State of the membership.
|
|
pub state: Option<String>,
|
|
/// The creation time of the membership a.k.a the time at which the member
|
|
/// joined the space, if applicable.
|
|
#[serde(rename="createTime")]
|
|
pub create_time: Option<String>,
|
|
/// Resource name of the membership, in the form "spaces/*/members/*".
|
|
///
|
|
/// Example: spaces/AAAAMpdlehY/members/105115627578887013105
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
impl ResponseResult for Membership {}
|
|
|
|
|
|
/// A UI element contains a key (label) and a value (content). And this
|
|
/// element may also contain some actions such as onclick button.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct KeyValue {
|
|
/// If the content should be multiline.
|
|
#[serde(rename="contentMultiline")]
|
|
pub content_multiline: Option<bool>,
|
|
/// The text of the bottom label. Formatted text supported.
|
|
#[serde(rename="bottomLabel")]
|
|
pub bottom_label: Option<String>,
|
|
/// The text of the top label. Formatted text supported.
|
|
#[serde(rename="topLabel")]
|
|
pub top_label: Option<String>,
|
|
/// A button that can be clicked to trigger an action.
|
|
pub button: Option<Button>,
|
|
/// The text of the content. Formatted text supported and always required.
|
|
pub content: Option<String>,
|
|
/// The icon specified by a URL.
|
|
#[serde(rename="iconUrl")]
|
|
pub icon_url: Option<String>,
|
|
/// The onclick action. Only the top label, bottom label and content region
|
|
/// are clickable.
|
|
#[serde(rename="onClick")]
|
|
pub on_click: Option<OnClick>,
|
|
/// An enum value that will be replaced by the Chat API with the
|
|
/// corresponding icon image.
|
|
pub icon: Option<String>,
|
|
}
|
|
|
|
impl Part for KeyValue {}
|
|
|
|
|
|
/// A generic empty message that you can re-use to avoid defining duplicated
|
|
/// empty messages in your APIs. A typical example is to use it as the request
|
|
/// or the response type of an API method. For instance:
|
|
///
|
|
/// ````text
|
|
/// service Foo {
|
|
/// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
|
/// }
|
|
/// ````
|
|
///
|
|
/// The JSON representation for `Empty` is empty JSON object `{}`.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [messages delete spaces](struct.SpaceMessageDeleteCall.html) (response)
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Empty { _never_set: Option<bool> }
|
|
|
|
impl ResponseResult for Empty {}
|
|
|
|
|
|
/// An onclick action (e.g. open a link).
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct OnClick {
|
|
/// A form action will be trigger by this onclick if specified.
|
|
pub action: Option<FormAction>,
|
|
/// This onclick triggers an open link action if specified.
|
|
#[serde(rename="openLink")]
|
|
pub open_link: Option<OpenLink>,
|
|
}
|
|
|
|
impl Part for OnClick {}
|
|
|
|
|
|
/// Annotation metadata for user mentions (@).
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct UserMentionMetadata {
|
|
/// The type of user mention.
|
|
#[serde(rename="type")]
|
|
pub type_: Option<String>,
|
|
/// The user mentioned.
|
|
pub user: Option<User>,
|
|
}
|
|
|
|
impl Part for UserMentionMetadata {}
|
|
|
|
|
|
/// A message in Hangouts Chat.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [messages update spaces](struct.SpaceMessageUpdateCall.html) (request|response)
|
|
/// * [messages get spaces](struct.SpaceMessageGetCall.html) (response)
|
|
/// * [messages create spaces](struct.SpaceMessageCreateCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Message {
|
|
/// Input only. Parameters that a bot can use to configure how its response is
|
|
/// posted.
|
|
#[serde(rename="actionResponse")]
|
|
pub action_response: Option<ActionResponse>,
|
|
/// Resource name, in the form "spaces/*/messages/*".
|
|
///
|
|
/// Example: spaces/AAAAMpdlehY/messages/UMxbHmzDlr4.UMxbHmzDlr4
|
|
pub name: Option<String>,
|
|
/// The thread the message belongs to.
|
|
pub thread: Option<Thread>,
|
|
/// The space the message belongs to.
|
|
pub space: Option<Space>,
|
|
/// Plain-text body of the message.
|
|
pub text: Option<String>,
|
|
/// A plain-text description of the message's cards, used when the actual cards
|
|
/// cannot be displayed (e.g. mobile notifications).
|
|
#[serde(rename="fallbackText")]
|
|
pub fallback_text: Option<String>,
|
|
/// Output only. Annotations associated with the text in this message.
|
|
pub annotations: Option<Vec<Annotation>>,
|
|
/// Plain-text body of the message with all bot mentions stripped out.
|
|
#[serde(rename="argumentText")]
|
|
pub argument_text: Option<String>,
|
|
/// Rich, formatted and interactive cards that can be used to display UI
|
|
/// elements such as: formatted texts, buttons, clickable images. Cards are
|
|
/// normally displayed below the plain-text body of the message.
|
|
pub cards: Option<Vec<Card>>,
|
|
/// Text for generating preview chips. This text will not be displayed to the
|
|
/// user, but any links to images, web pages, videos, etc. included here will
|
|
/// generate preview chips.
|
|
#[serde(rename="previewText")]
|
|
pub preview_text: Option<String>,
|
|
/// Output only. The time at which the message was created in Hangouts Chat
|
|
/// server.
|
|
#[serde(rename="createTime")]
|
|
pub create_time: Option<String>,
|
|
/// The user who created the message.
|
|
pub sender: Option<User>,
|
|
}
|
|
|
|
impl RequestValue for Message {}
|
|
impl ResponseResult for Message {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [members list spaces](struct.SpaceMemberListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ListMembershipsResponse {
|
|
/// List of memberships in the requested (or first) page.
|
|
pub memberships: Option<Vec<Membership>>,
|
|
/// Continuation token to retrieve the next page of results. It will be empty
|
|
/// for the last page of results.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
}
|
|
|
|
impl ResponseResult for ListMembershipsResponse {}
|
|
|
|
|
|
/// Annotations associated with the plain-text body of the message.
|
|
///
|
|
/// Example plain-text message body:
|
|
///
|
|
/// ````text
|
|
/// Hello @FooBot how are you!"
|
|
/// ````
|
|
///
|
|
/// The corresponding annotations metadata:
|
|
///
|
|
/// ````text
|
|
/// "annotations":[{
|
|
/// "type":"USER_MENTION",
|
|
/// "startIndex":6,
|
|
/// "length":7,
|
|
/// "userMention": {
|
|
/// "user": {
|
|
/// "name":"users/107946847022116401880",
|
|
/// "displayName":"FooBot",
|
|
/// "avatarUrl":"https://goo.gl/aeDtrS",
|
|
/// "type":"BOT"
|
|
/// },
|
|
/// "type":"MENTION"
|
|
/// }
|
|
/// }]
|
|
/// ````
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Annotation {
|
|
/// The metadata of user mention.
|
|
#[serde(rename="userMention")]
|
|
pub user_mention: Option<UserMentionMetadata>,
|
|
/// The type of this annotation.
|
|
#[serde(rename="type")]
|
|
pub type_: Option<String>,
|
|
/// Length of the substring in the plain-text message body this annotation
|
|
/// corresponds to.
|
|
pub length: Option<i32>,
|
|
/// Start index (0-based, inclusive) in the plain-text message body this
|
|
/// annotation corresponds to.
|
|
#[serde(rename="startIndex")]
|
|
pub start_index: Option<i32>,
|
|
}
|
|
|
|
impl Part for Annotation {}
|
|
|
|
|
|
/// A card is a UI element that can contain UI widgets such as texts, images.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Card {
|
|
/// The header of the card. A header usually contains a title and an image.
|
|
pub header: Option<CardHeader>,
|
|
/// The actions of this card.
|
|
#[serde(rename="cardActions")]
|
|
pub card_actions: Option<Vec<CardAction>>,
|
|
/// Name of the card.
|
|
pub name: Option<String>,
|
|
/// Sections are separated by a line divider.
|
|
pub sections: Option<Vec<Section>>,
|
|
}
|
|
|
|
impl Part for Card {}
|
|
|
|
|
|
/// A user in Hangouts Chat.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct User {
|
|
/// The user's display name.
|
|
#[serde(rename="displayName")]
|
|
pub display_name: Option<String>,
|
|
/// Obfuscated domain information.
|
|
#[serde(rename="domainId")]
|
|
pub domain_id: Option<String>,
|
|
/// User type.
|
|
#[serde(rename="type")]
|
|
pub type_: Option<String>,
|
|
/// Resource name, in the format "users/*".
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
impl Part for User {}
|
|
|
|
|
|
|
|
// ###################
|
|
// MethodBuilders ###
|
|
// #################
|
|
|
|
/// A builder providing access to all methods supported on *space* resources.
|
|
/// It is not used directly, but through the `HangoutsChat` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_chat1 as chat1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use chat1::HangoutsChat;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `get(...)`, `list(...)`, `members_get(...)`, `members_list(...)`, `messages_create(...)`, `messages_delete(...)`, `messages_get(...)` and `messages_update(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.spaces();
|
|
/// # }
|
|
/// ```
|
|
pub struct SpaceMethods<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a HangoutsChat<C, A>,
|
|
}
|
|
|
|
impl<'a, C, A> MethodsBuilder for SpaceMethods<'a, C, A> {}
|
|
|
|
impl<'a, C, A> SpaceMethods<'a, C, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Lists spaces the caller is a member of.
|
|
pub fn list(&self) -> SpaceListCall<'a, C, A> {
|
|
SpaceListCall {
|
|
hub: self.hub,
|
|
_page_token: Default::default(),
|
|
_page_size: Default::default(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns a message.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Resource name of the message to be retrieved, in the form
|
|
/// "spaces/*/messages/*".
|
|
/// Example: spaces/AAAAMpdlehY/messages/UMxbHmzDlr4.UMxbHmzDlr4
|
|
pub fn messages_get(&self, name: &str) -> SpaceMessageGetCall<'a, C, A> {
|
|
SpaceMessageGetCall {
|
|
hub: self.hub,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns a space.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Resource name of the space, in the form "spaces/*".
|
|
/// Example: spaces/AAAAMpdlehY
|
|
pub fn get(&self, name: &str) -> SpaceGetCall<'a, C, A> {
|
|
SpaceGetCall {
|
|
hub: self.hub,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates a message.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Resource name, in the form "spaces/*/messages/*".
|
|
/// Example: spaces/AAAAMpdlehY/messages/UMxbHmzDlr4.UMxbHmzDlr4
|
|
pub fn messages_update(&self, request: Message, name: &str) -> SpaceMessageUpdateCall<'a, C, A> {
|
|
SpaceMessageUpdateCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_update_mask: Default::default(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Lists human memberships in a space.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The resource name of the space for which membership list is to be
|
|
/// fetched, in the form "spaces/*".
|
|
/// Example: spaces/AAAAMpdlehY
|
|
pub fn members_list(&self, parent: &str) -> SpaceMemberListCall<'a, C, A> {
|
|
SpaceMemberListCall {
|
|
hub: self.hub,
|
|
_parent: parent.to_string(),
|
|
_page_token: Default::default(),
|
|
_page_size: Default::default(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns a membership.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Resource name of the membership to be retrieved, in the form
|
|
/// "spaces/*/members/*".
|
|
/// Example: spaces/AAAAMpdlehY/members/105115627578887013105
|
|
pub fn members_get(&self, name: &str) -> SpaceMemberGetCall<'a, C, A> {
|
|
SpaceMemberGetCall {
|
|
hub: self.hub,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes a message.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Resource name of the message to be deleted, in the form
|
|
/// "spaces/*/messages/*"
|
|
/// Example: spaces/AAAAMpdlehY/messages/UMxbHmzDlr4.UMxbHmzDlr4
|
|
pub fn messages_delete(&self, name: &str) -> SpaceMessageDeleteCall<'a, C, A> {
|
|
SpaceMessageDeleteCall {
|
|
hub: self.hub,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Creates a message.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `parent` - Required. Space resource name, in the form "spaces/*".
|
|
/// Example: spaces/AAAAMpdlehY
|
|
pub fn messages_create(&self, request: Message, parent: &str) -> SpaceMessageCreateCall<'a, C, A> {
|
|
SpaceMessageCreateCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_parent: parent.to_string(),
|
|
_thread_key: Default::default(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ###################
|
|
// CallBuilders ###
|
|
// #################
|
|
|
|
/// Lists spaces the caller is a member of.
|
|
///
|
|
/// A builder for the *list* method supported by a *space* resource.
|
|
/// It is not used directly, but through a `SpaceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_chat1 as chat1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use chat1::HangoutsChat;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.spaces().list()
|
|
/// .page_token("kasd")
|
|
/// .page_size(-22)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SpaceListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a HangoutsChat<C, A>,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_delegate: Option<&'a mut dyn Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for SpaceListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> SpaceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ListSpacesResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut dyn Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "chat.spaces.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_size {
|
|
params.push(("pageSize", value.to_string()));
|
|
}
|
|
for &field in ["alt", "pageToken", "pageSize"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/spaces";
|
|
|
|
let mut key = self.hub.auth.borrow_mut().api_key();
|
|
if key.is_none() {
|
|
key = dlg.api_key();
|
|
}
|
|
match key {
|
|
Some(value) => params.push(("key", value)),
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingAPIKey)
|
|
}
|
|
}
|
|
|
|
|
|
let url = hyper::Url::parse_with_params(&url, params).unwrap();
|
|
|
|
|
|
|
|
loop {
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
|
.header(UserAgent(self.hub._user_agent.clone()));
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
|
|
let json_server_error = json::from_str::<JsonServerError>(&json_err).ok();
|
|
let server_error = json::from_str::<ServerError>(&json_err)
|
|
.or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error))
|
|
.ok();
|
|
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json_server_error,
|
|
server_error) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// A token identifying a page of results the server should return.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> SpaceListCall<'a, C, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Requested page size. The value is capped at 1000.
|
|
/// Server may return fewer results than requested.
|
|
/// If unspecified, server will default to 100.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> SpaceListCall<'a, C, A> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SpaceListCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known parameters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *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.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SpaceListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// Returns a message.
|
|
///
|
|
/// A builder for the *messages.get* method supported by a *space* resource.
|
|
/// It is not used directly, but through a `SpaceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_chat1 as chat1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use chat1::HangoutsChat;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.spaces().messages_get("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SpaceMessageGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a HangoutsChat<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for SpaceMessageGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> SpaceMessageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Message)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut dyn Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "chat.spaces.messages.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}";
|
|
|
|
let mut key = self.hub.auth.borrow_mut().api_key();
|
|
if key.is_none() {
|
|
key = dlg.api_key();
|
|
}
|
|
match key {
|
|
Some(value) => params.push(("key", value)),
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingAPIKey)
|
|
}
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string();
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].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 url = hyper::Url::parse_with_params(&url, params).unwrap();
|
|
|
|
|
|
|
|
loop {
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
|
.header(UserAgent(self.hub._user_agent.clone()));
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
|
|
let json_server_error = json::from_str::<JsonServerError>(&json_err).ok();
|
|
let server_error = json::from_str::<ServerError>(&json_err)
|
|
.or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error))
|
|
.ok();
|
|
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json_server_error,
|
|
server_error) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Resource name of the message to be retrieved, in the form
|
|
/// "spaces/*/messages/*".
|
|
///
|
|
/// Example: spaces/AAAAMpdlehY/messages/UMxbHmzDlr4.UMxbHmzDlr4
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> SpaceMessageGetCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SpaceMessageGetCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known parameters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *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.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SpaceMessageGetCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// Returns a space.
|
|
///
|
|
/// A builder for the *get* method supported by a *space* resource.
|
|
/// It is not used directly, but through a `SpaceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_chat1 as chat1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use chat1::HangoutsChat;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.spaces().get("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SpaceGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a HangoutsChat<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for SpaceGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> SpaceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Space)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut dyn Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "chat.spaces.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}";
|
|
|
|
let mut key = self.hub.auth.borrow_mut().api_key();
|
|
if key.is_none() {
|
|
key = dlg.api_key();
|
|
}
|
|
match key {
|
|
Some(value) => params.push(("key", value)),
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingAPIKey)
|
|
}
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string();
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].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 url = hyper::Url::parse_with_params(&url, params).unwrap();
|
|
|
|
|
|
|
|
loop {
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
|
.header(UserAgent(self.hub._user_agent.clone()));
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
|
|
let json_server_error = json::from_str::<JsonServerError>(&json_err).ok();
|
|
let server_error = json::from_str::<ServerError>(&json_err)
|
|
.or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error))
|
|
.ok();
|
|
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json_server_error,
|
|
server_error) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Resource name of the space, in the form "spaces/*".
|
|
///
|
|
/// Example: spaces/AAAAMpdlehY
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> SpaceGetCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SpaceGetCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known parameters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *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.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SpaceGetCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// Updates a message.
|
|
///
|
|
/// A builder for the *messages.update* method supported by a *space* resource.
|
|
/// It is not used directly, but through a `SpaceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_chat1 as chat1;
|
|
/// use chat1::Message;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use chat1::HangoutsChat;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req = Message::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.spaces().messages_update(req, "name")
|
|
/// .update_mask("erat")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SpaceMessageUpdateCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a HangoutsChat<C, A>,
|
|
_request: Message,
|
|
_name: String,
|
|
_update_mask: Option<String>,
|
|
_delegate: Option<&'a mut dyn Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for SpaceMessageUpdateCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> SpaceMessageUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Message)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut dyn Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "chat.spaces.messages.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
if let Some(value) = self._update_mask {
|
|
params.push(("updateMask", value.to_string()));
|
|
}
|
|
for &field in ["alt", "name", "updateMask"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}";
|
|
|
|
let mut key = self.hub.auth.borrow_mut().api_key();
|
|
if key.is_none() {
|
|
key = dlg.api_key();
|
|
}
|
|
match key {
|
|
Some(value) => params.push(("key", value)),
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingAPIKey)
|
|
}
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string();
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].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 url = hyper::Url::parse_with_params(&url, params).unwrap();
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.clone())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
|
|
let json_server_error = json::from_str::<JsonServerError>(&json_err).ok();
|
|
let server_error = json::from_str::<ServerError>(&json_err)
|
|
.or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error))
|
|
.ok();
|
|
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json_server_error,
|
|
server_error) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: Message) -> SpaceMessageUpdateCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Resource name, in the form "spaces/*/messages/*".
|
|
///
|
|
/// Example: spaces/AAAAMpdlehY/messages/UMxbHmzDlr4.UMxbHmzDlr4
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> SpaceMessageUpdateCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// Required. The field paths to be updated, comma separated if there are
|
|
/// multiple.
|
|
///
|
|
/// Currently supported field paths:
|
|
/// * text
|
|
/// * cards
|
|
///
|
|
/// Sets the *update mask* query property to the given value.
|
|
pub fn update_mask(mut self, new_value: &str) -> SpaceMessageUpdateCall<'a, C, A> {
|
|
self._update_mask = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SpaceMessageUpdateCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known parameters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *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.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SpaceMessageUpdateCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// Lists human memberships in a space.
|
|
///
|
|
/// A builder for the *members.list* method supported by a *space* resource.
|
|
/// It is not used directly, but through a `SpaceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_chat1 as chat1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use chat1::HangoutsChat;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.spaces().members_list("parent")
|
|
/// .page_token("sea")
|
|
/// .page_size(-90)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SpaceMemberListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a HangoutsChat<C, A>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_delegate: Option<&'a mut dyn Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for SpaceMemberListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> SpaceMemberListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ListMembershipsResponse)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut dyn Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "chat.spaces.members.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
|
|
params.push(("parent", self._parent.to_string()));
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_size {
|
|
params.push(("pageSize", value.to_string()));
|
|
}
|
|
for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+parent}/members";
|
|
|
|
let mut key = self.hub.auth.borrow_mut().api_key();
|
|
if key.is_none() {
|
|
key = dlg.api_key();
|
|
}
|
|
match key {
|
|
Some(value) => params.push(("key", value)),
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingAPIKey)
|
|
}
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string();
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["parent"].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 url = hyper::Url::parse_with_params(&url, params).unwrap();
|
|
|
|
|
|
|
|
loop {
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
|
.header(UserAgent(self.hub._user_agent.clone()));
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
|
|
let json_server_error = json::from_str::<JsonServerError>(&json_err).ok();
|
|
let server_error = json::from_str::<ServerError>(&json_err)
|
|
.or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error))
|
|
.ok();
|
|
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json_server_error,
|
|
server_error) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The resource name of the space for which membership list is to be
|
|
/// fetched, in the form "spaces/*".
|
|
///
|
|
/// Example: spaces/AAAAMpdlehY
|
|
///
|
|
/// Sets the *parent* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn parent(mut self, new_value: &str) -> SpaceMemberListCall<'a, C, A> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// A token identifying a page of results the server should return.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> SpaceMemberListCall<'a, C, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Requested page size. The value is capped at 1000.
|
|
/// Server may return fewer results than requested.
|
|
/// If unspecified, server will default to 100.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> SpaceMemberListCall<'a, C, A> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SpaceMemberListCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known parameters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *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.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SpaceMemberListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// Returns a membership.
|
|
///
|
|
/// A builder for the *members.get* method supported by a *space* resource.
|
|
/// It is not used directly, but through a `SpaceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_chat1 as chat1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use chat1::HangoutsChat;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.spaces().members_get("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SpaceMemberGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a HangoutsChat<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for SpaceMemberGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> SpaceMemberGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Membership)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut dyn Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "chat.spaces.members.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}";
|
|
|
|
let mut key = self.hub.auth.borrow_mut().api_key();
|
|
if key.is_none() {
|
|
key = dlg.api_key();
|
|
}
|
|
match key {
|
|
Some(value) => params.push(("key", value)),
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingAPIKey)
|
|
}
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string();
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].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 url = hyper::Url::parse_with_params(&url, params).unwrap();
|
|
|
|
|
|
|
|
loop {
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone())
|
|
.header(UserAgent(self.hub._user_agent.clone()));
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
|
|
let json_server_error = json::from_str::<JsonServerError>(&json_err).ok();
|
|
let server_error = json::from_str::<ServerError>(&json_err)
|
|
.or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error))
|
|
.ok();
|
|
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json_server_error,
|
|
server_error) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Resource name of the membership to be retrieved, in the form
|
|
/// "spaces/*/members/*".
|
|
///
|
|
/// Example: spaces/AAAAMpdlehY/members/105115627578887013105
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> SpaceMemberGetCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SpaceMemberGetCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known parameters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *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.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SpaceMemberGetCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// Deletes a message.
|
|
///
|
|
/// A builder for the *messages.delete* method supported by a *space* resource.
|
|
/// It is not used directly, but through a `SpaceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_chat1 as chat1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use chat1::HangoutsChat;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.spaces().messages_delete("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SpaceMessageDeleteCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a HangoutsChat<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for SpaceMessageDeleteCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> SpaceMessageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut dyn Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "chat.spaces.messages.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}";
|
|
|
|
let mut key = self.hub.auth.borrow_mut().api_key();
|
|
if key.is_none() {
|
|
key = dlg.api_key();
|
|
}
|
|
match key {
|
|
Some(value) => params.push(("key", value)),
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingAPIKey)
|
|
}
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string();
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].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 url = hyper::Url::parse_with_params(&url, params).unwrap();
|
|
|
|
|
|
|
|
loop {
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone())
|
|
.header(UserAgent(self.hub._user_agent.clone()));
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
|
|
let json_server_error = json::from_str::<JsonServerError>(&json_err).ok();
|
|
let server_error = json::from_str::<ServerError>(&json_err)
|
|
.or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error))
|
|
.ok();
|
|
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json_server_error,
|
|
server_error) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Resource name of the message to be deleted, in the form
|
|
/// "spaces/*/messages/*"
|
|
///
|
|
/// Example: spaces/AAAAMpdlehY/messages/UMxbHmzDlr4.UMxbHmzDlr4
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> SpaceMessageDeleteCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SpaceMessageDeleteCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known parameters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *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.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SpaceMessageDeleteCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// Creates a message.
|
|
///
|
|
/// A builder for the *messages.create* method supported by a *space* resource.
|
|
/// It is not used directly, but through a `SpaceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_chat1 as chat1;
|
|
/// use chat1::Message;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use chat1::HangoutsChat;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = HangoutsChat::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req = Message::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.spaces().messages_create(req, "parent")
|
|
/// .thread_key("aliquyam")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SpaceMessageCreateCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a HangoutsChat<C, A>,
|
|
_request: Message,
|
|
_parent: String,
|
|
_thread_key: Option<String>,
|
|
_delegate: Option<&'a mut dyn Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for SpaceMessageCreateCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> SpaceMessageCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Message)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut dyn Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "chat.spaces.messages.create",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
|
|
params.push(("parent", self._parent.to_string()));
|
|
if let Some(value) = self._thread_key {
|
|
params.push(("threadKey", value.to_string()));
|
|
}
|
|
for &field in ["alt", "parent", "threadKey"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+parent}/messages";
|
|
|
|
let mut key = self.hub.auth.borrow_mut().api_key();
|
|
if key.is_none() {
|
|
key = dlg.api_key();
|
|
}
|
|
match key {
|
|
Some(value) => params.push(("key", value)),
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingAPIKey)
|
|
}
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string();
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["parent"].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 url = hyper::Url::parse_with_params(&url, params).unwrap();
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
|
|
let json_server_error = json::from_str::<JsonServerError>(&json_err).ok();
|
|
let server_error = json::from_str::<ServerError>(&json_err)
|
|
.or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error))
|
|
.ok();
|
|
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json_server_error,
|
|
server_error) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: Message) -> SpaceMessageCreateCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Space resource name, in the form "spaces/*".
|
|
/// Example: spaces/AAAAMpdlehY
|
|
///
|
|
/// Sets the *parent* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn parent(mut self, new_value: &str) -> SpaceMessageCreateCall<'a, C, A> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Opaque thread identifier string that can be specified to group messages
|
|
/// into a single thread. If this is the first message with a given thread
|
|
/// identifier, a new thread is created. Subsequent messages with the same
|
|
/// thread identifier will be posted into the same thread. This relieves bots
|
|
/// and webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post
|
|
/// further updates to it.
|
|
///
|
|
/// Has no effect if thread field,
|
|
/// corresponding to an existing thread, is set in message.
|
|
///
|
|
/// Sets the *thread key* query property to the given value.
|
|
pub fn thread_key(mut self, new_value: &str) -> SpaceMessageCreateCall<'a, C, A> {
|
|
self._thread_key = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// 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.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> SpaceMessageCreateCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known parameters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *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.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *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.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SpaceMessageCreateCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
}
|
|
|
|
|