mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-05 02:55:32 +01:00
4967 lines
204 KiB
Rust
4967 lines
204 KiB
Rust
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
|
// DO NOT EDIT !
|
|
|
|
//! This documentation was generated from *coordinate* crate version *0.1.7+20141215*, where *20141215* is the exact revision of the *coordinate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.7*.
|
|
//!
|
|
//! Everything else about the *coordinate* *v1* API can be found at the
|
|
//! [official documentation site](https://developers.google.com/coordinate/).
|
|
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/coordinate1).
|
|
//! # Features
|
|
//!
|
|
//! Handle the following *Resources* with ease from the central [hub](struct.Coordinate.html) ...
|
|
//!
|
|
//! * [custom field def](struct.CustomFieldDef.html)
|
|
//! * [*list*](struct.CustomFieldDefListCall.html)
|
|
//! * [jobs](struct.Job.html)
|
|
//! * [*get*](struct.JobGetCall.html), [*insert*](struct.JobInsertCall.html), [*list*](struct.JobListCall.html), [*patch*](struct.JobPatchCall.html) and [*update*](struct.JobUpdateCall.html)
|
|
//! * [location](struct.Location.html)
|
|
//! * [*list*](struct.LocationListCall.html)
|
|
//! * [schedule](struct.Schedule.html)
|
|
//! * [*get*](struct.ScheduleGetCall.html), [*patch*](struct.SchedulePatchCall.html) and [*update*](struct.ScheduleUpdateCall.html)
|
|
//! * [team](struct.Team.html)
|
|
//! * [*list*](struct.TeamListCall.html)
|
|
//! * [worker](struct.Worker.html)
|
|
//! * [*list*](struct.WorkerListCall.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.Coordinate.html)**
|
|
//! * a central object to maintain state and allow accessing all *Activities*
|
|
//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
|
|
//! allow access to individual [*Call Builders*](trait.CallBuilder.html)
|
|
//! * **[Resources](trait.Resource.html)**
|
|
//! * primary types that you can apply *Activities* to
|
|
//! * a collection of properties and *Parts*
|
|
//! * **[Parts](trait.Part.html)**
|
|
//! * a collection of properties
|
|
//! * never directly used in *Activities*
|
|
//! * **[Activities](trait.CallBuilder.html)**
|
|
//! * operations to apply to *Resources*
|
|
//!
|
|
//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
|
|
//!
|
|
//! Generally speaking, you can invoke *Activities* like this:
|
|
//!
|
|
//! ```Rust,ignore
|
|
//! let r = hub.resource().activity(...).doit()
|
|
//! ```
|
|
//!
|
|
//! Or specifically ...
|
|
//!
|
|
//! ```ignore
|
|
//! let r = hub.jobs().get(...).doit()
|
|
//! let r = hub.jobs().update(...).doit()
|
|
//! let r = hub.jobs().patch(...).doit()
|
|
//! let r = hub.jobs().list(...).doit()
|
|
//! let r = hub.jobs().insert(...).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-coordinate1 = "*"
|
|
//! ```
|
|
//!
|
|
//! ## A complete example
|
|
//!
|
|
//! ```test_harness,no_run
|
|
//! extern crate hyper;
|
|
//! extern crate yup_oauth2 as oauth2;
|
|
//! extern crate google_coordinate1 as coordinate1;
|
|
//! use coordinate1::Job;
|
|
//! use coordinate1::{Result, Error};
|
|
//! # #[test] fn egal() {
|
|
//! use std::default::Default;
|
|
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
//! use coordinate1::Coordinate;
|
|
//!
|
|
//! // 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 = Coordinate::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 = Job::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.jobs().update(req, "teamId", "jobId")
|
|
//! .title("nonumy")
|
|
//! .progress("dolores")
|
|
//! .note("gubergren")
|
|
//! .lng(0.0653431304201)
|
|
//! .lat(0.699208331616)
|
|
//! .customer_phone_number("ea")
|
|
//! .customer_name("no")
|
|
//! .add_custom_field("justo")
|
|
//! .assignee("justo")
|
|
//! .address("et")
|
|
//! .doit();
|
|
//!
|
|
//! match result {
|
|
//! Err(e) => match e {
|
|
//! // The Error enum provides details about what exactly happened.
|
|
//! // You can also just use its `Debug`, `Display` or `Error` traits
|
|
//! Error::HttpError(_)
|
|
//! |Error::MissingAPIKey
|
|
//! |Error::MissingToken(_)
|
|
//! |Error::Cancelled
|
|
//! |Error::UploadSizeLimitExceeded(_, _)
|
|
//! |Error::Failure(_)
|
|
//! |Error::BadRequest(_)
|
|
//! |Error::FieldClash(_)
|
|
//! |Error::JsonDecodeError(_, _) => println!("{}", e),
|
|
//! },
|
|
//! Ok(res) => println!("Success: {:?}", res),
|
|
//! }
|
|
//! # }
|
|
//! ```
|
|
//! ## Handling Errors
|
|
//!
|
|
//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of
|
|
//! the doit() methods, or handed as possibly intermediate results to either the
|
|
//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../yup-oauth2/trait.AuthenticatorDelegate.html).
|
|
//!
|
|
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
|
//! makes the system potentially resilient to all kinds of errors.
|
|
//!
|
|
//! ## Uploads and Downloads
|
|
//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
|
|
//! read by you to obtain the media.
|
|
//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
|
|
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
|
|
//! this call: `.param("alt", "media")`.
|
|
//!
|
|
//! Methods supporting uploads can do so using up to 2 different protocols:
|
|
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
|
|
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
|
|
//!
|
|
//! ## Customization and Callbacks
|
|
//!
|
|
//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the
|
|
//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call.
|
|
//! Respective methods will be called to provide progress information, as well as determine whether the system should
|
|
//! retry on failure.
|
|
//!
|
|
//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
|
|
//!
|
|
//! ## Optional Parts in Server-Requests
|
|
//!
|
|
//! All structures provided by this library are made to be [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 identifiable by name, which will be sent to
|
|
//! the server to indicate either the set parts of the request or the desired parts in the response.
|
|
//!
|
|
//! ## Builder Arguments
|
|
//!
|
|
//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
|
|
//! These will always take a single argument, for which the following statements are true.
|
|
//!
|
|
//! * [PODs][wiki-pod] are handed by copy
|
|
//! * strings are passed as `&str`
|
|
//! * [request values](trait.RequestValue.html) are moved
|
|
//!
|
|
//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
|
|
//!
|
|
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
|
|
//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
|
|
//! [google-go-api]: https://github.com/google/google-api-go-client
|
|
//!
|
|
//!
|
|
// Unused attributes happen thanks to defined, but unused structures
|
|
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
|
|
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
|
// unused imports in fully featured APIs. Same with unused_mut ... .
|
|
#![allow(unused_imports, unused_mut, dead_code)]
|
|
// Required for serde annotations
|
|
#![feature(custom_derive, custom_attribute, plugin, slice_patterns)]
|
|
#![plugin(serde_macros)]
|
|
|
|
#[macro_use]
|
|
extern crate hyper;
|
|
extern crate serde;
|
|
extern crate yup_oauth2 as oauth2;
|
|
extern crate mime;
|
|
extern crate url;
|
|
extern crate json_tools;
|
|
|
|
mod cmn;
|
|
|
|
use std::collections::HashMap;
|
|
use std::cell::RefCell;
|
|
use std::borrow::BorrowMut;
|
|
use std::default::Default;
|
|
use std::collections::BTreeMap;
|
|
use serde::json;
|
|
use std::io;
|
|
use std::fs;
|
|
use std::thread::sleep_ms;
|
|
|
|
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse};
|
|
|
|
|
|
// ##############
|
|
// 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 and manage your Google Maps Coordinate jobs
|
|
Full,
|
|
|
|
/// View your Google Coordinate jobs
|
|
Readonly,
|
|
}
|
|
|
|
impl AsRef<str> for Scope {
|
|
fn as_ref(&self) -> &str {
|
|
match *self {
|
|
Scope::Full => "https://www.googleapis.com/auth/coordinate",
|
|
Scope::Readonly => "https://www.googleapis.com/auth/coordinate.readonly",
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Scope {
|
|
fn default() -> Scope {
|
|
Scope::Readonly
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ########
|
|
// HUB ###
|
|
// ######
|
|
|
|
/// Central instance to access all Coordinate related resource activities
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// Instantiate a new hub
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_coordinate1 as coordinate1;
|
|
/// use coordinate1::Job;
|
|
/// use coordinate1::{Result, Error};
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use coordinate1::Coordinate;
|
|
///
|
|
/// // 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 = Coordinate::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 = Job::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.jobs().update(req, "teamId", "jobId")
|
|
/// .title("ipsum")
|
|
/// .progress("Lorem")
|
|
/// .note("et")
|
|
/// .lng(0.313727897996)
|
|
/// .lat(0.69054137112)
|
|
/// .customer_phone_number("sea")
|
|
/// .customer_name("Lorem")
|
|
/// .add_custom_field("eos")
|
|
/// .assignee("erat")
|
|
/// .address("sadipscing")
|
|
/// .doit();
|
|
///
|
|
/// match result {
|
|
/// Err(e) => match e {
|
|
/// // The Error enum provides details about what exactly happened.
|
|
/// // You can also just use its `Debug`, `Display` or `Error` traits
|
|
/// Error::HttpError(_)
|
|
/// |Error::MissingAPIKey
|
|
/// |Error::MissingToken(_)
|
|
/// |Error::Cancelled
|
|
/// |Error::UploadSizeLimitExceeded(_, _)
|
|
/// |Error::Failure(_)
|
|
/// |Error::BadRequest(_)
|
|
/// |Error::FieldClash(_)
|
|
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
|
|
/// },
|
|
/// Ok(res) => println!("Success: {:?}", res),
|
|
/// }
|
|
/// # }
|
|
/// ```
|
|
pub struct Coordinate<C, A> {
|
|
client: RefCell<C>,
|
|
auth: RefCell<A>,
|
|
_user_agent: String,
|
|
}
|
|
|
|
impl<'a, C, A> Hub for Coordinate<C, A> {}
|
|
|
|
impl<'a, C, A> Coordinate<C, A>
|
|
where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
pub fn new(client: C, authenticator: A) -> Coordinate<C, A> {
|
|
Coordinate {
|
|
client: RefCell::new(client),
|
|
auth: RefCell::new(authenticator),
|
|
_user_agent: "google-api-rust-client/0.1.7".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn custom_field_def(&'a self) -> CustomFieldDefMethods<'a, C, A> {
|
|
CustomFieldDefMethods { hub: &self }
|
|
}
|
|
pub fn jobs(&'a self) -> JobMethods<'a, C, A> {
|
|
JobMethods { hub: &self }
|
|
}
|
|
pub fn location(&'a self) -> LocationMethods<'a, C, A> {
|
|
LocationMethods { hub: &self }
|
|
}
|
|
pub fn schedule(&'a self) -> ScheduleMethods<'a, C, A> {
|
|
ScheduleMethods { hub: &self }
|
|
}
|
|
pub fn team(&'a self) -> TeamMethods<'a, C, A> {
|
|
TeamMethods { hub: &self }
|
|
}
|
|
pub fn worker(&'a self) -> WorkerMethods<'a, C, A> {
|
|
WorkerMethods { 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.7`.
|
|
///
|
|
/// 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 ###
|
|
// ##########
|
|
/// Response from a List Locations request.
|
|
///
|
|
/// # 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 location](struct.LocationListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct LocationListResponse {
|
|
/// A token to provide to get the next page of results.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
/// Locations in the collection.
|
|
pub items: Option<Vec<LocationRecord>>,
|
|
/// Identifies this object as a list of locations.
|
|
pub kind: Option<String>,
|
|
/// Pagination information for token pagination.
|
|
#[serde(rename="tokenPagination")]
|
|
pub token_pagination: Option<TokenPagination>,
|
|
}
|
|
|
|
impl ResponseResult for LocationListResponse {}
|
|
|
|
|
|
/// Change to a job. For example assigning the job to a different worker.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct JobChange {
|
|
/// Time at which this change was applied.
|
|
pub timestamp: Option<String>,
|
|
/// Identifies this object as a job change.
|
|
pub kind: Option<String>,
|
|
/// Change applied to the job. Only the fields that were changed are set.
|
|
pub state: Option<JobState>,
|
|
}
|
|
|
|
impl Part for JobChange {}
|
|
|
|
|
|
/// Enum Item definition.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct EnumItemDef {
|
|
/// Whether the enum item is active. Jobs may contain inactive enum values; however, setting an enum to an inactive value when creating or updating a job will result in a 500 error.
|
|
pub active: Option<bool>,
|
|
/// Identifies this object as an enum item definition.
|
|
pub kind: Option<String>,
|
|
/// Custom field value.
|
|
pub value: Option<String>,
|
|
}
|
|
|
|
impl Part for EnumItemDef {}
|
|
|
|
|
|
/// Collection of custom field definitions for a team.
|
|
///
|
|
/// # 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 custom field def](struct.CustomFieldDefListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CustomFieldDefListResponse {
|
|
/// Collection of custom field definitions in a team.
|
|
pub items: Option<Vec<CustomFieldDef>>,
|
|
/// Identifies this object as a collection of custom field definitions in a team.
|
|
pub kind: Option<String>,
|
|
}
|
|
|
|
impl ResponseResult for CustomFieldDefListResponse {}
|
|
|
|
|
|
/// Pagination information.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct TokenPagination {
|
|
/// A token to provide to get the next page of results.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
/// A token to provide to get the previous page of results.
|
|
#[serde(rename="previousPageToken")]
|
|
pub previous_page_token: Option<String>,
|
|
/// Identifies this object as pagination information.
|
|
pub kind: Option<String>,
|
|
}
|
|
|
|
impl Part for TokenPagination {}
|
|
|
|
|
|
/// Location of a job.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Location {
|
|
/// Latitude.
|
|
pub lat: Option<f64>,
|
|
/// Identifies this object as a location.
|
|
pub kind: Option<String>,
|
|
/// Address.
|
|
#[serde(rename="addressLine")]
|
|
pub address_line: Option<Vec<String>>,
|
|
/// Longitude.
|
|
pub lng: Option<f64>,
|
|
}
|
|
|
|
impl Part for Location {}
|
|
|
|
|
|
/// A Coordinate team.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Team {
|
|
/// Identifies this object as a team.
|
|
pub kind: Option<String>,
|
|
/// Team id, as found in a coordinate team url e.g. https://coordinate.google.com/f/xyz where "xyz" is the team id.
|
|
pub id: Option<String>,
|
|
/// Team name
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
impl Part for Team {}
|
|
|
|
|
|
/// Current state of a job.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct JobState {
|
|
/// Identifies this object as a job state.
|
|
pub kind: Option<String>,
|
|
/// Customer name.
|
|
#[serde(rename="customerName")]
|
|
pub customer_name: Option<String>,
|
|
/// Job title.
|
|
pub title: Option<String>,
|
|
/// Note added to the job.
|
|
pub note: Option<Vec<String>>,
|
|
/// Email address of the assignee, or the string "DELETED_USER" if the account is no longer available.
|
|
pub assignee: Option<String>,
|
|
/// Customer phone number.
|
|
#[serde(rename="customerPhoneNumber")]
|
|
pub customer_phone_number: Option<String>,
|
|
/// Job location.
|
|
pub location: Option<Location>,
|
|
/// Job progress.
|
|
pub progress: Option<String>,
|
|
/// Custom fields.
|
|
#[serde(rename="customFields")]
|
|
pub custom_fields: Option<CustomFields>,
|
|
}
|
|
|
|
impl Part for JobState {}
|
|
|
|
|
|
/// Collection of custom fields.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CustomFields {
|
|
/// Identifies this object as a collection of custom fields.
|
|
pub kind: Option<String>,
|
|
/// Collection of custom fields.
|
|
#[serde(rename="customField")]
|
|
pub custom_field: Option<Vec<CustomField>>,
|
|
}
|
|
|
|
impl Part for CustomFields {}
|
|
|
|
|
|
/// Response from a List Workers request.
|
|
///
|
|
/// # 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 worker](struct.WorkerListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct WorkerListResponse {
|
|
/// Workers in the collection.
|
|
pub items: Option<Vec<Worker>>,
|
|
/// Identifies this object as a list of workers.
|
|
pub kind: Option<String>,
|
|
}
|
|
|
|
impl ResponseResult for WorkerListResponse {}
|
|
|
|
|
|
/// Recorded location of a worker.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct LocationRecord {
|
|
/// Latitude.
|
|
pub latitude: Option<f64>,
|
|
/// The collection time in milliseconds since the epoch.
|
|
#[serde(rename="collectionTime")]
|
|
pub collection_time: Option<String>,
|
|
/// The location accuracy in meters. This is the radius of a 95% confidence interval around the location measurement.
|
|
#[serde(rename="confidenceRadius")]
|
|
pub confidence_radius: Option<f64>,
|
|
/// Identifies this object as a location.
|
|
pub kind: Option<String>,
|
|
/// Longitude.
|
|
pub longitude: Option<f64>,
|
|
}
|
|
|
|
impl Part for LocationRecord {}
|
|
|
|
|
|
/// Job schedule.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [update schedule](struct.ScheduleUpdateCall.html) (request|response)
|
|
/// * [patch schedule](struct.SchedulePatchCall.html) (request|response)
|
|
/// * [get schedule](struct.ScheduleGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Schedule {
|
|
/// Job duration in milliseconds.
|
|
pub duration: Option<String>,
|
|
/// Identifies this object as a job schedule.
|
|
pub kind: Option<String>,
|
|
/// Whether the job is scheduled for the whole day. Time of day in start/end times is ignored if this is true.
|
|
#[serde(rename="allDay")]
|
|
pub all_day: Option<bool>,
|
|
/// Scheduled start time in milliseconds since epoch.
|
|
#[serde(rename="startTime")]
|
|
pub start_time: Option<String>,
|
|
/// Scheduled end time in milliseconds since epoch.
|
|
#[serde(rename="endTime")]
|
|
pub end_time: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for Schedule {}
|
|
impl ResponseResult for Schedule {}
|
|
|
|
|
|
/// Response from a List Teams request.
|
|
///
|
|
/// # 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 team](struct.TeamListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct TeamListResponse {
|
|
/// Teams in the collection.
|
|
pub items: Option<Vec<Team>>,
|
|
/// Identifies this object as a list of teams.
|
|
pub kind: Option<String>,
|
|
}
|
|
|
|
impl ResponseResult for TeamListResponse {}
|
|
|
|
|
|
/// Response from a List Jobs request.
|
|
///
|
|
/// # 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 jobs](struct.JobListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct JobListResponse {
|
|
/// A token to provide to get the next page of results.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
/// Jobs in the collection.
|
|
pub items: Option<Vec<Job>>,
|
|
/// Identifies this object as a list of jobs.
|
|
pub kind: Option<String>,
|
|
}
|
|
|
|
impl ResponseResult for JobListResponse {}
|
|
|
|
|
|
/// A worker in a Coordinate team.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Worker {
|
|
/// Identifies this object as a worker.
|
|
pub kind: Option<String>,
|
|
/// Worker email address. If a worker has been deleted from your team, the email address will appear as DELETED_USER.
|
|
pub id: Option<String>,
|
|
}
|
|
|
|
impl Part for Worker {}
|
|
|
|
|
|
/// A job.
|
|
///
|
|
/// # 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 jobs](struct.JobGetCall.html) (response)
|
|
/// * [update jobs](struct.JobUpdateCall.html) (request|response)
|
|
/// * [patch jobs](struct.JobPatchCall.html) (request|response)
|
|
/// * [list jobs](struct.JobListCall.html) (none)
|
|
/// * [insert jobs](struct.JobInsertCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Job {
|
|
/// Identifies this object as a job.
|
|
pub kind: Option<String>,
|
|
/// List of job changes since it was created. The first change corresponds to the state of the job when it was created.
|
|
#[serde(rename="jobChange")]
|
|
pub job_change: Option<Vec<JobChange>>,
|
|
/// Job id.
|
|
pub id: Option<String>,
|
|
/// Current job state.
|
|
pub state: Option<JobState>,
|
|
}
|
|
|
|
impl RequestValue for Job {}
|
|
impl Resource for Job {}
|
|
impl ResponseResult for Job {}
|
|
|
|
|
|
/// Custom field definition.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CustomFieldDef {
|
|
/// Identifies this object as a custom field definition.
|
|
pub kind: Option<String>,
|
|
/// List of enum items for this custom field. Populated only if the field type is enum. Enum fields appear as 'lists' in the Coordinate web and mobile UI.
|
|
pub enumitems: Option<Vec<EnumItemDef>>,
|
|
/// Custom field name.
|
|
pub name: Option<String>,
|
|
/// Custom field type.
|
|
#[serde(rename="type")]
|
|
pub type_: Option<String>,
|
|
/// Whether the field is required for checkout.
|
|
#[serde(rename="requiredForCheckout")]
|
|
pub required_for_checkout: Option<bool>,
|
|
/// Whether the field is enabled.
|
|
pub enabled: Option<bool>,
|
|
/// Custom field id.
|
|
pub id: Option<String>,
|
|
}
|
|
|
|
impl Part for CustomFieldDef {}
|
|
|
|
|
|
/// Custom field.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CustomField {
|
|
/// Identifies this object as a custom field.
|
|
pub kind: Option<String>,
|
|
/// Custom field id.
|
|
#[serde(rename="customFieldId")]
|
|
pub custom_field_id: Option<String>,
|
|
/// Custom field value.
|
|
pub value: Option<String>,
|
|
}
|
|
|
|
impl Part for CustomField {}
|
|
|
|
|
|
|
|
// ###################
|
|
// MethodBuilders ###
|
|
// #################
|
|
|
|
/// A builder providing access to all methods supported on *job* resources.
|
|
/// It is not used directly, but through the `Coordinate` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_coordinate1 as coordinate1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use coordinate1::Coordinate;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Coordinate::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.jobs();
|
|
/// # }
|
|
/// ```
|
|
pub struct JobMethods<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
}
|
|
|
|
impl<'a, C, A> MethodsBuilder for JobMethods<'a, C, A> {}
|
|
|
|
impl<'a, C, A> JobMethods<'a, C, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Retrieves a job, including all the changes made to the job.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `teamId` - Team ID
|
|
/// * `jobId` - Job number
|
|
pub fn get(&self, team_id: &str, job_id: &str) -> JobGetCall<'a, C, A> {
|
|
JobGetCall {
|
|
hub: self.hub,
|
|
_team_id: team_id.to_string(),
|
|
_job_id: job_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates a job. Fields that are set in the job state will be updated.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `teamId` - Team ID
|
|
/// * `jobId` - Job number
|
|
pub fn update(&self, request: Job, team_id: &str, job_id: &str) -> JobUpdateCall<'a, C, A> {
|
|
JobUpdateCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_team_id: team_id.to_string(),
|
|
_job_id: job_id.to_string(),
|
|
_title: Default::default(),
|
|
_progress: Default::default(),
|
|
_note: Default::default(),
|
|
_lng: Default::default(),
|
|
_lat: Default::default(),
|
|
_customer_phone_number: Default::default(),
|
|
_customer_name: Default::default(),
|
|
_custom_field: Default::default(),
|
|
_assignee: Default::default(),
|
|
_address: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates a job. Fields that are set in the job state will be updated. This method supports patch semantics.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `teamId` - Team ID
|
|
/// * `jobId` - Job number
|
|
pub fn patch(&self, request: Job, team_id: &str, job_id: &str) -> JobPatchCall<'a, C, A> {
|
|
JobPatchCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_team_id: team_id.to_string(),
|
|
_job_id: job_id.to_string(),
|
|
_title: Default::default(),
|
|
_progress: Default::default(),
|
|
_note: Default::default(),
|
|
_lng: Default::default(),
|
|
_lat: Default::default(),
|
|
_customer_phone_number: Default::default(),
|
|
_customer_name: Default::default(),
|
|
_custom_field: Default::default(),
|
|
_assignee: Default::default(),
|
|
_address: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Retrieves jobs created or modified since the given timestamp.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `teamId` - Team ID
|
|
pub fn list(&self, team_id: &str) -> JobListCall<'a, C, A> {
|
|
JobListCall {
|
|
hub: self.hub,
|
|
_team_id: team_id.to_string(),
|
|
_page_token: Default::default(),
|
|
_min_modified_timestamp_ms: 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:
|
|
///
|
|
/// Inserts a new job. Only the state field of the job should be set.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `teamId` - Team ID
|
|
/// * `address` - Job address as newline (Unix) separated string
|
|
/// * `lat` - The latitude coordinate of this job's location.
|
|
/// * `lng` - The longitude coordinate of this job's location.
|
|
/// * `title` - Job title
|
|
pub fn insert(&self, request: Job, team_id: &str, address: &str, lat: f64, lng: f64, title: &str) -> JobInsertCall<'a, C, A> {
|
|
JobInsertCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_team_id: team_id.to_string(),
|
|
_address: address.to_string(),
|
|
_lat: lat,
|
|
_lng: lng,
|
|
_title: title.to_string(),
|
|
_note: Default::default(),
|
|
_customer_phone_number: Default::default(),
|
|
_customer_name: Default::default(),
|
|
_custom_field: Default::default(),
|
|
_assignee: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *schedule* resources.
|
|
/// It is not used directly, but through the `Coordinate` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_coordinate1 as coordinate1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use coordinate1::Coordinate;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Coordinate::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `get(...)`, `patch(...)` and `update(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.schedule();
|
|
/// # }
|
|
/// ```
|
|
pub struct ScheduleMethods<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
}
|
|
|
|
impl<'a, C, A> MethodsBuilder for ScheduleMethods<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ScheduleMethods<'a, C, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Replaces the schedule of a job with the provided schedule.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `teamId` - Team ID
|
|
/// * `jobId` - Job number
|
|
pub fn update(&self, request: Schedule, team_id: &str, job_id: &str) -> ScheduleUpdateCall<'a, C, A> {
|
|
ScheduleUpdateCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_team_id: team_id.to_string(),
|
|
_job_id: job_id.to_string(),
|
|
_start_time: Default::default(),
|
|
_end_time: Default::default(),
|
|
_duration: Default::default(),
|
|
_all_day: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Replaces the schedule of a job with the provided schedule. This method supports patch semantics.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `teamId` - Team ID
|
|
/// * `jobId` - Job number
|
|
pub fn patch(&self, request: Schedule, team_id: &str, job_id: &str) -> SchedulePatchCall<'a, C, A> {
|
|
SchedulePatchCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_team_id: team_id.to_string(),
|
|
_job_id: job_id.to_string(),
|
|
_start_time: Default::default(),
|
|
_end_time: Default::default(),
|
|
_duration: Default::default(),
|
|
_all_day: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Retrieves the schedule for a job.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `teamId` - Team ID
|
|
/// * `jobId` - Job number
|
|
pub fn get(&self, team_id: &str, job_id: &str) -> ScheduleGetCall<'a, C, A> {
|
|
ScheduleGetCall {
|
|
hub: self.hub,
|
|
_team_id: team_id.to_string(),
|
|
_job_id: job_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *worker* resources.
|
|
/// It is not used directly, but through the `Coordinate` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_coordinate1 as coordinate1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use coordinate1::Coordinate;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Coordinate::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `list(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.worker();
|
|
/// # }
|
|
/// ```
|
|
pub struct WorkerMethods<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
}
|
|
|
|
impl<'a, C, A> MethodsBuilder for WorkerMethods<'a, C, A> {}
|
|
|
|
impl<'a, C, A> WorkerMethods<'a, C, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Retrieves a list of workers in a team.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `teamId` - Team ID
|
|
pub fn list(&self, team_id: &str) -> WorkerListCall<'a, C, A> {
|
|
WorkerListCall {
|
|
hub: self.hub,
|
|
_team_id: team_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *location* resources.
|
|
/// It is not used directly, but through the `Coordinate` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_coordinate1 as coordinate1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use coordinate1::Coordinate;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Coordinate::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `list(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.location();
|
|
/// # }
|
|
/// ```
|
|
pub struct LocationMethods<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
}
|
|
|
|
impl<'a, C, A> MethodsBuilder for LocationMethods<'a, C, A> {}
|
|
|
|
impl<'a, C, A> LocationMethods<'a, C, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Retrieves a list of locations for a worker.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `teamId` - Team ID
|
|
/// * `workerEmail` - Worker email address.
|
|
/// * `startTimestampMs` - Start timestamp in milliseconds since the epoch.
|
|
pub fn list(&self, team_id: &str, worker_email: &str, start_timestamp_ms: &str) -> LocationListCall<'a, C, A> {
|
|
LocationListCall {
|
|
hub: self.hub,
|
|
_team_id: team_id.to_string(),
|
|
_worker_email: worker_email.to_string(),
|
|
_start_timestamp_ms: start_timestamp_ms.to_string(),
|
|
_page_token: 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 *team* resources.
|
|
/// It is not used directly, but through the `Coordinate` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_coordinate1 as coordinate1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use coordinate1::Coordinate;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Coordinate::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `list(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.team();
|
|
/// # }
|
|
/// ```
|
|
pub struct TeamMethods<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
}
|
|
|
|
impl<'a, C, A> MethodsBuilder for TeamMethods<'a, C, A> {}
|
|
|
|
impl<'a, C, A> TeamMethods<'a, C, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Retrieves a list of teams for a user.
|
|
pub fn list(&self) -> TeamListCall<'a, C, A> {
|
|
TeamListCall {
|
|
hub: self.hub,
|
|
_worker: Default::default(),
|
|
_dispatcher: Default::default(),
|
|
_admin: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *customFieldDef* resources.
|
|
/// It is not used directly, but through the `Coordinate` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_coordinate1 as coordinate1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use coordinate1::Coordinate;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Coordinate::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `list(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.custom_field_def();
|
|
/// # }
|
|
/// ```
|
|
pub struct CustomFieldDefMethods<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
}
|
|
|
|
impl<'a, C, A> MethodsBuilder for CustomFieldDefMethods<'a, C, A> {}
|
|
|
|
impl<'a, C, A> CustomFieldDefMethods<'a, C, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Retrieves a list of custom field definitions for a team.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `teamId` - Team ID
|
|
pub fn list(&self, team_id: &str) -> CustomFieldDefListCall<'a, C, A> {
|
|
CustomFieldDefListCall {
|
|
hub: self.hub,
|
|
_team_id: team_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ###################
|
|
// CallBuilders ###
|
|
// #################
|
|
|
|
/// Retrieves a job, including all the changes made to the job.
|
|
///
|
|
/// A builder for the *get* method supported by a *job* resource.
|
|
/// It is not used directly, but through a `JobMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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.jobs().get("teamId", "jobId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct JobGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_team_id: String,
|
|
_job_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for JobGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Job)> {
|
|
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: "coordinate.jobs.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
params.push(("jobId", self._job_id.to_string()));
|
|
for &field in ["alt", "teamId", "jobId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/jobs/{jobId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].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 ["teamId", "jobId"].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));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> JobGetCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Job number
|
|
///
|
|
/// Sets the *job id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn job_id(mut self, new_value: &str) -> JobGetCall<'a, C, A> {
|
|
self._job_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> JobGetCall<'a, C, 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) -> JobGetCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Readonly`.
|
|
///
|
|
/// 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) -> JobGetCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates a job. Fields that are set in the job state will be updated.
|
|
///
|
|
/// A builder for the *update* method supported by a *job* resource.
|
|
/// It is not used directly, but through a `JobMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// use coordinate1::Job;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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 = Job::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.jobs().update(req, "teamId", "jobId")
|
|
/// .title("no")
|
|
/// .progress("labore")
|
|
/// .note("eirmod")
|
|
/// .lng(0.675598874816)
|
|
/// .lat(0.634997883415)
|
|
/// .customer_phone_number("aliquyam")
|
|
/// .customer_name("accusam")
|
|
/// .add_custom_field("Lorem")
|
|
/// .assignee("sea")
|
|
/// .address("et")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct JobUpdateCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_request: Job,
|
|
_team_id: String,
|
|
_job_id: String,
|
|
_title: Option<String>,
|
|
_progress: Option<String>,
|
|
_note: Option<String>,
|
|
_lng: Option<f64>,
|
|
_lat: Option<f64>,
|
|
_customer_phone_number: Option<String>,
|
|
_customer_name: Option<String>,
|
|
_custom_field: Vec<String>,
|
|
_assignee: Option<String>,
|
|
_address: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for JobUpdateCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> JobUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Job)> {
|
|
use json_tools::{TokenReader, Lexer, BufferType, TokenType, FilterTypedKeyValuePairs, IteratorExt};
|
|
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: "coordinate.jobs.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((15 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
params.push(("jobId", self._job_id.to_string()));
|
|
if let Some(value) = self._title {
|
|
params.push(("title", value.to_string()));
|
|
}
|
|
if let Some(value) = self._progress {
|
|
params.push(("progress", value.to_string()));
|
|
}
|
|
if let Some(value) = self._note {
|
|
params.push(("note", value.to_string()));
|
|
}
|
|
if let Some(value) = self._lng {
|
|
params.push(("lng", value.to_string()));
|
|
}
|
|
if let Some(value) = self._lat {
|
|
params.push(("lat", value.to_string()));
|
|
}
|
|
if let Some(value) = self._customer_phone_number {
|
|
params.push(("customerPhoneNumber", value.to_string()));
|
|
}
|
|
if let Some(value) = self._customer_name {
|
|
params.push(("customerName", value.to_string()));
|
|
}
|
|
if self._custom_field.len() > 0 {
|
|
let mut s = String::new();
|
|
for f in self._custom_field.iter() {
|
|
s.push_str(&("/".to_string() + &f.to_string()));
|
|
}
|
|
params.push(("customField", s));
|
|
}
|
|
if let Some(value) = self._assignee {
|
|
params.push(("assignee", value.to_string()));
|
|
}
|
|
if let Some(value) = self._address {
|
|
params.push(("address", value.to_string()));
|
|
}
|
|
for &field in ["alt", "teamId", "jobId", "title", "progress", "note", "lng", "lat", "customerPhoneNumber", "customerName", "customField", "assignee", "address"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/jobs/{jobId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].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 ["teamId", "jobId"].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));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let json_cache = json::to_string(&self._request).unwrap();
|
|
let mut mem_dst = io::Cursor::new(Vec::with_capacity(json_cache.len()));
|
|
io::copy(&mut Lexer::new(json_cache.bytes(), BufferType::Span)
|
|
.filter_key_value_by_type(TokenType::Null)
|
|
.reader(Some(&json_cache)), &mut mem_dst).unwrap();
|
|
mem_dst.seek(io::SeekFrom::Start(0)).unwrap();
|
|
mem_dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: Job) -> JobUpdateCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> JobUpdateCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Job number
|
|
///
|
|
/// Sets the *job id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn job_id(mut self, new_value: &str) -> JobUpdateCall<'a, C, A> {
|
|
self._job_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Job title
|
|
///
|
|
/// Sets the *title* query property to the given value.
|
|
pub fn title(mut self, new_value: &str) -> JobUpdateCall<'a, C, A> {
|
|
self._title = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Job progress
|
|
///
|
|
/// Sets the *progress* query property to the given value.
|
|
pub fn progress(mut self, new_value: &str) -> JobUpdateCall<'a, C, A> {
|
|
self._progress = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Job note as newline (Unix) separated string
|
|
///
|
|
/// Sets the *note* query property to the given value.
|
|
pub fn note(mut self, new_value: &str) -> JobUpdateCall<'a, C, A> {
|
|
self._note = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The longitude coordinate of this job's location.
|
|
///
|
|
/// Sets the *lng* query property to the given value.
|
|
pub fn lng(mut self, new_value: f64) -> JobUpdateCall<'a, C, A> {
|
|
self._lng = Some(new_value);
|
|
self
|
|
}
|
|
/// The latitude coordinate of this job's location.
|
|
///
|
|
/// Sets the *lat* query property to the given value.
|
|
pub fn lat(mut self, new_value: f64) -> JobUpdateCall<'a, C, A> {
|
|
self._lat = Some(new_value);
|
|
self
|
|
}
|
|
/// Customer phone number
|
|
///
|
|
/// Sets the *customer phone number* query property to the given value.
|
|
pub fn customer_phone_number(mut self, new_value: &str) -> JobUpdateCall<'a, C, A> {
|
|
self._customer_phone_number = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Customer name
|
|
///
|
|
/// Sets the *customer name* query property to the given value.
|
|
pub fn customer_name(mut self, new_value: &str) -> JobUpdateCall<'a, C, A> {
|
|
self._customer_name = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the value of custom fields. To set a custom field, pass the field id (from /team/teamId/custom_fields), a URL escaped '=' character, and the desired value as a parameter. For example, customField=12%3DAlice. Repeat the parameter for each custom field. Note that '=' cannot appear in the parameter value. Specifying an invalid, or inactive enum field will result in an error 500.
|
|
///
|
|
/// Append the given value to the *custom field* query property.
|
|
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
|
|
pub fn add_custom_field(mut self, new_value: &str) -> JobUpdateCall<'a, C, A> {
|
|
self._custom_field.push(new_value.to_string());
|
|
self
|
|
}
|
|
/// Assignee email address, or empty string to unassign.
|
|
///
|
|
/// Sets the *assignee* query property to the given value.
|
|
pub fn assignee(mut self, new_value: &str) -> JobUpdateCall<'a, C, A> {
|
|
self._assignee = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Job address as newline (Unix) separated string
|
|
///
|
|
/// Sets the *address* query property to the given value.
|
|
pub fn address(mut self, new_value: &str) -> JobUpdateCall<'a, C, A> {
|
|
self._address = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> JobUpdateCall<'a, C, 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) -> JobUpdateCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Full`.
|
|
///
|
|
/// 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) -> JobUpdateCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates a job. Fields that are set in the job state will be updated. This method supports patch semantics.
|
|
///
|
|
/// A builder for the *patch* method supported by a *job* resource.
|
|
/// It is not used directly, but through a `JobMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// use coordinate1::Job;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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 = Job::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.jobs().patch(req, "teamId", "jobId")
|
|
/// .title("eirmod")
|
|
/// .progress("sanctus")
|
|
/// .note("et")
|
|
/// .lng(0.549609244211)
|
|
/// .lat(0.77599682643)
|
|
/// .customer_phone_number("consetetur")
|
|
/// .customer_name("ut")
|
|
/// .add_custom_field("ea")
|
|
/// .assignee("sed")
|
|
/// .address("dolor")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct JobPatchCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_request: Job,
|
|
_team_id: String,
|
|
_job_id: String,
|
|
_title: Option<String>,
|
|
_progress: Option<String>,
|
|
_note: Option<String>,
|
|
_lng: Option<f64>,
|
|
_lat: Option<f64>,
|
|
_customer_phone_number: Option<String>,
|
|
_customer_name: Option<String>,
|
|
_custom_field: Vec<String>,
|
|
_assignee: Option<String>,
|
|
_address: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for JobPatchCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> JobPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Job)> {
|
|
use json_tools::{TokenReader, Lexer, BufferType, TokenType, FilterTypedKeyValuePairs, IteratorExt};
|
|
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: "coordinate.jobs.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((15 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
params.push(("jobId", self._job_id.to_string()));
|
|
if let Some(value) = self._title {
|
|
params.push(("title", value.to_string()));
|
|
}
|
|
if let Some(value) = self._progress {
|
|
params.push(("progress", value.to_string()));
|
|
}
|
|
if let Some(value) = self._note {
|
|
params.push(("note", value.to_string()));
|
|
}
|
|
if let Some(value) = self._lng {
|
|
params.push(("lng", value.to_string()));
|
|
}
|
|
if let Some(value) = self._lat {
|
|
params.push(("lat", value.to_string()));
|
|
}
|
|
if let Some(value) = self._customer_phone_number {
|
|
params.push(("customerPhoneNumber", value.to_string()));
|
|
}
|
|
if let Some(value) = self._customer_name {
|
|
params.push(("customerName", value.to_string()));
|
|
}
|
|
if self._custom_field.len() > 0 {
|
|
let mut s = String::new();
|
|
for f in self._custom_field.iter() {
|
|
s.push_str(&("/".to_string() + &f.to_string()));
|
|
}
|
|
params.push(("customField", s));
|
|
}
|
|
if let Some(value) = self._assignee {
|
|
params.push(("assignee", value.to_string()));
|
|
}
|
|
if let Some(value) = self._address {
|
|
params.push(("address", value.to_string()));
|
|
}
|
|
for &field in ["alt", "teamId", "jobId", "title", "progress", "note", "lng", "lat", "customerPhoneNumber", "customerName", "customField", "assignee", "address"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/jobs/{jobId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].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 ["teamId", "jobId"].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));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let json_cache = json::to_string(&self._request).unwrap();
|
|
let mut mem_dst = io::Cursor::new(Vec::with_capacity(json_cache.len()));
|
|
io::copy(&mut Lexer::new(json_cache.bytes(), BufferType::Span)
|
|
.filter_key_value_by_type(TokenType::Null)
|
|
.reader(Some(&json_cache)), &mut mem_dst).unwrap();
|
|
mem_dst.seek(io::SeekFrom::Start(0)).unwrap();
|
|
mem_dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: Job) -> JobPatchCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> JobPatchCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Job number
|
|
///
|
|
/// Sets the *job id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn job_id(mut self, new_value: &str) -> JobPatchCall<'a, C, A> {
|
|
self._job_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Job title
|
|
///
|
|
/// Sets the *title* query property to the given value.
|
|
pub fn title(mut self, new_value: &str) -> JobPatchCall<'a, C, A> {
|
|
self._title = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Job progress
|
|
///
|
|
/// Sets the *progress* query property to the given value.
|
|
pub fn progress(mut self, new_value: &str) -> JobPatchCall<'a, C, A> {
|
|
self._progress = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Job note as newline (Unix) separated string
|
|
///
|
|
/// Sets the *note* query property to the given value.
|
|
pub fn note(mut self, new_value: &str) -> JobPatchCall<'a, C, A> {
|
|
self._note = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The longitude coordinate of this job's location.
|
|
///
|
|
/// Sets the *lng* query property to the given value.
|
|
pub fn lng(mut self, new_value: f64) -> JobPatchCall<'a, C, A> {
|
|
self._lng = Some(new_value);
|
|
self
|
|
}
|
|
/// The latitude coordinate of this job's location.
|
|
///
|
|
/// Sets the *lat* query property to the given value.
|
|
pub fn lat(mut self, new_value: f64) -> JobPatchCall<'a, C, A> {
|
|
self._lat = Some(new_value);
|
|
self
|
|
}
|
|
/// Customer phone number
|
|
///
|
|
/// Sets the *customer phone number* query property to the given value.
|
|
pub fn customer_phone_number(mut self, new_value: &str) -> JobPatchCall<'a, C, A> {
|
|
self._customer_phone_number = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Customer name
|
|
///
|
|
/// Sets the *customer name* query property to the given value.
|
|
pub fn customer_name(mut self, new_value: &str) -> JobPatchCall<'a, C, A> {
|
|
self._customer_name = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the value of custom fields. To set a custom field, pass the field id (from /team/teamId/custom_fields), a URL escaped '=' character, and the desired value as a parameter. For example, customField=12%3DAlice. Repeat the parameter for each custom field. Note that '=' cannot appear in the parameter value. Specifying an invalid, or inactive enum field will result in an error 500.
|
|
///
|
|
/// Append the given value to the *custom field* query property.
|
|
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
|
|
pub fn add_custom_field(mut self, new_value: &str) -> JobPatchCall<'a, C, A> {
|
|
self._custom_field.push(new_value.to_string());
|
|
self
|
|
}
|
|
/// Assignee email address, or empty string to unassign.
|
|
///
|
|
/// Sets the *assignee* query property to the given value.
|
|
pub fn assignee(mut self, new_value: &str) -> JobPatchCall<'a, C, A> {
|
|
self._assignee = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Job address as newline (Unix) separated string
|
|
///
|
|
/// Sets the *address* query property to the given value.
|
|
pub fn address(mut self, new_value: &str) -> JobPatchCall<'a, C, A> {
|
|
self._address = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> JobPatchCall<'a, C, 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) -> JobPatchCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Full`.
|
|
///
|
|
/// 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) -> JobPatchCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Retrieves jobs created or modified since the given timestamp.
|
|
///
|
|
/// A builder for the *list* method supported by a *job* resource.
|
|
/// It is not used directly, but through a `JobMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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.jobs().list("teamId")
|
|
/// .page_token("dolor")
|
|
/// .min_modified_timestamp_ms("et")
|
|
/// .max_results(5)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct JobListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_team_id: String,
|
|
_page_token: Option<String>,
|
|
_min_modified_timestamp_ms: Option<String>,
|
|
_max_results: Option<u32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for JobListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> JobListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, JobListResponse)> {
|
|
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: "coordinate.jobs.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._min_modified_timestamp_ms {
|
|
params.push(("minModifiedTimestampMs", value.to_string()));
|
|
}
|
|
if let Some(value) = self._max_results {
|
|
params.push(("maxResults", value.to_string()));
|
|
}
|
|
for &field in ["alt", "teamId", "pageToken", "minModifiedTimestampMs", "maxResults"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/jobs".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId")].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 ["teamId"].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));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> JobListCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Continuation token
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> JobListCall<'a, C, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Minimum time a job was modified in milliseconds since epoch.
|
|
///
|
|
/// Sets the *min modified timestamp ms* query property to the given value.
|
|
pub fn min_modified_timestamp_ms(mut self, new_value: &str) -> JobListCall<'a, C, A> {
|
|
self._min_modified_timestamp_ms = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Maximum number of results to return in one page.
|
|
///
|
|
/// Sets the *max results* query property to the given value.
|
|
pub fn max_results(mut self, new_value: u32) -> JobListCall<'a, C, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> JobListCall<'a, C, 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) -> JobListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Readonly`.
|
|
///
|
|
/// 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) -> JobListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Inserts a new job. Only the state field of the job should be set.
|
|
///
|
|
/// A builder for the *insert* method supported by a *job* resource.
|
|
/// It is not used directly, but through a `JobMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// use coordinate1::Job;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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 = Job::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.jobs().insert(req, "teamId", "address", 0.455185502569, 0.898789428358, "title")
|
|
/// .note("sit")
|
|
/// .customer_phone_number("vero")
|
|
/// .customer_name("diam")
|
|
/// .add_custom_field("rebum.")
|
|
/// .assignee("consetetur")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct JobInsertCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_request: Job,
|
|
_team_id: String,
|
|
_address: String,
|
|
_lat: f64,
|
|
_lng: f64,
|
|
_title: String,
|
|
_note: Option<String>,
|
|
_customer_phone_number: Option<String>,
|
|
_customer_name: Option<String>,
|
|
_custom_field: Vec<String>,
|
|
_assignee: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for JobInsertCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Job)> {
|
|
use json_tools::{TokenReader, Lexer, BufferType, TokenType, FilterTypedKeyValuePairs, IteratorExt};
|
|
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: "coordinate.jobs.insert",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
params.push(("address", self._address.to_string()));
|
|
params.push(("lat", self._lat.to_string()));
|
|
params.push(("lng", self._lng.to_string()));
|
|
params.push(("title", self._title.to_string()));
|
|
if let Some(value) = self._note {
|
|
params.push(("note", value.to_string()));
|
|
}
|
|
if let Some(value) = self._customer_phone_number {
|
|
params.push(("customerPhoneNumber", value.to_string()));
|
|
}
|
|
if let Some(value) = self._customer_name {
|
|
params.push(("customerName", value.to_string()));
|
|
}
|
|
if self._custom_field.len() > 0 {
|
|
let mut s = String::new();
|
|
for f in self._custom_field.iter() {
|
|
s.push_str(&("/".to_string() + &f.to_string()));
|
|
}
|
|
params.push(("customField", s));
|
|
}
|
|
if let Some(value) = self._assignee {
|
|
params.push(("assignee", value.to_string()));
|
|
}
|
|
for &field in ["alt", "teamId", "address", "lat", "lng", "title", "note", "customerPhoneNumber", "customerName", "customField", "assignee"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/jobs".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId")].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 ["teamId"].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));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let json_cache = json::to_string(&self._request).unwrap();
|
|
let mut mem_dst = io::Cursor::new(Vec::with_capacity(json_cache.len()));
|
|
io::copy(&mut Lexer::new(json_cache.bytes(), BufferType::Span)
|
|
.filter_key_value_by_type(TokenType::Null)
|
|
.reader(Some(&json_cache)), &mut mem_dst).unwrap();
|
|
mem_dst.seek(io::SeekFrom::Start(0)).unwrap();
|
|
mem_dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: Job) -> JobInsertCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> JobInsertCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Job address as newline (Unix) separated string
|
|
///
|
|
/// Sets the *address* 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.
|
|
pub fn address(mut self, new_value: &str) -> JobInsertCall<'a, C, A> {
|
|
self._address = new_value.to_string();
|
|
self
|
|
}
|
|
/// The latitude coordinate of this job's location.
|
|
///
|
|
/// Sets the *lat* 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.
|
|
pub fn lat(mut self, new_value: f64) -> JobInsertCall<'a, C, A> {
|
|
self._lat = new_value;
|
|
self
|
|
}
|
|
/// The longitude coordinate of this job's location.
|
|
///
|
|
/// Sets the *lng* 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.
|
|
pub fn lng(mut self, new_value: f64) -> JobInsertCall<'a, C, A> {
|
|
self._lng = new_value;
|
|
self
|
|
}
|
|
/// Job title
|
|
///
|
|
/// Sets the *title* 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.
|
|
pub fn title(mut self, new_value: &str) -> JobInsertCall<'a, C, A> {
|
|
self._title = new_value.to_string();
|
|
self
|
|
}
|
|
/// Job note as newline (Unix) separated string
|
|
///
|
|
/// Sets the *note* query property to the given value.
|
|
pub fn note(mut self, new_value: &str) -> JobInsertCall<'a, C, A> {
|
|
self._note = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Customer phone number
|
|
///
|
|
/// Sets the *customer phone number* query property to the given value.
|
|
pub fn customer_phone_number(mut self, new_value: &str) -> JobInsertCall<'a, C, A> {
|
|
self._customer_phone_number = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Customer name
|
|
///
|
|
/// Sets the *customer name* query property to the given value.
|
|
pub fn customer_name(mut self, new_value: &str) -> JobInsertCall<'a, C, A> {
|
|
self._customer_name = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the value of custom fields. To set a custom field, pass the field id (from /team/teamId/custom_fields), a URL escaped '=' character, and the desired value as a parameter. For example, customField=12%3DAlice. Repeat the parameter for each custom field. Note that '=' cannot appear in the parameter value. Specifying an invalid, or inactive enum field will result in an error 500.
|
|
///
|
|
/// Append the given value to the *custom field* query property.
|
|
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
|
|
pub fn add_custom_field(mut self, new_value: &str) -> JobInsertCall<'a, C, A> {
|
|
self._custom_field.push(new_value.to_string());
|
|
self
|
|
}
|
|
/// Assignee email address, or empty string to unassign.
|
|
///
|
|
/// Sets the *assignee* query property to the given value.
|
|
pub fn assignee(mut self, new_value: &str) -> JobInsertCall<'a, C, A> {
|
|
self._assignee = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> JobInsertCall<'a, C, 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) -> JobInsertCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Full`.
|
|
///
|
|
/// 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) -> JobInsertCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Replaces the schedule of a job with the provided schedule.
|
|
///
|
|
/// A builder for the *update* method supported by a *schedule* resource.
|
|
/// It is not used directly, but through a `ScheduleMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// use coordinate1::Schedule;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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 = Schedule::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.schedule().update(req, "teamId", "jobId")
|
|
/// .start_time("sadipscing")
|
|
/// .end_time("invidunt")
|
|
/// .duration("consetetur")
|
|
/// .all_day(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ScheduleUpdateCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_request: Schedule,
|
|
_team_id: String,
|
|
_job_id: String,
|
|
_start_time: Option<String>,
|
|
_end_time: Option<String>,
|
|
_duration: Option<String>,
|
|
_all_day: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ScheduleUpdateCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ScheduleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Schedule)> {
|
|
use json_tools::{TokenReader, Lexer, BufferType, TokenType, FilterTypedKeyValuePairs, IteratorExt};
|
|
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: "coordinate.schedule.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
params.push(("jobId", self._job_id.to_string()));
|
|
if let Some(value) = self._start_time {
|
|
params.push(("startTime", value.to_string()));
|
|
}
|
|
if let Some(value) = self._end_time {
|
|
params.push(("endTime", value.to_string()));
|
|
}
|
|
if let Some(value) = self._duration {
|
|
params.push(("duration", value.to_string()));
|
|
}
|
|
if let Some(value) = self._all_day {
|
|
params.push(("allDay", value.to_string()));
|
|
}
|
|
for &field in ["alt", "teamId", "jobId", "startTime", "endTime", "duration", "allDay"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/jobs/{jobId}/schedule".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].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 ["teamId", "jobId"].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));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let json_cache = json::to_string(&self._request).unwrap();
|
|
let mut mem_dst = io::Cursor::new(Vec::with_capacity(json_cache.len()));
|
|
io::copy(&mut Lexer::new(json_cache.bytes(), BufferType::Span)
|
|
.filter_key_value_by_type(TokenType::Null)
|
|
.reader(Some(&json_cache)), &mut mem_dst).unwrap();
|
|
mem_dst.seek(io::SeekFrom::Start(0)).unwrap();
|
|
mem_dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: Schedule) -> ScheduleUpdateCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> ScheduleUpdateCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Job number
|
|
///
|
|
/// Sets the *job id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn job_id(mut self, new_value: &str) -> ScheduleUpdateCall<'a, C, A> {
|
|
self._job_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Scheduled start time in milliseconds since epoch.
|
|
///
|
|
/// Sets the *start time* query property to the given value.
|
|
pub fn start_time(mut self, new_value: &str) -> ScheduleUpdateCall<'a, C, A> {
|
|
self._start_time = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Scheduled end time in milliseconds since epoch.
|
|
///
|
|
/// Sets the *end time* query property to the given value.
|
|
pub fn end_time(mut self, new_value: &str) -> ScheduleUpdateCall<'a, C, A> {
|
|
self._end_time = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Job duration in milliseconds.
|
|
///
|
|
/// Sets the *duration* query property to the given value.
|
|
pub fn duration(mut self, new_value: &str) -> ScheduleUpdateCall<'a, C, A> {
|
|
self._duration = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Whether the job is scheduled for the whole day. Time of day in start/end times is ignored if this is true.
|
|
///
|
|
/// Sets the *all day* query property to the given value.
|
|
pub fn all_day(mut self, new_value: bool) -> ScheduleUpdateCall<'a, C, A> {
|
|
self._all_day = Some(new_value);
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ScheduleUpdateCall<'a, C, 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) -> ScheduleUpdateCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Full`.
|
|
///
|
|
/// 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) -> ScheduleUpdateCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Replaces the schedule of a job with the provided schedule. This method supports patch semantics.
|
|
///
|
|
/// A builder for the *patch* method supported by a *schedule* resource.
|
|
/// It is not used directly, but through a `ScheduleMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// use coordinate1::Schedule;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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 = Schedule::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.schedule().patch(req, "teamId", "jobId")
|
|
/// .start_time("Lorem")
|
|
/// .end_time("et")
|
|
/// .duration("clita")
|
|
/// .all_day(true)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SchedulePatchCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_request: Schedule,
|
|
_team_id: String,
|
|
_job_id: String,
|
|
_start_time: Option<String>,
|
|
_end_time: Option<String>,
|
|
_duration: Option<String>,
|
|
_all_day: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for SchedulePatchCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> SchedulePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Schedule)> {
|
|
use json_tools::{TokenReader, Lexer, BufferType, TokenType, FilterTypedKeyValuePairs, IteratorExt};
|
|
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: "coordinate.schedule.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
params.push(("jobId", self._job_id.to_string()));
|
|
if let Some(value) = self._start_time {
|
|
params.push(("startTime", value.to_string()));
|
|
}
|
|
if let Some(value) = self._end_time {
|
|
params.push(("endTime", value.to_string()));
|
|
}
|
|
if let Some(value) = self._duration {
|
|
params.push(("duration", value.to_string()));
|
|
}
|
|
if let Some(value) = self._all_day {
|
|
params.push(("allDay", value.to_string()));
|
|
}
|
|
for &field in ["alt", "teamId", "jobId", "startTime", "endTime", "duration", "allDay"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/jobs/{jobId}/schedule".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].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 ["teamId", "jobId"].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));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let json_cache = json::to_string(&self._request).unwrap();
|
|
let mut mem_dst = io::Cursor::new(Vec::with_capacity(json_cache.len()));
|
|
io::copy(&mut Lexer::new(json_cache.bytes(), BufferType::Span)
|
|
.filter_key_value_by_type(TokenType::Null)
|
|
.reader(Some(&json_cache)), &mut mem_dst).unwrap();
|
|
mem_dst.seek(io::SeekFrom::Start(0)).unwrap();
|
|
mem_dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: Schedule) -> SchedulePatchCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> SchedulePatchCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Job number
|
|
///
|
|
/// Sets the *job id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn job_id(mut self, new_value: &str) -> SchedulePatchCall<'a, C, A> {
|
|
self._job_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Scheduled start time in milliseconds since epoch.
|
|
///
|
|
/// Sets the *start time* query property to the given value.
|
|
pub fn start_time(mut self, new_value: &str) -> SchedulePatchCall<'a, C, A> {
|
|
self._start_time = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Scheduled end time in milliseconds since epoch.
|
|
///
|
|
/// Sets the *end time* query property to the given value.
|
|
pub fn end_time(mut self, new_value: &str) -> SchedulePatchCall<'a, C, A> {
|
|
self._end_time = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Job duration in milliseconds.
|
|
///
|
|
/// Sets the *duration* query property to the given value.
|
|
pub fn duration(mut self, new_value: &str) -> SchedulePatchCall<'a, C, A> {
|
|
self._duration = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Whether the job is scheduled for the whole day. Time of day in start/end times is ignored if this is true.
|
|
///
|
|
/// Sets the *all day* query property to the given value.
|
|
pub fn all_day(mut self, new_value: bool) -> SchedulePatchCall<'a, C, A> {
|
|
self._all_day = Some(new_value);
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SchedulePatchCall<'a, C, 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) -> SchedulePatchCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Full`.
|
|
///
|
|
/// 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) -> SchedulePatchCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Retrieves the schedule for a job.
|
|
///
|
|
/// A builder for the *get* method supported by a *schedule* resource.
|
|
/// It is not used directly, but through a `ScheduleMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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.schedule().get("teamId", "jobId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ScheduleGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_team_id: String,
|
|
_job_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ScheduleGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ScheduleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Schedule)> {
|
|
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: "coordinate.schedule.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
params.push(("jobId", self._job_id.to_string()));
|
|
for &field in ["alt", "teamId", "jobId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/jobs/{jobId}/schedule".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].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 ["teamId", "jobId"].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));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> ScheduleGetCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Job number
|
|
///
|
|
/// Sets the *job id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn job_id(mut self, new_value: &str) -> ScheduleGetCall<'a, C, A> {
|
|
self._job_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ScheduleGetCall<'a, C, 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) -> ScheduleGetCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Readonly`.
|
|
///
|
|
/// 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) -> ScheduleGetCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Retrieves a list of workers in a team.
|
|
///
|
|
/// A builder for the *list* method supported by a *worker* resource.
|
|
/// It is not used directly, but through a `WorkerMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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.worker().list("teamId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct WorkerListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_team_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for WorkerListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> WorkerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, WorkerListResponse)> {
|
|
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: "coordinate.worker.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
for &field in ["alt", "teamId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/workers".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId")].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 ["teamId"].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));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> WorkerListCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> WorkerListCall<'a, C, 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) -> WorkerListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Readonly`.
|
|
///
|
|
/// 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) -> WorkerListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Retrieves a list of locations for a worker.
|
|
///
|
|
/// A builder for the *list* method supported by a *location* resource.
|
|
/// It is not used directly, but through a `LocationMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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.location().list("teamId", "workerEmail", "startTimestampMs")
|
|
/// .page_token("labore")
|
|
/// .max_results(64)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct LocationListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_team_id: String,
|
|
_worker_email: String,
|
|
_start_timestamp_ms: String,
|
|
_page_token: Option<String>,
|
|
_max_results: Option<u32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for LocationListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> LocationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, LocationListResponse)> {
|
|
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: "coordinate.location.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
params.push(("workerEmail", self._worker_email.to_string()));
|
|
params.push(("startTimestampMs", self._start_timestamp_ms.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", "teamId", "workerEmail", "startTimestampMs", "pageToken", "maxResults"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/workers/{workerEmail}/locations".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId"), ("{workerEmail}", "workerEmail")].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 ["teamId", "workerEmail"].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));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> LocationListCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Worker email address.
|
|
///
|
|
/// Sets the *worker email* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn worker_email(mut self, new_value: &str) -> LocationListCall<'a, C, A> {
|
|
self._worker_email = new_value.to_string();
|
|
self
|
|
}
|
|
/// Start timestamp in milliseconds since the epoch.
|
|
///
|
|
/// Sets the *start timestamp ms* 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.
|
|
pub fn start_timestamp_ms(mut self, new_value: &str) -> LocationListCall<'a, C, A> {
|
|
self._start_timestamp_ms = new_value.to_string();
|
|
self
|
|
}
|
|
/// Continuation token
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> LocationListCall<'a, C, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Maximum number of results to return in one page.
|
|
///
|
|
/// Sets the *max results* query property to the given value.
|
|
pub fn max_results(mut self, new_value: u32) -> LocationListCall<'a, C, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> LocationListCall<'a, C, 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) -> LocationListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Readonly`.
|
|
///
|
|
/// 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) -> LocationListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Retrieves a list of teams for a user.
|
|
///
|
|
/// A builder for the *list* method supported by a *team* resource.
|
|
/// It is not used directly, but through a `TeamMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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.team().list()
|
|
/// .worker(false)
|
|
/// .dispatcher(false)
|
|
/// .admin(false)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct TeamListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_worker: Option<bool>,
|
|
_dispatcher: Option<bool>,
|
|
_admin: Option<bool>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for TeamListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> TeamListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, TeamListResponse)> {
|
|
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: "coordinate.team.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._worker {
|
|
params.push(("worker", value.to_string()));
|
|
}
|
|
if let Some(value) = self._dispatcher {
|
|
params.push(("dispatcher", value.to_string()));
|
|
}
|
|
if let Some(value) = self._admin {
|
|
params.push(("admin", value.to_string()));
|
|
}
|
|
for &field in ["alt", "worker", "dispatcher", "admin"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_ref().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Whether to include teams for which the user has the Worker role.
|
|
///
|
|
/// Sets the *worker* query property to the given value.
|
|
pub fn worker(mut self, new_value: bool) -> TeamListCall<'a, C, A> {
|
|
self._worker = Some(new_value);
|
|
self
|
|
}
|
|
/// Whether to include teams for which the user has the Dispatcher role.
|
|
///
|
|
/// Sets the *dispatcher* query property to the given value.
|
|
pub fn dispatcher(mut self, new_value: bool) -> TeamListCall<'a, C, A> {
|
|
self._dispatcher = Some(new_value);
|
|
self
|
|
}
|
|
/// Whether to include teams for which the user has the Admin role.
|
|
///
|
|
/// Sets the *admin* query property to the given value.
|
|
pub fn admin(mut self, new_value: bool) -> TeamListCall<'a, C, A> {
|
|
self._admin = Some(new_value);
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> TeamListCall<'a, C, 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) -> TeamListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Readonly`.
|
|
///
|
|
/// 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) -> TeamListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Retrieves a list of custom field definitions for a team.
|
|
///
|
|
/// A builder for the *list* method supported by a *customFieldDef* resource.
|
|
/// It is not used directly, but through a `CustomFieldDefMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_coordinate1 as coordinate1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use coordinate1::Coordinate;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Coordinate::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.custom_field_def().list("teamId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct CustomFieldDefListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a Coordinate<C, A>,
|
|
_team_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for CustomFieldDefListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> CustomFieldDefListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, CustomFieldDefListResponse)> {
|
|
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: "coordinate.customFieldDef.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("teamId", self._team_id.to_string()));
|
|
for &field in ["alt", "teamId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/coordinate/v1/teams/{teamId}/custom_fields".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Readonly.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{teamId}", "teamId")].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 ["teamId"].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));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.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)
|
|
.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_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::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(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
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 Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Team ID
|
|
///
|
|
/// Sets the *team id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn team_id(mut self, new_value: &str) -> CustomFieldDefListCall<'a, C, A> {
|
|
self._team_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> CustomFieldDefListCall<'a, C, 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) -> CustomFieldDefListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::Readonly`.
|
|
///
|
|
/// 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) -> CustomFieldDefListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|