mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
12235 lines
534 KiB
Rust
12235 lines
534 KiB
Rust
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/mako/lib.rs.mako'
|
|
// DO NOT EDIT !
|
|
|
|
//! This documentation was generated from *calendar* crate version *0.1.0+20141123*, where *20141123* is the exact revision of the *calendar:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.0*.
|
|
//!
|
|
//! Everything else about the *calendar* *v3* API can be found at the
|
|
//! [official documentation site](https://developers.google.com/google-apps/calendar/firstapp).
|
|
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/calendar3).
|
|
//! # Features
|
|
//!
|
|
//! Handle the following *Resources* with ease from the central [hub](struct.CalendarHub.html) ...
|
|
//!
|
|
//! * [acl](struct.Acl.html)
|
|
//! * [*delete*](struct.AclDeleteCall.html), [*get*](struct.AclGetCall.html), [*insert*](struct.AclInsertCall.html), [*list*](struct.AclListCall.html), [*patch*](struct.AclPatchCall.html), [*update*](struct.AclUpdateCall.html) and [*watch*](struct.AclWatchCall.html)
|
|
//! * [calendar list](struct.CalendarList.html)
|
|
//! * [*delete*](struct.CalendarListDeleteCall.html), [*get*](struct.CalendarListGetCall.html), [*insert*](struct.CalendarListInsertCall.html), [*list*](struct.CalendarListListCall.html), [*patch*](struct.CalendarListPatchCall.html), [*update*](struct.CalendarListUpdateCall.html) and [*watch*](struct.CalendarListWatchCall.html)
|
|
//! * [calendars](struct.Calendar.html)
|
|
//! * [*clear*](struct.CalendarClearCall.html), [*delete*](struct.CalendarDeleteCall.html), [*get*](struct.CalendarGetCall.html), [*insert*](struct.CalendarInsertCall.html), [*patch*](struct.CalendarPatchCall.html) and [*update*](struct.CalendarUpdateCall.html)
|
|
//! * [channels](struct.Channel.html)
|
|
//! * [*stop*](struct.ChannelStopCall.html)
|
|
//! * colors
|
|
//! * [*get*](struct.ColorGetCall.html)
|
|
//! * [events](struct.Event.html)
|
|
//! * [*delete*](struct.EventDeleteCall.html), [*get*](struct.EventGetCall.html), [*import*](struct.EventImportCall.html), [*insert*](struct.EventInsertCall.html), [*instances*](struct.EventInstanceCall.html), [*list*](struct.EventListCall.html), [*move*](struct.EventMoveCall.html), [*patch*](struct.EventPatchCall.html), [*quick add*](struct.EventQuickAddCall.html), [*update*](struct.EventUpdateCall.html) and [*watch*](struct.EventWatchCall.html)
|
|
//! * freebusy
|
|
//! * [*query*](struct.FreebusyQueryCall.html)
|
|
//! * [settings](struct.Setting.html)
|
|
//! * [*get*](struct.SettingGetCall.html), [*list*](struct.SettingListCall.html) and [*watch*](struct.SettingWatchCall.html)
|
|
//!
|
|
//!
|
|
//! Subscription supported by ...
|
|
//!
|
|
//! * [*list settings*](struct.SettingListCall.html)
|
|
//! * [*list events*](struct.EventListCall.html)
|
|
//! * [*list calendar list*](struct.CalendarListListCall.html)
|
|
//! * [*watch events*](struct.EventWatchCall.html)
|
|
//! * [*instances events*](struct.EventInstanceCall.html)
|
|
//! * [*watch settings*](struct.SettingWatchCall.html)
|
|
//! * [*watch acl*](struct.AclWatchCall.html)
|
|
//! * [*list acl*](struct.AclListCall.html)
|
|
//! * [*watch calendar list*](struct.CalendarListWatchCall.html)
|
|
//!
|
|
//!
|
|
//!
|
|
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html).
|
|
//!
|
|
//! # Structure of this Library
|
|
//!
|
|
//! The API is structured into the following primary items:
|
|
//!
|
|
//! * **[Hub](struct.CalendarHub.html)**
|
|
//! * a central object to maintain state and allow accessing all *Activities*
|
|
//! * **[Resources](trait.Resource.html)**
|
|
//! * primary types that you can apply *Activities* to
|
|
//! * a collection of properties and *Parts*
|
|
//! * **[Parts](trait.Part.html)**
|
|
//! * a collection of properties
|
|
//! * never directly used in *Activities*
|
|
//! * **[Activities](trait.CallBuilder.html)**
|
|
//! * operations to apply to *Resources*
|
|
//!
|
|
//! Generally speaking, you can invoke *Activities* like this:
|
|
//!
|
|
//! ```Rust,ignore
|
|
//! let r = hub.resource().activity(...).doit()
|
|
//! ```
|
|
//!
|
|
//! Or specifically ...
|
|
//!
|
|
//! ```ignore
|
|
//! let r = hub.events().delete(...).doit()
|
|
//! let r = hub.events().insert(...).doit()
|
|
//! let r = hub.events().instances(...).doit()
|
|
//! let r = hub.events().quick_add(...).doit()
|
|
//! let r = hub.events().patch(...).doit()
|
|
//! let r = hub.events().import(...).doit()
|
|
//! let r = hub.events().move_(...).doit()
|
|
//! let r = hub.events().update(...).doit()
|
|
//! let r = hub.events().watch(...).doit()
|
|
//! let r = hub.events().get(...).doit()
|
|
//! let r = hub.events().list(...).doit()
|
|
//! ```
|
|
//!
|
|
//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
|
|
//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
|
|
//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
|
|
//! The `doit()` method performs the actual communication with the server and returns the respective result.
|
|
//!
|
|
//! # Usage
|
|
//!
|
|
//! ## Setting up your Project
|
|
//!
|
|
//! To use this library, you would put the following lines into your `Cargo.toml` file:
|
|
//!
|
|
//! ```toml
|
|
//! [dependencies]
|
|
//! google-calendar3 = "*"
|
|
//! ```
|
|
//!
|
|
//! ## A complete example
|
|
//!
|
|
//! ```test_harness,no_run
|
|
//! extern crate hyper;
|
|
//! extern crate "yup-oauth2" as oauth2;
|
|
//! extern crate "google-calendar3" as calendar3;
|
|
//! use calendar3::Channel;
|
|
//! use calendar3::Result;
|
|
//! # #[test] fn egal() {
|
|
//! use std::default::Default;
|
|
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
//! use calendar3::CalendarHub;
|
|
//!
|
|
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
//! // `client_secret`, among other things.
|
|
//! let secret: ApplicationSecret = Default::default();
|
|
//! // Instantiate the authenticator. It will choose a suitable authentication flow for you,
|
|
//! // unless you replace `None` with the desired Flow.
|
|
//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
|
|
//! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
|
|
//! // retrieve them from storage.
|
|
//! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
//! hyper::Client::new(),
|
|
//! <MemoryStorage as Default>::default(), None);
|
|
//! let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
//! // As the method needs a request, you would usually fill it with the desired information
|
|
//! // into the respective structure. Some of the parts shown here might not be applicable !
|
|
//! // Values shown here are possibly random and not representative !
|
|
//! let mut req: Channel = Default::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.events().watch(&req, "calendarId")
|
|
//! .updated_min("ea")
|
|
//! .time_zone("no")
|
|
//! .time_min("justo")
|
|
//! .time_max("justo")
|
|
//! .sync_token("et")
|
|
//! .single_events(true)
|
|
//! .show_hidden_invitations(true)
|
|
//! .show_deleted(false)
|
|
//! .add_shared_extended_property("Lorem")
|
|
//! .q("et")
|
|
//! .add_private_extended_property("duo")
|
|
//! .page_token("aliquyam")
|
|
//! .order_by("sea")
|
|
//! .max_results(-55)
|
|
//! .max_attendees(-75)
|
|
//! .i_cal_uid("erat")
|
|
//! .always_include_email(false)
|
|
//! .doit();
|
|
//!
|
|
//! match result {
|
|
//! Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
|
//! Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
|
//! Result::MissingToken => println!("OAuth2: Missing Token"),
|
|
//! Result::Cancelled => println!("Operation cancelled by user"),
|
|
//! Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
|
//! Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
|
//! Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
|
//! Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
|
//! Result::Success(_) => println!("Success (value doesn't print)"),
|
|
//! }
|
|
//! # }
|
|
//! ```
|
|
//! ## Handling Errors
|
|
//!
|
|
//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of
|
|
//! the doit() methods, or handed as possibly intermediate results to either the
|
|
//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../yup-oauth2/trait.AuthenticatorDelegate.html).
|
|
//!
|
|
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
|
//! makes the system potentially resilient to all kinds of errors.
|
|
//!
|
|
//! ## Uploads and Downlods
|
|
//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
|
|
//! read by you to obtain the media.
|
|
//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
|
|
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
|
|
//! this call: `.param("alt", "media")`.
|
|
//!
|
|
//! Methods supporting uploads can do so using up to 2 different protocols:
|
|
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
|
|
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
|
|
//!
|
|
//! ## Customization and Callbacks
|
|
//!
|
|
//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the
|
|
//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call.
|
|
//! Respective methods will be called to provide progress information, as well as determine whether the system should
|
|
//! retry on failure.
|
|
//!
|
|
//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
|
|
//!
|
|
//! ## Optional Parts in Server-Requests
|
|
//!
|
|
//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and
|
|
//! [decodable](trait.ResponseResult.html) via json. Optionals are used to indicate that partial requests are responses are valid.
|
|
//! Most optionals are are considered [Parts](trait.Part.html) which are identifyable by name, which will be sent to
|
|
//! the server to indicate either the set parts of the request or the desired parts in the response.
|
|
//!
|
|
//! ## Builder Arguments
|
|
//!
|
|
//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
|
|
//! These will always take a single argument, for which the following statements are true.
|
|
//!
|
|
//! * [PODs][wiki-pod] are handed by copy
|
|
//! * strings are passed as `&str`
|
|
//! * [request values](trait.RequestValue.html) are borrowed
|
|
//!
|
|
//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
|
|
//!
|
|
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
|
|
//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
|
|
//! [google-go-api]: https://github.com/google/google-api-go-client
|
|
//!
|
|
//!
|
|
#![feature(core,io,thread_sleep)]
|
|
// Unused attributes happen thanks to defined, but unused structures
|
|
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
|
|
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
|
// unused imports in fully featured APIs. Same with unused_mut ... .
|
|
#![allow(unused_imports, unused_mut, dead_code)]
|
|
// Required for serde annotations
|
|
#![feature(custom_derive, custom_attribute, plugin)]
|
|
#![plugin(serde_macros)]
|
|
|
|
#[macro_use]
|
|
extern crate hyper;
|
|
extern crate serde;
|
|
extern crate "yup-oauth2" as oauth2;
|
|
extern crate mime;
|
|
extern crate url;
|
|
|
|
mod cmn;
|
|
|
|
use std::collections::HashMap;
|
|
use std::cell::RefCell;
|
|
use std::borrow::BorrowMut;
|
|
use std::default::Default;
|
|
use std::collections::BTreeMap;
|
|
use std::marker::PhantomData;
|
|
use serde::json;
|
|
use std::io;
|
|
use std::fs;
|
|
use std::thread::sleep;
|
|
|
|
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, ResourceMethodsBuilder, Resource, JsonServerError};
|
|
|
|
|
|
// ##############
|
|
// 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 calendars
|
|
Readonly,
|
|
|
|
/// Manage your calendars
|
|
Full,
|
|
}
|
|
|
|
impl Str for Scope {
|
|
fn as_slice(&self) -> &str {
|
|
match *self {
|
|
Scope::Readonly => "https://www.googleapis.com/auth/calendar.readonly",
|
|
Scope::Full => "https://www.googleapis.com/auth/calendar",
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Scope {
|
|
fn default() -> Scope {
|
|
Scope::Readonly
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ########
|
|
// HUB ###
|
|
// ######
|
|
|
|
/// Central instance to access all CalendarHub related resource activities
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// Instantiate a new hub
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Channel;
|
|
/// use calendar3::Result;
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use calendar3::CalendarHub;
|
|
///
|
|
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
/// // `client_secret`, among other things.
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
|
|
/// // unless you replace `None` with the desired Flow.
|
|
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
|
|
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
|
|
/// // retrieve them from storage.
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Channel = Default::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.events().watch(&req, "calendarId")
|
|
/// .updated_min("eirmod")
|
|
/// .time_zone("elitr")
|
|
/// .time_min("amet")
|
|
/// .time_max("no")
|
|
/// .sync_token("labore")
|
|
/// .single_events(true)
|
|
/// .show_hidden_invitations(true)
|
|
/// .show_deleted(true)
|
|
/// .add_shared_extended_property("aliquyam")
|
|
/// .q("accusam")
|
|
/// .add_private_extended_property("Lorem")
|
|
/// .page_token("sea")
|
|
/// .order_by("et")
|
|
/// .max_results(-70)
|
|
/// .max_attendees(-21)
|
|
/// .i_cal_uid("eirmod")
|
|
/// .always_include_email(false)
|
|
/// .doit();
|
|
///
|
|
/// match result {
|
|
/// Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
|
/// Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
|
/// Result::MissingToken => println!("OAuth2: Missing Token"),
|
|
/// Result::Cancelled => println!("Operation cancelled by user"),
|
|
/// Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
|
/// Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
|
/// Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
|
/// Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
|
/// Result::Success(_) => println!("Success (value doesn't print)"),
|
|
/// }
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarHub<C, NC, A> {
|
|
client: RefCell<C>,
|
|
auth: RefCell<A>,
|
|
_user_agent: String,
|
|
|
|
_m: PhantomData<NC>
|
|
}
|
|
|
|
impl<'a, C, NC, A> Hub for CalendarHub<C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarHub<C, NC, A>
|
|
where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
pub fn new(client: C, authenticator: A) -> CalendarHub<C, NC, A> {
|
|
CalendarHub {
|
|
client: RefCell::new(client),
|
|
auth: RefCell::new(authenticator),
|
|
_user_agent: "google-api-rust-client/0.1.0".to_string(),
|
|
_m: PhantomData
|
|
}
|
|
}
|
|
|
|
pub fn acl(&'a self) -> AclMethods<'a, C, NC, A> {
|
|
AclMethods { hub: &self }
|
|
}
|
|
pub fn calendar_list(&'a self) -> CalendarListMethods<'a, C, NC, A> {
|
|
CalendarListMethods { hub: &self }
|
|
}
|
|
pub fn calendars(&'a self) -> CalendarMethods<'a, C, NC, A> {
|
|
CalendarMethods { hub: &self }
|
|
}
|
|
pub fn channels(&'a self) -> ChannelMethods<'a, C, NC, A> {
|
|
ChannelMethods { hub: &self }
|
|
}
|
|
pub fn colors(&'a self) -> ColorMethods<'a, C, NC, A> {
|
|
ColorMethods { hub: &self }
|
|
}
|
|
pub fn events(&'a self) -> EventMethods<'a, C, NC, A> {
|
|
EventMethods { hub: &self }
|
|
}
|
|
pub fn freebusy(&'a self) -> FreebusyMethods<'a, C, NC, A> {
|
|
FreebusyMethods { hub: &self }
|
|
}
|
|
pub fn settings(&'a self) -> SettingMethods<'a, C, NC, A> {
|
|
SettingMethods { hub: &self }
|
|
}
|
|
|
|
/// Set the user-agent header field to use in all requests to the server.
|
|
/// It defaults to `google-api-rust-client/0.1.0`.
|
|
///
|
|
/// Returns the previously set user-agent.
|
|
pub fn user_agent(&mut self, agent_name: String) -> String {
|
|
let prev = self._user_agent.clone();
|
|
self._user_agent = agent_name;
|
|
prev
|
|
}
|
|
}
|
|
|
|
|
|
// ############
|
|
// SCHEMAS ###
|
|
// ##########
|
|
/// A gadget that extends this event.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct EventGadget {
|
|
/// Preferences.
|
|
pub preferences: HashMap<String, String>,
|
|
/// The gadget's title.
|
|
pub title: String,
|
|
/// The gadget's height in pixels. Optional.
|
|
pub height: i32,
|
|
/// The gadget's width in pixels. Optional.
|
|
pub width: i32,
|
|
/// The gadget's URL.
|
|
pub link: String,
|
|
/// The gadget's type.
|
|
#[serde(alias="type")]
|
|
pub type_: String,
|
|
/// The gadget's display mode. Optional. Possible values are:
|
|
/// - "icon" - The gadget displays next to the event's title in the calendar view.
|
|
/// - "chip" - The gadget displays when the event is clicked.
|
|
pub display: String,
|
|
/// The gadget's icon URL.
|
|
#[serde(alias="iconLink")]
|
|
pub icon_link: String,
|
|
}
|
|
|
|
impl NestedType for EventGadget {}
|
|
impl Part for EventGadget {}
|
|
|
|
|
|
/// 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, Deserialize)]
|
|
pub struct FreeBusyCalendar {
|
|
/// List of time ranges during which this calendar should be regarded as busy.
|
|
pub busy: Vec<TimePeriod>,
|
|
/// Optional error(s) (if computation for the calendar failed).
|
|
pub errors: Vec<Error>,
|
|
}
|
|
|
|
impl Part for FreeBusyCalendar {}
|
|
|
|
|
|
/// The scope of the rule.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AclRuleScope {
|
|
/// The type of the scope. Possible values are:
|
|
/// - "default" - The public scope. This is the default value.
|
|
/// - "user" - Limits the scope to a single user.
|
|
/// - "group" - Limits the scope to a group.
|
|
/// - "domain" - Limits the scope to a domain. Note: The permissions granted to the "default", or public, scope apply to any user, authenticated or not.
|
|
#[serde(alias="type")]
|
|
pub type_: String,
|
|
/// The email address of a user or group, or the name of a domain, depending on the scope type. Omitted for type "default".
|
|
pub value: String,
|
|
}
|
|
|
|
impl NestedType for AclRuleScope {}
|
|
impl Part for AclRuleScope {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [list settings](struct.SettingListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct Settings {
|
|
/// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
|
|
#[serde(alias="nextPageToken")]
|
|
pub next_page_token: String,
|
|
/// List of user settings.
|
|
pub items: Vec<Setting>,
|
|
/// Type of the collection ("calendar#settings").
|
|
pub kind: String,
|
|
/// Etag of the collection.
|
|
pub etag: String,
|
|
/// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided.
|
|
#[serde(alias="nextSyncToken")]
|
|
pub next_sync_token: String,
|
|
}
|
|
|
|
impl ResponseResult for Settings {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [clear calendars](struct.CalendarClearCall.html) (none)
|
|
/// * [get calendars](struct.CalendarGetCall.html) (response)
|
|
/// * [update calendars](struct.CalendarUpdateCall.html) (request|response)
|
|
/// * [patch calendars](struct.CalendarPatchCall.html) (request|response)
|
|
/// * [insert calendars](struct.CalendarInsertCall.html) (request|response)
|
|
/// * [delete calendars](struct.CalendarDeleteCall.html) (none)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Calendar {
|
|
/// Type of the resource ("calendar#calendar").
|
|
pub kind: Option<String>,
|
|
/// ETag of the resource.
|
|
pub etag: Option<String>,
|
|
/// Description of the calendar. Optional.
|
|
pub description: Option<String>,
|
|
/// Identifier of the calendar.
|
|
pub id: Option<String>,
|
|
/// The time zone of the calendar. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) Optional.
|
|
#[serde(alias="timeZone")]
|
|
pub time_zone: Option<String>,
|
|
/// Geographic location of the calendar as free-form text. Optional.
|
|
pub location: Option<String>,
|
|
/// Title of the calendar.
|
|
pub summary: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for Calendar {}
|
|
impl Resource for Calendar {}
|
|
impl ResponseResult for Calendar {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [get calendar list](struct.CalendarListGetCall.html) (response)
|
|
/// * [update calendar list](struct.CalendarListUpdateCall.html) (request|response)
|
|
/// * [patch calendar list](struct.CalendarListPatchCall.html) (request|response)
|
|
/// * [insert calendar list](struct.CalendarListInsertCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CalendarListEntry {
|
|
/// The notifications that the authenticated user is receiving for this calendar.
|
|
#[serde(alias="notificationSettings")]
|
|
pub notification_settings: Option<CalendarListEntryNotificationSettings>,
|
|
/// Description of the calendar. Optional. Read-only.
|
|
pub description: Option<String>,
|
|
/// Whether this calendar list entry has been deleted from the calendar list. Read-only. Optional. The default is False.
|
|
pub deleted: Option<bool>,
|
|
/// Whether the calendar is the primary calendar of the authenticated user. Read-only. Optional. The default is False.
|
|
pub primary: Option<bool>,
|
|
/// The effective access role that the authenticated user has on the calendar. Read-only. Possible values are:
|
|
/// - "freeBusyReader" - Provides read access to free/busy information.
|
|
/// - "reader" - Provides read access to the calendar. Private events will appear to users with reader access, but event details will be hidden.
|
|
/// - "writer" - Provides read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible.
|
|
/// - "owner" - Provides ownership of the calendar. This role has all of the permissions of the writer role with the additional ability to see and manipulate ACLs.
|
|
#[serde(alias="accessRole")]
|
|
pub access_role: Option<String>,
|
|
/// Identifier of the calendar.
|
|
pub id: Option<String>,
|
|
/// Type of the resource ("calendar#calendarListEntry").
|
|
pub kind: Option<String>,
|
|
/// The foreground color of the calendar in the hexadecimal format "#ffffff". This property supersedes the index-based colorId property. Optional.
|
|
#[serde(alias="foregroundColor")]
|
|
pub foreground_color: Option<String>,
|
|
/// The default reminders that the authenticated user has for this calendar.
|
|
#[serde(alias="defaultReminders")]
|
|
pub default_reminders: Option<Vec<EventReminder>>,
|
|
/// The color of the calendar. This is an ID referring to an entry in the calendar section of the colors definition (see the colors endpoint). Optional.
|
|
#[serde(alias="colorId")]
|
|
pub color_id: Option<String>,
|
|
/// Whether the calendar content shows up in the calendar UI. Optional. The default is False.
|
|
pub selected: Option<bool>,
|
|
/// Title of the calendar. Read-only.
|
|
pub summary: Option<String>,
|
|
/// ETag of the resource.
|
|
pub etag: Option<String>,
|
|
/// Geographic location of the calendar as free-form text. Optional. Read-only.
|
|
pub location: Option<String>,
|
|
/// The main color of the calendar in the hexadecimal format "#0088aa". This property supersedes the index-based colorId property. Optional.
|
|
#[serde(alias="backgroundColor")]
|
|
pub background_color: Option<String>,
|
|
/// The summary that the authenticated user has set for this calendar. Optional.
|
|
#[serde(alias="summaryOverride")]
|
|
pub summary_override: Option<String>,
|
|
/// The time zone of the calendar. Optional. Read-only.
|
|
#[serde(alias="timeZone")]
|
|
pub time_zone: Option<String>,
|
|
/// Whether the calendar has been hidden from the list. Optional. The default is False.
|
|
pub hidden: Option<bool>,
|
|
}
|
|
|
|
impl RequestValue for CalendarListEntry {}
|
|
impl ResponseResult for CalendarListEntry {}
|
|
|
|
|
|
/// The notifications that the authenticated user is receiving for this calendar.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CalendarListEntryNotificationSettings {
|
|
/// The list of notifications set for this calendar.
|
|
pub notifications: Vec<CalendarNotification>,
|
|
}
|
|
|
|
impl NestedType for CalendarListEntryNotificationSettings {}
|
|
impl Part for CalendarListEntryNotificationSettings {}
|
|
|
|
|
|
/// 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, Deserialize)]
|
|
pub struct ColorDefinition {
|
|
/// The foreground color that can be used to write on top of a background with 'background' color.
|
|
pub foreground: String,
|
|
/// The background color associated with this color definition.
|
|
pub background: String,
|
|
}
|
|
|
|
impl Part for ColorDefinition {}
|
|
|
|
|
|
/// 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 EventDateTime {
|
|
/// The date, in the format "yyyy-mm-dd", if this is an all-day event.
|
|
pub date: String,
|
|
/// The time zone in which the time is specified. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) For recurring events this field is required and specifies the time zone in which the recurrence is expanded. For single events this field is optional and indicates a custom time zone for the event start/end.
|
|
#[serde(alias="timeZone")]
|
|
pub time_zone: String,
|
|
/// The time, as a combined date-time value (formatted according to RFC 3339). A time zone offset is required unless a time zone is explicitly specified in timeZone.
|
|
#[serde(alias="dateTime")]
|
|
pub date_time: String,
|
|
}
|
|
|
|
impl Part for EventDateTime {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [list settings](struct.SettingListCall.html) (none)
|
|
/// * [watch settings](struct.SettingWatchCall.html) (none)
|
|
/// * [get settings](struct.SettingGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct Setting {
|
|
/// Type of the resource ("calendar#setting").
|
|
pub kind: String,
|
|
/// ETag of the resource.
|
|
pub etag: String,
|
|
/// The id of the user setting.
|
|
pub id: String,
|
|
/// Value of the user setting. The format of the value depends on the ID of the setting. It must always be a UTF-8 string of length up to 1024 characters.
|
|
pub value: String,
|
|
}
|
|
|
|
impl Resource for Setting {}
|
|
impl ResponseResult for Setting {}
|
|
|
|
|
|
/// The creator of the event. Read-only.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct EventCreator {
|
|
/// Whether the creator corresponds to the calendar on which this copy of the event appears. Read-only. The default is False.
|
|
#[serde(alias="self")]
|
|
pub self_: bool,
|
|
/// The creator's name, if available.
|
|
#[serde(alias="displayName")]
|
|
pub display_name: String,
|
|
/// The creator's email address, if available.
|
|
pub email: String,
|
|
/// The creator's Profile ID, if available.
|
|
pub id: String,
|
|
}
|
|
|
|
impl NestedType for EventCreator {}
|
|
impl Part for EventCreator {}
|
|
|
|
|
|
/// 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, Deserialize)]
|
|
pub struct Error {
|
|
/// Domain, or broad category, of the error.
|
|
pub domain: String,
|
|
/// Specific reason for the error. Some of the possible values are:
|
|
/// - "groupTooBig" - The group of users requested is too large for a single query.
|
|
/// - "tooManyCalendarsRequested" - The number of calendars requested is too large for a single query.
|
|
/// - "notFound" - The requested resource was not found.
|
|
/// - "internalError" - The API service has encountered an internal error. Additional error types may be added in the future, so clients should gracefully handle additional error statuses not included in this list.
|
|
pub reason: String,
|
|
}
|
|
|
|
impl Part for Error {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [patch acl](struct.AclPatchCall.html) (request|response)
|
|
/// * [update acl](struct.AclUpdateCall.html) (request|response)
|
|
/// * [get acl](struct.AclGetCall.html) (response)
|
|
/// * [insert acl](struct.AclInsertCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AclRule {
|
|
/// The scope of the rule.
|
|
pub scope: Option<AclRuleScope>,
|
|
/// Type of the resource ("calendar#aclRule").
|
|
pub kind: Option<String>,
|
|
/// ETag of the resource.
|
|
pub etag: Option<String>,
|
|
/// The role assigned to the scope. Possible values are:
|
|
/// - "none" - Provides no access.
|
|
/// - "freeBusyReader" - Provides read access to free/busy information.
|
|
/// - "reader" - Provides read access to the calendar. Private events will appear to users with reader access, but event details will be hidden.
|
|
/// - "writer" - Provides read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible.
|
|
/// - "owner" - Provides ownership of the calendar. This role has all of the permissions of the writer role with the additional ability to see and manipulate ACLs.
|
|
pub role: Option<String>,
|
|
/// Identifier of the ACL rule.
|
|
pub id: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for AclRule {}
|
|
impl ResponseResult for AclRule {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [list acl](struct.AclListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct Acl {
|
|
/// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
|
|
#[serde(alias="nextPageToken")]
|
|
pub next_page_token: String,
|
|
/// List of rules on the access control list.
|
|
pub items: Vec<AclRule>,
|
|
/// Type of the collection ("calendar#acl").
|
|
pub kind: String,
|
|
/// ETag of the collection.
|
|
pub etag: String,
|
|
/// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided.
|
|
#[serde(alias="nextSyncToken")]
|
|
pub next_sync_token: String,
|
|
}
|
|
|
|
impl ResponseResult for Acl {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [instances events](struct.EventInstanceCall.html) (response)
|
|
/// * [list events](struct.EventListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct Events {
|
|
/// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
|
|
#[serde(alias="nextPageToken")]
|
|
pub next_page_token: String,
|
|
/// Type of the collection ("calendar#events").
|
|
pub kind: String,
|
|
/// The default reminders on the calendar for the authenticated user. These reminders apply to all events on this calendar that do not explicitly override them (i.e. do not have reminders.useDefault set to True).
|
|
#[serde(alias="defaultReminders")]
|
|
pub default_reminders: Vec<EventReminder>,
|
|
/// Description of the calendar. Read-only.
|
|
pub description: String,
|
|
/// List of events on the calendar.
|
|
pub items: Vec<Event>,
|
|
/// Last modification time of the calendar (as a RFC 3339 timestamp). Read-only.
|
|
pub updated: String,
|
|
/// Title of the calendar. Read-only.
|
|
pub summary: String,
|
|
/// ETag of the collection.
|
|
pub etag: String,
|
|
/// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided.
|
|
#[serde(alias="nextSyncToken")]
|
|
pub next_sync_token: String,
|
|
/// The time zone of the calendar. Read-only.
|
|
#[serde(alias="timeZone")]
|
|
pub time_zone: String,
|
|
/// The user's access role for this calendar. Read-only. Possible values are:
|
|
/// - "none" - The user has no access.
|
|
/// - "freeBusyReader" - The user has read access to free/busy information.
|
|
/// - "reader" - The user has read access to the calendar. Private events will appear to users with reader access, but event details will be hidden.
|
|
/// - "writer" - The user has read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible.
|
|
/// - "owner" - The user has ownership of the calendar. This role has all of the permissions of the writer role with the additional ability to see and manipulate ACLs.
|
|
#[serde(alias="accessRole")]
|
|
pub access_role: String,
|
|
}
|
|
|
|
impl ResponseResult for Events {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [stop channels](struct.ChannelStopCall.html) (request)
|
|
/// * [watch settings](struct.SettingWatchCall.html) (request|response)
|
|
/// * [watch acl](struct.AclWatchCall.html) (request|response)
|
|
/// * [watch calendar list](struct.CalendarListWatchCall.html) (request|response)
|
|
/// * [watch events](struct.EventWatchCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Channel {
|
|
/// A version-specific identifier for the watched resource.
|
|
#[serde(alias="resourceUri")]
|
|
pub resource_uri: Option<String>,
|
|
/// Identifies this as a notification channel used to watch for changes to a resource. Value: the fixed string "api#channel".
|
|
pub kind: Option<String>,
|
|
/// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.
|
|
#[serde(alias="resourceId")]
|
|
pub resource_id: Option<String>,
|
|
/// A UUID or similar unique string that identifies this channel.
|
|
pub id: Option<String>,
|
|
/// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.
|
|
pub token: Option<String>,
|
|
/// Additional parameters controlling delivery channel behavior. Optional.
|
|
pub params: Option<HashMap<String, String>>,
|
|
/// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.
|
|
pub expiration: Option<String>,
|
|
/// The address where notifications are delivered for this channel.
|
|
pub address: Option<String>,
|
|
/// The type of delivery mechanism used for this channel.
|
|
#[serde(alias="type")]
|
|
pub type_: Option<String>,
|
|
/// A Boolean value to indicate whether payload is wanted. Optional.
|
|
pub payload: Option<bool>,
|
|
}
|
|
|
|
impl RequestValue for Channel {}
|
|
impl Resource for Channel {}
|
|
impl ResponseResult for Channel {}
|
|
|
|
|
|
/// 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 EventAttendee {
|
|
/// The attendee's response comment. Optional.
|
|
pub comment: String,
|
|
/// The attendee's name, if available. Optional.
|
|
#[serde(alias="displayName")]
|
|
pub display_name: String,
|
|
/// Whether this entry represents the calendar on which this copy of the event appears. Read-only. The default is False.
|
|
#[serde(alias="self")]
|
|
pub self_: bool,
|
|
/// The attendee's email address, if available. This field must be present when adding an attendee.
|
|
pub email: String,
|
|
/// The attendee's Profile ID, if available.
|
|
pub id: String,
|
|
/// Number of additional guests. Optional. The default is 0.
|
|
#[serde(alias="additionalGuests")]
|
|
pub additional_guests: i32,
|
|
/// Whether the attendee is a resource. Read-only. The default is False.
|
|
pub resource: bool,
|
|
/// Whether the attendee is the organizer of the event. Read-only. The default is False.
|
|
pub organizer: bool,
|
|
/// Whether this is an optional attendee. Optional. The default is False.
|
|
pub optional: bool,
|
|
/// The attendee's response status. Possible values are:
|
|
/// - "needsAction" - The attendee has not responded to the invitation.
|
|
/// - "declined" - The attendee has declined the invitation.
|
|
/// - "tentative" - The attendee has tentatively accepted the invitation.
|
|
/// - "accepted" - The attendee has accepted the invitation.
|
|
#[serde(alias="responseStatus")]
|
|
pub response_status: String,
|
|
}
|
|
|
|
impl Part for EventAttendee {}
|
|
|
|
|
|
/// 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, Deserialize)]
|
|
pub struct FreeBusyGroup {
|
|
/// Optional error(s) (if computation for the group failed).
|
|
pub errors: Vec<Error>,
|
|
/// List of calendars' identifiers within a group.
|
|
pub calendars: Vec<String>,
|
|
}
|
|
|
|
impl Part for FreeBusyGroup {}
|
|
|
|
|
|
/// Information about the event's reminders for the authenticated 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 EventReminders {
|
|
/// If the event doesn't use the default reminders, this lists the reminders specific to the event, or, if not set, indicates that no reminders are set for this event.
|
|
pub overrides: Vec<EventReminder>,
|
|
/// Whether the default reminders of the calendar apply to the event.
|
|
#[serde(alias="useDefault")]
|
|
pub use_default: bool,
|
|
}
|
|
|
|
impl NestedType for EventReminders {}
|
|
impl Part for EventReminders {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [list calendar list](struct.CalendarListListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct CalendarList {
|
|
/// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
|
|
#[serde(alias="nextPageToken")]
|
|
pub next_page_token: String,
|
|
/// Calendars that are present on the user's calendar list.
|
|
pub items: Vec<CalendarListEntry>,
|
|
/// Type of the collection ("calendar#calendarList").
|
|
pub kind: String,
|
|
/// ETag of the collection.
|
|
pub etag: String,
|
|
/// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided.
|
|
#[serde(alias="nextSyncToken")]
|
|
pub next_sync_token: String,
|
|
}
|
|
|
|
impl ResponseResult for CalendarList {}
|
|
|
|
|
|
/// Extended properties of the event.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct EventExtendedProperties {
|
|
/// Properties that are shared between copies of the event on other attendees' calendars.
|
|
pub shared: HashMap<String, String>,
|
|
/// Properties that are private to the copy of the event that appears on this calendar.
|
|
pub private: HashMap<String, String>,
|
|
}
|
|
|
|
impl NestedType for EventExtendedProperties {}
|
|
impl Part for EventExtendedProperties {}
|
|
|
|
|
|
/// 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)]
|
|
pub struct FreeBusyRequestItem {
|
|
/// The identifier of a calendar or a group.
|
|
pub id: String,
|
|
}
|
|
|
|
impl Part for FreeBusyRequestItem {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [query freebusy](struct.FreebusyQueryCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct FreeBusyResponse {
|
|
/// The end of the interval.
|
|
#[serde(alias="timeMax")]
|
|
pub time_max: String,
|
|
/// Type of the resource ("calendar#freeBusy").
|
|
pub kind: String,
|
|
/// List of free/busy information for calendars.
|
|
pub calendars: HashMap<String, FreeBusyCalendar>,
|
|
/// Expansion of groups.
|
|
pub groups: HashMap<String, FreeBusyGroup>,
|
|
/// The start of the interval.
|
|
#[serde(alias="timeMin")]
|
|
pub time_min: String,
|
|
}
|
|
|
|
impl ResponseResult for FreeBusyResponse {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [get colors](struct.ColorGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct Colors {
|
|
/// Palette of calendar colors, mapping from the color ID to its definition. A calendarListEntry resource refers to one of these color IDs in its color field. Read-only.
|
|
pub calendar: HashMap<String, ColorDefinition>,
|
|
/// Last modification time of the color palette (as a RFC 3339 timestamp). Read-only.
|
|
pub updated: String,
|
|
/// Type of the resource ("calendar#colors").
|
|
pub kind: String,
|
|
/// Palette of event colors, mapping from the color ID to its definition. An event resource may refer to one of these color IDs in its color field. Read-only.
|
|
pub event: HashMap<String, ColorDefinition>,
|
|
}
|
|
|
|
impl ResponseResult for Colors {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [query freebusy](struct.FreebusyQueryCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize)]
|
|
pub struct FreeBusyRequest {
|
|
/// Maximal number of calendars for which FreeBusy information is to be provided. Optional.
|
|
#[serde(alias="calendarExpansionMax")]
|
|
pub calendar_expansion_max: Option<i32>,
|
|
/// The start of the interval for the query.
|
|
#[serde(alias="timeMin")]
|
|
pub time_min: Option<String>,
|
|
/// Maximal number of calendar identifiers to be provided for a single group. Optional. An error will be returned for a group with more members than this value.
|
|
#[serde(alias="groupExpansionMax")]
|
|
pub group_expansion_max: Option<i32>,
|
|
/// The end of the interval for the query.
|
|
#[serde(alias="timeMax")]
|
|
pub time_max: Option<String>,
|
|
/// List of calendars and/or groups to query.
|
|
pub items: Option<Vec<FreeBusyRequestItem>>,
|
|
/// Time zone used in the response. Optional. The default is UTC.
|
|
#[serde(alias="timeZone")]
|
|
pub time_zone: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for FreeBusyRequest {}
|
|
|
|
|
|
/// Source of an event from which it was created; for example a web page, an email message or any document identifiable by an URL using HTTP/HTTPS protocol. Accessible only by the creator of the event.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct EventSource {
|
|
/// URL of the source pointing to a resource. URL's protocol must be HTTP or HTTPS.
|
|
pub url: String,
|
|
/// Title of the source; for example a title of a web page or an email subject.
|
|
pub title: String,
|
|
}
|
|
|
|
impl NestedType for EventSource {}
|
|
impl Part for EventSource {}
|
|
|
|
|
|
/// The organizer of the event. If the organizer is also an attendee, this is indicated with a separate entry in attendees with the organizer field set to True. To change the organizer, use the move operation. Read-only, except when importing an event.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct EventOrganizer {
|
|
/// Whether the organizer corresponds to the calendar on which this copy of the event appears. Read-only. The default is False.
|
|
#[serde(alias="self")]
|
|
pub self_: bool,
|
|
/// The organizer's name, if available.
|
|
#[serde(alias="displayName")]
|
|
pub display_name: String,
|
|
/// The organizer's email address, if available.
|
|
pub email: String,
|
|
/// The organizer's Profile ID, if available.
|
|
pub id: String,
|
|
}
|
|
|
|
impl NestedType for EventOrganizer {}
|
|
impl Part for EventOrganizer {}
|
|
|
|
|
|
/// 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 EventReminder {
|
|
/// Number of minutes before the start of the event when the reminder should trigger.
|
|
pub minutes: i32,
|
|
/// The method used by this reminder. Possible values are:
|
|
/// - "email" - Reminders are sent via email.
|
|
/// - "sms" - Reminders are sent via SMS.
|
|
/// - "popup" - Reminders are sent via a UI popup.
|
|
pub method: String,
|
|
}
|
|
|
|
impl Part for EventReminder {}
|
|
|
|
|
|
/// 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, Deserialize)]
|
|
pub struct TimePeriod {
|
|
/// The (inclusive) start of the time period.
|
|
pub start: String,
|
|
/// The (exclusive) end of the time period.
|
|
pub end: String,
|
|
}
|
|
|
|
impl Part for TimePeriod {}
|
|
|
|
|
|
/// 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 CalendarNotification {
|
|
/// The type of notification. Possible values are:
|
|
/// - "eventCreation" - Notification sent when a new event is put on the calendar.
|
|
/// - "eventChange" - Notification sent when an event is changed.
|
|
/// - "eventCancellation" - Notification sent when an event is cancelled.
|
|
/// - "eventResponse" - Notification sent when an event is changed.
|
|
/// - "agenda" - An agenda with the events of the day (sent out in the morning).
|
|
#[serde(alias="type")]
|
|
pub type_: String,
|
|
/// The method used to deliver the notification. Possible values are:
|
|
/// - "email" - Reminders are sent via email.
|
|
/// - "sms" - Reminders are sent via SMS. This value is read-only and is ignored on inserts and updates.
|
|
pub method: String,
|
|
}
|
|
|
|
impl Part for CalendarNotification {}
|
|
|
|
|
|
/// There is no detailed description.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [delete events](struct.EventDeleteCall.html) (none)
|
|
/// * [insert events](struct.EventInsertCall.html) (request|response)
|
|
/// * [instances events](struct.EventInstanceCall.html) (none)
|
|
/// * [quick add events](struct.EventQuickAddCall.html) (response)
|
|
/// * [patch events](struct.EventPatchCall.html) (request|response)
|
|
/// * [import events](struct.EventImportCall.html) (request|response)
|
|
/// * [move events](struct.EventMoveCall.html) (response)
|
|
/// * [update events](struct.EventUpdateCall.html) (request|response)
|
|
/// * [watch events](struct.EventWatchCall.html) (none)
|
|
/// * [get events](struct.EventGetCall.html) (response)
|
|
/// * [list events](struct.EventListCall.html) (none)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Event {
|
|
/// The creator of the event. Read-only.
|
|
pub creator: Option<EventCreator>,
|
|
/// The organizer of the event. If the organizer is also an attendee, this is indicated with a separate entry in attendees with the organizer field set to True. To change the organizer, use the move operation. Read-only, except when importing an event.
|
|
pub organizer: Option<EventOrganizer>,
|
|
/// Identifier of the event. When creating new single or recurring events, you can specify their IDs. Provided IDs must follow these rules:
|
|
/// - characters allowed in the ID are those used in base32hex encoding, i.e. lowercase letters a-v and digits 0-9, see section 3.1.2 in RFC2938
|
|
/// - the length of the ID must be between 5 and 1024 characters
|
|
/// - the ID must be unique per calendar Due to the globally distributed nature of the system, we cannot guarantee that ID collisions will be detected at event creation time. To minimize the risk of collisions we recommend using an established UUID algorithm such as one described in RFC4122.
|
|
pub id: Option<String>,
|
|
/// An absolute link to the Google+ hangout associated with this event. Read-only.
|
|
#[serde(alias="hangoutLink")]
|
|
pub hangout_link: Option<String>,
|
|
/// Whether attendees other than the organizer can invite others to the event. Optional. The default is True.
|
|
#[serde(alias="guestsCanInviteOthers")]
|
|
pub guests_can_invite_others: Option<bool>,
|
|
/// The attendees of the event.
|
|
pub attendees: Option<Vec<EventAttendee>>,
|
|
/// The (inclusive) start time of the event. For a recurring event, this is the start time of the first instance.
|
|
pub start: Option<EventDateTime>,
|
|
/// An absolute link to this event in the Google Calendar Web UI. Read-only.
|
|
#[serde(alias="htmlLink")]
|
|
pub html_link: Option<String>,
|
|
/// List of RRULE, EXRULE, RDATE and EXDATE lines for a recurring event. This field is omitted for single events or instances of recurring events.
|
|
pub recurrence: Option<Vec<String>>,
|
|
/// Source of an event from which it was created; for example a web page, an email message or any document identifiable by an URL using HTTP/HTTPS protocol. Accessible only by the creator of the event.
|
|
pub source: Option<EventSource>,
|
|
/// ETag of the resource.
|
|
pub etag: Option<String>,
|
|
/// Geographic location of the event as free-form text. Optional.
|
|
pub location: Option<String>,
|
|
/// For an instance of a recurring event, this is the event ID of the recurring event itself. Immutable.
|
|
#[serde(alias="recurringEventId")]
|
|
pub recurring_event_id: Option<String>,
|
|
/// For an instance of a recurring event, this is the time at which this event would start according to the recurrence data in the recurring event identified by recurringEventId. Immutable.
|
|
#[serde(alias="originalStartTime")]
|
|
pub original_start_time: Option<EventDateTime>,
|
|
/// Status of the event. Optional. Possible values are:
|
|
/// - "confirmed" - The event is confirmed. This is the default status.
|
|
/// - "tentative" - The event is tentatively confirmed.
|
|
/// - "cancelled" - The event is cancelled.
|
|
pub status: Option<String>,
|
|
/// Last modification time of the event (as a RFC 3339 timestamp). Read-only.
|
|
pub updated: Option<String>,
|
|
/// Description of the event. Optional.
|
|
pub description: Option<String>,
|
|
/// Event ID in the iCalendar format.
|
|
#[serde(alias="iCalUID")]
|
|
pub i_cal_uid: Option<String>,
|
|
/// A gadget that extends this event.
|
|
pub gadget: Option<EventGadget>,
|
|
/// Whether the end time is actually unspecified. An end time is still provided for compatibility reasons, even if this attribute is set to True. The default is False.
|
|
#[serde(alias="endTimeUnspecified")]
|
|
pub end_time_unspecified: Option<bool>,
|
|
/// Sequence number as per iCalendar.
|
|
pub sequence: Option<i32>,
|
|
/// Visibility of the event. Optional. Possible values are:
|
|
/// - "default" - Uses the default visibility for events on the calendar. This is the default value.
|
|
/// - "public" - The event is public and event details are visible to all readers of the calendar.
|
|
/// - "private" - The event is private and only event attendees may view event details.
|
|
/// - "confidential" - The event is private. This value is provided for compatibility reasons.
|
|
pub visibility: Option<String>,
|
|
/// Whether attendees other than the organizer can modify the event. Optional. The default is False.
|
|
#[serde(alias="guestsCanModify")]
|
|
pub guests_can_modify: Option<bool>,
|
|
/// The (exclusive) end time of the event. For a recurring event, this is the end time of the first instance.
|
|
pub end: Option<EventDateTime>,
|
|
/// Whether attendees may have been omitted from the event's representation. When retrieving an event, this may be due to a restriction specified by the maxAttendee query parameter. When updating an event, this can be used to only update the participant's response. Optional. The default is False.
|
|
#[serde(alias="attendeesOmitted")]
|
|
pub attendees_omitted: Option<bool>,
|
|
/// Type of the resource ("calendar#event").
|
|
pub kind: Option<String>,
|
|
/// Whether this is a locked event copy where no changes can be made to the main event fields "summary", "description", "location", "start", "end" or "recurrence". The default is False. Read-Only.
|
|
pub locked: Option<bool>,
|
|
/// Creation time of the event (as a RFC 3339 timestamp). Read-only.
|
|
pub created: Option<String>,
|
|
/// The color of the event. This is an ID referring to an entry in the event section of the colors definition (see the colors endpoint). Optional.
|
|
#[serde(alias="colorId")]
|
|
pub color_id: Option<String>,
|
|
/// Whether anyone can invite themselves to the event. Optional. The default is False.
|
|
#[serde(alias="anyoneCanAddSelf")]
|
|
pub anyone_can_add_self: Option<bool>,
|
|
/// Information about the event's reminders for the authenticated user.
|
|
pub reminders: Option<EventReminders>,
|
|
/// Whether attendees other than the organizer can see who the event's attendees are. Optional. The default is True.
|
|
#[serde(alias="guestsCanSeeOtherGuests")]
|
|
pub guests_can_see_other_guests: Option<bool>,
|
|
/// Title of the event.
|
|
pub summary: Option<String>,
|
|
/// Extended properties of the event.
|
|
#[serde(alias="extendedProperties")]
|
|
pub extended_properties: Option<EventExtendedProperties>,
|
|
/// Whether the event blocks time on the calendar. Optional. Possible values are:
|
|
/// - "opaque" - The event blocks time on the calendar. This is the default value.
|
|
/// - "transparent" - The event does not block time on the calendar.
|
|
pub transparency: Option<String>,
|
|
/// Whether this is a private event copy where changes are not shared with other copies on other calendars. Optional. Immutable. The default is False.
|
|
#[serde(alias="privateCopy")]
|
|
pub private_copy: Option<bool>,
|
|
}
|
|
|
|
impl RequestValue for Event {}
|
|
impl Resource for Event {}
|
|
impl ResponseResult for Event {}
|
|
|
|
|
|
|
|
// ###################
|
|
// MethodBuilders ###
|
|
// #################
|
|
|
|
/// A builder providing access to all methods supported on *freebusy* resources.
|
|
/// It is not used directly, but through the `CalendarHub` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-calendar3" as calendar3;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use calendar3::CalendarHub;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `query(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.freebusy();
|
|
/// # }
|
|
/// ```
|
|
pub struct FreebusyMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> ResourceMethodsBuilder for FreebusyMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> FreebusyMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns free/busy information for a set of calendars.
|
|
pub fn query(&self, request: &FreeBusyRequest) -> FreebusyQueryCall<'a, C, NC, A> {
|
|
FreebusyQueryCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *setting* resources.
|
|
/// It is not used directly, but through the `CalendarHub` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-calendar3" as calendar3;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use calendar3::CalendarHub;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `get(...)`, `list(...)` and `watch(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.settings();
|
|
/// # }
|
|
/// ```
|
|
pub struct SettingMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> ResourceMethodsBuilder for SettingMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> SettingMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns all user settings for the authenticated user.
|
|
pub fn list(&self) -> SettingListCall<'a, C, NC, A> {
|
|
SettingListCall {
|
|
hub: self.hub,
|
|
_sync_token: Default::default(),
|
|
_page_token: Default::default(),
|
|
_max_results: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Watch for changes to Settings resources.
|
|
pub fn watch(&self, request: &Channel) -> SettingWatchCall<'a, C, NC, A> {
|
|
SettingWatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_sync_token: Default::default(),
|
|
_page_token: Default::default(),
|
|
_max_results: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns a single user setting.
|
|
pub fn get(&self, setting: &str) -> SettingGetCall<'a, C, NC, A> {
|
|
SettingGetCall {
|
|
hub: self.hub,
|
|
_setting: setting.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *calendarList* resources.
|
|
/// It is not used directly, but through the `CalendarHub` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-calendar3" as calendar3;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use calendar3::CalendarHub;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `update(...)` and `watch(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.calendar_list();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarListMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> ResourceMethodsBuilder for CalendarListMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarListMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates an entry on the user's calendar list.
|
|
pub fn update(&self, request: &CalendarListEntry, calendar_id: &str) -> CalendarListUpdateCall<'a, C, NC, A> {
|
|
CalendarListUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_color_rgb_format: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes an entry on the user's calendar list.
|
|
pub fn delete(&self, calendar_id: &str) -> CalendarListDeleteCall<'a, C, NC, A> {
|
|
CalendarListDeleteCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns an entry on the user's calendar list.
|
|
pub fn get(&self, calendar_id: &str) -> CalendarListGetCall<'a, C, NC, A> {
|
|
CalendarListGetCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns entries on the user's calendar list.
|
|
pub fn list(&self) -> CalendarListListCall<'a, C, NC, A> {
|
|
CalendarListListCall {
|
|
hub: self.hub,
|
|
_sync_token: Default::default(),
|
|
_show_hidden: Default::default(),
|
|
_show_deleted: Default::default(),
|
|
_page_token: Default::default(),
|
|
_min_access_role: Default::default(),
|
|
_max_results: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Adds an entry to the user's calendar list.
|
|
pub fn insert(&self, request: &CalendarListEntry) -> CalendarListInsertCall<'a, C, NC, A> {
|
|
CalendarListInsertCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_color_rgb_format: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates an entry on the user's calendar list. This method supports patch semantics.
|
|
pub fn patch(&self, request: &CalendarListEntry, calendar_id: &str) -> CalendarListPatchCall<'a, C, NC, A> {
|
|
CalendarListPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_color_rgb_format: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Watch for changes to CalendarList resources.
|
|
pub fn watch(&self, request: &Channel) -> CalendarListWatchCall<'a, C, NC, A> {
|
|
CalendarListWatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_sync_token: Default::default(),
|
|
_show_hidden: Default::default(),
|
|
_show_deleted: Default::default(),
|
|
_page_token: Default::default(),
|
|
_min_access_role: Default::default(),
|
|
_max_results: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *calendar* resources.
|
|
/// It is not used directly, but through the `CalendarHub` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-calendar3" as calendar3;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use calendar3::CalendarHub;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `clear(...)`, `delete(...)`, `get(...)`, `insert(...)`, `patch(...)` and `update(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.calendars();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> ResourceMethodsBuilder for CalendarMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates metadata for a calendar. This method supports patch semantics.
|
|
pub fn patch(&self, request: &Calendar, calendar_id: &str) -> CalendarPatchCall<'a, C, NC, A> {
|
|
CalendarPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes a secondary calendar. Use calendars.clear for clearing all events on primary calendars.
|
|
pub fn delete(&self, calendar_id: &str) -> CalendarDeleteCall<'a, C, NC, A> {
|
|
CalendarDeleteCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns metadata for a calendar.
|
|
pub fn get(&self, calendar_id: &str) -> CalendarGetCall<'a, C, NC, A> {
|
|
CalendarGetCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.
|
|
pub fn clear(&self, calendar_id: &str) -> CalendarClearCall<'a, C, NC, A> {
|
|
CalendarClearCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Creates a secondary calendar.
|
|
pub fn insert(&self, request: &Calendar) -> CalendarInsertCall<'a, C, NC, A> {
|
|
CalendarInsertCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates metadata for a calendar.
|
|
pub fn update(&self, request: &Calendar, calendar_id: &str) -> CalendarUpdateCall<'a, C, NC, A> {
|
|
CalendarUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *acl* resources.
|
|
/// It is not used directly, but through the `CalendarHub` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-calendar3" as calendar3;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use calendar3::CalendarHub;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `update(...)` and `watch(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.acl();
|
|
/// # }
|
|
/// ```
|
|
pub struct AclMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> ResourceMethodsBuilder for AclMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> AclMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Watch for changes to ACL resources.
|
|
pub fn watch(&self, request: &Channel, calendar_id: &str) -> AclWatchCall<'a, C, NC, A> {
|
|
AclWatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_sync_token: Default::default(),
|
|
_show_deleted: Default::default(),
|
|
_page_token: Default::default(),
|
|
_max_results: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Creates an access control rule.
|
|
pub fn insert(&self, request: &AclRule, calendar_id: &str) -> AclInsertCall<'a, C, NC, A> {
|
|
AclInsertCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates an access control rule.
|
|
pub fn update(&self, request: &AclRule, calendar_id: &str, rule_id: &str) -> AclUpdateCall<'a, C, NC, A> {
|
|
AclUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_rule_id: rule_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates an access control rule. This method supports patch semantics.
|
|
pub fn patch(&self, request: &AclRule, calendar_id: &str, rule_id: &str) -> AclPatchCall<'a, C, NC, A> {
|
|
AclPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_rule_id: rule_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns the rules in the access control list for the calendar.
|
|
pub fn list(&self, calendar_id: &str) -> AclListCall<'a, C, NC, A> {
|
|
AclListCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_sync_token: Default::default(),
|
|
_show_deleted: Default::default(),
|
|
_page_token: Default::default(),
|
|
_max_results: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes an access control rule.
|
|
pub fn delete(&self, calendar_id: &str, rule_id: &str) -> AclDeleteCall<'a, C, NC, A> {
|
|
AclDeleteCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_rule_id: rule_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns an access control rule.
|
|
pub fn get(&self, calendar_id: &str, rule_id: &str) -> AclGetCall<'a, C, NC, A> {
|
|
AclGetCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_rule_id: rule_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *channel* resources.
|
|
/// It is not used directly, but through the `CalendarHub` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-calendar3" as calendar3;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use calendar3::CalendarHub;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `stop(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.channels();
|
|
/// # }
|
|
/// ```
|
|
pub struct ChannelMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> ResourceMethodsBuilder for ChannelMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ChannelMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Stop watching resources through this channel
|
|
pub fn stop(&self, request: &Channel) -> ChannelStopCall<'a, C, NC, A> {
|
|
ChannelStopCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *color* resources.
|
|
/// It is not used directly, but through the `CalendarHub` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-calendar3" as calendar3;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use calendar3::CalendarHub;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `get(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.colors();
|
|
/// # }
|
|
/// ```
|
|
pub struct ColorMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> ResourceMethodsBuilder for ColorMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ColorMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns the color definitions for calendars and events.
|
|
pub fn get(&self) -> ColorGetCall<'a, C, NC, A> {
|
|
ColorGetCall {
|
|
hub: self.hub,
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *event* resources.
|
|
/// It is not used directly, but through the `CalendarHub` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-calendar3" as calendar3;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use calendar3::CalendarHub;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `delete(...)`, `get(...)`, `import(...)`, `insert(...)`, `instances(...)`, `list(...)`, `move_(...)`, `patch(...)`, `quick_add(...)`, `update(...)` and `watch(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.events();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> ResourceMethodsBuilder for EventMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes an event.
|
|
pub fn delete(&self, calendar_id: &str, event_id: &str) -> EventDeleteCall<'a, C, NC, A> {
|
|
EventDeleteCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_event_id: event_id.to_string(),
|
|
_send_notifications: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Creates an event.
|
|
pub fn insert(&self, request: &Event, calendar_id: &str) -> EventInsertCall<'a, C, NC, A> {
|
|
EventInsertCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_send_notifications: Default::default(),
|
|
_max_attendees: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Imports an event. This operation is used to add a private copy of an existing event to a calendar.
|
|
pub fn import(&self, request: &Event, calendar_id: &str) -> EventImportCall<'a, C, NC, A> {
|
|
EventImportCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns instances of the specified recurring event.
|
|
pub fn instances(&self, calendar_id: &str, event_id: &str) -> EventInstanceCall<'a, C, NC, A> {
|
|
EventInstanceCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_event_id: event_id.to_string(),
|
|
_time_zone: Default::default(),
|
|
_time_min: Default::default(),
|
|
_time_max: Default::default(),
|
|
_show_deleted: Default::default(),
|
|
_page_token: Default::default(),
|
|
_original_start: Default::default(),
|
|
_max_results: Default::default(),
|
|
_max_attendees: Default::default(),
|
|
_always_include_email: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns an event.
|
|
pub fn get(&self, calendar_id: &str, event_id: &str) -> EventGetCall<'a, C, NC, A> {
|
|
EventGetCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_event_id: event_id.to_string(),
|
|
_time_zone: Default::default(),
|
|
_max_attendees: Default::default(),
|
|
_always_include_email: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns events on the specified calendar.
|
|
pub fn list(&self, calendar_id: &str) -> EventListCall<'a, C, NC, A> {
|
|
EventListCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_updated_min: Default::default(),
|
|
_time_zone: Default::default(),
|
|
_time_min: Default::default(),
|
|
_time_max: Default::default(),
|
|
_sync_token: Default::default(),
|
|
_single_events: Default::default(),
|
|
_show_hidden_invitations: Default::default(),
|
|
_show_deleted: Default::default(),
|
|
_shared_extended_property: Default::default(),
|
|
_q: Default::default(),
|
|
_private_extended_property: Default::default(),
|
|
_page_token: Default::default(),
|
|
_order_by: Default::default(),
|
|
_max_results: Default::default(),
|
|
_max_attendees: Default::default(),
|
|
_i_cal_uid: Default::default(),
|
|
_always_include_email: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates an event. This method supports patch semantics.
|
|
pub fn patch(&self, request: &Event, calendar_id: &str, event_id: &str) -> EventPatchCall<'a, C, NC, A> {
|
|
EventPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_event_id: event_id.to_string(),
|
|
_send_notifications: Default::default(),
|
|
_max_attendees: Default::default(),
|
|
_always_include_email: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Moves an event to another calendar, i.e. changes an event's organizer.
|
|
pub fn move_(&self, calendar_id: &str, event_id: &str, destination: &str) -> EventMoveCall<'a, C, NC, A> {
|
|
EventMoveCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_event_id: event_id.to_string(),
|
|
_destination: destination.to_string(),
|
|
_send_notifications: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates an event.
|
|
pub fn update(&self, request: &Event, calendar_id: &str, event_id: &str) -> EventUpdateCall<'a, C, NC, A> {
|
|
EventUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_event_id: event_id.to_string(),
|
|
_send_notifications: Default::default(),
|
|
_max_attendees: Default::default(),
|
|
_always_include_email: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Watch for changes to Events resources.
|
|
pub fn watch(&self, request: &Channel, calendar_id: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
EventWatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_calendar_id: calendar_id.to_string(),
|
|
_updated_min: Default::default(),
|
|
_time_zone: Default::default(),
|
|
_time_min: Default::default(),
|
|
_time_max: Default::default(),
|
|
_sync_token: Default::default(),
|
|
_single_events: Default::default(),
|
|
_show_hidden_invitations: Default::default(),
|
|
_show_deleted: Default::default(),
|
|
_shared_extended_property: Default::default(),
|
|
_q: Default::default(),
|
|
_private_extended_property: Default::default(),
|
|
_page_token: Default::default(),
|
|
_order_by: Default::default(),
|
|
_max_results: Default::default(),
|
|
_max_attendees: Default::default(),
|
|
_i_cal_uid: Default::default(),
|
|
_always_include_email: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Creates an event based on a simple text string.
|
|
pub fn quick_add(&self, calendar_id: &str, text: &str) -> EventQuickAddCall<'a, C, NC, A> {
|
|
EventQuickAddCall {
|
|
hub: self.hub,
|
|
_calendar_id: calendar_id.to_string(),
|
|
_text: text.to_string(),
|
|
_send_notifications: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ###################
|
|
// CallBuilders ###
|
|
// #################
|
|
|
|
/// Returns free/busy information for a set of calendars.
|
|
///
|
|
/// A builder for the *query* method supported by a *freebusy* resource.
|
|
/// It is not used directly, but through a `FreebusyMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::FreeBusyRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: FreeBusyRequest = Default::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.freebusy().query(&req)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct FreebusyQueryCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: FreeBusyRequest,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for FreebusyQueryCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> FreebusyQueryCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, FreeBusyResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.freebusy.query",
|
|
http_method: hyper::method::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 Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/freeBusy".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &FreeBusyRequest) -> FreebusyQueryCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> FreebusyQueryCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> FreebusyQueryCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> FreebusyQueryCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns all user settings for the authenticated user.
|
|
///
|
|
/// A builder for the *list* method supported by a *setting* resource.
|
|
/// It is not used directly, but through a `SettingMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.settings().list()
|
|
/// .sync_token("et")
|
|
/// .page_token("amet")
|
|
/// .max_results(-23)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SettingListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_sync_token: Option<String>,
|
|
_page_token: Option<String>,
|
|
_max_results: Option<i32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for SettingListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> SettingListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Settings)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.settings.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
if let Some(value) = self._sync_token {
|
|
params.push(("syncToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_results {
|
|
params.push(("maxResults", value.to_string()));
|
|
}
|
|
for &field in ["alt", "syncToken", "pageToken", "maxResults"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/users/me/settings".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *sync token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then.
|
|
/// If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken.
|
|
/// Learn more about incremental synchronization.
|
|
/// Optional. The default is to return all entries.
|
|
pub fn sync_token(mut self, new_value: &str) -> SettingListCall<'a, C, NC, A> {
|
|
self._sync_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token specifying which result page to return. Optional.
|
|
pub fn page_token(mut self, new_value: &str) -> SettingListCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
|
|
pub fn max_results(mut self, new_value: i32) -> SettingListCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SettingListCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SettingListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> SettingListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Watch for changes to Settings resources.
|
|
///
|
|
/// A builder for the *watch* method supported by a *setting* resource.
|
|
/// It is not used directly, but through a `SettingMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Channel;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Channel = Default::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.settings().watch(&req)
|
|
/// .sync_token("consetetur")
|
|
/// .page_token("ut")
|
|
/// .max_results(-16)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SettingWatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Channel,
|
|
_sync_token: Option<String>,
|
|
_page_token: Option<String>,
|
|
_max_results: Option<i32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for SettingWatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> SettingWatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Channel)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.settings.watch",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
if let Some(value) = self._sync_token {
|
|
params.push(("syncToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_results {
|
|
params.push(("maxResults", value.to_string()));
|
|
}
|
|
for &field in ["alt", "syncToken", "pageToken", "maxResults"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/users/me/settings/watch".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Channel) -> SettingWatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *sync token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then.
|
|
/// If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken.
|
|
/// Learn more about incremental synchronization.
|
|
/// Optional. The default is to return all entries.
|
|
pub fn sync_token(mut self, new_value: &str) -> SettingWatchCall<'a, C, NC, A> {
|
|
self._sync_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token specifying which result page to return. Optional.
|
|
pub fn page_token(mut self, new_value: &str) -> SettingWatchCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
|
|
pub fn max_results(mut self, new_value: i32) -> SettingWatchCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SettingWatchCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SettingWatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> SettingWatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns a single user setting.
|
|
///
|
|
/// A builder for the *get* method supported by a *setting* resource.
|
|
/// It is not used directly, but through a `SettingMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.settings().get("setting")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SettingGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_setting: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for SettingGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> SettingGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Setting)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.settings.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("setting", self._setting.to_string()));
|
|
for &field in ["alt", "setting"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/users/me/settings/{setting}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{setting}", "setting")].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 ["setting"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *setting* 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.
|
|
///
|
|
/// The id of the user setting.
|
|
pub fn setting(mut self, new_value: &str) -> SettingGetCall<'a, C, NC, A> {
|
|
self._setting = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SettingGetCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SettingGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> SettingGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates an entry on the user's calendar list.
|
|
///
|
|
/// A builder for the *update* method supported by a *calendarList* resource.
|
|
/// It is not used directly, but through a `CalendarListMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::CalendarListEntry;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: CalendarListEntry = Default::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.calendar_list().update(&req, "calendarId")
|
|
/// .color_rgb_format(true)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarListUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: CalendarListEntry,
|
|
_calendar_id: String,
|
|
_color_rgb_format: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarListUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarListUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, CalendarListEntry)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendarList.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
if let Some(value) = self._color_rgb_format {
|
|
params.push(("colorRgbFormat", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "colorRgbFormat"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/users/me/calendarList/{calendarId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &CalendarListEntry) -> CalendarListUpdateCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> CalendarListUpdateCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *color rgb format* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to use the foregroundColor and backgroundColor fields to write the calendar colors (RGB). If this feature is used, the index-based colorId field will be set to the best matching option automatically. Optional. The default is False.
|
|
pub fn color_rgb_format(mut self, new_value: bool) -> CalendarListUpdateCall<'a, C, NC, A> {
|
|
self._color_rgb_format = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarListUpdateCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarListUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarListUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes an entry on the user's calendar list.
|
|
///
|
|
/// A builder for the *delete* method supported by a *calendarList* resource.
|
|
/// It is not used directly, but through a `CalendarListMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.calendar_list().delete("calendarId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarListDeleteCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarListDeleteCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarListDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendarList.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
for &field in ["calendarId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/users/me/calendarList/{calendarId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> CalendarListDeleteCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarListDeleteCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarListDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarListDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns an entry on the user's calendar list.
|
|
///
|
|
/// A builder for the *get* method supported by a *calendarList* resource.
|
|
/// It is not used directly, but through a `CalendarListMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.calendar_list().get("calendarId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarListGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarListGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarListGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, CalendarListEntry)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendarList.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
for &field in ["alt", "calendarId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/users/me/calendarList/{calendarId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> CalendarListGetCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarListGetCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarListGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarListGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns entries on the user's calendar list.
|
|
///
|
|
/// A builder for the *list* method supported by a *calendarList* resource.
|
|
/// It is not used directly, but through a `CalendarListMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.calendar_list().list()
|
|
/// .sync_token("consetetur")
|
|
/// .show_hidden(false)
|
|
/// .show_deleted(true)
|
|
/// .page_token("Lorem")
|
|
/// .min_access_role("gubergren")
|
|
/// .max_results(-20)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarListListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_sync_token: Option<String>,
|
|
_show_hidden: Option<bool>,
|
|
_show_deleted: Option<bool>,
|
|
_page_token: Option<String>,
|
|
_min_access_role: Option<String>,
|
|
_max_results: Option<i32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarListListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarListListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, CalendarList)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendarList.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len()));
|
|
if let Some(value) = self._sync_token {
|
|
params.push(("syncToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_hidden {
|
|
params.push(("showHidden", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_deleted {
|
|
params.push(("showDeleted", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._min_access_role {
|
|
params.push(("minAccessRole", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_results {
|
|
params.push(("maxResults", value.to_string()));
|
|
}
|
|
for &field in ["alt", "syncToken", "showHidden", "showDeleted", "pageToken", "minAccessRole", "maxResults"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/users/me/calendarList".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *sync token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. If only read-only fields such as calendar properties or ACLs have changed, the entry won't be returned. All entries deleted and hidden since the previous list request will always be in the result set and it is not allowed to set showDeleted neither showHidden to False.
|
|
/// To ensure client state consistency minAccessRole query parameter cannot be specified together with nextSyncToken.
|
|
/// If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken.
|
|
/// Learn more about incremental synchronization.
|
|
/// Optional. The default is to return all entries.
|
|
pub fn sync_token(mut self, new_value: &str) -> CalendarListListCall<'a, C, NC, A> {
|
|
self._sync_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *show hidden* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to show hidden entries. Optional. The default is False.
|
|
pub fn show_hidden(mut self, new_value: bool) -> CalendarListListCall<'a, C, NC, A> {
|
|
self._show_hidden = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *show deleted* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to include deleted calendar list entries in the result. Optional. The default is False.
|
|
pub fn show_deleted(mut self, new_value: bool) -> CalendarListListCall<'a, C, NC, A> {
|
|
self._show_deleted = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token specifying which result page to return. Optional.
|
|
pub fn page_token(mut self, new_value: &str) -> CalendarListListCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *min access role* query property to the given value.
|
|
///
|
|
///
|
|
/// The minimum access role for the user in the returned entires. Optional. The default is no restriction.
|
|
pub fn min_access_role(mut self, new_value: &str) -> CalendarListListCall<'a, C, NC, A> {
|
|
self._min_access_role = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
|
|
pub fn max_results(mut self, new_value: i32) -> CalendarListListCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarListListCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarListListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarListListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Adds an entry to the user's calendar list.
|
|
///
|
|
/// A builder for the *insert* method supported by a *calendarList* resource.
|
|
/// It is not used directly, but through a `CalendarListMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::CalendarListEntry;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: CalendarListEntry = Default::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.calendar_list().insert(&req)
|
|
/// .color_rgb_format(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarListInsertCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: CalendarListEntry,
|
|
_color_rgb_format: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarListInsertCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarListInsertCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, CalendarListEntry)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendarList.insert",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
if let Some(value) = self._color_rgb_format {
|
|
params.push(("colorRgbFormat", value.to_string()));
|
|
}
|
|
for &field in ["alt", "colorRgbFormat"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/users/me/calendarList".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &CalendarListEntry) -> CalendarListInsertCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *color rgb format* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to use the foregroundColor and backgroundColor fields to write the calendar colors (RGB). If this feature is used, the index-based colorId field will be set to the best matching option automatically. Optional. The default is False.
|
|
pub fn color_rgb_format(mut self, new_value: bool) -> CalendarListInsertCall<'a, C, NC, A> {
|
|
self._color_rgb_format = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarListInsertCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarListInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarListInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates an entry on the user's calendar list. This method supports patch semantics.
|
|
///
|
|
/// A builder for the *patch* method supported by a *calendarList* resource.
|
|
/// It is not used directly, but through a `CalendarListMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::CalendarListEntry;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: CalendarListEntry = Default::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.calendar_list().patch(&req, "calendarId")
|
|
/// .color_rgb_format(true)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarListPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: CalendarListEntry,
|
|
_calendar_id: String,
|
|
_color_rgb_format: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarListPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarListPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, CalendarListEntry)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendarList.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
if let Some(value) = self._color_rgb_format {
|
|
params.push(("colorRgbFormat", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "colorRgbFormat"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/users/me/calendarList/{calendarId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &CalendarListEntry) -> CalendarListPatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> CalendarListPatchCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *color rgb format* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to use the foregroundColor and backgroundColor fields to write the calendar colors (RGB). If this feature is used, the index-based colorId field will be set to the best matching option automatically. Optional. The default is False.
|
|
pub fn color_rgb_format(mut self, new_value: bool) -> CalendarListPatchCall<'a, C, NC, A> {
|
|
self._color_rgb_format = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarListPatchCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarListPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarListPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Watch for changes to CalendarList resources.
|
|
///
|
|
/// A builder for the *watch* method supported by a *calendarList* resource.
|
|
/// It is not used directly, but through a `CalendarListMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Channel;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Channel = Default::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.calendar_list().watch(&req)
|
|
/// .sync_token("rebum.")
|
|
/// .show_hidden(true)
|
|
/// .show_deleted(true)
|
|
/// .page_token("vero")
|
|
/// .min_access_role("sadipscing")
|
|
/// .max_results(-88)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarListWatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Channel,
|
|
_sync_token: Option<String>,
|
|
_show_hidden: Option<bool>,
|
|
_show_deleted: Option<bool>,
|
|
_page_token: Option<String>,
|
|
_min_access_role: Option<String>,
|
|
_max_results: Option<i32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarListWatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarListWatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Channel)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendarList.watch",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len()));
|
|
if let Some(value) = self._sync_token {
|
|
params.push(("syncToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_hidden {
|
|
params.push(("showHidden", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_deleted {
|
|
params.push(("showDeleted", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._min_access_role {
|
|
params.push(("minAccessRole", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_results {
|
|
params.push(("maxResults", value.to_string()));
|
|
}
|
|
for &field in ["alt", "syncToken", "showHidden", "showDeleted", "pageToken", "minAccessRole", "maxResults"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/users/me/calendarList/watch".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Channel) -> CalendarListWatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *sync token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. If only read-only fields such as calendar properties or ACLs have changed, the entry won't be returned. All entries deleted and hidden since the previous list request will always be in the result set and it is not allowed to set showDeleted neither showHidden to False.
|
|
/// To ensure client state consistency minAccessRole query parameter cannot be specified together with nextSyncToken.
|
|
/// If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken.
|
|
/// Learn more about incremental synchronization.
|
|
/// Optional. The default is to return all entries.
|
|
pub fn sync_token(mut self, new_value: &str) -> CalendarListWatchCall<'a, C, NC, A> {
|
|
self._sync_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *show hidden* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to show hidden entries. Optional. The default is False.
|
|
pub fn show_hidden(mut self, new_value: bool) -> CalendarListWatchCall<'a, C, NC, A> {
|
|
self._show_hidden = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *show deleted* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to include deleted calendar list entries in the result. Optional. The default is False.
|
|
pub fn show_deleted(mut self, new_value: bool) -> CalendarListWatchCall<'a, C, NC, A> {
|
|
self._show_deleted = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token specifying which result page to return. Optional.
|
|
pub fn page_token(mut self, new_value: &str) -> CalendarListWatchCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *min access role* query property to the given value.
|
|
///
|
|
///
|
|
/// The minimum access role for the user in the returned entires. Optional. The default is no restriction.
|
|
pub fn min_access_role(mut self, new_value: &str) -> CalendarListWatchCall<'a, C, NC, A> {
|
|
self._min_access_role = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
|
|
pub fn max_results(mut self, new_value: i32) -> CalendarListWatchCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarListWatchCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarListWatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarListWatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates metadata for a calendar. This method supports patch semantics.
|
|
///
|
|
/// A builder for the *patch* method supported by a *calendar* resource.
|
|
/// It is not used directly, but through a `CalendarMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Calendar;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Calendar = Default::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.calendars().patch(&req, "calendarId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Calendar,
|
|
_calendar_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Calendar)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendars.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
for &field in ["alt", "calendarId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Calendar) -> CalendarPatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> CalendarPatchCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarPatchCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes a secondary calendar. Use calendars.clear for clearing all events on primary calendars.
|
|
///
|
|
/// A builder for the *delete* method supported by a *calendar* resource.
|
|
/// It is not used directly, but through a `CalendarMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.calendars().delete("calendarId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarDeleteCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarDeleteCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendars.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
for &field in ["calendarId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> CalendarDeleteCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarDeleteCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns metadata for a calendar.
|
|
///
|
|
/// A builder for the *get* method supported by a *calendar* resource.
|
|
/// It is not used directly, but through a `CalendarMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.calendars().get("calendarId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Calendar)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendars.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
for &field in ["alt", "calendarId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> CalendarGetCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarGetCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.
|
|
///
|
|
/// A builder for the *clear* method supported by a *calendar* resource.
|
|
/// It is not used directly, but through a `CalendarMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.calendars().clear("calendarId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarClearCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarClearCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarClearCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendars.clear",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
for &field in ["calendarId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/clear".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> CalendarClearCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarClearCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarClearCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarClearCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Creates a secondary calendar.
|
|
///
|
|
/// A builder for the *insert* method supported by a *calendar* resource.
|
|
/// It is not used directly, but through a `CalendarMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Calendar;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Calendar = Default::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.calendars().insert(&req)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarInsertCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Calendar,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarInsertCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarInsertCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Calendar)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendars.insert",
|
|
http_method: hyper::method::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 Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Calendar) -> CalendarInsertCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarInsertCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates metadata for a calendar.
|
|
///
|
|
/// A builder for the *update* method supported by a *calendar* resource.
|
|
/// It is not used directly, but through a `CalendarMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Calendar;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Calendar = Default::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.calendars().update(&req, "calendarId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CalendarUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Calendar,
|
|
_calendar_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for CalendarUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> CalendarUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Calendar)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.calendars.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
for &field in ["alt", "calendarId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Calendar) -> CalendarUpdateCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> CalendarUpdateCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CalendarUpdateCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> CalendarUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> CalendarUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Watch for changes to ACL resources.
|
|
///
|
|
/// A builder for the *watch* method supported by a *acl* resource.
|
|
/// It is not used directly, but through a `AclMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Channel;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Channel = Default::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.acl().watch(&req, "calendarId")
|
|
/// .sync_token("clita")
|
|
/// .show_deleted(true)
|
|
/// .page_token("takimata")
|
|
/// .max_results(-40)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct AclWatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Channel,
|
|
_calendar_id: String,
|
|
_sync_token: Option<String>,
|
|
_show_deleted: Option<bool>,
|
|
_page_token: Option<String>,
|
|
_max_results: Option<i32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for AclWatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> AclWatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Channel)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.acl.watch",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
if let Some(value) = self._sync_token {
|
|
params.push(("syncToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_deleted {
|
|
params.push(("showDeleted", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_results {
|
|
params.push(("maxResults", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "syncToken", "showDeleted", "pageToken", "maxResults"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/acl/watch".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Channel) -> AclWatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> AclWatchCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *sync token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. All entries deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted to False.
|
|
/// If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken.
|
|
/// Learn more about incremental synchronization.
|
|
/// Optional. The default is to return all entries.
|
|
pub fn sync_token(mut self, new_value: &str) -> AclWatchCall<'a, C, NC, A> {
|
|
self._sync_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *show deleted* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to include deleted ACLs in the result. Deleted ACLs are represented by role equal to "none". Deleted ACLs will always be included if syncToken is provided. Optional. The default is False.
|
|
pub fn show_deleted(mut self, new_value: bool) -> AclWatchCall<'a, C, NC, A> {
|
|
self._show_deleted = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token specifying which result page to return. Optional.
|
|
pub fn page_token(mut self, new_value: &str) -> AclWatchCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
|
|
pub fn max_results(mut self, new_value: i32) -> AclWatchCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AclWatchCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> AclWatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> AclWatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Creates an access control rule.
|
|
///
|
|
/// A builder for the *insert* method supported by a *acl* resource.
|
|
/// It is not used directly, but through a `AclMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::AclRule;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: AclRule = Default::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.acl().insert(&req, "calendarId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct AclInsertCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: AclRule,
|
|
_calendar_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for AclInsertCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> AclInsertCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AclRule)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.acl.insert",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
for &field in ["alt", "calendarId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/acl".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &AclRule) -> AclInsertCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> AclInsertCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AclInsertCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> AclInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> AclInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates an access control rule.
|
|
///
|
|
/// A builder for the *update* method supported by a *acl* resource.
|
|
/// It is not used directly, but through a `AclMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::AclRule;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: AclRule = Default::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.acl().update(&req, "calendarId", "ruleId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct AclUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: AclRule,
|
|
_calendar_id: String,
|
|
_rule_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for AclUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> AclUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AclRule)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.acl.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("ruleId", self._rule_id.to_string()));
|
|
for &field in ["alt", "calendarId", "ruleId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/acl/{ruleId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].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 ["calendarId", "ruleId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &AclRule) -> AclUpdateCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> AclUpdateCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *rule 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.
|
|
///
|
|
/// ACL rule identifier.
|
|
pub fn rule_id(mut self, new_value: &str) -> AclUpdateCall<'a, C, NC, A> {
|
|
self._rule_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AclUpdateCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> AclUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> AclUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates an access control rule. This method supports patch semantics.
|
|
///
|
|
/// A builder for the *patch* method supported by a *acl* resource.
|
|
/// It is not used directly, but through a `AclMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::AclRule;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: AclRule = Default::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.acl().patch(&req, "calendarId", "ruleId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct AclPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: AclRule,
|
|
_calendar_id: String,
|
|
_rule_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for AclPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> AclPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AclRule)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.acl.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("ruleId", self._rule_id.to_string()));
|
|
for &field in ["alt", "calendarId", "ruleId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/acl/{ruleId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].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 ["calendarId", "ruleId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &AclRule) -> AclPatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> AclPatchCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *rule 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.
|
|
///
|
|
/// ACL rule identifier.
|
|
pub fn rule_id(mut self, new_value: &str) -> AclPatchCall<'a, C, NC, A> {
|
|
self._rule_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AclPatchCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> AclPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> AclPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns the rules in the access control list for the calendar.
|
|
///
|
|
/// A builder for the *list* method supported by a *acl* resource.
|
|
/// It is not used directly, but through a `AclMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.acl().list("calendarId")
|
|
/// .sync_token("ea")
|
|
/// .show_deleted(false)
|
|
/// .page_token("rebum.")
|
|
/// .max_results(-33)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct AclListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_sync_token: Option<String>,
|
|
_show_deleted: Option<bool>,
|
|
_page_token: Option<String>,
|
|
_max_results: Option<i32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for AclListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> AclListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Acl)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.acl.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
if let Some(value) = self._sync_token {
|
|
params.push(("syncToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_deleted {
|
|
params.push(("showDeleted", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_results {
|
|
params.push(("maxResults", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "syncToken", "showDeleted", "pageToken", "maxResults"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/acl".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> AclListCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *sync token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. All entries deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted to False.
|
|
/// If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken.
|
|
/// Learn more about incremental synchronization.
|
|
/// Optional. The default is to return all entries.
|
|
pub fn sync_token(mut self, new_value: &str) -> AclListCall<'a, C, NC, A> {
|
|
self._sync_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *show deleted* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to include deleted ACLs in the result. Deleted ACLs are represented by role equal to "none". Deleted ACLs will always be included if syncToken is provided. Optional. The default is False.
|
|
pub fn show_deleted(mut self, new_value: bool) -> AclListCall<'a, C, NC, A> {
|
|
self._show_deleted = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token specifying which result page to return. Optional.
|
|
pub fn page_token(mut self, new_value: &str) -> AclListCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
|
|
pub fn max_results(mut self, new_value: i32) -> AclListCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AclListCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> AclListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> AclListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes an access control rule.
|
|
///
|
|
/// A builder for the *delete* method supported by a *acl* resource.
|
|
/// It is not used directly, but through a `AclMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.acl().delete("calendarId", "ruleId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct AclDeleteCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_rule_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for AclDeleteCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> AclDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.acl.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("ruleId", self._rule_id.to_string()));
|
|
for &field in ["calendarId", "ruleId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/acl/{ruleId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].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 ["calendarId", "ruleId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> AclDeleteCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *rule 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.
|
|
///
|
|
/// ACL rule identifier.
|
|
pub fn rule_id(mut self, new_value: &str) -> AclDeleteCall<'a, C, NC, A> {
|
|
self._rule_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AclDeleteCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> AclDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> AclDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns an access control rule.
|
|
///
|
|
/// A builder for the *get* method supported by a *acl* resource.
|
|
/// It is not used directly, but through a `AclMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.acl().get("calendarId", "ruleId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct AclGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_rule_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for AclGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> AclGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, AclRule)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.acl.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("ruleId", self._rule_id.to_string()));
|
|
for &field in ["alt", "calendarId", "ruleId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/acl/{ruleId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].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 ["calendarId", "ruleId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> AclGetCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *rule 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.
|
|
///
|
|
/// ACL rule identifier.
|
|
pub fn rule_id(mut self, new_value: &str) -> AclGetCall<'a, C, NC, A> {
|
|
self._rule_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AclGetCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> AclGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> AclGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Stop watching resources through this channel
|
|
///
|
|
/// A builder for the *stop* method supported by a *channel* resource.
|
|
/// It is not used directly, but through a `ChannelMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Channel;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Channel = Default::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.channels().stop(&req)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ChannelStopCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Channel,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ChannelStopCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ChannelStopCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.channels.stop",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len()));
|
|
for &field in [].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/channels/stop".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Channel) -> ChannelStopCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ChannelStopCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ChannelStopCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> ChannelStopCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns the color definitions for calendars and events.
|
|
///
|
|
/// A builder for the *get* method supported by a *color* resource.
|
|
/// It is not used directly, but through a `ColorMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.colors().get()
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ColorGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ColorGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ColorGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Colors)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.colors.get",
|
|
http_method: hyper::method::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 Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/colors".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ColorGetCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ColorGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> ColorGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes an event.
|
|
///
|
|
/// A builder for the *delete* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.events().delete("calendarId", "eventId")
|
|
/// .send_notifications(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventDeleteCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_event_id: String,
|
|
_send_notifications: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventDeleteCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("eventId", self._event_id.to_string()));
|
|
if let Some(value) = self._send_notifications {
|
|
params.push(("sendNotifications", value.to_string()));
|
|
}
|
|
for &field in ["calendarId", "eventId", "sendNotifications"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/{eventId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].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 ["calendarId", "eventId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventDeleteCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *event 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.
|
|
///
|
|
/// Event identifier.
|
|
pub fn event_id(mut self, new_value: &str) -> EventDeleteCall<'a, C, NC, A> {
|
|
self._event_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *send notifications* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to send notifications about the deletion of the event. Optional. The default is False.
|
|
pub fn send_notifications(mut self, new_value: bool) -> EventDeleteCall<'a, C, NC, A> {
|
|
self._send_notifications = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventDeleteCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventDeleteCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Creates an event.
|
|
///
|
|
/// A builder for the *insert* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Event;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Event = Default::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.events().insert(&req, "calendarId")
|
|
/// .send_notifications(true)
|
|
/// .max_attendees(-62)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventInsertCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Event,
|
|
_calendar_id: String,
|
|
_send_notifications: Option<bool>,
|
|
_max_attendees: Option<i32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventInsertCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventInsertCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Event)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.insert",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
if let Some(value) = self._send_notifications {
|
|
params.push(("sendNotifications", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_attendees {
|
|
params.push(("maxAttendees", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "sendNotifications", "maxAttendees"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Event) -> EventInsertCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventInsertCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *send notifications* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to send notifications about the creation of the new event. Optional. The default is False.
|
|
pub fn send_notifications(mut self, new_value: bool) -> EventInsertCall<'a, C, NC, A> {
|
|
self._send_notifications = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *max attendees* query property to the given value.
|
|
///
|
|
///
|
|
/// The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
|
|
pub fn max_attendees(mut self, new_value: i32) -> EventInsertCall<'a, C, NC, A> {
|
|
self._max_attendees = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventInsertCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Imports an event. This operation is used to add a private copy of an existing event to a calendar.
|
|
///
|
|
/// A builder for the *import* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Event;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Event = Default::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.events().import(&req, "calendarId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventImportCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Event,
|
|
_calendar_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventImportCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventImportCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Event)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.import",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
for &field in ["alt", "calendarId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/import".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Event) -> EventImportCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventImportCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventImportCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventImportCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventImportCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns instances of the specified recurring event.
|
|
///
|
|
/// A builder for the *instances* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.events().instances("calendarId", "eventId")
|
|
/// .time_zone("sea")
|
|
/// .time_min("labore")
|
|
/// .time_max("ipsum")
|
|
/// .show_deleted(true)
|
|
/// .page_token("dolores")
|
|
/// .original_start("sit")
|
|
/// .max_results(-41)
|
|
/// .max_attendees(-37)
|
|
/// .always_include_email(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventInstanceCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_event_id: String,
|
|
_time_zone: Option<String>,
|
|
_time_min: Option<String>,
|
|
_time_max: Option<String>,
|
|
_show_deleted: Option<bool>,
|
|
_page_token: Option<String>,
|
|
_original_start: Option<String>,
|
|
_max_results: Option<i32>,
|
|
_max_attendees: Option<i32>,
|
|
_always_include_email: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventInstanceCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventInstanceCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Events)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.instances",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("eventId", self._event_id.to_string()));
|
|
if let Some(value) = self._time_zone {
|
|
params.push(("timeZone", value.to_string()));
|
|
}
|
|
if let Some(value) = self._time_min {
|
|
params.push(("timeMin", value.to_string()));
|
|
}
|
|
if let Some(value) = self._time_max {
|
|
params.push(("timeMax", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_deleted {
|
|
params.push(("showDeleted", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._original_start {
|
|
params.push(("originalStart", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_results {
|
|
params.push(("maxResults", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_attendees {
|
|
params.push(("maxAttendees", value.to_string()));
|
|
}
|
|
if let Some(value) = self._always_include_email {
|
|
params.push(("alwaysIncludeEmail", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "eventId", "timeZone", "timeMin", "timeMax", "showDeleted", "pageToken", "originalStart", "maxResults", "maxAttendees", "alwaysIncludeEmail"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/{eventId}/instances".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].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 ["calendarId", "eventId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *event 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.
|
|
///
|
|
/// Recurring event identifier.
|
|
pub fn event_id(mut self, new_value: &str) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._event_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *time zone* query property to the given value.
|
|
///
|
|
///
|
|
/// Time zone used in the response. Optional. The default is the time zone of the calendar.
|
|
pub fn time_zone(mut self, new_value: &str) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._time_zone = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *time min* query property to the given value.
|
|
///
|
|
///
|
|
/// Lower bound (inclusive) for an event's end time to filter by. Optional. The default is not to filter by end time.
|
|
pub fn time_min(mut self, new_value: &str) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._time_min = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *time max* query property to the given value.
|
|
///
|
|
///
|
|
/// Upper bound (exclusive) for an event's start time to filter by. Optional. The default is not to filter by start time.
|
|
pub fn time_max(mut self, new_value: &str) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._time_max = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *show deleted* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to include deleted events (with status equals "cancelled") in the result. Cancelled instances of recurring events will still be included if singleEvents is False. Optional. The default is False.
|
|
pub fn show_deleted(mut self, new_value: bool) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._show_deleted = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token specifying which result page to return. Optional.
|
|
pub fn page_token(mut self, new_value: &str) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *original start* query property to the given value.
|
|
///
|
|
///
|
|
/// The original start time of the instance in the result. Optional.
|
|
pub fn original_start(mut self, new_value: &str) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._original_start = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Maximum number of events returned on one result page. By default the value is 250 events. The page size can never be larger than 2500 events. Optional.
|
|
pub fn max_results(mut self, new_value: i32) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *max attendees* query property to the given value.
|
|
///
|
|
///
|
|
/// The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
|
|
pub fn max_attendees(mut self, new_value: i32) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._max_attendees = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *always include email* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to always include a value in the email field for the organizer, creator and attendees, even if no real email is available (i.e. a generated, non-working value will be provided). The use of this option is discouraged and should only be used by clients which cannot handle the absence of an email address value in the mentioned places. Optional. The default is False.
|
|
pub fn always_include_email(mut self, new_value: bool) -> EventInstanceCall<'a, C, NC, A> {
|
|
self._always_include_email = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventInstanceCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventInstanceCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventInstanceCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns an event.
|
|
///
|
|
/// A builder for the *get* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.events().get("calendarId", "eventId")
|
|
/// .time_zone("accusam")
|
|
/// .max_attendees(-13)
|
|
/// .always_include_email(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_event_id: String,
|
|
_time_zone: Option<String>,
|
|
_max_attendees: Option<i32>,
|
|
_always_include_email: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Event)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("eventId", self._event_id.to_string()));
|
|
if let Some(value) = self._time_zone {
|
|
params.push(("timeZone", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_attendees {
|
|
params.push(("maxAttendees", value.to_string()));
|
|
}
|
|
if let Some(value) = self._always_include_email {
|
|
params.push(("alwaysIncludeEmail", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "eventId", "timeZone", "maxAttendees", "alwaysIncludeEmail"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/{eventId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].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 ["calendarId", "eventId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventGetCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *event 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.
|
|
///
|
|
/// Event identifier.
|
|
pub fn event_id(mut self, new_value: &str) -> EventGetCall<'a, C, NC, A> {
|
|
self._event_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *time zone* query property to the given value.
|
|
///
|
|
///
|
|
/// Time zone used in the response. Optional. The default is the time zone of the calendar.
|
|
pub fn time_zone(mut self, new_value: &str) -> EventGetCall<'a, C, NC, A> {
|
|
self._time_zone = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max attendees* query property to the given value.
|
|
///
|
|
///
|
|
/// The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
|
|
pub fn max_attendees(mut self, new_value: i32) -> EventGetCall<'a, C, NC, A> {
|
|
self._max_attendees = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *always include email* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to always include a value in the email field for the organizer, creator and attendees, even if no real email is available (i.e. a generated, non-working value will be provided). The use of this option is discouraged and should only be used by clients which cannot handle the absence of an email address value in the mentioned places. Optional. The default is False.
|
|
pub fn always_include_email(mut self, new_value: bool) -> EventGetCall<'a, C, NC, A> {
|
|
self._always_include_email = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventGetCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns events on the specified calendar.
|
|
///
|
|
/// A builder for the *list* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.events().list("calendarId")
|
|
/// .updated_min("est")
|
|
/// .time_zone("clita")
|
|
/// .time_min("invidunt")
|
|
/// .time_max("ut")
|
|
/// .sync_token("dolores")
|
|
/// .single_events(true)
|
|
/// .show_hidden_invitations(false)
|
|
/// .show_deleted(true)
|
|
/// .add_shared_extended_property("sed")
|
|
/// .q("aliquyam")
|
|
/// .add_private_extended_property("ea")
|
|
/// .page_token("ea")
|
|
/// .order_by("et")
|
|
/// .max_results(-48)
|
|
/// .max_attendees(-41)
|
|
/// .i_cal_uid("kasd")
|
|
/// .always_include_email(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_updated_min: Option<String>,
|
|
_time_zone: Option<String>,
|
|
_time_min: Option<String>,
|
|
_time_max: Option<String>,
|
|
_sync_token: Option<String>,
|
|
_single_events: Option<bool>,
|
|
_show_hidden_invitations: Option<bool>,
|
|
_show_deleted: Option<bool>,
|
|
_shared_extended_property: Vec<String>,
|
|
_q: Option<String>,
|
|
_private_extended_property: Vec<String>,
|
|
_page_token: Option<String>,
|
|
_order_by: Option<String>,
|
|
_max_results: Option<i32>,
|
|
_max_attendees: Option<i32>,
|
|
_i_cal_uid: Option<String>,
|
|
_always_include_email: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Events)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((20 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
if let Some(value) = self._updated_min {
|
|
params.push(("updatedMin", value.to_string()));
|
|
}
|
|
if let Some(value) = self._time_zone {
|
|
params.push(("timeZone", value.to_string()));
|
|
}
|
|
if let Some(value) = self._time_min {
|
|
params.push(("timeMin", value.to_string()));
|
|
}
|
|
if let Some(value) = self._time_max {
|
|
params.push(("timeMax", value.to_string()));
|
|
}
|
|
if let Some(value) = self._sync_token {
|
|
params.push(("syncToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._single_events {
|
|
params.push(("singleEvents", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_hidden_invitations {
|
|
params.push(("showHiddenInvitations", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_deleted {
|
|
params.push(("showDeleted", value.to_string()));
|
|
}
|
|
if self._shared_extended_property.len() > 0 {
|
|
let mut s = String::new();
|
|
for f in self._shared_extended_property.iter() {
|
|
s.push_str(&("/".to_string() + &f.to_string()));
|
|
}
|
|
params.push(("sharedExtendedProperty", s));
|
|
}
|
|
if let Some(value) = self._q {
|
|
params.push(("q", value.to_string()));
|
|
}
|
|
if self._private_extended_property.len() > 0 {
|
|
let mut s = String::new();
|
|
for f in self._private_extended_property.iter() {
|
|
s.push_str(&("/".to_string() + &f.to_string()));
|
|
}
|
|
params.push(("privateExtendedProperty", s));
|
|
}
|
|
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._max_attendees {
|
|
params.push(("maxAttendees", value.to_string()));
|
|
}
|
|
if let Some(value) = self._i_cal_uid {
|
|
params.push(("iCalUID", value.to_string()));
|
|
}
|
|
if let Some(value) = self._always_include_email {
|
|
params.push(("alwaysIncludeEmail", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "updatedMin", "timeZone", "timeMin", "timeMax", "syncToken", "singleEvents", "showHiddenInvitations", "showDeleted", "sharedExtendedProperty", "q", "privateExtendedProperty", "pageToken", "orderBy", "maxResults", "maxAttendees", "iCalUID", "alwaysIncludeEmail"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *updated min* query property to the given value.
|
|
///
|
|
///
|
|
/// Lower bound for an event's last modification time (as a RFC 3339 timestamp) to filter by. When specified, entries deleted since this time will always be included regardless of showDeleted. Optional. The default is not to filter by last modification time.
|
|
pub fn updated_min(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._updated_min = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *time zone* query property to the given value.
|
|
///
|
|
///
|
|
/// Time zone used in the response. Optional. The default is the time zone of the calendar.
|
|
pub fn time_zone(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._time_zone = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *time min* query property to the given value.
|
|
///
|
|
///
|
|
/// Lower bound (inclusive) for an event's end time to filter by. Optional. The default is not to filter by end time.
|
|
pub fn time_min(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._time_min = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *time max* query property to the given value.
|
|
///
|
|
///
|
|
/// Upper bound (exclusive) for an event's start time to filter by. Optional. The default is not to filter by start time.
|
|
pub fn time_max(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._time_max = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *sync token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. All events deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted to False.
|
|
/// There are several query parameters that cannot be specified together with nextSyncToken to ensure consistency of the client state.
|
|
///
|
|
/// These are:
|
|
/// - iCalUID
|
|
/// - orderBy
|
|
/// - privateExtendedProperty
|
|
/// - q
|
|
/// - sharedExtendedProperty
|
|
/// - timeMin
|
|
/// - timeMax
|
|
/// - updatedMin If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken.
|
|
/// Learn more about incremental synchronization.
|
|
/// Optional. The default is to return all entries.
|
|
pub fn sync_token(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._sync_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *single events* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to expand recurring events into instances and only return single one-off events and instances of recurring events, but not the underlying recurring events themselves. Optional. The default is False.
|
|
pub fn single_events(mut self, new_value: bool) -> EventListCall<'a, C, NC, A> {
|
|
self._single_events = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *show hidden invitations* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to include hidden invitations in the result. Optional. The default is False.
|
|
pub fn show_hidden_invitations(mut self, new_value: bool) -> EventListCall<'a, C, NC, A> {
|
|
self._show_hidden_invitations = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *show deleted* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to include deleted events (with status equals "cancelled") in the result. Cancelled instances of recurring events (but not the underlying recurring event) will still be included if showDeleted and singleEvents are both False. If showDeleted and singleEvents are both True, only single instances of deleted events (but not the underlying recurring events) are returned. Optional. The default is False.
|
|
pub fn show_deleted(mut self, new_value: bool) -> EventListCall<'a, C, NC, A> {
|
|
self._show_deleted = Some(new_value);
|
|
self
|
|
}
|
|
/// Append the given value to the *shared extended property* query property.
|
|
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
|
|
///
|
|
///
|
|
/// Extended properties constraint specified as propertyName=value. Matches only shared properties. This parameter might be repeated multiple times to return events that match all given constraints.
|
|
pub fn add_shared_extended_property(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._shared_extended_property.push(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *q* query property to the given value.
|
|
///
|
|
///
|
|
/// Free text search terms to find events that match these terms in any field, except for extended properties. Optional.
|
|
pub fn q(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._q = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Append the given value to the *private extended property* query property.
|
|
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
|
|
///
|
|
///
|
|
/// Extended properties constraint specified as propertyName=value. Matches only private properties. This parameter might be repeated multiple times to return events that match all given constraints.
|
|
pub fn add_private_extended_property(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._private_extended_property.push(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token specifying which result page to return. Optional.
|
|
pub fn page_token(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *order by* query property to the given value.
|
|
///
|
|
///
|
|
/// The order of the events returned in the result. Optional. The default is an unspecified, stable order.
|
|
pub fn order_by(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._order_by = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Maximum number of events returned on one result page. By default the value is 250 events. The page size can never be larger than 2500 events. Optional.
|
|
pub fn max_results(mut self, new_value: i32) -> EventListCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *max attendees* query property to the given value.
|
|
///
|
|
///
|
|
/// The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
|
|
pub fn max_attendees(mut self, new_value: i32) -> EventListCall<'a, C, NC, A> {
|
|
self._max_attendees = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *i cal uid* query property to the given value.
|
|
///
|
|
///
|
|
/// Specifies event ID in the iCalendar format to be included in the response. Optional.
|
|
pub fn i_cal_uid(mut self, new_value: &str) -> EventListCall<'a, C, NC, A> {
|
|
self._i_cal_uid = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *always include email* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to always include a value in the email field for the organizer, creator and attendees, even if no real email is available (i.e. a generated, non-working value will be provided). The use of this option is discouraged and should only be used by clients which cannot handle the absence of an email address value in the mentioned places. Optional. The default is False.
|
|
pub fn always_include_email(mut self, new_value: bool) -> EventListCall<'a, C, NC, A> {
|
|
self._always_include_email = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventListCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates an event. This method supports patch semantics.
|
|
///
|
|
/// A builder for the *patch* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Event;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Event = Default::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.events().patch(&req, "calendarId", "eventId")
|
|
/// .send_notifications(false)
|
|
/// .max_attendees(-37)
|
|
/// .always_include_email(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Event,
|
|
_calendar_id: String,
|
|
_event_id: String,
|
|
_send_notifications: Option<bool>,
|
|
_max_attendees: Option<i32>,
|
|
_always_include_email: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Event)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("eventId", self._event_id.to_string()));
|
|
if let Some(value) = self._send_notifications {
|
|
params.push(("sendNotifications", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_attendees {
|
|
params.push(("maxAttendees", value.to_string()));
|
|
}
|
|
if let Some(value) = self._always_include_email {
|
|
params.push(("alwaysIncludeEmail", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "eventId", "sendNotifications", "maxAttendees", "alwaysIncludeEmail"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/{eventId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].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 ["calendarId", "eventId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Event) -> EventPatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventPatchCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *event 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.
|
|
///
|
|
/// Event identifier.
|
|
pub fn event_id(mut self, new_value: &str) -> EventPatchCall<'a, C, NC, A> {
|
|
self._event_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *send notifications* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to send notifications about the event update (e.g. attendee's responses, title changes, etc.). Optional. The default is False.
|
|
pub fn send_notifications(mut self, new_value: bool) -> EventPatchCall<'a, C, NC, A> {
|
|
self._send_notifications = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *max attendees* query property to the given value.
|
|
///
|
|
///
|
|
/// The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
|
|
pub fn max_attendees(mut self, new_value: i32) -> EventPatchCall<'a, C, NC, A> {
|
|
self._max_attendees = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *always include email* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to always include a value in the email field for the organizer, creator and attendees, even if no real email is available (i.e. a generated, non-working value will be provided). The use of this option is discouraged and should only be used by clients which cannot handle the absence of an email address value in the mentioned places. Optional. The default is False.
|
|
pub fn always_include_email(mut self, new_value: bool) -> EventPatchCall<'a, C, NC, A> {
|
|
self._always_include_email = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventPatchCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventPatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Moves an event to another calendar, i.e. changes an event's organizer.
|
|
///
|
|
/// A builder for the *move* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.events().move_("calendarId", "eventId", "destination")
|
|
/// .send_notifications(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventMoveCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_event_id: String,
|
|
_destination: String,
|
|
_send_notifications: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventMoveCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventMoveCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Event)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.move",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("eventId", self._event_id.to_string()));
|
|
params.push(("destination", self._destination.to_string()));
|
|
if let Some(value) = self._send_notifications {
|
|
params.push(("sendNotifications", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "eventId", "destination", "sendNotifications"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/{eventId}/move".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].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 ["calendarId", "eventId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier of the source calendar where the event currently is on.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventMoveCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *event 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.
|
|
///
|
|
/// Event identifier.
|
|
pub fn event_id(mut self, new_value: &str) -> EventMoveCall<'a, C, NC, A> {
|
|
self._event_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *destination* query property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
///
|
|
/// Calendar identifier of the target calendar where the event is to be moved to.
|
|
pub fn destination(mut self, new_value: &str) -> EventMoveCall<'a, C, NC, A> {
|
|
self._destination = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *send notifications* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to send notifications about the change of the event's organizer. Optional. The default is False.
|
|
pub fn send_notifications(mut self, new_value: bool) -> EventMoveCall<'a, C, NC, A> {
|
|
self._send_notifications = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventMoveCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventMoveCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventMoveCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates an event.
|
|
///
|
|
/// A builder for the *update* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Event;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Event = Default::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.events().update(&req, "calendarId", "eventId")
|
|
/// .send_notifications(true)
|
|
/// .max_attendees(-91)
|
|
/// .always_include_email(true)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Event,
|
|
_calendar_id: String,
|
|
_event_id: String,
|
|
_send_notifications: Option<bool>,
|
|
_max_attendees: Option<i32>,
|
|
_always_include_email: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Event)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("eventId", self._event_id.to_string()));
|
|
if let Some(value) = self._send_notifications {
|
|
params.push(("sendNotifications", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_attendees {
|
|
params.push(("maxAttendees", value.to_string()));
|
|
}
|
|
if let Some(value) = self._always_include_email {
|
|
params.push(("alwaysIncludeEmail", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "eventId", "sendNotifications", "maxAttendees", "alwaysIncludeEmail"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/{eventId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].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 ["calendarId", "eventId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Event) -> EventUpdateCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventUpdateCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *event 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.
|
|
///
|
|
/// Event identifier.
|
|
pub fn event_id(mut self, new_value: &str) -> EventUpdateCall<'a, C, NC, A> {
|
|
self._event_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *send notifications* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to send notifications about the event update (e.g. attendee's responses, title changes, etc.). Optional. The default is False.
|
|
pub fn send_notifications(mut self, new_value: bool) -> EventUpdateCall<'a, C, NC, A> {
|
|
self._send_notifications = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *max attendees* query property to the given value.
|
|
///
|
|
///
|
|
/// The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
|
|
pub fn max_attendees(mut self, new_value: i32) -> EventUpdateCall<'a, C, NC, A> {
|
|
self._max_attendees = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *always include email* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to always include a value in the email field for the organizer, creator and attendees, even if no real email is available (i.e. a generated, non-working value will be provided). The use of this option is discouraged and should only be used by clients which cannot handle the absence of an email address value in the mentioned places. Optional. The default is False.
|
|
pub fn always_include_email(mut self, new_value: bool) -> EventUpdateCall<'a, C, NC, A> {
|
|
self._always_include_email = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventUpdateCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Watch for changes to Events resources.
|
|
///
|
|
/// A builder for the *watch* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// use calendar3::Channel;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req: Channel = Default::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.events().watch(&req, "calendarId")
|
|
/// .updated_min("Lorem")
|
|
/// .time_zone("diam")
|
|
/// .time_min("ut")
|
|
/// .time_max("ut")
|
|
/// .sync_token("amet.")
|
|
/// .single_events(false)
|
|
/// .show_hidden_invitations(false)
|
|
/// .show_deleted(true)
|
|
/// .add_shared_extended_property("sea")
|
|
/// .q("ut")
|
|
/// .add_private_extended_property("eirmod")
|
|
/// .page_token("sanctus")
|
|
/// .order_by("voluptua.")
|
|
/// .max_results(-99)
|
|
/// .max_attendees(-22)
|
|
/// .i_cal_uid("et")
|
|
/// .always_include_email(true)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventWatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_request: Channel,
|
|
_calendar_id: String,
|
|
_updated_min: Option<String>,
|
|
_time_zone: Option<String>,
|
|
_time_min: Option<String>,
|
|
_time_max: Option<String>,
|
|
_sync_token: Option<String>,
|
|
_single_events: Option<bool>,
|
|
_show_hidden_invitations: Option<bool>,
|
|
_show_deleted: Option<bool>,
|
|
_shared_extended_property: Vec<String>,
|
|
_q: Option<String>,
|
|
_private_extended_property: Vec<String>,
|
|
_page_token: Option<String>,
|
|
_order_by: Option<String>,
|
|
_max_results: Option<i32>,
|
|
_max_attendees: Option<i32>,
|
|
_i_cal_uid: Option<String>,
|
|
_always_include_email: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventWatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventWatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Channel)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.watch",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((21 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
if let Some(value) = self._updated_min {
|
|
params.push(("updatedMin", value.to_string()));
|
|
}
|
|
if let Some(value) = self._time_zone {
|
|
params.push(("timeZone", value.to_string()));
|
|
}
|
|
if let Some(value) = self._time_min {
|
|
params.push(("timeMin", value.to_string()));
|
|
}
|
|
if let Some(value) = self._time_max {
|
|
params.push(("timeMax", value.to_string()));
|
|
}
|
|
if let Some(value) = self._sync_token {
|
|
params.push(("syncToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._single_events {
|
|
params.push(("singleEvents", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_hidden_invitations {
|
|
params.push(("showHiddenInvitations", value.to_string()));
|
|
}
|
|
if let Some(value) = self._show_deleted {
|
|
params.push(("showDeleted", value.to_string()));
|
|
}
|
|
if self._shared_extended_property.len() > 0 {
|
|
let mut s = String::new();
|
|
for f in self._shared_extended_property.iter() {
|
|
s.push_str(&("/".to_string() + &f.to_string()));
|
|
}
|
|
params.push(("sharedExtendedProperty", s));
|
|
}
|
|
if let Some(value) = self._q {
|
|
params.push(("q", value.to_string()));
|
|
}
|
|
if self._private_extended_property.len() > 0 {
|
|
let mut s = String::new();
|
|
for f in self._private_extended_property.iter() {
|
|
s.push_str(&("/".to_string() + &f.to_string()));
|
|
}
|
|
params.push(("privateExtendedProperty", s));
|
|
}
|
|
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._max_attendees {
|
|
params.push(("maxAttendees", value.to_string()));
|
|
}
|
|
if let Some(value) = self._i_cal_uid {
|
|
params.push(("iCalUID", value.to_string()));
|
|
}
|
|
if let Some(value) = self._always_include_email {
|
|
params.push(("alwaysIncludeEmail", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "updatedMin", "timeZone", "timeMin", "timeMax", "syncToken", "singleEvents", "showHiddenInvitations", "showDeleted", "sharedExtendedProperty", "q", "privateExtendedProperty", "pageToken", "orderBy", "maxResults", "maxAttendees", "iCalUID", "alwaysIncludeEmail"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/watch".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &Channel) -> EventWatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *updated min* query property to the given value.
|
|
///
|
|
///
|
|
/// Lower bound for an event's last modification time (as a RFC 3339 timestamp) to filter by. When specified, entries deleted since this time will always be included regardless of showDeleted. Optional. The default is not to filter by last modification time.
|
|
pub fn updated_min(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._updated_min = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *time zone* query property to the given value.
|
|
///
|
|
///
|
|
/// Time zone used in the response. Optional. The default is the time zone of the calendar.
|
|
pub fn time_zone(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._time_zone = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *time min* query property to the given value.
|
|
///
|
|
///
|
|
/// Lower bound (inclusive) for an event's end time to filter by. Optional. The default is not to filter by end time.
|
|
pub fn time_min(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._time_min = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *time max* query property to the given value.
|
|
///
|
|
///
|
|
/// Upper bound (exclusive) for an event's start time to filter by. Optional. The default is not to filter by start time.
|
|
pub fn time_max(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._time_max = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *sync token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. All events deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted to False.
|
|
/// There are several query parameters that cannot be specified together with nextSyncToken to ensure consistency of the client state.
|
|
///
|
|
/// These are:
|
|
/// - iCalUID
|
|
/// - orderBy
|
|
/// - privateExtendedProperty
|
|
/// - q
|
|
/// - sharedExtendedProperty
|
|
/// - timeMin
|
|
/// - timeMax
|
|
/// - updatedMin If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken.
|
|
/// Learn more about incremental synchronization.
|
|
/// Optional. The default is to return all entries.
|
|
pub fn sync_token(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._sync_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *single events* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to expand recurring events into instances and only return single one-off events and instances of recurring events, but not the underlying recurring events themselves. Optional. The default is False.
|
|
pub fn single_events(mut self, new_value: bool) -> EventWatchCall<'a, C, NC, A> {
|
|
self._single_events = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *show hidden invitations* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to include hidden invitations in the result. Optional. The default is False.
|
|
pub fn show_hidden_invitations(mut self, new_value: bool) -> EventWatchCall<'a, C, NC, A> {
|
|
self._show_hidden_invitations = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *show deleted* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to include deleted events (with status equals "cancelled") in the result. Cancelled instances of recurring events (but not the underlying recurring event) will still be included if showDeleted and singleEvents are both False. If showDeleted and singleEvents are both True, only single instances of deleted events (but not the underlying recurring events) are returned. Optional. The default is False.
|
|
pub fn show_deleted(mut self, new_value: bool) -> EventWatchCall<'a, C, NC, A> {
|
|
self._show_deleted = Some(new_value);
|
|
self
|
|
}
|
|
/// Append the given value to the *shared extended property* query property.
|
|
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
|
|
///
|
|
///
|
|
/// Extended properties constraint specified as propertyName=value. Matches only shared properties. This parameter might be repeated multiple times to return events that match all given constraints.
|
|
pub fn add_shared_extended_property(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._shared_extended_property.push(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *q* query property to the given value.
|
|
///
|
|
///
|
|
/// Free text search terms to find events that match these terms in any field, except for extended properties. Optional.
|
|
pub fn q(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._q = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Append the given value to the *private extended property* query property.
|
|
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
|
|
///
|
|
///
|
|
/// Extended properties constraint specified as propertyName=value. Matches only private properties. This parameter might be repeated multiple times to return events that match all given constraints.
|
|
pub fn add_private_extended_property(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._private_extended_property.push(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Token specifying which result page to return. Optional.
|
|
pub fn page_token(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *order by* query property to the given value.
|
|
///
|
|
///
|
|
/// The order of the events returned in the result. Optional. The default is an unspecified, stable order.
|
|
pub fn order_by(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._order_by = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Maximum number of events returned on one result page. By default the value is 250 events. The page size can never be larger than 2500 events. Optional.
|
|
pub fn max_results(mut self, new_value: i32) -> EventWatchCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *max attendees* query property to the given value.
|
|
///
|
|
///
|
|
/// The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
|
|
pub fn max_attendees(mut self, new_value: i32) -> EventWatchCall<'a, C, NC, A> {
|
|
self._max_attendees = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *i cal uid* query property to the given value.
|
|
///
|
|
///
|
|
/// Specifies event ID in the iCalendar format to be included in the response. Optional.
|
|
pub fn i_cal_uid(mut self, new_value: &str) -> EventWatchCall<'a, C, NC, A> {
|
|
self._i_cal_uid = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *always include email* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to always include a value in the email field for the organizer, creator and attendees, even if no real email is available (i.e. a generated, non-working value will be provided). The use of this option is discouraged and should only be used by clients which cannot handle the absence of an email address value in the mentioned places. Optional. The default is False.
|
|
pub fn always_include_email(mut self, new_value: bool) -> EventWatchCall<'a, C, NC, A> {
|
|
self._always_include_email = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventWatchCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventWatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventWatchCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Creates an event based on a simple text string.
|
|
///
|
|
/// A builder for the *quickAdd* method supported by a *event* resource.
|
|
/// It is not used directly, but through a `EventMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-calendar3" as calendar3;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use calendar3::CalendarHub;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = CalendarHub::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.events().quick_add("calendarId", "text")
|
|
/// .send_notifications(true)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct EventQuickAddCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a CalendarHub<C, NC, A>,
|
|
_calendar_id: String,
|
|
_text: String,
|
|
_send_notifications: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for EventQuickAddCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> EventQuickAddCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Event)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "calendar.events.quickAdd",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("calendarId", self._calendar_id.to_string()));
|
|
params.push(("text", self._text.to_string()));
|
|
if let Some(value) = self._send_notifications {
|
|
params.push(("sendNotifications", value.to_string()));
|
|
}
|
|
for &field in ["alt", "calendarId", "text", "sendNotifications"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::FieldClash(field);
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/quickAdd".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{calendarId}", "calendarId")].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 ["calendarId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Result::MissingToken
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_slice())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::HttpError(err)
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::Failure(res)
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *calendar 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.
|
|
///
|
|
/// Calendar identifier.
|
|
pub fn calendar_id(mut self, new_value: &str) -> EventQuickAddCall<'a, C, NC, A> {
|
|
self._calendar_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *text* query property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
///
|
|
/// The text describing the event to be created.
|
|
pub fn text(mut self, new_value: &str) -> EventQuickAddCall<'a, C, NC, A> {
|
|
self._text = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *send notifications* query property to the given value.
|
|
///
|
|
///
|
|
/// Whether to send notifications about the creation of the event. Optional. The default is False.
|
|
pub fn send_notifications(mut self, new_value: bool) -> EventQuickAddCall<'a, C, NC, A> {
|
|
self._send_notifications = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given 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.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> EventQuickAddCall<'a, C, NC, 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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> EventQuickAddCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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 of relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// 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>(mut self, scope: T) -> EventQuickAddCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|