use std::collections::HashMap; use std::cell::RefCell; 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 crate::client; // ############## // 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 google_chat1 as chat1; /// use chat1::api::Message; /// use chat1::{Result, Error}; /// # async fn dox() { /// use std::default::Default; /// use chat1::{HangoutsChat, oauth2, hyper, hyper_rustls}; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. /// let secret: oauth2::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 = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = HangoutsChat::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.dms().conversations_messages(req, "parent") /// .thread_key("sed") /// .request_id("amet.") /// .doit().await; /// /// 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::Io(_) /// |Error::MissingAPIKey /// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) /// |Error::BadRequest(_) /// |Error::FieldClash(_) /// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } /// # } /// ``` #[derive(Clone)] pub struct HangoutsChat<> { pub client: hyper::Client, hyper::body::Body>, pub auth: oauth2::authenticator::Authenticator>, _user_agent: String, _base_url: String, _root_url: String, } impl<'a, > client::Hub for HangoutsChat<> {} impl<'a, > HangoutsChat<> { pub fn new(client: hyper::Client, hyper::body::Body>, authenticator: oauth2::authenticator::Authenticator>) -> HangoutsChat<> { HangoutsChat { client, auth: authenticator, _user_agent: "google-api-rust-client/3.0.0".to_string(), _base_url: "https://chat.googleapis.com/".to_string(), _root_url: "https://chat.googleapis.com/".to_string(), } } pub fn dms(&'a self) -> DmMethods<'a> { DmMethods { hub: &self } } pub fn media(&'a self) -> MediaMethods<'a> { MediaMethods { hub: &self } } pub fn rooms(&'a self) -> RoomMethods<'a> { RoomMethods { hub: &self } } pub fn spaces(&'a self) -> SpaceMethods<'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/3.0.0`. /// /// 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 ### // ########## /// 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 client::Part for ActionParameter {} /// 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 { /// A response to an event related to a [dialog](https://developers.google.com/chat/how-tos/bot-dialogs). Must be accompanied by `ResponseType.Dialog`. #[serde(rename="dialogAction")] pub dialog_action: Option, /// The type of bot response. #[serde(rename="type")] pub type_: Option, /// URL for users to auth or config. (Only for REQUEST_CONFIG response types.) pub url: Option, } impl client::Part for ActionResponse {} /// Represents the status of a request. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActionStatus { /// The status code. #[serde(rename="statusCode")] pub status_code: Option, /// The message to send users about the status of their request. If unset, a generic message based on the `status_code` is sent. #[serde(rename="userFacingMessage")] pub user_facing_message: Option, } impl client::Part for ActionStatus {} /// Annotations associated with the plain-text body of the message. Example plain-text message body: ``` Hello @FooBot how are you!" ``` The corresponding annotations metadata: ``` "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 { /// Length of the substring in the plain-text message body this annotation corresponds to. pub length: Option, /// The metadata for a slash command. #[serde(rename="slashCommand")] pub slash_command: Option, /// Start index (0-based, inclusive) in the plain-text message body this annotation corresponds to. #[serde(rename="startIndex")] pub start_index: Option, /// The type of this annotation. #[serde(rename="type")] pub type_: Option, /// The metadata of user mention. #[serde(rename="userMention")] pub user_mention: Option, } impl client::Part for Annotation {} /// An attachment in Google 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 attachments get spaces](SpaceMessageAttachmentGetCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Attachment { /// A reference to the attachment data. This is used with the media API to download the attachment data. #[serde(rename="attachmentDataRef")] pub attachment_data_ref: Option, /// The original file name for the content, not the full path. #[serde(rename="contentName")] pub content_name: Option, /// The content type (MIME type) of the file. #[serde(rename="contentType")] pub content_type: Option, /// Output only. The download URL which should be used to allow a human user to download the attachment. Bots should not use this URL to download attachment content. #[serde(rename="downloadUri")] pub download_uri: Option, /// A reference to the drive attachment. This is used with the Drive API. #[serde(rename="driveDataRef")] pub drive_data_ref: Option, /// Resource name of the attachment, in the form "spaces/*/messages/*/attachments/*". pub name: Option, /// The source of the attachment. pub source: Option, /// Output only. The thumbnail URL which should be used to preview the attachment to a human user. Bots should not use this URL to download attachment content. #[serde(rename="thumbnailUri")] pub thumbnail_uri: Option, } impl client::ResponseResult for Attachment {} /// A reference to the data of an attachment. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AttachmentDataRef { /// The resource name of the attachment data. This is used with the media API to download the attachment data. #[serde(rename="resourceName")] pub resource_name: Option, } impl client::Part for AttachmentDataRef {} /// 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 client::Part for Button {} /// 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 actions of this card. #[serde(rename="cardActions")] pub card_actions: Option>, /// The header of the card. A header usually contains a title and an image. pub header: Option, /// Name of the card. pub name: Option, /// Sections are separated by a line divider. pub sections: Option>, } impl client::Part for Card {} /// 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 client::Part for CardAction {} /// 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 client::Part for CardHeader {} /// Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Color { /// The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). pub alpha: Option, /// The amount of blue in the color as a value in the interval [0, 1]. pub blue: Option, /// The amount of green in the color as a value in the interval [0, 1]. pub green: Option, /// The amount of red in the color as a value in the interval [0, 1]. pub red: Option, } impl client::Part for Color {} /// Wrapper around the card body of the dialog. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Dialog { /// Body of the dialog, which is rendered in a modal. Google Chat apps do not support the following card entities: `DateTimePicker`, `OnChangeAction`. pub body: Option, } impl client::Part for Dialog {} /// Contains a [dialog](https://developers.google.com/chat/how-tos/bot-dialogs) and request status code. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DialogAction { /// Status for a request to either invoke or submit a [dialog](https://developers.google.com/chat/how-tos/bot-dialogs). Displays a status and message to users, if necessary. For example, in case of an error or success. #[serde(rename="actionStatus")] pub action_status: Option, /// [Dialog](https://developers.google.com/chat/how-tos/bot-dialogs) for the request. pub dialog: Option, } impl client::Part for DialogAction {} /// A reference to the data of a drive attachment. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DriveDataRef { /// The id for the drive file, for use with the Drive API. #[serde(rename="driveFileId")] pub drive_file_id: Option, } impl client::Part for DriveDataRef {} /// 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: 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](SpaceMessageDeleteCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Empty { _never_set: Option } impl client::ResponseResult for Empty {} /// 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 client::Part for FormAction {} /// An action that 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 GoogleAppsCardV1Action { /// Apps Script function to invoke when the containing element is clicked/activated. pub function: Option, /// Specifies the loading indicator that the action displays while making the call to the action. #[serde(rename="loadIndicator")] pub load_indicator: Option, /// List of action parameters. pub parameters: Option>, /// Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. #[serde(rename="persistValues")] pub persist_values: Option, } impl client::Part for GoogleAppsCardV1Action {} /// 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 GoogleAppsCardV1ActionParameter { /// The name of the parameter for the action script. pub key: Option, /// The value of the parameter. pub value: Option, } impl client::Part for GoogleAppsCardV1ActionParameter {} /// Represents the complete border style applied to widgets. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1BorderStyle { /// The corner radius for the border. #[serde(rename="cornerRadius")] pub corner_radius: Option, /// The colors to use when the type is `BORDER_TYPE_STROKE`. #[serde(rename="strokeColor")] pub stroke_color: Option, /// The border type. #[serde(rename="type")] pub type_: Option, } impl client::Part for GoogleAppsCardV1BorderStyle {} /// 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 GoogleAppsCardV1Button { /// The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. #[serde(rename="altText")] pub alt_text: Option, /// If set, the button is filled with a solid background. pub color: Option, /// If `true`, the button is displayed in a disabled state and doesn't respond to user actions. pub disabled: Option, /// The icon image. pub icon: Option, /// The action to perform when the button is clicked. #[serde(rename="onClick")] pub on_click: Option, /// The text of the button. pub text: Option, } impl client::Part for GoogleAppsCardV1Button {} /// A list of buttons layed out horizontally. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1ButtonList { /// An array of buttons. pub buttons: Option>, } impl client::Part for GoogleAppsCardV1ButtonList {} /// A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Sasha", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/sasha.png", "imageAltText": "Avatar for Sasha" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "sasha@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1Card { /// The card's actions. Actions are added to the card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Settings", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` #[serde(rename="cardActions")] pub card_actions: Option>, /// The display style for `peekCardHeader`. #[serde(rename="displayStyle")] pub display_style: Option, /// The fixed footer shown at the bottom of this card. #[serde(rename="fixedFooter")] pub fixed_footer: Option, /// The header of the card. A header usually contains a title and an image. pub header: Option, /// Name of the card. Used as a card identifier in card navigation. pub name: Option, /// When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. #[serde(rename="peekCardHeader")] pub peek_card_header: Option, /// Sections are separated by a line divider. pub sections: Option>, } impl client::Part for GoogleAppsCardV1Card {} /// A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a 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 GoogleAppsCardV1CardAction { /// The label that displays as 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 client::Part for GoogleAppsCardV1CardAction {} /// A persistent (sticky) footer that is added to the bottom of the card. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1CardFixedFooter { /// The primary button of the fixed footer. The button must be a text button with text and color set. #[serde(rename="primaryButton")] pub primary_button: Option, /// The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. #[serde(rename="secondaryButton")] pub secondary_button: Option, } impl client::Part for GoogleAppsCardV1CardFixedFooter {} /// Represents a card header. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1CardHeader { /// The alternative text of this image which is used for accessibility. #[serde(rename="imageAltText")] pub image_alt_text: Option, /// The image's type. #[serde(rename="imageType")] pub image_type: 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, /// Required. The title of the card header. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. pub title: Option, } impl client::Part for GoogleAppsCardV1CardHeader {} /// The widget that lets users to specify a date and time. Not supported by Google Chat apps. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1DateTimePicker { /// The label for the field that displays to the user. pub label: Option, /// The name of the text input that's used in `formInput`, and uniquely identifies this input. pub name: Option, /// Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. #[serde(rename="onChangeAction")] pub on_change_action: Option, /// The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. #[serde(rename="timezoneOffsetDate")] pub timezone_offset_date: Option, /// The type of the date/time picker. #[serde(rename="type")] pub type_: Option, /// The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. #[serde(rename="valueMsEpoch")] pub value_ms_epoch: Option, } impl client::Part for GoogleAppsCardV1DateTimePicker {} /// A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1DecoratedText { /// The formatted text label that shows below the main text. #[serde(rename="bottomLabel")] pub bottom_label: Option, /// A button that can be clicked to trigger an action. pub button: Option, /// An icon displayed after the text. #[serde(rename="endIcon")] pub end_icon: Option, /// Deprecated in favor of start_icon. pub icon: Option, /// Only the top and bottom label and content region are clickable. #[serde(rename="onClick")] pub on_click: Option, /// The icon displayed in front of the text. #[serde(rename="startIcon")] pub start_icon: Option, /// A switch widget can be clicked to change its state or trigger an action. #[serde(rename="switchControl")] pub switch_control: Option, /// Required. The main widget formatted text. See Text formatting for details. pub text: Option, /// The formatted text label that shows above the main text. #[serde(rename="topLabel")] pub top_label: Option, /// The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. #[serde(rename="wrapText")] pub wrap_text: Option, } impl client::Part for GoogleAppsCardV1DecoratedText {} /// A divider that appears in between widgets. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1Divider { _never_set: Option } impl client::Part for GoogleAppsCardV1Divider {} /// Represents a Grid widget that displays items in a configurable grid layout. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1Grid { /// The border style to apply to each grid item. #[serde(rename="borderStyle")] pub border_style: Option, /// The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). #[serde(rename="columnCount")] pub column_count: Option, /// The items to display in the grid. pub items: Option>, /// This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. #[serde(rename="onClick")] pub on_click: Option, /// The text that displays in the grid header. pub title: Option, } impl client::Part for GoogleAppsCardV1Grid {} /// Represents a single item in the grid layout. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1GridItem { /// A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. pub id: Option, /// The image that displays in the grid item. pub image: Option, /// The layout to use for the grid item. pub layout: Option, /// The grid item's subtitle. pub subtitle: Option, /// The horizontal alignment of the grid item's text. #[serde(rename="textAlignment")] pub text_alignment: Option, /// The grid item's title. pub title: Option, } impl client::Part for GoogleAppsCardV1GridItem {} /// 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 GoogleAppsCardV1Icon { /// The description of the icon, used for accessibility. The default value is provided if you don't specify one. #[serde(rename="altText")] pub alt_text: Option, /// The icon specified by a URL. #[serde(rename="iconUrl")] pub icon_url: Option, /// The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. #[serde(rename="imageType")] pub image_type: Option, /// The icon specified by the string name of a list of known icons. #[serde(rename="knownIcon")] pub known_icon: Option, } impl client::Part for GoogleAppsCardV1Icon {} /// 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 GoogleAppsCardV1Image { /// The alternative text of this image, used for accessibility. #[serde(rename="altText")] pub alt_text: Option, /// An image URL. #[serde(rename="imageUrl")] pub image_url: Option, /// The action triggered by an `onClick` event. #[serde(rename="onClick")] pub on_click: Option, } impl client::Part for GoogleAppsCardV1Image {} /// Represents an image. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1ImageComponent { /// The accessibility label for the image. #[serde(rename="altText")] pub alt_text: Option, /// The border style to apply to the image. #[serde(rename="borderStyle")] pub border_style: Option, /// The crop style to apply to the image. #[serde(rename="cropStyle")] pub crop_style: Option, /// The image URL. #[serde(rename="imageUri")] pub image_uri: Option, } impl client::Part for GoogleAppsCardV1ImageComponent {} /// Represents the crop style applied to an image. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1ImageCropStyle { /// The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. #[serde(rename="aspectRatio")] pub aspect_ratio: Option, /// The crop type. #[serde(rename="type")] pub type_: Option, } impl client::Part for GoogleAppsCardV1ImageCropStyle {} /// Represents the response to an `onClick` event. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1OnClick { /// If specified, an action is triggered by this `onClick`. pub action: Option, /// A new card is pushed to the card stack after clicking if specified. pub card: Option, /// An add-on triggers this action when the action needs to open a link. This differs from the `open_link` above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. #[serde(rename="openDynamicLinkAction")] pub open_dynamic_link_action: Option, /// If specified, this `onClick` triggers an open link action. #[serde(rename="openLink")] pub open_link: Option, } impl client::Part for GoogleAppsCardV1OnClick {} /// Represents an `onClick` event that opens a hyperlink. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1OpenLink { /// Whether the client forgets about a link after opening it, or observes it until the window closes. Not supported by Chat apps. #[serde(rename="onClose")] pub on_close: Option, /// How to open a link. Not supported by Chat apps. #[serde(rename="openAs")] pub open_as: Option, /// The URL to open. pub url: Option, } impl client::Part for GoogleAppsCardV1OpenLink {} /// 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, for example, 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 GoogleAppsCardV1Section { /// Indicates whether this section is collapsible. If a section is collapsible, the description must be given. pub collapsible: Option, /// The header of the section. Formatted text is supported. pub header: Option, /// The number of uncollapsible widgets. For example, when a section contains five widgets and the `uncollapsibleWidgetsCount` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `uncollapsibleWidgetsCount` is taken into account only when `collapsible` is `true`. #[serde(rename="uncollapsibleWidgetsCount")] pub uncollapsible_widgets_count: Option, /// A section must contain at least 1 widget. pub widgets: Option>, } impl client::Part for GoogleAppsCardV1Section {} /// A widget that creates a UI item with options for users to select. For example, a dropdown menu. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1SelectionInput { /// An array of the selected items. pub items: Option>, /// The label displayed ahead of the switch control. pub label: Option, /// The name of the text input which is used in `formInput`. pub name: Option, /// If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. #[serde(rename="onChangeAction")] pub on_change_action: Option, /// The type of the selection. #[serde(rename="type")] pub type_: Option, } impl client::Part for GoogleAppsCardV1SelectionInput {} /// A selectable item in the switch control. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1SelectionItem { /// If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. pub selected: Option, /// The text to be displayed. pub text: Option, /// The value associated with this item. The client should use this as a form input value. pub value: Option, } impl client::Part for GoogleAppsCardV1SelectionItem {} /// A suggestion item. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1SuggestionItem { /// The suggested autocomplete result. pub text: Option, } impl client::Part for GoogleAppsCardV1SuggestionItem {} /// A container wrapping elements necessary for showing suggestion items used in text input autocomplete. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1Suggestions { /// A list of suggestions used for autocomplete recommendations. pub items: Option>, } impl client::Part for GoogleAppsCardV1Suggestions {} /// Either a toggle-style switch or a checkbox. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1SwitchControl { /// The control type, either switch or checkbox. #[serde(rename="controlType")] pub control_type: Option, /// The name of the switch widget that's used in `formInput`. pub name: Option, /// The action when the switch state is changed. #[serde(rename="onChangeAction")] pub on_change_action: Option, /// If the switch is selected. pub selected: Option, /// The value is what is passed back in the callback. pub value: Option, } impl client::Part for GoogleAppsCardV1SwitchControl {} /// A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1TextInput { /// The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. #[serde(rename="autoCompleteAction")] pub auto_complete_action: Option, /// The hint text. #[serde(rename="hintText")] pub hint_text: Option, /// The initial suggestions made before any user input. #[serde(rename="initialSuggestions")] pub initial_suggestions: Option, /// At least one of label and hintText must be specified. pub label: Option, /// The name of the text input which is used in `formInput`. pub name: Option, /// The onChange action, for example, invoke a function. #[serde(rename="onChangeAction")] pub on_change_action: Option, /// The style of the text, for example, a single line or multiple lines. #[serde(rename="type")] pub type_: Option, /// The default value when there is no input from the user. pub value: Option, } impl client::Part for GoogleAppsCardV1TextInput {} /// A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoogleAppsCardV1TextParagraph { /// The text that's shown in the widget. pub text: Option, } impl client::Part for GoogleAppsCardV1TextParagraph {} /// 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 GoogleAppsCardV1Widget { /// A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` #[serde(rename="buttonList")] pub button_list: Option, /// Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` #[serde(rename="dateTimePicker")] pub date_time_picker: Option, /// Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "sasha@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_sasha", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` #[serde(rename="decoratedText")] pub decorated_text: Option, /// Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` pub divider: Option, /// Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` pub grid: Option, /// The horizontal alignment of this widget. #[serde(rename="horizontalAlignment")] pub horizontal_alignment: Option, /// Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/sasha.png" "altText": "Avatar for Sasha" } ``` pub image: Option, /// Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` #[serde(rename="selectionInput")] pub selection_input: Option, /// Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` #[serde(rename="textInput")] pub text_input: Option, /// Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` #[serde(rename="textParagraph")] pub text_paragraph: Option, } impl client::Part for GoogleAppsCardV1Widget {} /// 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 client::Part for Image {} /// 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 an enum that indices to an icon provided by Chat API. pub icon: Option, /// 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, } impl client::Part for ImageButton {} /// 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 { /// The text of the bottom label. Formatted text supported. #[serde(rename="bottomLabel")] pub bottom_label: Option, /// A button that can be clicked to trigger an action. pub button: Option