// 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())), //! ::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())), /// ::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 { client: RefCell, auth: RefCell, _user_agent: String, _base_url: String, _root_url: String, } impl<'a, C, A> Hub for HangoutsChat {} impl<'a, C, A> HangoutsChat where C: BorrowMut, A: oauth2::GetToken { pub fn new(client: C, authenticator: A) -> HangoutsChat { 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, } 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, /// The type of bot response. #[serde(rename="type")] pub type_: Option, } 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, } 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, /// Whether the space is a DM between a bot and a single human. #[serde(rename="singleUserBotDm")] pub single_user_bot_dm: Option, /// Whether the messages are threaded in this space. pub threaded: Option, /// Output only. The type of a space. /// This is deprecated. Use `single_user_bot_dm` instead. #[serde(rename="type")] pub type_: Option, /// Resource name of the space, in the form "spaces/*". /// /// Example: spaces/AAAAMpdlehYs pub name: Option, } 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>, /// Display a key value item in this widget. #[serde(rename="keyValue")] pub key_value: Option, /// Display an image in this widget. pub image: Option, /// Display a text paragraph in this widget. #[serde(rename="textParagraph")] pub text_paragraph: Option, } 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>, /// The header of the section, text formatted supported. pub header: Option, } 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, } 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, /// List of action parameters. pub parameters: Option>, } 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, /// The URL of the image in the card header. #[serde(rename="imageUrl")] pub image_url: Option, /// The subtitle of the card header. pub subtitle: Option, /// 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, } 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, /// A button with text and onclick action. #[serde(rename="textButton")] pub text_button: Option, } 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, /// List of spaces in the requested (or first) page. pub spaces: Option>, } 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, /// The value of the parameter. pub value: Option, } 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, /// The onclick action for this action item. #[serde(rename="onClick")] pub on_click: Option, } 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, /// The onclick action of the button. #[serde(rename="onClick")] pub on_click: Option, } 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, /// 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, /// The onclick action. #[serde(rename="onClick")] pub on_click: Option, /// The icon specified by an enum that indices to an icon provided by Chat /// API. pub icon: Option, } 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, /// The URL of the image. #[serde(rename="imageUrl")] pub image_url: Option, /// The onclick action. #[serde(rename="onClick")] pub on_click: Option, } 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, /// State of the membership. pub state: Option, /// 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, /// Resource name of the membership, in the form "spaces/*/members/*". /// /// Example: spaces/AAAAMpdlehY/members/105115627578887013105 pub name: Option, } 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, /// The text of the bottom label. Formatted text supported. #[serde(rename="bottomLabel")] pub bottom_label: Option, /// The text of the top label. Formatted text supported. #[serde(rename="topLabel")] pub top_label: Option, /// A button that can be clicked to trigger an action. pub button: Option