Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Google Gmail1
https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1
Admin
A complete library to interact with Gmail (protocol v1) using Rust.
Tokens:
20,930
Snippets:
70
Trust Score:
9.7
Update:
1 year ago
Context
Chat
Benchmark
60.4
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Sending, Getting, and Modifying Gmail Messages Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1/index This Rust code snippet illustrates specific Gmail API operations using the google-gmail1 crate, including sending drafts, retrieving messages, importing, inserting, modifying, sending, and trashing messages. These operations are performed using the hub and specific resource methods followed by `.doit().await`. ```rust let r = hub.users().drafts_send(...).doit().await let r = hub.users().messages_get(...).doit().await let r = hub.users().messages_import(...).doit().await let r = hub.users().messages_insert(...).doit().await let r = hub.users().messages_modify(...).doit().await let r = hub.users().messages_send(...).doit().await let r = hub.users().messages_trash(...).doit().await let r = hub.users().messages_untrash(...).doit().await ``` -------------------------------- ### Gmail API v1 - Users Drafts Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1 Handles operations related to user drafts, including creating, deleting, getting, listing, sending, and updating drafts. ```APIDOC ## POST /users/{userId}/drafts ### Description Creates a new draft in the user's mailbox. ### Method POST ### Endpoint `/gmail/v1/users/{userId}/drafts` ### Parameters #### Path Parameters - **userId** (string) - Required - The user's email address. The special value "me" can be used to indicate the authenticated user. #### Request Body - **draft** (object) - Required - The draft object to be inserted. - **message** (object) - The message to be stored in the draft. - **raw** (string) - The raw email message in RFC 2822 format. - **payload** (object) - The body of the message. Only one of 'raw' or 'payload' can be specified. - **headers** (array of objects) - The list of headers. - **name** (string) - Header name. - **value** (string) - Header value. - **body** (object) - The body of the message. - **data** (string) - Base64url encoded email data. - **attachmentId** (string) - The ID of an attached file that was previously uploaded. - **partId** (string) - The part ID of the MIME message. - **mimeType** (string) - MIME type of the part. - **filename** (string) - Filename of the attachment. - **parts** (array of objects) - The parts of a multipart MIME message. ### Request Example ```json { "message": { "raw": "From: sender@example.com\r\nTo: receiver@example.com\r\nSubject: Test Draft\r\n\r\nThis is the body of the draft." } } ``` ### Response #### Success Response (200) - **id** (string) - The unique ID of the draft. - **message** (object) - The message associated with the draft. - **id** (string) - The unique ID of the message. - **threadId** (string) - The ID of the thread associated with the message. - **labelIds** (array of strings) - The list of IDs of labels associated with this message. - **snippet** (string) - The short part of the text of the latest message - **historyId** (string) - The ID of the history record for the latest message change. - **internalDate** (long) - The internal message creation time. - **payload** (object) - The body of the message. - **sizeEstimate** (integer) - The estimated size of the message in bytes. - **raw** (string) - The raw email message in RFC 2822 format. #### Response Example ```json { "id": "d1234567890abcdef", "message": { "id": "m1234567890abcdef", "threadId": "t1234567890abcdef", "labelIds": ["DRAFT"], "snippet": "This is the body of the draft.", "historyId": "1", "internalDate": 1678886400000, "payload": { "partId": "0", "mimeType": "text/plain", "body": { "data": "VGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgZHJhZnQu" } }, "sizeEstimate": 100 } } ``` ``` -------------------------------- ### Gmail API v1 - Users Threads Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1 Handles operations related to user threads, including deleting, getting, listing, and modifying threads. ```APIDOC ## GET /users/{userId}/threads/{id} ### Description Gets the specified thread. ### Method GET ### Endpoint `/gmail/v1/users/{userId}/threads/{id}` ### Parameters #### Path Parameters - **userId** (string) - Required - The user's email address. The special value "me" can be used to indicate the authenticated user. - **id** (string) - Required - The ID of the thread to retrieve. #### Query Parameters - **userId** (string) - Required - The user's email address. The special value "me" can be used to indicate the authenticated user. ### Request Example ``` GET /gmail/v1/users/me/threads/t1234567890abcdef ``` ### Response #### Success Response (200) - **id** (string) - The unique ID of the thread. - **messages** (array of objects) - The list of messages associated with the thread. - **id** (string) - The unique ID of the message. - **threadId** (string) - The ID of the thread associated with the message. - **labelIds** (array of strings) - The list of IDs of labels associated with this message. - **snippet** (string) - The short part of the text of the latest message - **historyId** (string) - The ID of the history record for the latest message change. - **internalDate** (long) - The internal message creation time. - **payload** (object) - The body of the message. - **sizeEstimate** (integer) - The estimated size of the message in bytes. - **raw** (string) - The raw email message in RFC 2822 format. - **messagesTotal** (integer) - The total number of messages in the thread. - **messagesUnread** (integer) - The number of unread messages in the thread. #### Response Example ```json { "id": "t1234567890abcdef", "messages": [ { "id": "m1234567890abcdef", "threadId": "t1234567890abcdef", "labelIds": ["INBOX", "UNREAD"], "snippet": "Hello, this is a test message.", "historyId": "1", "internalDate": 1678886400000, "payload": { "partId": "0", "mimeType": "text/plain", "headers": [ { "name": "Subject", "value": "Test Thread" } ], "body": { "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IG1lc3NhZ2Uu" } }, "sizeEstimate": 200 } ], "messagesTotal": 1, "messagesUnread": 1 } ``` ``` -------------------------------- ### Gmail API v1 - Users Messages Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1 Handles operations related to user messages, including deleting, getting, importing, inserting, listing, modifying, sending, trashing, and untrashing messages. ```APIDOC ## GET /users/{userId}/messages/{id} ### Description Gets the specified message. ### Method GET ### Endpoint `/gmail/v1/users/{userId}/messages/{id}` ### Parameters #### Path Parameters - **userId** (string) - Required - The user's email address. The special value "me" can be used to indicate the authenticated user. - **id** (string) - Required - The ID of the message to retrieve. #### Query Parameters - **format** (string) - Optional - The desired format for the message. - `full`: Returns the complete email message data. - `metadata`: Returns only the message metadata. - `minimal`: Returns only the message id and thread id. - `raw`: Returns the raw message as is. - **userId** (string) - Required - The user's email address. The special value "me" can be used to indicate the authenticated user. ### Request Example ``` GET /gmail/v1/users/me/messages/1234567890abcdef?format=full ``` ### Response #### Success Response (200) - **id** (string) - The unique ID of the message. - **threadId** (string) - The ID of the thread associated with the message. - **labelIds** (array of strings) - The list of IDs of labels associated with this message. - **snippet** (string) - The short part of the text of the latest message - **historyId** (string) - The ID of the history record for the latest message change. - **internalDate** (long) - The internal message creation time. - **payload** (object) - The body of the message. - **partId** (string) - The part ID of the MIME message. - **mimeType** (string) - MIME type of the part. - **filename** (string) - Filename of the attachment. - **headers** (array of objects) - The list of headers. - **name** (string) - Header name. - **value** (string) - Header value. - **body** (object) - The body of the message. - **data** (string) - Base64url encoded email data. - **attachmentId** (string) - The ID of an attached file that was previously uploaded. - **parts** (array of objects) - The parts of a multipart MIME message. - **sizeEstimate** (integer) - The estimated size of the message in bytes. - **raw** (string) - The raw email message in RFC 2822 format. #### Response Example ```json { "id": "m1234567890abcdef", "threadId": "t1234567890abcdef", "labelIds": ["INBOX", "UNREAD"], "snippet": "Hello, this is a test message.", "historyId": "1", "internalDate": 1678886400000, "payload": { "partId": "0", "mimeType": "text/plain", "filename": "test.txt", "headers": [ { "name": "Subject", "value": "Test Message" }, { "name": "From", "value": "sender@example.com" }, { "name": "To", "value": "receiver@example.com" } ], "body": { "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IG1lc3NhZ2Uu" } }, "sizeEstimate": 200, "raw": "From: sender@example.com\r\nTo: receiver@example.com\r\nSubject: Test Message\r\nDate: Wed, 15 Mar 2023 10:00:00 +0000\r\nMessage-ID: <123@example.com>\r\nContent-Type: text/plain; charset=\"US-ASCII\"\r\n\r\nHello, this is a test message." } ``` ``` ```APIDOC ## POST /users/{userId}/messages/import ### Description Imports a message into the user's mailbox. ### Method POST ### Endpoint `/gmail/v1/users/{userId}/messages/import` ### Parameters #### Path Parameters - **userId** (string) - Required - The user's email address. The special value "me" can be used to indicate the authenticated user. #### Query Parameters - **userId** (string) - Required - The user's email address. The special value "me" can be used to indicate the authenticated user. #### Request Body - **message** (object) - Required - The message to be imported. - **raw** (string) - The raw email message in RFC 2822 format. - **payload** (object) - The body of the message. Only one of 'raw' or 'payload' can be specified. - **headers** (array of objects) - The list of headers. - **name** (string) - Header name. - **value** (string) - Header value. - **body** (object) - The body of the message. - **data** (string) - Base64url encoded email data. - **attachmentId** (string) - The ID of an attached file that was previously uploaded. - **partId** (string) - The part ID of the MIME message. - **mimeType** (string) - MIME type of the part. - **filename** (string) - Filename of the attachment. - **parts** (array of objects) - The parts of a multipart MIME message. ### Request Example ```json { "message": { "raw": "From: sender@example.com\r\nTo: receiver@example.com\r\nSubject: Test Import\r\n\r\nThis is the body of the imported message." } } ``` ### Response #### Success Response (200) - **id** (string) - The unique ID of the message. - **threadId** (string) - The ID of the thread associated with the message. - **labelIds** (array of strings) - The list of IDs of labels associated with this message. - **snippet** (string) - The short part of the text of the latest message - **historyId** (string) - The ID of the history record for the latest message change. - **internalDate** (long) - The internal message creation time. - **payload** (object) - The body of the message. - **sizeEstimate** (integer) - The estimated size of the message in bytes. - **raw** (string) - The raw email message in RFC 2822 format. #### Response Example ```json { "id": "m9876543210fedcba", "threadId": "t9876543210fedcba", "labelIds": ["INBOX"], "snippet": "This is the body of the imported message.", "historyId": "2", "internalDate": 1678887000000, "payload": { "partId": "0", "mimeType": "text/plain", "body": { "data": "VGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgaW1wb3J0ZWQgbWVzc2FnZS4" } }, "sizeEstimate": 150, "raw": "From: sender@example.com\r\nTo: receiver@example.com\r\nSubject: Test Import\r\nDate: Wed, 15 Mar 2023 10:10:00 +0000\r\nMessage-ID: <456@example.com>\r\nContent-Type: text/plain; charset=\"US-ASCII\"\r\n\r\nThis is the body of the imported message." } ``` ``` ```APIDOC ## POST /users/{userId}/messages/send ### Description Sends the specified message to the email recipients. ### Method POST ### Endpoint `/gmail/v1/users/{userId}/messages/send` ### Parameters #### Path Parameters - **userId** (string) - Required - The user's email address. The special value "me" can be used to indicate the authenticated user. #### Request Body - **message** (object) - Required - The message to be sent. - **raw** (string) - The raw email message in RFC 2822 format. - **payload** (object) - The body of the message. Only one of 'raw' or 'payload' can be specified. - **headers** (array of objects) - The list of headers. - **name** (string) - Header name. - **value** (string) - Header value. - **body** (object) - The body of the message. - **data** (string) - Base64url encoded email data. - **attachmentId** (string) - The ID of an attached file that was previously uploaded. - **partId** (string) - The part ID of the MIME message. - **mimeType** (string) - MIME type of the part. - **filename** (string) - Filename of the attachment. - **parts** (array of objects) - The parts of a multipart MIME message. ### Request Example ```json { "message": { "raw": "From: sender@example.com\r\nTo: receiver@example.com\r\nSubject: Test Send\r\n\r\nThis is the body of the sent message." } } ``` ### Response #### Success Response (200) - **id** (string) - The unique ID of the message. - **threadId** (string) - The ID of the thread associated with the message. - **labelIds** (array of strings) - The list of IDs of labels associated with this message. - **snippet** (string) - The short part of the text of the latest message - **historyId** (string) - The ID of the history record for the latest message change. - **internalDate** (long) - The internal message creation time. - **payload** (object) - The body of the message. - **sizeEstimate** (integer) - The estimated size of the message in bytes. - **raw** (string) - The raw email message in RFC 2822 format. #### Response Example ```json { "id": "m1122334455aabbcc", "threadId": "t1122334455aabbcc", "labelIds": ["SENT"], "snippet": "This is the body of the sent message.", "historyId": "3", "internalDate": 1678887600000, "payload": { "partId": "0", "mimeType": "text/plain", "body": { "data": "VGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgc2VudCBtZXNzYWdl." } }, "sizeEstimate": 120, "raw": "From: sender@example.com\r\nTo: receiver@example.com\r\nSubject: Test Send\r\nDate: Wed, 15 Mar 2023 10:20:00 +0000\r\nMessage-ID: <789@example.com>\r\nContent-Type: text/plain; charset=\"US-ASCII\"\r\n\r\nThis is the body of the sent message." } ``` ``` -------------------------------- ### Gmail API v1 - Users Messages Get Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/index Retrieves a message by its ID for a specific user. ```APIDOC ## GET /gmail/v1/users/{userId}/messages/{id} ### Description Gets the specified message and any related messages in the same conversation. ### Method GET ### Endpoint /gmail/v1/users/{userId}/messages/{id} ### Parameters #### Path Parameters - **userId** (string) - Required - The user's email address. The special value "me" can be used to indicate the authenticated user. - **id** (string) - Required - The ID of the message to retrieve. #### Query Parameters - **format** (string) - Optional - The format to return the message in. - `"FULL"`: Returns the complete email message data, as a MIME document. - `"RAW"`: Returns the email data in the same format as it was sent or received. - `"METADATA"`: Returns only the message metadata such as labels and ID. - **metadataHeaders** (array) - Optional - When given and format is METADATA, also partially MIME-decodes the headers and returns them in the metadata. ### Request Example ```json { "userId": "me", "id": "message_id", "format": "FULL" } ``` ### Response #### Success Response (200) - **Message** (object) - The message. - **id** (string) - The unique ID of the message. - **threadId** (string) - The ID of the thread to which the message belongs. - **labelIds** (array) - The list of IDs of labels associated with this message. - **snippet** (string) - The short part of the message text. - **historyId** (string) - The ID of the last history record that contained this message. - **raw** (string) - The entire email message in all its parts. - **payload** (object) - The parts of a message contained in the payload. - **partId** (string) - The part ID. - **mimeType** (string) - The MIME type of the part. - **filename** (string) - The filename of the part. - **headers** (array) - The value of the header, or null if no such header was present. - **name** (string) - Header name. - **value** (string) - Header value. - **parts** (array) - The body of the part. Only used for multipart MIME messages. #### Response Example ```json { "id": "message_id", "threadId": "thread_id", "labelIds": ["INBOX", "UNREAD"], "snippet": "Hello there!", "historyId": "history_id", "payload": { "partId": "0", "mimeType": "text/plain", "body": { "size": 123, "data": "SGVsbG8gdGhlcmUh" } } } ``` ``` -------------------------------- ### Gmail API Operations via google-gmail1 Hub Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1/index This Rust code demonstrates the general pattern for invoking Gmail API operations using the google-gmail1 crate. It shows how to create a hub, select a resource, perform an activity, and execute the request with `.doit().await`. ```rust let r = hub.resource().activity(...).doit().await ``` -------------------------------- ### Setting up Project Dependencies for google-gmail1 Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1/index This snippet shows how to add the google-gmail1 crate and its associated dependencies (serde, serde_json) to a Rust project's Cargo.toml file. These dependencies are necessary for serializing and deserializing data when interacting with the Gmail API. ```toml [dependencies] google-gmail1 = "*" serde = "1" serde_json = "1" ``` -------------------------------- ### Import Gmail Message with Rust Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1/index This snippet shows how to authenticate with the Gmail API, build an HTTP client, and import a message using the google-gmail1 library. It includes handling for success and various error types returned by the API. It requires the `hyper`, `hyper_rustls`, `google_gmail1`, and `yup_oauth2` crates. ```rust extern crate hyper; extern crate hyper_rustls; extern crate google_gmail1 as gmail1; use gmail1::api::Message; use gmail1::{Result, Error}; use std::fs; use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; // Get an ApplicationSecret instance by some means. It contains the `client_id` and // `client_secret`, among other things. let secret: yup_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 = yup_oauth2::InstalledFlowAuthenticator::builder( secret, yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, ).build().await.unwrap(); let client = hyper_util::client::legacy::Client::builder( hyper_util::rt::TokioExecutor::new() ) .build( hyper_rustls::HttpsConnectorBuilder::new() .with_native_roots() .unwrap() .https_or_http() .enable_http1() .build() ); let mut hub = Gmail::new(client, 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 `upload_resumable(...)`. // Values shown here are possibly random and not representative ! let result = hub.users().messages_import(req, "userId") .process_for_calendar(true) .never_mark_spam(true) .internal_date_source("Lorem") .deleted(false) .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).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), } ``` -------------------------------- ### User Settings Forwarding Addresses API Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1/api/index Manages forwarding addresses for a Gmail account, including creation, deletion, retrieval, and listing. ```APIDOC ## User Settings Forwarding Addresses API Manages forwarding addresses for a Gmail account, including creation, deletion, retrieval, and listing. ### POST /users/{userId}/settings/forwardingAddresses #### Description Creates a forwarding address. If ownership verification is required, a message will be sent to the recipient and the resource’s verification status will be set to `pending`; otherwise, the resource will be created with verification status set to `accepted`. #### Method POST #### Endpoint `/users/{userId}/settings/forwardingAddresses` #### Parameters ##### Request Body - **forwardingEmail** (string) - Required - The forwarding address. ### DELETE /users/{userId}/settings/forwardingAddresses/{forwardingEmail} #### Description Deletes the specified forwarding address and revokes any verification that may have been required. #### Method DELETE #### Endpoint `/users/{userId}/settings/forwardingAddresses/{forwardingEmail}` #### Parameters ##### Path Parameters - **forwardingEmail** (string) - Required - The forwarding address to delete. ### GET /users/{userId}/settings/forwardingAddresses/{forwardingEmail} #### Description Gets the specified forwarding address. #### Method GET #### Endpoint `/users/{userId}/settings/forwardingAddresses/{forwardingEmail}` #### Parameters ##### Path Parameters - **forwardingEmail** (string) - Required - The forwarding address to retrieve. ### GET /users/{userId}/settings/forwardingAddresses #### Description Lists the forwarding addresses for the specified account. #### Method GET #### Endpoint `/users/{userId}/settings/forwardingAddresses` ``` -------------------------------- ### User Settings Delegates API Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1/api/index Manages delegate users for a Gmail account, allowing for addition, deletion, retrieval, and listing of delegates. ```APIDOC ## User Settings Delegates API Manages delegate users for a Gmail account, allowing for addition, deletion, retrieval, and listing of delegates. ### POST /users/{userId}/settings/delegates #### Description Adds a delegate with its verification status set directly to `accepted`, without sending any verification email. The delegate user must be a member of the same Google Workspace organization as the delegator user. #### Method POST #### Endpoint `/users/{userId}/settings/delegates` #### Parameters ##### Request Body - **delegateEmail** (string) - Required - The email address of the delegate. ### DELETE /users/{userId}/settings/delegates/{delegateEmail} #### Description Removes the specified delegate and revokes any verification that may have been required for using it. #### Method DELETE #### Endpoint `/users/{userId}/settings/delegates/{delegateEmail}` #### Parameters ##### Path Parameters - **delegateEmail** (string) - Required - The delegate's email address. ### GET /users/{userId}/settings/delegates/{delegateEmail} #### Description Gets the specified delegate. #### Method GET #### Endpoint `/users/{userId}/settings/delegates/{delegateEmail}` #### Parameters ##### Path Parameters - **delegateEmail** (string) - Required - The delegate's email address. ### GET /users/{userId}/settings/delegates #### Description Lists the delegates for the specified account. #### Method GET #### Endpoint `/users/{userId}/settings/delegates` ``` -------------------------------- ### User Settings Other Settings API Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1/api/index Provides endpoints for retrieving various Gmail user settings like auto-forwarding, IMAP, language, POP, and vacation responder. ```APIDOC ## User Settings Other Settings API Provides endpoints for retrieving various Gmail user settings like auto-forwarding, IMAP, language, POP, and vacation responder. ### GET /users/{userId}/settings/autoForwarding #### Description Gets the auto-forwarding setting for the specified account. #### Method GET #### Endpoint `/users/{userId}/settings/autoForwarding` ### GET /users/{userId}/settings/IMAP #### Description Gets IMAP settings. #### Method GET #### Endpoint `/users/{userId}/settings/IMAP` ### GET /users/{userId}/settings/language #### Description Gets language settings. #### Method GET #### Endpoint `/users/{userId}/settings/language` ### GET /users/{userId}/settings/POP #### Description Gets POP settings. #### Method GET #### Endpoint `/users/{userId}/settings/POP` ### GET /users/{userId}/settings/vacation #### Description Gets vacation responder settings. #### Method GET #### Endpoint `/users/{userId}/settings/vacation` ``` -------------------------------- ### User Settings Send-As Aliases API Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1/api/index Manages custom "from" send-as aliases for a Gmail account, including creation, deletion, retrieval, listing, and S/MIME configuration. ```APIDOC ## User Settings Send-As Aliases API Manages custom "from" send-as aliases for a Gmail account, including creation, deletion, retrieval, listing, and S/MIME configuration. ### POST /users/{userId}/settings/sendAs #### Description Creates a custom "from" send-as alias. If an SMTP MSA is specified, Gmail will attempt to connect to the SMTP service to validate the configuration before creating the alias. If ownership verification is required for the alias, a message will be sent to the email address and the resource’s verification status will be set to `pending`; otherwise, the resource will be created with verification status set to `accepted`. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. #### Method POST #### Endpoint `/users/{userId}/settings/sendAs` #### Parameters ##### Request Body - **sendAsEmail** (string) - Required - The email address of the send-as alias. - **displayName** (string) - Optional - The name to be used for the send-as alias. - **replyToAddresses** (array) - Optional - The reply-to email addresses for the send-as alias. - **signature** (string) - Optional - The HTML signature for the send-as alias. - **isDefault** (boolean) - Optional - Whether this is the default send-as alias. - **verificationStatus** (string) - Optional - The verification status of the send-as alias (`pending` or `accepted`). ### DELETE /users/{userId}/settings/sendAs/{sendAsId} #### Description Deletes the specified send-as alias. Revokes any verification that may have been required for using it. #### Method DELETE #### Endpoint `/users/{userId}/settings/sendAs/{sendAsId}` #### Parameters ##### Path Parameters - **sendAsId** (string) - Required - The ID of the send-as alias to delete. ### GET /users/{userId}/settings/sendAs/{sendAsId} #### Description Gets the specified send-as alias. Fails with an HTTP 404 error if the specified address is not a member of the collection. #### Method GET #### Endpoint `/users/{userId}/settings/sendAs/{sendAsId}` #### Parameters ##### Path Parameters - **sendAsId** (string) - Required - The ID of the send-as alias to retrieve. ### GET /users/{userId}/settings/sendAs #### Description Lists the send-as aliases for the specified account. The result includes the primary send-as address associated with the account as well as any custom "from" aliases. #### Method GET #### Endpoint `/users/{userId}/settings/sendAs` ### PATCH /users/{userId}/settings/sendAs/{sendAsId} #### Description Patch the specified send-as alias. #### Method PATCH #### Endpoint `/users/{userId}/settings/sendAs/{sendAsId}` #### Parameters ##### Path Parameters - **sendAsId** (string) - Required - The ID of the send-as alias to patch. ##### Request Body - **displayName** (string) - Optional - The new display name for the send-as alias. - **replyToAddresses** (array) - Optional - The new reply-to email addresses for the send-as alias. - **signature** (string) - Optional - The new HTML signature for the send-as alias. - **isDefault** (boolean) - Optional - Whether this is the default send-as alias. ### DELETE /users/{userId}/settings/sendAs/{sendAsId}/smimeInfo/{nickname} #### Description Deletes the specified S/MIME config for the specified send-as alias. #### Method DELETE #### Endpoint `/users/{userId}/settings/sendAs/{sendAsId}/smimeInfo/{nickname}` #### Parameters ##### Path Parameters - **sendAsId** (string) - Required - The ID of the send-as alias. - **nickname** (string) - Required - The nickname of the S/MIME config to delete. ### GET /users/{userId}/settings/sendAs/{sendAsId}/smimeInfo/{nickname} #### Description Gets the specified S/MIME config for the specified send-as alias. #### Method GET #### Endpoint `/users/{userId}/settings/sendAs/{sendAsId}/smimeInfo/{nickname}` #### Parameters ##### Path Parameters - **sendAsId** (string) - Required - The ID of the send-as alias. - **nickname** (string) - Required - The nickname of the S/MIME config to retrieve. ### POST /users/{userId}/settings/sendAs/{sendAsId}/smimeInfo #### Description Insert (upload) the given S/MIME config for the specified send-as alias. Note that pkcs12 format is required for the key. #### Method POST #### Endpoint `/users/{userId}/settings/sendAs/{sendAsId}/smimeInfo` #### Parameters ##### Path Parameters - **sendAsId** (string) - Required - The ID of the send-as alias. ##### Request Body - **smimeConfig** (object) - Required - The S/MIME configuration object. ### GET /users/{userId}/settings/sendAs/{sendAsId}/smimeInfo #### Description Lists S/MIME configs for the specified send-as alias. #### Method GET #### Endpoint `/users/{userId}/settings/sendAs/{sendAsId}/smimeInfo` #### Parameters ##### Path Parameters - **sendAsId** (string) - Required - The ID of the send-as alias. ### PUT /users/{userId}/settings/sendAs/{sendAsId}/smimeInfo/{nickname}/setDefault #### Description Sets the default S/MIME config for the specified send-as alias. #### Method PUT #### Endpoint `/users/{userId}/settings/sendAs/{sendAsId}/smimeInfo/{nickname}/setDefault` #### Parameters ##### Path Parameters - **sendAsId** (string) - Required - The ID of the send-as alias. - **nickname** (string) - Required - The nickname of the S/MIME config to set as default. ``` -------------------------------- ### Delegate Trait API Documentation Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1/trait Documentation for the `Delegate` trait, which provides methods to control and customize API requests made by the google-gmail1 library. It covers aspects like request lifecycle events, error handling, authentication, and media uploads. ```APIDOC ## Delegate Trait ### Description A trait specifying functionality to help controlling any request performed by the API. The trait has a conservative default implementation. It contains methods to deal with all common issues, as well as the ones related to uploading media. ### Methods #### `fn begin(&mut self, _info: MethodInfo)` Called at the beginning of any API request. The delegate should store the method information if it is interested in knowing more context when further calls to it are made. The matching `finished()` call will always be made, no matter whether or not the API request was successful. That way, the delegate may easily maintain a clean state between various API calls. #### `fn http_error(&mut self, _err: &Error) -> Retry` Called whenever there is an HttpError, usually if there are network problems. If you choose to retry after a duration, the duration should be chosen using the exponential backoff algorithm. Returns retry information. #### `fn api_key(&mut self) -> Option<String>` Called whenever there is the need for your application's API key after the official authenticator implementation didn’t provide one, for some reason. If this method returns `None` as well, the underlying operation will fail. #### `fn token(&mut self, e: Box<dyn Error + Sync + Send>) -> Result<Option<String>, Box<dyn Error + Sync + Send>>` Called whenever the Authenticator didn’t yield a token. The delegate may attempt to provide one, or just take it as a general information about the impending failure. The given `Error` provides information about why the token couldn’t be acquired in the first place. #### `fn upload_url(&mut self) -> Option<String>` Called during resumable uploads to provide a URL for the impending upload. It was saved after a previous call to `store_upload_url(...)`, and if not `None`, will be used instead of asking the server for a new upload URL. This is useful in case a previous resumable upload was aborted/canceled, but should now be resumed. The returned URL will be used exactly once - if it fails again and the delegate allows to retry, we will ask the server for a new upload URL. #### `fn store_upload_url(&mut self, url: Option<&str>)` Called after we have retrieved a new upload URL for a resumable upload to store it in case we fail or cancel. That way, we can attempt to resume the upload later, see `upload_url()`. It will also be called with `None` after a successful upload, which allows the delegate to forget the URL. That way, we will not attempt to resume an upload that has already finished. #### `fn response_json_decode_error(&mut self, json_encoded_value: &str, json_decode_error: &Error)` Called whenever a server response could not be decoded from JSON. It’s for informational purposes only; the caller will return with an error accordingly. * **Arguments** * `json_encoded_value` (string) - The JSON-encoded value which failed to decode. * `json_decode_error` (Error) - The decoder error. #### `fn http_failure(&mut self, _: &Response<BoxBody<Bytes, Error>>, _err: Option<&Value>) -> Retry` Called whenever the HTTP request returns with a non-success status code. This can involve authentication issues, or anything else that very much depends on the used API method. The delegate should check the status, header, and decoded JSON error to decide whether to retry or not. In the latter case, the underlying call will fail. If you choose to retry after a duration, the duration should be chosen using the exponential backoff algorithm. #### `fn pre_request(&mut self)` Called prior to sending the main request of the given method. It can be used to time the call or to print progress information. It’s also useful as you can be sure that a request will definitely be made. #### `fn chunk_size(&mut self) -> u64` Returns the chunk size to use for media uploads. #### `fn cancel_chunk_upload(&mut self, chunk: &ContentRange) -> bool` Called to determine if a chunk upload should be canceled. Returns `true` if the upload should be canceled, `false` otherwise. #### `fn finished(&mut self, is_success: bool)` Called when an API request has finished, regardless of success or failure. `is_success` indicates whether the request was successful. ``` -------------------------------- ### Rust Fallible Conversions (`TryFrom`, `try_from`, `TryInto`, `try_into`) Source: https://docs.rs/google-gmail1/6.0.0+20240624/google_gmail1/google-gmail1/6.0.0%2B20240624/google_gmail1/struct These snippets demonstrate fallible conversion between types using the `TryFrom` and `TryInto` traits. `TryFrom` allows conversion from one type to another with a potential error, while `TryInto` is the reciprocal. They are essential for safe data transformations where errors might occur. ```rust /// Performs the conversion. type Error = Infallible; fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> /// Performs the conversion. type Error = <U as TryFrom<T>>::Error; fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> ```