mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-09 21:13:23 +01:00
7887 lines
334 KiB
Rust
7887 lines
334 KiB
Rust
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 ###
|
||
// ############
|
||
|
||
/// Identifies the an OAuth2 authorization scope.
|
||
/// A scope is needed when requesting an
|
||
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
|
||
#[derive(PartialEq, Eq, Hash)]
|
||
pub enum Scope {
|
||
/// View your location
|
||
GlasLocation,
|
||
|
||
/// View and manage your Glass timeline
|
||
GlasTimeline,
|
||
}
|
||
|
||
impl AsRef<str> for Scope {
|
||
fn as_ref(&self) -> &str {
|
||
match *self {
|
||
Scope::GlasLocation => "https://www.googleapis.com/auth/glass.location",
|
||
Scope::GlasTimeline => "https://www.googleapis.com/auth/glass.timeline",
|
||
}
|
||
}
|
||
}
|
||
|
||
impl Default for Scope {
|
||
fn default() -> Scope {
|
||
Scope::GlasLocation
|
||
}
|
||
}
|
||
|
||
|
||
|
||
// ########
|
||
// HUB ###
|
||
// ######
|
||
|
||
/// Central instance to access all Mirror related resource activities
|
||
///
|
||
/// # Examples
|
||
///
|
||
/// Instantiate a new hub
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate google_mirror1 as mirror1;
|
||
/// use mirror1::api::Contact;
|
||
/// use mirror1::{Result, Error};
|
||
/// # async fn dox() {
|
||
/// use std::default::Default;
|
||
/// use mirror1::{Mirror, 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 = Mirror::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 = Contact::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.contacts().patch(req, "id")
|
||
/// .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 Mirror<> {
|
||
pub client: hyper::Client<hyper_rustls::HttpsConnector<hyper::client::connect::HttpConnector>, hyper::body::Body>,
|
||
pub auth: oauth2::authenticator::Authenticator<hyper_rustls::HttpsConnector<hyper::client::connect::HttpConnector>>,
|
||
_user_agent: String,
|
||
_base_url: String,
|
||
_root_url: String,
|
||
}
|
||
|
||
impl<'a, > client::Hub for Mirror<> {}
|
||
|
||
impl<'a, > Mirror<> {
|
||
|
||
pub fn new(client: hyper::Client<hyper_rustls::HttpsConnector<hyper::client::connect::HttpConnector>, hyper::body::Body>, authenticator: oauth2::authenticator::Authenticator<hyper_rustls::HttpsConnector<hyper::client::connect::HttpConnector>>) -> Mirror<> {
|
||
Mirror {
|
||
client,
|
||
auth: authenticator,
|
||
_user_agent: "google-api-rust-client/3.0.0".to_string(),
|
||
_base_url: "https://www.googleapis.com/mirror/v1/".to_string(),
|
||
_root_url: "https://www.googleapis.com/".to_string(),
|
||
}
|
||
}
|
||
|
||
pub fn accounts(&'a self) -> AccountMethods<'a> {
|
||
AccountMethods { hub: &self }
|
||
}
|
||
pub fn contacts(&'a self) -> ContactMethods<'a> {
|
||
ContactMethods { hub: &self }
|
||
}
|
||
pub fn locations(&'a self) -> LocationMethods<'a> {
|
||
LocationMethods { hub: &self }
|
||
}
|
||
pub fn settings(&'a self) -> SettingMethods<'a> {
|
||
SettingMethods { hub: &self }
|
||
}
|
||
pub fn subscriptions(&'a self) -> SubscriptionMethods<'a> {
|
||
SubscriptionMethods { hub: &self }
|
||
}
|
||
pub fn timeline(&'a self) -> TimelineMethods<'a> {
|
||
TimelineMethods { 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://www.googleapis.com/mirror/v1/`.
|
||
///
|
||
/// 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://www.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 ###
|
||
// ##########
|
||
/// Represents an account passed into the Account Manager on Glass.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [insert accounts](AccountInsertCall) (request|response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Account {
|
||
/// no description provided
|
||
#[serde(rename="authTokens")]
|
||
pub auth_tokens: Option<Vec<AuthToken>>,
|
||
/// no description provided
|
||
pub features: Option<Vec<String>>,
|
||
/// no description provided
|
||
pub password: Option<String>,
|
||
/// no description provided
|
||
#[serde(rename="userData")]
|
||
pub user_data: Option<Vec<UserData>>,
|
||
}
|
||
|
||
impl client::RequestValue for Account {}
|
||
impl client::Resource for Account {}
|
||
impl client::ResponseResult for Account {}
|
||
|
||
|
||
/// Represents media content, such as a photo, that can be attached to a timeline item.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [attachments get timeline](TimelineAttachmentGetCall) (response)
|
||
/// * [attachments insert timeline](TimelineAttachmentInsertCall) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Attachment {
|
||
/// The MIME type of the attachment.
|
||
#[serde(rename="contentType")]
|
||
pub content_type: Option<String>,
|
||
/// The URL for the content.
|
||
#[serde(rename="contentUrl")]
|
||
pub content_url: Option<String>,
|
||
/// The ID of the attachment.
|
||
pub id: Option<String>,
|
||
/// Indicates that the contentUrl is not available because the attachment content is still being processed. If the caller wishes to retrieve the content, it should try again later.
|
||
#[serde(rename="isProcessingContent")]
|
||
pub is_processing_content: Option<bool>,
|
||
}
|
||
|
||
impl client::ResponseResult for Attachment {}
|
||
|
||
|
||
/// A list of Attachments. This is the response from the server to GET requests on the attachments collection.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [attachments list timeline](TimelineAttachmentListCall) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct AttachmentsListResponse {
|
||
/// The list of attachments.
|
||
pub items: Option<Vec<Attachment>>,
|
||
/// The type of resource. This is always mirror#attachmentsList.
|
||
pub kind: Option<String>,
|
||
}
|
||
|
||
impl client::ResponseResult for AttachmentsListResponse {}
|
||
|
||
|
||
/// 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 AuthToken {
|
||
/// no description provided
|
||
#[serde(rename="authToken")]
|
||
pub auth_token: Option<String>,
|
||
/// no description provided
|
||
#[serde(rename="type")]
|
||
pub type_: Option<String>,
|
||
}
|
||
|
||
impl client::Part for AuthToken {}
|
||
|
||
|
||
/// A single menu command that is part of a Contact.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Command {
|
||
/// The type of operation this command corresponds to. Allowed values are:
|
||
/// - TAKE_A_NOTE - Shares a timeline item with the transcription of user speech from the "Take a note" voice menu command.
|
||
/// - POST_AN_UPDATE - Shares a timeline item with the transcription of user speech from the "Post an update" voice menu command.
|
||
#[serde(rename="type")]
|
||
pub type_: Option<String>,
|
||
}
|
||
|
||
impl client::Part for Command {}
|
||
|
||
|
||
/// A person or group that can be used as a creator or a contact.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [delete contacts](ContactDeleteCall) (none)
|
||
/// * [get contacts](ContactGetCall) (response)
|
||
/// * [insert contacts](ContactInsertCall) (request|response)
|
||
/// * [list contacts](ContactListCall) (none)
|
||
/// * [patch contacts](ContactPatchCall) (request|response)
|
||
/// * [update contacts](ContactUpdateCall) (request|response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Contact {
|
||
/// A list of voice menu commands that a contact can handle. Glass shows up to three contacts for each voice menu command. If there are more than that, the three contacts with the highest priority are shown for that particular command.
|
||
#[serde(rename="acceptCommands")]
|
||
pub accept_commands: Option<Vec<Command>>,
|
||
/// A list of MIME types that a contact supports. The contact will be shown to the user if any of its acceptTypes matches any of the types of the attachments on the item. If no acceptTypes are given, the contact will be shown for all items.
|
||
#[serde(rename="acceptTypes")]
|
||
pub accept_types: Option<Vec<String>>,
|
||
/// The name to display for this contact.
|
||
#[serde(rename="displayName")]
|
||
pub display_name: Option<String>,
|
||
/// An ID for this contact. This is generated by the application and is treated as an opaque token.
|
||
pub id: Option<String>,
|
||
/// Set of image URLs to display for a contact. Most contacts will have a single image, but a "group" contact may include up to 8 image URLs and they will be resized and cropped into a mosaic on the client.
|
||
#[serde(rename="imageUrls")]
|
||
pub image_urls: Option<Vec<String>>,
|
||
/// The type of resource. This is always mirror#contact.
|
||
pub kind: Option<String>,
|
||
/// Primary phone number for the contact. This can be a fully-qualified number, with country calling code and area code, or a local number.
|
||
#[serde(rename="phoneNumber")]
|
||
pub phone_number: Option<String>,
|
||
/// Priority for the contact to determine ordering in a list of contacts. Contacts with higher priorities will be shown before ones with lower priorities.
|
||
pub priority: Option<u32>,
|
||
/// A list of sharing features that a contact can handle. Allowed values are:
|
||
/// - ADD_CAPTION
|
||
#[serde(rename="sharingFeatures")]
|
||
pub sharing_features: Option<Vec<String>>,
|
||
/// The ID of the application that created this contact. This is populated by the API
|
||
pub source: Option<String>,
|
||
/// Name of this contact as it should be pronounced. If this contact's name must be spoken as part of a voice disambiguation menu, this name is used as the expected pronunciation. This is useful for contact names with unpronounceable characters or whose display spelling is otherwise not phonetic.
|
||
#[serde(rename="speakableName")]
|
||
pub speakable_name: Option<String>,
|
||
/// The type for this contact. This is used for sorting in UIs. Allowed values are:
|
||
/// - INDIVIDUAL - Represents a single person. This is the default.
|
||
/// - GROUP - Represents more than a single person.
|
||
#[serde(rename="type")]
|
||
pub type_: Option<String>,
|
||
}
|
||
|
||
impl client::RequestValue for Contact {}
|
||
impl client::Resource for Contact {}
|
||
impl client::ResponseResult for Contact {}
|
||
|
||
|
||
/// A list of Contacts representing contacts. This is the response from the server to GET requests on the contacts collection.
|
||
///
|
||
/// # 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 contacts](ContactListCall) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ContactsListResponse {
|
||
/// Contact list.
|
||
pub items: Option<Vec<Contact>>,
|
||
/// The type of resource. This is always mirror#contacts.
|
||
pub kind: Option<String>,
|
||
}
|
||
|
||
impl client::ResponseResult for ContactsListResponse {}
|
||
|
||
|
||
/// A geographic location that can be associated with a timeline item.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [get locations](LocationGetCall) (response)
|
||
/// * [list locations](LocationListCall) (none)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Location {
|
||
/// The accuracy of the location fix in meters.
|
||
pub accuracy: Option<f64>,
|
||
/// The full address of the location.
|
||
pub address: Option<String>,
|
||
/// The name to be displayed. This may be a business name or a user-defined place, such as "Home".
|
||
#[serde(rename="displayName")]
|
||
pub display_name: Option<String>,
|
||
/// The ID of the location.
|
||
pub id: Option<String>,
|
||
/// The type of resource. This is always mirror#location.
|
||
pub kind: Option<String>,
|
||
/// The latitude, in degrees.
|
||
pub latitude: Option<f64>,
|
||
/// The longitude, in degrees.
|
||
pub longitude: Option<f64>,
|
||
/// The time at which this location was captured, formatted according to RFC 3339.
|
||
pub timestamp: Option<String>,
|
||
}
|
||
|
||
impl client::Resource for Location {}
|
||
impl client::ResponseResult for Location {}
|
||
|
||
|
||
/// A list of Locations. This is the response from the server to GET requests on the locations collection.
|
||
///
|
||
/// # 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 locations](LocationListCall) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct LocationsListResponse {
|
||
/// The list of locations.
|
||
pub items: Option<Vec<Location>>,
|
||
/// The type of resource. This is always mirror#locationsList.
|
||
pub kind: Option<String>,
|
||
}
|
||
|
||
impl client::ResponseResult for LocationsListResponse {}
|
||
|
||
|
||
/// A custom menu item that can be presented to the user by a timeline 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 MenuItem {
|
||
/// Controls the behavior when the user picks the menu option. Allowed values are:
|
||
/// - CUSTOM - Custom action set by the service. When the user selects this menuItem, the API triggers a notification to your callbackUrl with the userActions.type set to CUSTOM and the userActions.payload set to the ID of this menu item. This is the default value.
|
||
/// - Built-in actions:
|
||
/// - REPLY - Initiate a reply to the timeline item using the voice recording UI. The creator attribute must be set in the timeline item for this menu to be available.
|
||
/// - REPLY_ALL - Same behavior as REPLY. The original timeline item's recipients will be added to the reply item.
|
||
/// - DELETE - Delete the timeline item.
|
||
/// - SHARE - Share the timeline item with the available contacts.
|
||
/// - READ_ALOUD - Read the timeline item's speakableText aloud; if this field is not set, read the text field; if none of those fields are set, this menu item is ignored.
|
||
/// - GET_MEDIA_INPUT - Allow users to provide media payloads to Glassware from a menu item (currently, only transcribed text from voice input is supported). Subscribe to notifications when users invoke this menu item to receive the timeline item ID. Retrieve the media from the timeline item in the payload property.
|
||
/// - VOICE_CALL - Initiate a phone call using the timeline item's creator.phoneNumber attribute as recipient.
|
||
/// - NAVIGATE - Navigate to the timeline item's location.
|
||
/// - TOGGLE_PINNED - Toggle the isPinned state of the timeline item.
|
||
/// - OPEN_URI - Open the payload of the menu item in the browser.
|
||
/// - PLAY_VIDEO - Open the payload of the menu item in the Glass video player.
|
||
/// - SEND_MESSAGE - Initiate sending a message to the timeline item's creator:
|
||
/// - If the creator.phoneNumber is set and Glass is connected to an Android phone, the message is an SMS.
|
||
/// - Otherwise, if the creator.email is set, the message is an email.
|
||
pub action: Option<String>,
|
||
/// The ContextualMenus.Command associated with this MenuItem (e.g. READ_ALOUD). The voice label for this command will be displayed in the voice menu and the touch label will be displayed in the touch menu. Note that the default menu value's display name will be overriden if you specify this property. Values that do not correspond to a ContextualMenus.Command name will be ignored.
|
||
pub contextual_command: Option<String>,
|
||
/// The ID for this menu item. This is generated by the application and is treated as an opaque token.
|
||
pub id: Option<String>,
|
||
/// A generic payload whose meaning changes depending on this MenuItem's action.
|
||
/// - When the action is OPEN_URI, the payload is the URL of the website to view.
|
||
/// - When the action is PLAY_VIDEO, the payload is the streaming URL of the video
|
||
/// - When the action is GET_MEDIA_INPUT, the payload is the text transcription of a user's speech input
|
||
pub payload: Option<String>,
|
||
/// If set to true on a CUSTOM menu item, that item will be removed from the menu after it is selected.
|
||
#[serde(rename="removeWhenSelected")]
|
||
pub remove_when_selected: Option<bool>,
|
||
/// For CUSTOM items, a list of values controlling the appearance of the menu item in each of its states. A value for the DEFAULT state must be provided. If the PENDING or CONFIRMED states are missing, they will not be shown.
|
||
pub values: Option<Vec<MenuValue>>,
|
||
}
|
||
|
||
impl client::Part for MenuItem {}
|
||
|
||
|
||
/// A single value that is part of a MenuItem.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct MenuValue {
|
||
/// The name to display for the menu item. If you specify this property for a built-in menu item, the default contextual voice command for that menu item is not shown.
|
||
#[serde(rename="displayName")]
|
||
pub display_name: Option<String>,
|
||
/// URL of an icon to display with the menu item.
|
||
#[serde(rename="iconUrl")]
|
||
pub icon_url: Option<String>,
|
||
/// The state that this value applies to. Allowed values are:
|
||
/// - DEFAULT - Default value shown when displayed in the menuItems list.
|
||
/// - PENDING - Value shown when the menuItem has been selected by the user but can still be cancelled.
|
||
/// - CONFIRMED - Value shown when the menuItem has been selected by the user and can no longer be cancelled.
|
||
pub state: Option<String>,
|
||
}
|
||
|
||
impl client::Part for MenuValue {}
|
||
|
||
|
||
/// A notification delivered by the API.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Notification {
|
||
/// The collection that generated the notification.
|
||
pub collection: Option<String>,
|
||
/// The ID of the item that generated the notification.
|
||
#[serde(rename="itemId")]
|
||
pub item_id: Option<String>,
|
||
/// The type of operation that generated the notification.
|
||
pub operation: Option<String>,
|
||
/// A list of actions taken by the user that triggered the notification.
|
||
#[serde(rename="userActions")]
|
||
pub user_actions: Option<Vec<UserAction>>,
|
||
/// The user token provided by the service when it subscribed for notifications.
|
||
#[serde(rename="userToken")]
|
||
pub user_token: Option<String>,
|
||
/// The secret verify token provided by the service when it subscribed for notifications.
|
||
#[serde(rename="verifyToken")]
|
||
pub verify_token: Option<String>,
|
||
}
|
||
|
||
impl client::Part for Notification {}
|
||
|
||
|
||
/// Controls how notifications for a timeline item are presented to the user.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct NotificationConfig {
|
||
/// The time at which the notification should be delivered.
|
||
#[serde(rename="deliveryTime")]
|
||
pub delivery_time: Option<String>,
|
||
/// Describes how important the notification is. Allowed values are:
|
||
/// - DEFAULT - Notifications of default importance. A chime will be played to alert users.
|
||
pub level: Option<String>,
|
||
}
|
||
|
||
impl client::Part for NotificationConfig {}
|
||
|
||
|
||
/// A setting for Glass.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [get settings](SettingGetCall) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Setting {
|
||
/// The setting's ID. The following IDs are valid:
|
||
/// - locale - The key to the user’s language/locale (BCP 47 identifier) that Glassware should use to render localized content.
|
||
/// - timezone - The key to the user’s current time zone region as defined in the tz database. Example: America/Los_Angeles.
|
||
pub id: Option<String>,
|
||
/// The type of resource. This is always mirror#setting.
|
||
pub kind: Option<String>,
|
||
/// The setting value, as a string.
|
||
pub value: Option<String>,
|
||
}
|
||
|
||
impl client::Resource for Setting {}
|
||
impl client::ResponseResult for Setting {}
|
||
|
||
|
||
/// A subscription to events on a collection.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [delete subscriptions](SubscriptionDeleteCall) (none)
|
||
/// * [insert subscriptions](SubscriptionInsertCall) (request|response)
|
||
/// * [list subscriptions](SubscriptionListCall) (none)
|
||
/// * [update subscriptions](SubscriptionUpdateCall) (request|response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Subscription {
|
||
/// The URL where notifications should be delivered (must start with https://).
|
||
#[serde(rename="callbackUrl")]
|
||
pub callback_url: Option<String>,
|
||
/// The collection to subscribe to. Allowed values are:
|
||
/// - timeline - Changes in the timeline including insertion, deletion, and updates.
|
||
/// - locations - Location updates.
|
||
/// - settings - Settings updates.
|
||
pub collection: Option<String>,
|
||
/// The ID of the subscription.
|
||
pub id: Option<String>,
|
||
/// The type of resource. This is always mirror#subscription.
|
||
pub kind: Option<String>,
|
||
/// Container object for notifications. This is not populated in the Subscription resource.
|
||
pub notification: Option<Notification>,
|
||
/// A list of operations that should be subscribed to. An empty list indicates that all operations on the collection should be subscribed to. Allowed values are:
|
||
/// - UPDATE - The item has been updated.
|
||
/// - INSERT - A new item has been inserted.
|
||
/// - DELETE - The item has been deleted.
|
||
/// - MENU_ACTION - A custom menu item has been triggered by the user.
|
||
pub operation: Option<Vec<String>>,
|
||
/// The time at which this subscription was last modified, formatted according to RFC 3339.
|
||
pub updated: Option<String>,
|
||
/// An opaque token sent to the subscriber in notifications so that it can determine the ID of the user.
|
||
#[serde(rename="userToken")]
|
||
pub user_token: Option<String>,
|
||
/// A secret token sent to the subscriber in notifications so that it can verify that the notification was generated by Google.
|
||
#[serde(rename="verifyToken")]
|
||
pub verify_token: Option<String>,
|
||
}
|
||
|
||
impl client::RequestValue for Subscription {}
|
||
impl client::Resource for Subscription {}
|
||
impl client::ResponseResult for Subscription {}
|
||
|
||
|
||
/// A list of Subscriptions. This is the response from the server to GET requests on the subscription collection.
|
||
///
|
||
/// # 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 subscriptions](SubscriptionListCall) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct SubscriptionsListResponse {
|
||
/// The list of subscriptions.
|
||
pub items: Option<Vec<Subscription>>,
|
||
/// The type of resource. This is always mirror#subscriptionsList.
|
||
pub kind: Option<String>,
|
||
}
|
||
|
||
impl client::ResponseResult for SubscriptionsListResponse {}
|
||
|
||
|
||
/// Each item in the user's timeline is represented as a TimelineItem JSON structure, described below.
|
||
///
|
||
/// # 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*).
|
||
///
|
||
/// * [get timeline](TimelineGetCall) (response)
|
||
/// * [insert timeline](TimelineInsertCall) (request|response)
|
||
/// * [patch timeline](TimelinePatchCall) (request|response)
|
||
/// * [update timeline](TimelineUpdateCall) (request|response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct TimelineItem {
|
||
/// A list of media attachments associated with this item. As a convenience, you can refer to attachments in your HTML payloads with the attachment or cid scheme. For example:
|
||
/// - attachment: <img src="attachment:attachment_index"> where attachment_index is the 0-based index of this array.
|
||
/// - cid: <img src="cid:attachment_id"> where attachment_id is the ID of the attachment.
|
||
pub attachments: Option<Vec<Attachment>>,
|
||
/// The bundle ID for this item. Services can specify a bundleId to group many items together. They appear under a single top-level item on the device.
|
||
#[serde(rename="bundleId")]
|
||
pub bundle_id: Option<String>,
|
||
/// A canonical URL pointing to the canonical/high quality version of the data represented by the timeline item.
|
||
#[serde(rename="canonicalUrl")]
|
||
pub canonical_url: Option<String>,
|
||
/// The time at which this item was created, formatted according to RFC 3339.
|
||
pub created: Option<String>,
|
||
/// The user or group that created this item.
|
||
pub creator: Option<Contact>,
|
||
/// The time that should be displayed when this item is viewed in the timeline, formatted according to RFC 3339. This user's timeline is sorted chronologically on display time, so this will also determine where the item is displayed in the timeline. If not set by the service, the display time defaults to the updated time.
|
||
#[serde(rename="displayTime")]
|
||
pub display_time: Option<String>,
|
||
/// ETag for this item.
|
||
pub etag: Option<String>,
|
||
/// HTML content for this item. If both text and html are provided for an item, the html will be rendered in the timeline.
|
||
/// Allowed HTML elements - You can use these elements in your timeline cards.
|
||
///
|
||
/// - Headers: h1, h2, h3, h4, h5, h6
|
||
/// - Images: img
|
||
/// - Lists: li, ol, ul
|
||
/// - HTML5 semantics: article, aside, details, figure, figcaption, footer, header, nav, section, summary, time
|
||
/// - Structural: blockquote, br, div, hr, p, span
|
||
/// - Style: b, big, center, em, i, u, s, small, strike, strong, style, sub, sup
|
||
/// - Tables: table, tbody, td, tfoot, th, thead, tr
|
||
/// Blocked HTML elements: These elements and their contents are removed from HTML payloads.
|
||
///
|
||
/// - Document headers: head, title
|
||
/// - Embeds: audio, embed, object, source, video
|
||
/// - Frames: frame, frameset
|
||
/// - Scripting: applet, script
|
||
/// Other elements: Any elements that aren't listed are removed, but their contents are preserved.
|
||
pub html: Option<String>,
|
||
/// The ID of the timeline item. This is unique within a user's timeline.
|
||
pub id: Option<String>,
|
||
/// If this item was generated as a reply to another item, this field will be set to the ID of the item being replied to. This can be used to attach a reply to the appropriate conversation or post.
|
||
#[serde(rename="inReplyTo")]
|
||
pub in_reply_to: Option<String>,
|
||
/// Whether this item is a bundle cover.
|
||
///
|
||
/// If an item is marked as a bundle cover, it will be the entry point to the bundle of items that have the same bundleId as that item. It will be shown only on the main timeline — not within the opened bundle.
|
||
///
|
||
/// On the main timeline, items that are shown are:
|
||
/// - Items that have isBundleCover set to true
|
||
/// - Items that do not have a bundleId In a bundle sub-timeline, items that are shown are:
|
||
/// - Items that have the bundleId in question AND isBundleCover set to false
|
||
#[serde(rename="isBundleCover")]
|
||
pub is_bundle_cover: Option<bool>,
|
||
/// When true, indicates this item is deleted, and only the ID property is set.
|
||
#[serde(rename="isDeleted")]
|
||
pub is_deleted: Option<bool>,
|
||
/// When true, indicates this item is pinned, which means it's grouped alongside "active" items like navigation and hangouts, on the opposite side of the home screen from historical (non-pinned) timeline items. You can allow the user to toggle the value of this property with the TOGGLE_PINNED built-in menu item.
|
||
#[serde(rename="isPinned")]
|
||
pub is_pinned: Option<bool>,
|
||
/// The type of resource. This is always mirror#timelineItem.
|
||
pub kind: Option<String>,
|
||
/// The geographic location associated with this item.
|
||
pub location: Option<Location>,
|
||
/// A list of menu items that will be presented to the user when this item is selected in the timeline.
|
||
#[serde(rename="menuItems")]
|
||
pub menu_items: Option<Vec<MenuItem>>,
|
||
/// Controls how notifications for this item are presented on the device. If this is missing, no notification will be generated.
|
||
pub notification: Option<NotificationConfig>,
|
||
/// For pinned items, this determines the order in which the item is displayed in the timeline, with a higher score appearing closer to the clock. Note: setting this field is currently not supported.
|
||
#[serde(rename="pinScore")]
|
||
pub pin_score: Option<i32>,
|
||
/// A list of users or groups that this item has been shared with.
|
||
pub recipients: Option<Vec<Contact>>,
|
||
/// A URL that can be used to retrieve this item.
|
||
#[serde(rename="selfLink")]
|
||
pub self_link: Option<String>,
|
||
/// Opaque string you can use to map a timeline item to data in your own service.
|
||
#[serde(rename="sourceItemId")]
|
||
pub source_item_id: Option<String>,
|
||
/// The speakable version of the content of this item. Along with the READ_ALOUD menu item, use this field to provide text that would be clearer when read aloud, or to provide extended information to what is displayed visually on Glass.
|
||
///
|
||
/// Glassware should also specify the speakableType field, which will be spoken before this text in cases where the additional context is useful, for example when the user requests that the item be read aloud following a notification.
|
||
#[serde(rename="speakableText")]
|
||
pub speakable_text: Option<String>,
|
||
/// A speakable description of the type of this item. This will be announced to the user prior to reading the content of the item in cases where the additional context is useful, for example when the user requests that the item be read aloud following a notification.
|
||
///
|
||
/// This should be a short, simple noun phrase such as "Email", "Text message", or "Daily Planet News Update".
|
||
///
|
||
/// Glassware are encouraged to populate this field for every timeline item, even if the item does not contain speakableText or text so that the user can learn the type of the item without looking at the screen.
|
||
#[serde(rename="speakableType")]
|
||
pub speakable_type: Option<String>,
|
||
/// Text content of this item.
|
||
pub text: Option<String>,
|
||
/// The title of this item.
|
||
pub title: Option<String>,
|
||
/// The time at which this item was last modified, formatted according to RFC 3339.
|
||
pub updated: Option<String>,
|
||
}
|
||
|
||
impl client::RequestValue for TimelineItem {}
|
||
impl client::ResponseResult for TimelineItem {}
|
||
|
||
|
||
/// A list of timeline items. This is the response from the server to GET requests on the timeline collection.
|
||
///
|
||
/// # 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 timeline](TimelineListCall) (response)
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct TimelineListResponse {
|
||
/// Items in the timeline.
|
||
pub items: Option<Vec<TimelineItem>>,
|
||
/// The type of resource. This is always mirror#timeline.
|
||
pub kind: Option<String>,
|
||
/// The next page token. Provide this as the pageToken parameter in the request to retrieve the next page of results.
|
||
#[serde(rename="nextPageToken")]
|
||
pub next_page_token: Option<String>,
|
||
}
|
||
|
||
impl client::ResponseResult for TimelineListResponse {}
|
||
|
||
|
||
/// Represents an action taken by the user that triggered a notification.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct UserAction {
|
||
/// An optional payload for the action.
|
||
///
|
||
/// For actions of type CUSTOM, this is the ID of the custom menu item that was selected.
|
||
pub payload: Option<String>,
|
||
/// The type of action. The value of this can be:
|
||
/// - SHARE - the user shared an item.
|
||
/// - REPLY - the user replied to an item.
|
||
/// - REPLY_ALL - the user replied to all recipients of an item.
|
||
/// - CUSTOM - the user selected a custom menu item on the timeline item.
|
||
/// - DELETE - the user deleted the item.
|
||
/// - PIN - the user pinned the item.
|
||
/// - UNPIN - the user unpinned the item.
|
||
/// - LAUNCH - the user initiated a voice command. In the future, additional types may be added. UserActions with unrecognized types should be ignored.
|
||
#[serde(rename="type")]
|
||
pub type_: Option<String>,
|
||
}
|
||
|
||
impl client::Part for UserAction {}
|
||
|
||
|
||
/// 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 UserData {
|
||
/// no description provided
|
||
pub key: Option<String>,
|
||
/// no description provided
|
||
pub value: Option<String>,
|
||
}
|
||
|
||
impl client::Part for UserData {}
|
||
|
||
|
||
|
||
// ###################
|
||
// MethodBuilders ###
|
||
// #################
|
||
|
||
/// A builder providing access to all methods supported on *account* resources.
|
||
/// It is not used directly, but through the `Mirror` hub.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate google_mirror1 as mirror1;
|
||
///
|
||
/// # async fn dox() {
|
||
/// use std::default::Default;
|
||
/// use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// secret,
|
||
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// ).build().await.unwrap();
|
||
/// let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||
/// // like `insert(...)`
|
||
/// // to build up your call.
|
||
/// let rb = hub.accounts();
|
||
/// # }
|
||
/// ```
|
||
pub struct AccountMethods<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
}
|
||
|
||
impl<'a> client::MethodsBuilder for AccountMethods<'a> {}
|
||
|
||
impl<'a> AccountMethods<'a> {
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Inserts a new account for a user
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `userToken` - The ID for the user.
|
||
/// * `accountType` - Account type to be passed to Android Account Manager.
|
||
/// * `accountName` - The name of the account to be passed to the Android Account Manager.
|
||
pub fn insert(&self, request: Account, user_token: &str, account_type: &str, account_name: &str) -> AccountInsertCall<'a> {
|
||
AccountInsertCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_user_token: user_token.to_string(),
|
||
_account_type: account_type.to_string(),
|
||
_account_name: account_name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// A builder providing access to all methods supported on *contact* resources.
|
||
/// It is not used directly, but through the `Mirror` hub.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate google_mirror1 as mirror1;
|
||
///
|
||
/// # async fn dox() {
|
||
/// use std::default::Default;
|
||
/// use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// secret,
|
||
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// ).build().await.unwrap();
|
||
/// let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||
/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
|
||
/// // to build up your call.
|
||
/// let rb = hub.contacts();
|
||
/// # }
|
||
/// ```
|
||
pub struct ContactMethods<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
}
|
||
|
||
impl<'a> client::MethodsBuilder for ContactMethods<'a> {}
|
||
|
||
impl<'a> ContactMethods<'a> {
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Deletes a contact.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `id` - The ID of the contact.
|
||
pub fn delete(&self, id: &str) -> ContactDeleteCall<'a> {
|
||
ContactDeleteCall {
|
||
hub: self.hub,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets a single contact by ID.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `id` - The ID of the contact.
|
||
pub fn get(&self, id: &str) -> ContactGetCall<'a> {
|
||
ContactGetCall {
|
||
hub: self.hub,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Inserts a new contact.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
pub fn insert(&self, request: Contact) -> ContactInsertCall<'a> {
|
||
ContactInsertCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Retrieves a list of contacts for the authenticated user.
|
||
pub fn list(&self) -> ContactListCall<'a> {
|
||
ContactListCall {
|
||
hub: self.hub,
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates a contact in place. This method supports patch semantics.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `id` - The ID of the contact.
|
||
pub fn patch(&self, request: Contact, id: &str) -> ContactPatchCall<'a> {
|
||
ContactPatchCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates a contact in place.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `id` - The ID of the contact.
|
||
pub fn update(&self, request: Contact, id: &str) -> ContactUpdateCall<'a> {
|
||
ContactUpdateCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// A builder providing access to all methods supported on *location* resources.
|
||
/// It is not used directly, but through the `Mirror` hub.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate google_mirror1 as mirror1;
|
||
///
|
||
/// # async fn dox() {
|
||
/// use std::default::Default;
|
||
/// use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// secret,
|
||
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// ).build().await.unwrap();
|
||
/// let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||
/// // like `get(...)` and `list(...)`
|
||
/// // to build up your call.
|
||
/// let rb = hub.locations();
|
||
/// # }
|
||
/// ```
|
||
pub struct LocationMethods<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
}
|
||
|
||
impl<'a> client::MethodsBuilder for LocationMethods<'a> {}
|
||
|
||
impl<'a> LocationMethods<'a> {
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets a single location by ID.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `id` - The ID of the location or latest for the last known location.
|
||
pub fn get(&self, id: &str) -> LocationGetCall<'a> {
|
||
LocationGetCall {
|
||
hub: self.hub,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Retrieves a list of locations for the user.
|
||
pub fn list(&self) -> LocationListCall<'a> {
|
||
LocationListCall {
|
||
hub: self.hub,
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// A builder providing access to all methods supported on *setting* resources.
|
||
/// It is not used directly, but through the `Mirror` hub.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate google_mirror1 as mirror1;
|
||
///
|
||
/// # async fn dox() {
|
||
/// use std::default::Default;
|
||
/// use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// secret,
|
||
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// ).build().await.unwrap();
|
||
/// let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||
/// // like `get(...)`
|
||
/// // to build up your call.
|
||
/// let rb = hub.settings();
|
||
/// # }
|
||
/// ```
|
||
pub struct SettingMethods<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
}
|
||
|
||
impl<'a> client::MethodsBuilder for SettingMethods<'a> {}
|
||
|
||
impl<'a> SettingMethods<'a> {
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets a single setting by ID.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `id` - The ID of the setting. The following IDs are valid:
|
||
/// - locale - The key to the user’s language/locale (BCP 47 identifier) that Glassware should use to render localized content.
|
||
/// - timezone - The key to the user’s current time zone region as defined in the tz database. Example: America/Los_Angeles.
|
||
pub fn get(&self, id: &str) -> SettingGetCall<'a> {
|
||
SettingGetCall {
|
||
hub: self.hub,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// A builder providing access to all methods supported on *subscription* resources.
|
||
/// It is not used directly, but through the `Mirror` hub.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate google_mirror1 as mirror1;
|
||
///
|
||
/// # async fn dox() {
|
||
/// use std::default::Default;
|
||
/// use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// secret,
|
||
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// ).build().await.unwrap();
|
||
/// let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||
/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)`
|
||
/// // to build up your call.
|
||
/// let rb = hub.subscriptions();
|
||
/// # }
|
||
/// ```
|
||
pub struct SubscriptionMethods<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
}
|
||
|
||
impl<'a> client::MethodsBuilder for SubscriptionMethods<'a> {}
|
||
|
||
impl<'a> SubscriptionMethods<'a> {
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Deletes a subscription.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `id` - The ID of the subscription.
|
||
pub fn delete(&self, id: &str) -> SubscriptionDeleteCall<'a> {
|
||
SubscriptionDeleteCall {
|
||
hub: self.hub,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Creates a new subscription.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
pub fn insert(&self, request: Subscription) -> SubscriptionInsertCall<'a> {
|
||
SubscriptionInsertCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Retrieves a list of subscriptions for the authenticated user and service.
|
||
pub fn list(&self) -> SubscriptionListCall<'a> {
|
||
SubscriptionListCall {
|
||
hub: self.hub,
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates an existing subscription in place.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `id` - The ID of the subscription.
|
||
pub fn update(&self, request: Subscription, id: &str) -> SubscriptionUpdateCall<'a> {
|
||
SubscriptionUpdateCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// A builder providing access to all methods supported on *timeline* resources.
|
||
/// It is not used directly, but through the `Mirror` hub.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate google_mirror1 as mirror1;
|
||
///
|
||
/// # async fn dox() {
|
||
/// use std::default::Default;
|
||
/// use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// secret,
|
||
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// ).build().await.unwrap();
|
||
/// let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||
/// // like `attachments_delete(...)`, `attachments_get(...)`, `attachments_insert(...)`, `attachments_list(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
|
||
/// // to build up your call.
|
||
/// let rb = hub.timeline();
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelineMethods<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
}
|
||
|
||
impl<'a> client::MethodsBuilder for TimelineMethods<'a> {}
|
||
|
||
impl<'a> TimelineMethods<'a> {
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Deletes an attachment from a timeline item.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `itemId` - The ID of the timeline item the attachment belongs to.
|
||
/// * `attachmentId` - The ID of the attachment.
|
||
pub fn attachments_delete(&self, item_id: &str, attachment_id: &str) -> TimelineAttachmentDeleteCall<'a> {
|
||
TimelineAttachmentDeleteCall {
|
||
hub: self.hub,
|
||
_item_id: item_id.to_string(),
|
||
_attachment_id: attachment_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Retrieves an attachment on a timeline item by item ID and attachment ID.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `itemId` - The ID of the timeline item the attachment belongs to.
|
||
/// * `attachmentId` - The ID of the attachment.
|
||
pub fn attachments_get(&self, item_id: &str, attachment_id: &str) -> TimelineAttachmentGetCall<'a> {
|
||
TimelineAttachmentGetCall {
|
||
hub: self.hub,
|
||
_item_id: item_id.to_string(),
|
||
_attachment_id: attachment_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Adds a new attachment to a timeline item.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `itemId` - The ID of the timeline item the attachment belongs to.
|
||
pub fn attachments_insert(&self, item_id: &str) -> TimelineAttachmentInsertCall<'a> {
|
||
TimelineAttachmentInsertCall {
|
||
hub: self.hub,
|
||
_item_id: item_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Returns a list of attachments for a timeline item.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `itemId` - The ID of the timeline item whose attachments should be listed.
|
||
pub fn attachments_list(&self, item_id: &str) -> TimelineAttachmentListCall<'a> {
|
||
TimelineAttachmentListCall {
|
||
hub: self.hub,
|
||
_item_id: item_id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Deletes a timeline item.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `id` - The ID of the timeline item.
|
||
pub fn delete(&self, id: &str) -> TimelineDeleteCall<'a> {
|
||
TimelineDeleteCall {
|
||
hub: self.hub,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets a single timeline item by ID.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `id` - The ID of the timeline item.
|
||
pub fn get(&self, id: &str) -> TimelineGetCall<'a> {
|
||
TimelineGetCall {
|
||
hub: self.hub,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Inserts a new item into the timeline.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
pub fn insert(&self, request: TimelineItem) -> TimelineInsertCall<'a> {
|
||
TimelineInsertCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Retrieves a list of timeline items for the authenticated user.
|
||
pub fn list(&self) -> TimelineListCall<'a> {
|
||
TimelineListCall {
|
||
hub: self.hub,
|
||
_source_item_id: Default::default(),
|
||
_pinned_only: Default::default(),
|
||
_page_token: Default::default(),
|
||
_order_by: Default::default(),
|
||
_max_results: Default::default(),
|
||
_include_deleted: Default::default(),
|
||
_bundle_id: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates a timeline item in place. This method supports patch semantics.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `id` - The ID of the timeline item.
|
||
pub fn patch(&self, request: TimelineItem, id: &str) -> TimelinePatchCall<'a> {
|
||
TimelinePatchCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates a timeline item in place.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `id` - The ID of the timeline item.
|
||
pub fn update(&self, request: TimelineItem, id: &str) -> TimelineUpdateCall<'a> {
|
||
TimelineUpdateCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_id: id.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
// ###################
|
||
// CallBuilders ###
|
||
// #################
|
||
|
||
/// Inserts a new account for a user
|
||
///
|
||
/// A builder for the *insert* method supported by a *account* resource.
|
||
/// It is not used directly, but through a `AccountMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// use mirror1::api::Account;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::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 = Account::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.accounts().insert(req, "userToken", "accountType", "accountName")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct AccountInsertCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_request: Account,
|
||
_user_token: String,
|
||
_account_type: String,
|
||
_account_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for AccountInsertCall<'a> {}
|
||
|
||
impl<'a> AccountInsertCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Account)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.accounts.insert",
|
||
http_method: hyper::Method::POST });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
|
||
params.push(("userToken", self._user_token.to_string()));
|
||
params.push(("accountType", self._account_type.to_string()));
|
||
params.push(("accountName", self._account_name.to_string()));
|
||
for &field in ["alt", "userToken", "accountType", "accountName"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "accounts/{userToken}/{accountType}/{accountName}";
|
||
|
||
let key = dlg.api_key();
|
||
match key {
|
||
Some(value) => params.push(("key", value)),
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingAPIKey)
|
||
}
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{userToken}", "userToken"), ("{accountType}", "accountType"), ("{accountName}", "accountName")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
||
for param_name in ["accountName", "accountType", "userToken"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Account) -> AccountInsertCall<'a> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// The ID for the user.
|
||
///
|
||
/// Sets the *user token* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn user_token(mut self, new_value: &str) -> AccountInsertCall<'a> {
|
||
self._user_token = new_value.to_string();
|
||
self
|
||
}
|
||
/// Account type to be passed to Android Account Manager.
|
||
///
|
||
/// Sets the *account type* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn account_type(mut self, new_value: &str) -> AccountInsertCall<'a> {
|
||
self._account_type = new_value.to_string();
|
||
self
|
||
}
|
||
/// The name of the account to be passed to the Android Account Manager.
|
||
///
|
||
/// Sets the *account name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn account_name(mut self, new_value: &str) -> AccountInsertCall<'a> {
|
||
self._account_name = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountInsertCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> AccountInsertCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// Deletes a contact.
|
||
///
|
||
/// A builder for the *delete* method supported by a *contact* resource.
|
||
/// It is not used directly, but through a `ContactMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.contacts().delete("id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ContactDeleteCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for ContactDeleteCall<'a> {}
|
||
|
||
impl<'a> ContactDeleteCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.contacts.delete",
|
||
http_method: hyper::Method::DELETE });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
|
||
let mut url = self.hub._base_url.clone() + "contacts/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = res;
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The ID of the contact.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> ContactDeleteCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContactDeleteCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> ContactDeleteCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> ContactDeleteCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Gets a single contact by ID.
|
||
///
|
||
/// A builder for the *get* method supported by a *contact* resource.
|
||
/// It is not used directly, but through a `ContactMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.contacts().get("id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ContactGetCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for ContactGetCall<'a> {}
|
||
|
||
impl<'a> ContactGetCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Contact)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.contacts.get",
|
||
http_method: hyper::Method::GET });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["alt", "id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "contacts/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The ID of the contact.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> ContactGetCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContactGetCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> ContactGetCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> ContactGetCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Inserts a new contact.
|
||
///
|
||
/// A builder for the *insert* method supported by a *contact* resource.
|
||
/// It is not used directly, but through a `ContactMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// use mirror1::api::Contact;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::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 = Contact::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.contacts().insert(req)
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ContactInsertCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_request: Contact,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for ContactInsertCall<'a> {}
|
||
|
||
impl<'a> ContactInsertCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Contact)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.contacts.insert",
|
||
http_method: hyper::Method::POST });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
for &field in ["alt"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "contacts";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Contact) -> ContactInsertCall<'a> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContactInsertCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> ContactInsertCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> ContactInsertCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Retrieves a list of contacts for the authenticated user.
|
||
///
|
||
/// A builder for the *list* method supported by a *contact* resource.
|
||
/// It is not used directly, but through a `ContactMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.contacts().list()
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ContactListCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for ContactListCall<'a> {}
|
||
|
||
impl<'a> ContactListCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ContactsListResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.contacts.list",
|
||
http_method: hyper::Method::GET });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
|
||
for &field in ["alt"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "contacts";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContactListCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> ContactListCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> ContactListCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Updates a contact in place. This method supports patch semantics.
|
||
///
|
||
/// A builder for the *patch* method supported by a *contact* resource.
|
||
/// It is not used directly, but through a `ContactMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// use mirror1::api::Contact;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::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 = Contact::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.contacts().patch(req, "id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ContactPatchCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_request: Contact,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for ContactPatchCall<'a> {}
|
||
|
||
impl<'a> ContactPatchCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Contact)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.contacts.patch",
|
||
http_method: hyper::Method::PATCH });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["alt", "id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "contacts/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Contact) -> ContactPatchCall<'a> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// The ID of the contact.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> ContactPatchCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContactPatchCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> ContactPatchCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> ContactPatchCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Updates a contact in place.
|
||
///
|
||
/// A builder for the *update* method supported by a *contact* resource.
|
||
/// It is not used directly, but through a `ContactMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// use mirror1::api::Contact;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::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 = Contact::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.contacts().update(req, "id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ContactUpdateCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_request: Contact,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for ContactUpdateCall<'a> {}
|
||
|
||
impl<'a> ContactUpdateCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Contact)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.contacts.update",
|
||
http_method: hyper::Method::PUT });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["alt", "id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "contacts/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Contact) -> ContactUpdateCall<'a> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// The ID of the contact.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> ContactUpdateCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContactUpdateCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> ContactUpdateCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> ContactUpdateCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Gets a single location by ID.
|
||
///
|
||
/// A builder for the *get* method supported by a *location* resource.
|
||
/// It is not used directly, but through a `LocationMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.locations().get("id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct LocationGetCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for LocationGetCall<'a> {}
|
||
|
||
impl<'a> LocationGetCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Location)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.locations.get",
|
||
http_method: hyper::Method::GET });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["alt", "id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "locations/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasLocation.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The ID of the location or latest for the last known location.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> LocationGetCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LocationGetCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> LocationGetCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasLocation`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> LocationGetCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Retrieves a list of locations for the user.
|
||
///
|
||
/// A builder for the *list* method supported by a *location* resource.
|
||
/// It is not used directly, but through a `LocationMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.locations().list()
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct LocationListCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for LocationListCall<'a> {}
|
||
|
||
impl<'a> LocationListCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, LocationsListResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.locations.list",
|
||
http_method: hyper::Method::GET });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
|
||
for &field in ["alt"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "locations";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasLocation.as_ref().to_string(), ());
|
||
}
|
||
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LocationListCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> LocationListCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasLocation`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> LocationListCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Gets a single setting by ID.
|
||
///
|
||
/// A builder for the *get* method supported by a *setting* resource.
|
||
/// It is not used directly, but through a `SettingMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.settings().get("id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct SettingGetCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for SettingGetCall<'a> {}
|
||
|
||
impl<'a> SettingGetCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Setting)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.settings.get",
|
||
http_method: hyper::Method::GET });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["alt", "id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "settings/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The ID of the setting. The following IDs are valid:
|
||
/// - locale - The key to the user’s language/locale (BCP 47 identifier) that Glassware should use to render localized content.
|
||
/// - timezone - The key to the user’s current time zone region as defined in the tz database. Example: America/Los_Angeles.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> SettingGetCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SettingGetCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> SettingGetCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> SettingGetCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Deletes a subscription.
|
||
///
|
||
/// A builder for the *delete* method supported by a *subscription* resource.
|
||
/// It is not used directly, but through a `SubscriptionMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.subscriptions().delete("id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct SubscriptionDeleteCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for SubscriptionDeleteCall<'a> {}
|
||
|
||
impl<'a> SubscriptionDeleteCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.subscriptions.delete",
|
||
http_method: hyper::Method::DELETE });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
|
||
let mut url = self.hub._base_url.clone() + "subscriptions/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = res;
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The ID of the subscription.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> SubscriptionDeleteCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubscriptionDeleteCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> SubscriptionDeleteCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> SubscriptionDeleteCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Creates a new subscription.
|
||
///
|
||
/// A builder for the *insert* method supported by a *subscription* resource.
|
||
/// It is not used directly, but through a `SubscriptionMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// use mirror1::api::Subscription;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::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 = Subscription::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.subscriptions().insert(req)
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct SubscriptionInsertCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_request: Subscription,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for SubscriptionInsertCall<'a> {}
|
||
|
||
impl<'a> SubscriptionInsertCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Subscription)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.subscriptions.insert",
|
||
http_method: hyper::Method::POST });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
for &field in ["alt"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "subscriptions";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Subscription) -> SubscriptionInsertCall<'a> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubscriptionInsertCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> SubscriptionInsertCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> SubscriptionInsertCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Retrieves a list of subscriptions for the authenticated user and service.
|
||
///
|
||
/// A builder for the *list* method supported by a *subscription* resource.
|
||
/// It is not used directly, but through a `SubscriptionMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.subscriptions().list()
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct SubscriptionListCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for SubscriptionListCall<'a> {}
|
||
|
||
impl<'a> SubscriptionListCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, SubscriptionsListResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.subscriptions.list",
|
||
http_method: hyper::Method::GET });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
|
||
for &field in ["alt"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "subscriptions";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubscriptionListCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> SubscriptionListCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> SubscriptionListCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Updates an existing subscription in place.
|
||
///
|
||
/// A builder for the *update* method supported by a *subscription* resource.
|
||
/// It is not used directly, but through a `SubscriptionMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// use mirror1::api::Subscription;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::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 = Subscription::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.subscriptions().update(req, "id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct SubscriptionUpdateCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_request: Subscription,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for SubscriptionUpdateCall<'a> {}
|
||
|
||
impl<'a> SubscriptionUpdateCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Subscription)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.subscriptions.update",
|
||
http_method: hyper::Method::PUT });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["alt", "id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "subscriptions/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Subscription) -> SubscriptionUpdateCall<'a> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// The ID of the subscription.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> SubscriptionUpdateCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubscriptionUpdateCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> SubscriptionUpdateCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> SubscriptionUpdateCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Deletes an attachment from a timeline item.
|
||
///
|
||
/// A builder for the *attachments.delete* method supported by a *timeline* resource.
|
||
/// It is not used directly, but through a `TimelineMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.timeline().attachments_delete("itemId", "attachmentId")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelineAttachmentDeleteCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_item_id: String,
|
||
_attachment_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for TimelineAttachmentDeleteCall<'a> {}
|
||
|
||
impl<'a> TimelineAttachmentDeleteCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.timeline.attachments.delete",
|
||
http_method: hyper::Method::DELETE });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
params.push(("itemId", self._item_id.to_string()));
|
||
params.push(("attachmentId", self._attachment_id.to_string()));
|
||
for &field in ["itemId", "attachmentId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
|
||
let mut url = self.hub._base_url.clone() + "timeline/{itemId}/attachments/{attachmentId}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{itemId}", "itemId"), ("{attachmentId}", "attachmentId")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
||
for param_name in ["attachmentId", "itemId"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = res;
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The ID of the timeline item the attachment belongs to.
|
||
///
|
||
/// Sets the *item id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn item_id(mut self, new_value: &str) -> TimelineAttachmentDeleteCall<'a> {
|
||
self._item_id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The ID of the attachment.
|
||
///
|
||
/// Sets the *attachment id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn attachment_id(mut self, new_value: &str) -> TimelineAttachmentDeleteCall<'a> {
|
||
self._attachment_id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TimelineAttachmentDeleteCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> TimelineAttachmentDeleteCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> TimelineAttachmentDeleteCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Retrieves an attachment on a timeline item by item ID and attachment ID.
|
||
///
|
||
/// This method supports **media download**. To enable it, adjust the builder like this:
|
||
/// `.param("alt", "media")`.
|
||
/// Please note that due to missing multi-part support on the server side, you will only receive the media,
|
||
/// but not the `Attachment` structure that you would usually get. The latter will be a default value.
|
||
///
|
||
/// A builder for the *attachments.get* method supported by a *timeline* resource.
|
||
/// It is not used directly, but through a `TimelineMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.timeline().attachments_get("itemId", "attachmentId")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelineAttachmentGetCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_item_id: String,
|
||
_attachment_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for TimelineAttachmentGetCall<'a> {}
|
||
|
||
impl<'a> TimelineAttachmentGetCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Attachment)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.timeline.attachments.get",
|
||
http_method: hyper::Method::GET });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
params.push(("itemId", self._item_id.to_string()));
|
||
params.push(("attachmentId", self._attachment_id.to_string()));
|
||
for &field in ["itemId", "attachmentId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
let (json_field_missing, enable_resource_parsing) = {
|
||
let mut enable = true;
|
||
let mut field_present = true;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == "alt" {
|
||
field_present = false;
|
||
if <String as AsRef<str>>::as_ref(&value) != "json" {
|
||
enable = false;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
(field_present, enable)
|
||
};
|
||
if json_field_missing {
|
||
params.push(("alt", "json".to_string()));
|
||
}
|
||
|
||
let mut url = self.hub._base_url.clone() + "timeline/{itemId}/attachments/{attachmentId}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{itemId}", "itemId"), ("{attachmentId}", "attachmentId")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
||
for param_name in ["attachmentId", "itemId"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = if enable_resource_parsing {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
} else { (res, Default::default()) };
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The ID of the timeline item the attachment belongs to.
|
||
///
|
||
/// Sets the *item id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn item_id(mut self, new_value: &str) -> TimelineAttachmentGetCall<'a> {
|
||
self._item_id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The ID of the attachment.
|
||
///
|
||
/// Sets the *attachment id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn attachment_id(mut self, new_value: &str) -> TimelineAttachmentGetCall<'a> {
|
||
self._attachment_id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TimelineAttachmentGetCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> TimelineAttachmentGetCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> TimelineAttachmentGetCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Adds a new attachment to a timeline item.
|
||
///
|
||
/// A builder for the *attachments.insert* method supported by a *timeline* resource.
|
||
/// It is not used directly, but through a `TimelineMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// use std::fs;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // 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.timeline().attachments_insert("itemId")
|
||
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelineAttachmentInsertCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_item_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for TimelineAttachmentInsertCall<'a> {}
|
||
|
||
impl<'a> TimelineAttachmentInsertCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
async fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> client::Result<(hyper::Response<hyper::body::Body>, Attachment)>
|
||
where RS: client::ReadSeek {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.timeline.attachments.insert",
|
||
http_method: hyper::Method::POST });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
params.push(("itemId", self._item_id.to_string()));
|
||
for &field in ["alt", "itemId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let (mut url, upload_type) =
|
||
if protocol == "resumable" {
|
||
(self.hub._root_url.clone() + "resumable/upload/mirror/v1/timeline/{itemId}/attachments", "resumable")
|
||
} else if protocol == "simple" {
|
||
(self.hub._root_url.clone() + "upload/mirror/v1/timeline/{itemId}/attachments", "multipart")
|
||
} else {
|
||
unreachable!()
|
||
};
|
||
params.push(("uploadType", upload_type.to_string()));
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{itemId}", "itemId")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["itemId"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
let mut should_ask_dlg_for_url = false;
|
||
let mut upload_url_from_server;
|
||
let mut upload_url: Option<String> = None;
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() {
|
||
should_ask_dlg_for_url = false;
|
||
upload_url_from_server = false;
|
||
Ok(hyper::Response::builder()
|
||
.status(hyper::StatusCode::OK)
|
||
.header("Location", upload_url.as_ref().unwrap().clone())
|
||
.body(hyper::body::Body::empty())
|
||
.unwrap())
|
||
} else {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
upload_url_from_server = true;
|
||
if protocol == "resumable" {
|
||
req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
|
||
}
|
||
|
||
let request = if protocol == "simple" {
|
||
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
if size > 10485760 {
|
||
return Err(client::Error::UploadSizeLimitExceeded(size, 10485760))
|
||
}
|
||
let mut bytes = Vec::with_capacity(size as usize);
|
||
reader.read_to_end(&mut bytes)?;
|
||
req_builder.header(CONTENT_TYPE, reader_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, size)
|
||
.body(hyper::body::Body::from(bytes))
|
||
} else {
|
||
req_builder.body(hyper::body::Body::from(Vec::new()))
|
||
};
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
}
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
if protocol == "resumable" {
|
||
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
if size > 10485760 {
|
||
return Err(client::Error::UploadSizeLimitExceeded(size, 10485760))
|
||
}
|
||
let upload_result = {
|
||
let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap();
|
||
if upload_url_from_server {
|
||
dlg.store_upload_url(Some(url_str));
|
||
}
|
||
|
||
client::ResumableUploadHelper {
|
||
client: &self.hub.client,
|
||
delegate: dlg,
|
||
start_at: if upload_url_from_server { Some(0) } else { None },
|
||
auth: &self.hub.auth,
|
||
user_agent: &self.hub._user_agent,
|
||
auth_header: format!("Bearer {}", token.as_str()),
|
||
url: url_str,
|
||
reader: &mut reader,
|
||
media_type: reader_mime_type.clone(),
|
||
content_length: size
|
||
}.upload().await
|
||
};
|
||
match upload_result {
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::Cancelled)
|
||
}
|
||
Some(Err(err)) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Some(Ok(upload_result)) => {
|
||
res = upload_result;
|
||
if !res.status().is_success() {
|
||
dlg.store_upload_url(None);
|
||
dlg.finished(false);
|
||
return Err(client::Error::Failure(res))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// Upload media in a resumable fashion.
|
||
/// Even if the upload fails or is interrupted, it can be resumed for a
|
||
/// certain amount of time as the server maintains state temporarily.
|
||
///
|
||
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
|
||
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
|
||
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
|
||
/// `cancel_chunk_upload(...)`.
|
||
///
|
||
/// * *multipart*: yes
|
||
/// * *max size*: 10MB
|
||
/// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
|
||
pub async fn upload_resumable<RS>(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response<hyper::body::Body>, Attachment)>
|
||
where RS: client::ReadSeek {
|
||
self.doit(resumeable_stream, mime_type, "resumable").await
|
||
}
|
||
/// Upload media all at once.
|
||
/// If the upload fails for whichever reason, all progress is lost.
|
||
///
|
||
/// * *multipart*: yes
|
||
/// * *max size*: 10MB
|
||
/// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
|
||
pub async fn upload<RS>(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response<hyper::body::Body>, Attachment)>
|
||
where RS: client::ReadSeek {
|
||
self.doit(stream, mime_type, "simple").await
|
||
}
|
||
|
||
/// The ID of the timeline item the attachment belongs to.
|
||
///
|
||
/// Sets the *item id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn item_id(mut self, new_value: &str) -> TimelineAttachmentInsertCall<'a> {
|
||
self._item_id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TimelineAttachmentInsertCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> TimelineAttachmentInsertCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> TimelineAttachmentInsertCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Returns a list of attachments for a timeline item.
|
||
///
|
||
/// A builder for the *attachments.list* method supported by a *timeline* resource.
|
||
/// It is not used directly, but through a `TimelineMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.timeline().attachments_list("itemId")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelineAttachmentListCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_item_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for TimelineAttachmentListCall<'a> {}
|
||
|
||
impl<'a> TimelineAttachmentListCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, AttachmentsListResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.timeline.attachments.list",
|
||
http_method: hyper::Method::GET });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
params.push(("itemId", self._item_id.to_string()));
|
||
for &field in ["alt", "itemId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "timeline/{itemId}/attachments";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasTimeline.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{itemId}", "itemId")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["itemId"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The ID of the timeline item whose attachments should be listed.
|
||
///
|
||
/// Sets the *item id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn item_id(mut self, new_value: &str) -> TimelineAttachmentListCall<'a> {
|
||
self._item_id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TimelineAttachmentListCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> TimelineAttachmentListCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasTimeline`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> TimelineAttachmentListCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Deletes a timeline item.
|
||
///
|
||
/// A builder for the *delete* method supported by a *timeline* resource.
|
||
/// It is not used directly, but through a `TimelineMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.timeline().delete("id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelineDeleteCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for TimelineDeleteCall<'a> {}
|
||
|
||
impl<'a> TimelineDeleteCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.timeline.delete",
|
||
http_method: hyper::Method::DELETE });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
|
||
let mut url = self.hub._base_url.clone() + "timeline/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasLocation.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = res;
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The ID of the timeline item.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> TimelineDeleteCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TimelineDeleteCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> TimelineDeleteCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasLocation`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> TimelineDeleteCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Gets a single timeline item by ID.
|
||
///
|
||
/// A builder for the *get* method supported by a *timeline* resource.
|
||
/// It is not used directly, but through a `TimelineMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.timeline().get("id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelineGetCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for TimelineGetCall<'a> {}
|
||
|
||
impl<'a> TimelineGetCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, TimelineItem)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.timeline.get",
|
||
http_method: hyper::Method::GET });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["alt", "id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "timeline/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasLocation.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The ID of the timeline item.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> TimelineGetCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TimelineGetCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> TimelineGetCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasLocation`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> TimelineGetCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Inserts a new item into the timeline.
|
||
///
|
||
/// A builder for the *insert* method supported by a *timeline* resource.
|
||
/// It is not used directly, but through a `TimelineMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// use mirror1::api::TimelineItem;
|
||
/// use std::fs;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::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 = TimelineItem::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.timeline().insert(req)
|
||
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelineInsertCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_request: TimelineItem,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for TimelineInsertCall<'a> {}
|
||
|
||
impl<'a> TimelineInsertCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
async fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> client::Result<(hyper::Response<hyper::body::Body>, TimelineItem)>
|
||
where RS: client::ReadSeek {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.timeline.insert",
|
||
http_method: hyper::Method::POST });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||
for &field in ["alt"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let (mut url, upload_type) =
|
||
if protocol == "resumable" {
|
||
(self.hub._root_url.clone() + "resumable/upload/mirror/v1/timeline", "resumable")
|
||
} else if protocol == "simple" {
|
||
(self.hub._root_url.clone() + "upload/mirror/v1/timeline", "multipart")
|
||
} else {
|
||
unreachable!()
|
||
};
|
||
params.push(("uploadType", upload_type.to_string()));
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasLocation.as_ref().to_string(), ());
|
||
}
|
||
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
let mut should_ask_dlg_for_url = false;
|
||
let mut upload_url_from_server;
|
||
let mut upload_url: Option<String> = None;
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() {
|
||
should_ask_dlg_for_url = false;
|
||
upload_url_from_server = false;
|
||
Ok(hyper::Response::builder()
|
||
.status(hyper::StatusCode::OK)
|
||
.header("Location", upload_url.as_ref().unwrap().clone())
|
||
.body(hyper::body::Body::empty())
|
||
.unwrap())
|
||
} else {
|
||
let mut mp_reader: client::MultiPartReader = Default::default();
|
||
let (mut body_reader, content_type) = match protocol {
|
||
"simple" => {
|
||
mp_reader.reserve_exact(2);
|
||
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
if size > 10485760 {
|
||
return Err(client::Error::UploadSizeLimitExceeded(size, 10485760))
|
||
}
|
||
mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone())
|
||
.add_part(&mut reader, size, reader_mime_type.clone());
|
||
let mime_type = mp_reader.mime_type();
|
||
(&mut mp_reader as &mut (dyn io::Read + Send), (CONTENT_TYPE, mime_type.to_string()))
|
||
},
|
||
_ => (&mut request_value_reader as &mut (dyn io::Read + Send), (CONTENT_TYPE, json_mime_type.to_string())),
|
||
};
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
upload_url_from_server = true;
|
||
if protocol == "resumable" {
|
||
req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
|
||
}
|
||
|
||
let mut body_reader_bytes = vec![];
|
||
body_reader.read_to_end(&mut body_reader_bytes).unwrap();
|
||
let request = req_builder
|
||
.header(content_type.0, content_type.1.to_string())
|
||
.body(hyper::body::Body::from(body_reader_bytes));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
}
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
if protocol == "resumable" {
|
||
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
if size > 10485760 {
|
||
return Err(client::Error::UploadSizeLimitExceeded(size, 10485760))
|
||
}
|
||
let upload_result = {
|
||
let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap();
|
||
if upload_url_from_server {
|
||
dlg.store_upload_url(Some(url_str));
|
||
}
|
||
|
||
client::ResumableUploadHelper {
|
||
client: &self.hub.client,
|
||
delegate: dlg,
|
||
start_at: if upload_url_from_server { Some(0) } else { None },
|
||
auth: &self.hub.auth,
|
||
user_agent: &self.hub._user_agent,
|
||
auth_header: format!("Bearer {}", token.as_str()),
|
||
url: url_str,
|
||
reader: &mut reader,
|
||
media_type: reader_mime_type.clone(),
|
||
content_length: size
|
||
}.upload().await
|
||
};
|
||
match upload_result {
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::Cancelled)
|
||
}
|
||
Some(Err(err)) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Some(Ok(upload_result)) => {
|
||
res = upload_result;
|
||
if !res.status().is_success() {
|
||
dlg.store_upload_url(None);
|
||
dlg.finished(false);
|
||
return Err(client::Error::Failure(res))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// Upload media in a resumable fashion.
|
||
/// Even if the upload fails or is interrupted, it can be resumed for a
|
||
/// certain amount of time as the server maintains state temporarily.
|
||
///
|
||
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
|
||
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
|
||
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
|
||
/// `cancel_chunk_upload(...)`.
|
||
///
|
||
/// * *multipart*: yes
|
||
/// * *max size*: 10MB
|
||
/// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
|
||
pub async fn upload_resumable<RS>(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response<hyper::body::Body>, TimelineItem)>
|
||
where RS: client::ReadSeek {
|
||
self.doit(resumeable_stream, mime_type, "resumable").await
|
||
}
|
||
/// Upload media all at once.
|
||
/// If the upload fails for whichever reason, all progress is lost.
|
||
///
|
||
/// * *multipart*: yes
|
||
/// * *max size*: 10MB
|
||
/// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
|
||
pub async fn upload<RS>(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response<hyper::body::Body>, TimelineItem)>
|
||
where RS: client::ReadSeek {
|
||
self.doit(stream, mime_type, "simple").await
|
||
}
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: TimelineItem) -> TimelineInsertCall<'a> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TimelineInsertCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> TimelineInsertCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasLocation`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> TimelineInsertCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Retrieves a list of timeline items for the authenticated user.
|
||
///
|
||
/// A builder for the *list* method supported by a *timeline* resource.
|
||
/// It is not used directly, but through a `TimelineMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth);
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.timeline().list()
|
||
/// .source_item_id("duo")
|
||
/// .pinned_only(true)
|
||
/// .page_token("sed")
|
||
/// .order_by("ut")
|
||
/// .max_results(89)
|
||
/// .include_deleted(true)
|
||
/// .bundle_id("ipsum")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelineListCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_source_item_id: Option<String>,
|
||
_pinned_only: Option<bool>,
|
||
_page_token: Option<String>,
|
||
_order_by: Option<String>,
|
||
_max_results: Option<u32>,
|
||
_include_deleted: Option<bool>,
|
||
_bundle_id: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for TimelineListCall<'a> {}
|
||
|
||
impl<'a> TimelineListCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, TimelineListResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.timeline.list",
|
||
http_method: hyper::Method::GET });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(9 + self._additional_params.len());
|
||
if let Some(value) = self._source_item_id {
|
||
params.push(("sourceItemId", value.to_string()));
|
||
}
|
||
if let Some(value) = self._pinned_only {
|
||
params.push(("pinnedOnly", value.to_string()));
|
||
}
|
||
if let Some(value) = self._page_token {
|
||
params.push(("pageToken", value.to_string()));
|
||
}
|
||
if let Some(value) = self._order_by {
|
||
params.push(("orderBy", value.to_string()));
|
||
}
|
||
if let Some(value) = self._max_results {
|
||
params.push(("maxResults", value.to_string()));
|
||
}
|
||
if let Some(value) = self._include_deleted {
|
||
params.push(("includeDeleted", value.to_string()));
|
||
}
|
||
if let Some(value) = self._bundle_id {
|
||
params.push(("bundleId", value.to_string()));
|
||
}
|
||
for &field in ["alt", "sourceItemId", "pinnedOnly", "pageToken", "orderBy", "maxResults", "includeDeleted", "bundleId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "timeline";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasLocation.as_ref().to_string(), ());
|
||
}
|
||
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// If provided, only items with the given sourceItemId will be returned.
|
||
///
|
||
/// Sets the *source item id* query property to the given value.
|
||
pub fn source_item_id(mut self, new_value: &str) -> TimelineListCall<'a> {
|
||
self._source_item_id = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// If true, only pinned items will be returned.
|
||
///
|
||
/// Sets the *pinned only* query property to the given value.
|
||
pub fn pinned_only(mut self, new_value: bool) -> TimelineListCall<'a> {
|
||
self._pinned_only = Some(new_value);
|
||
self
|
||
}
|
||
/// Token for the page of results to return.
|
||
///
|
||
/// Sets the *page token* query property to the given value.
|
||
pub fn page_token(mut self, new_value: &str) -> TimelineListCall<'a> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// Controls the order in which timeline items are returned.
|
||
///
|
||
/// Sets the *order by* query property to the given value.
|
||
pub fn order_by(mut self, new_value: &str) -> TimelineListCall<'a> {
|
||
self._order_by = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of items to include in the response, used for paging.
|
||
///
|
||
/// Sets the *max results* query property to the given value.
|
||
pub fn max_results(mut self, new_value: u32) -> TimelineListCall<'a> {
|
||
self._max_results = Some(new_value);
|
||
self
|
||
}
|
||
/// If true, tombstone records for deleted items will be returned.
|
||
///
|
||
/// Sets the *include deleted* query property to the given value.
|
||
pub fn include_deleted(mut self, new_value: bool) -> TimelineListCall<'a> {
|
||
self._include_deleted = Some(new_value);
|
||
self
|
||
}
|
||
/// If provided, only items with the given bundleId will be returned.
|
||
///
|
||
/// Sets the *bundle id* query property to the given value.
|
||
pub fn bundle_id(mut self, new_value: &str) -> TimelineListCall<'a> {
|
||
self._bundle_id = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TimelineListCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> TimelineListCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasLocation`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> TimelineListCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Updates a timeline item in place. This method supports patch semantics.
|
||
///
|
||
/// A builder for the *patch* method supported by a *timeline* resource.
|
||
/// It is not used directly, but through a `TimelineMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// use mirror1::api::TimelineItem;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::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 = TimelineItem::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.timeline().patch(req, "id")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelinePatchCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_request: TimelineItem,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for TimelinePatchCall<'a> {}
|
||
|
||
impl<'a> TimelinePatchCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, TimelineItem)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.timeline.patch",
|
||
http_method: hyper::Method::PATCH });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["alt", "id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let mut url = self.hub._base_url.clone() + "timeline/{id}";
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasLocation.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: TimelineItem) -> TimelinePatchCall<'a> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// The ID of the timeline item.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> TimelinePatchCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TimelinePatchCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> TimelinePatchCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasLocation`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> TimelinePatchCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Updates a timeline item in place.
|
||
///
|
||
/// A builder for the *update* method supported by a *timeline* resource.
|
||
/// It is not used directly, but through a `TimelineMethods` instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_mirror1 as mirror1;
|
||
/// use mirror1::api::TimelineItem;
|
||
/// use std::fs;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use mirror1::{Mirror, oauth2, hyper, hyper_rustls};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = Mirror::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 = TimelineItem::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.timeline().update(req, "id")
|
||
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
|
||
/// # }
|
||
/// ```
|
||
pub struct TimelineUpdateCall<'a>
|
||
where {
|
||
|
||
hub: &'a Mirror<>,
|
||
_request: TimelineItem,
|
||
_id: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeMap<String, ()>
|
||
}
|
||
|
||
impl<'a> client::CallBuilder for TimelineUpdateCall<'a> {}
|
||
|
||
impl<'a> TimelineUpdateCall<'a> {
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
async fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> client::Result<(hyper::Response<hyper::body::Body>, TimelineItem)>
|
||
where RS: client::ReadSeek {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::ToParts;
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = match self._delegate {
|
||
Some(d) => d,
|
||
None => &mut dd
|
||
};
|
||
dlg.begin(client::MethodInfo { id: "mirror.timeline.update",
|
||
http_method: hyper::Method::PUT });
|
||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||
params.push(("id", self._id.to_string()));
|
||
for &field in ["alt", "id"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
for (name, value) in self._additional_params.iter() {
|
||
params.push((&name, value.clone()));
|
||
}
|
||
|
||
params.push(("alt", "json".to_string()));
|
||
|
||
let (mut url, upload_type) =
|
||
if protocol == "resumable" {
|
||
(self.hub._root_url.clone() + "resumable/upload/mirror/v1/timeline/{id}", "resumable")
|
||
} else if protocol == "simple" {
|
||
(self.hub._root_url.clone() + "upload/mirror/v1/timeline/{id}", "multipart")
|
||
} else {
|
||
unreachable!()
|
||
};
|
||
params.push(("uploadType", upload_type.to_string()));
|
||
if self._scopes.len() == 0 {
|
||
self._scopes.insert(Scope::GlasLocation.as_ref().to_string(), ());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{id}", "id")].iter() {
|
||
let mut replace_with: Option<&str> = None;
|
||
for &(name, ref value) in params.iter() {
|
||
if name == param_name {
|
||
replace_with = Some(value);
|
||
break;
|
||
}
|
||
}
|
||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||
}
|
||
{
|
||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||
for param_name in ["id"].iter() {
|
||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||
indices_for_removal.push(index);
|
||
}
|
||
}
|
||
for &index in indices_for_removal.iter() {
|
||
params.remove(index);
|
||
}
|
||
}
|
||
|
||
let url = url::Url::parse_with_params(&url, params).unwrap();
|
||
|
||
let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
let mut should_ask_dlg_for_url = false;
|
||
let mut upload_url_from_server;
|
||
let mut upload_url: Option<String> = None;
|
||
|
||
loop {
|
||
let token = match self.hub.auth.token(&self._scopes.keys().collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token.clone(),
|
||
Err(err) => {
|
||
match dlg.token(&err) {
|
||
Some(token) => token,
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(err))
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() {
|
||
should_ask_dlg_for_url = false;
|
||
upload_url_from_server = false;
|
||
Ok(hyper::Response::builder()
|
||
.status(hyper::StatusCode::OK)
|
||
.header("Location", upload_url.as_ref().unwrap().clone())
|
||
.body(hyper::body::Body::empty())
|
||
.unwrap())
|
||
} else {
|
||
let mut mp_reader: client::MultiPartReader = Default::default();
|
||
let (mut body_reader, content_type) = match protocol {
|
||
"simple" => {
|
||
mp_reader.reserve_exact(2);
|
||
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
if size > 10485760 {
|
||
return Err(client::Error::UploadSizeLimitExceeded(size, 10485760))
|
||
}
|
||
mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone())
|
||
.add_part(&mut reader, size, reader_mime_type.clone());
|
||
let mime_type = mp_reader.mime_type();
|
||
(&mut mp_reader as &mut (dyn io::Read + Send), (CONTENT_TYPE, mime_type.to_string()))
|
||
},
|
||
_ => (&mut request_value_reader as &mut (dyn io::Read + Send), (CONTENT_TYPE, json_mime_type.to_string())),
|
||
};
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string())
|
||
.header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
|
||
|
||
upload_url_from_server = true;
|
||
if protocol == "resumable" {
|
||
req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
|
||
}
|
||
|
||
let mut body_reader_bytes = vec![];
|
||
body_reader.read_to_end(&mut body_reader_bytes).unwrap();
|
||
let request = req_builder
|
||
.header(content_type.0, content_type.1.to_string())
|
||
.body(hyper::body::Body::from(body_reader_bytes));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
}
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d);
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
if protocol == "resumable" {
|
||
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
if size > 10485760 {
|
||
return Err(client::Error::UploadSizeLimitExceeded(size, 10485760))
|
||
}
|
||
let upload_result = {
|
||
let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap();
|
||
if upload_url_from_server {
|
||
dlg.store_upload_url(Some(url_str));
|
||
}
|
||
|
||
client::ResumableUploadHelper {
|
||
client: &self.hub.client,
|
||
delegate: dlg,
|
||
start_at: if upload_url_from_server { Some(0) } else { None },
|
||
auth: &self.hub.auth,
|
||
user_agent: &self.hub._user_agent,
|
||
auth_header: format!("Bearer {}", token.as_str()),
|
||
url: url_str,
|
||
reader: &mut reader,
|
||
media_type: reader_mime_type.clone(),
|
||
content_length: size
|
||
}.upload().await
|
||
};
|
||
match upload_result {
|
||
None => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::Cancelled)
|
||
}
|
||
Some(Err(err)) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Some(Ok(upload_result)) => {
|
||
res = upload_result;
|
||
if !res.status().is_success() {
|
||
dlg.store_upload_url(None);
|
||
dlg.finished(false);
|
||
return Err(client::Error::Failure(res))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// Upload media in a resumable fashion.
|
||
/// Even if the upload fails or is interrupted, it can be resumed for a
|
||
/// certain amount of time as the server maintains state temporarily.
|
||
///
|
||
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
|
||
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
|
||
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
|
||
/// `cancel_chunk_upload(...)`.
|
||
///
|
||
/// * *multipart*: yes
|
||
/// * *max size*: 10MB
|
||
/// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
|
||
pub async fn upload_resumable<RS>(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response<hyper::body::Body>, TimelineItem)>
|
||
where RS: client::ReadSeek {
|
||
self.doit(resumeable_stream, mime_type, "resumable").await
|
||
}
|
||
/// Upload media all at once.
|
||
/// If the upload fails for whichever reason, all progress is lost.
|
||
///
|
||
/// * *multipart*: yes
|
||
/// * *max size*: 10MB
|
||
/// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
|
||
pub async fn upload<RS>(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response<hyper::body::Body>, TimelineItem)>
|
||
where RS: client::ReadSeek {
|
||
self.doit(stream, mime_type, "simple").await
|
||
}
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: TimelineItem) -> TimelineUpdateCall<'a> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// The ID of the timeline item.
|
||
///
|
||
/// Sets the *id* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn id(mut self, new_value: &str) -> TimelineUpdateCall<'a> {
|
||
self._id = new_value.to_string();
|
||
self
|
||
}
|
||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||
/// while executing the actual API request.
|
||
///
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TimelineUpdateCall<'a> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *alt* (query-string) - Data format for the response.
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
|
||
/// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
|
||
pub fn param<T>(mut self, name: T, value: T) -> TimelineUpdateCall<'a>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||
/// `Scope::GlasLocation`.
|
||
///
|
||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||
/// tokens for more than one scope.
|
||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||
/// function for details).
|
||
///
|
||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||
/// sufficient, a read-write scope will do as well.
|
||
pub fn add_scope<T, S>(mut self, scope: T) -> TimelineUpdateCall<'a>
|
||
where T: Into<Option<S>>,
|
||
S: AsRef<str> {
|
||
match scope.into() {
|
||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||
None => None,
|
||
};
|
||
self
|
||
}
|
||
}
|
||
|
||
|