mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
Merge branch 'refactor'
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,9 +2,10 @@
|
||||
.pyenv
|
||||
.virtualenv
|
||||
gen/doc/
|
||||
gen/*-cli/
|
||||
*.go
|
||||
*.pyc
|
||||
**target/
|
||||
.api.deps
|
||||
.*.deps
|
||||
**Cargo.lock
|
||||
*.sublime-workspace
|
||||
|
||||
48
Makefile
48
Makefile
@@ -1,4 +1,4 @@
|
||||
.PHONY: json-to-xml clean help api-deps regen-apis license
|
||||
.PHONY: clean help deps regen-apis license
|
||||
.SUFFIXES:
|
||||
|
||||
VENV = .virtualenv/virtualenv.py
|
||||
@@ -13,8 +13,12 @@ MAKO_SRC = src/mako
|
||||
RUST_SRC = src/rust
|
||||
API_DEPS_TPL = $(MAKO_SRC)/deps.mako
|
||||
API_DEPS = .api.deps
|
||||
API_SHARED_INFO = etc/api/shared.yaml
|
||||
API_LIST = etc/api/
|
||||
CLI_DEPS = .cli.deps
|
||||
API_DIR = etc/api
|
||||
API_SHARED_INFO = $(API_DIR)/shared.yaml
|
||||
TYPE_API_INFO = $(API_DIR)/type-api.yaml
|
||||
TYPE_CLI_INFO = $(API_DIR)/type-cli.yaml
|
||||
API_LIST = $(API_DIR)/
|
||||
ifdef TRAVIS
|
||||
API_LIST := $(API_LIST)api-list_travis.yaml
|
||||
else
|
||||
@@ -30,18 +34,16 @@ help:
|
||||
$(info using template engine: '$(TPL)')
|
||||
$(info )
|
||||
$(info Targets)
|
||||
$(info docs - cargo-doc on all APIs, assemble them together and generate index)
|
||||
$(info github-pages - invoke ghp-import on all documentation)
|
||||
$(info apis - make all APIs)
|
||||
$(info cargo - run cargo on all APIs, use ARGS="args ..." to specify cargo arguments)
|
||||
$(info publish - run cargo publish on all APIs and remember successful ones with marker files)
|
||||
$(info regen-apis - clear out all generated apis, and regenerate them)
|
||||
$(info clean-apis - delete all generated APIs)
|
||||
$(info help-api - show all api targets to build individually)
|
||||
$(info help - print this help)
|
||||
$(info license - regenerate the main license file)
|
||||
$(info update-json - rediscover API schema json files and update api-list.yaml with latest versions)
|
||||
$(info api-deps - generate a file to tell make what API file dependencies will be)
|
||||
$(info help-api - show all api targets to build individually)
|
||||
$(info help-cli - show all cli targets to build individually)
|
||||
$(info docs-all - cargo-doc on all APIs and associates, assemble them together and generate index)
|
||||
$(info docs-all-clean - remove the entire set of generated documentation)
|
||||
$(info github-pages - invoke ghp-import on all documentation)
|
||||
$(info regen-apis - clear out all generated apis, and regenerate them)
|
||||
$(info license - regenerate the main license file)
|
||||
$(info update-json - rediscover API schema json files and update api-list.yaml with latest versions)
|
||||
$(info deps - generate a file to tell how to build libraries and programs)
|
||||
$(info help - print this help)
|
||||
|
||||
$(VENV):
|
||||
wget -nv https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.7.tar.gz -O virtualenv-12.0.7.tar.gz
|
||||
@@ -56,20 +58,24 @@ $(MAKO_RENDER): $(PYTHON)
|
||||
|
||||
# Explicitly NOT depending on $(MAKO_LIB_FILES), as it's quite stable and now takes 'too long' thanks
|
||||
# to a URL get call to the google discovery service
|
||||
$(API_DEPS): $(API_DEPS_TPL) $(API_SHARED_INFO) $(MAKO_RENDER) $(API_LIST)
|
||||
$(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(API_LIST)
|
||||
$(API_DEPS): $(API_DEPS_TPL) $(API_SHARED_INFO) $(MAKO_RENDER) $(TYPE_API_INFO) $(API_LIST)
|
||||
$(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(TYPE_API_INFO) $(API_LIST)
|
||||
|
||||
api-deps: $(API_DEPS)
|
||||
$(CLI_DEPS): $(API_DEPS_TPL) $(API_SHARED_INFO) $(MAKO_RENDER) $(TYPE_CLI_INFO) $(API_LIST)
|
||||
$(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(TYPE_CLI_INFO) $(API_LIST)
|
||||
|
||||
deps: $(API_DEPS) $(CLI_DEPS)
|
||||
|
||||
include $(API_DEPS)
|
||||
include $(CLI_DEPS)
|
||||
|
||||
LICENSE.md: $(MAKO_SRC)/LICENSE.md.mako $(API_SHARED_INFO) $(MAKO_RENDER)
|
||||
$(MAKO) -io $<=$@ --data-files $(API_SHARED_INFO)
|
||||
|
||||
license: LICENSE.md
|
||||
|
||||
regen-apis: clean-apis apis license
|
||||
regen-apis: | clean-all-api clean-all-cli gen-all-api gen-all-cli license
|
||||
|
||||
clean: clean-apis
|
||||
clean: clean-all-api clean-all-cli
|
||||
-rm -Rf $(VENV_DIR)
|
||||
-rm $(API_DEPS)
|
||||
-rm $(API_DEPS) $(CLI_DEPS)
|
||||
|
||||
@@ -37,9 +37,6 @@ api:
|
||||
- v1
|
||||
calendar:
|
||||
- v3
|
||||
# Does not build yet, see serde issue: https://github.com/erickt/rust-serde/issues/45
|
||||
# civicinfo:
|
||||
# - v2
|
||||
cloudlatencytest:
|
||||
- v2
|
||||
cloudmonitoring:
|
||||
@@ -62,9 +59,6 @@ api:
|
||||
- v2beta1
|
||||
dfareporting:
|
||||
- v2.0
|
||||
# Does not build yet, see serde issue: https://github.com/erickt/rust-serde/issues/45
|
||||
# discovery:
|
||||
# - v1
|
||||
dns:
|
||||
- v1beta1
|
||||
doubleclickbidmanager:
|
||||
@@ -85,9 +79,6 @@ api:
|
||||
- v1configuration
|
||||
gamesmanagement:
|
||||
- v1management
|
||||
# Does not build yet, see serde issue: https://github.com/erickt/rust-serde/issues/45
|
||||
# gan:
|
||||
# - v1beta1
|
||||
genomics:
|
||||
- v1beta2
|
||||
gmail:
|
||||
@@ -110,9 +101,6 @@ api:
|
||||
- v2
|
||||
pagespeedonline:
|
||||
- v2
|
||||
# Does not build yet, see serde issue: https://github.com/erickt/rust-serde/issues/45
|
||||
# plus:
|
||||
# - v1
|
||||
plusdomains:
|
||||
- v1
|
||||
prediction:
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
api:
|
||||
blacklist:
|
||||
# All of these require Box<> support in serde
|
||||
# See https://github.com/erickt/rust-serde/issues/45
|
||||
- civicinfo
|
||||
- discovery
|
||||
- gan
|
||||
- plus
|
||||
# Contains values shared among all API implementations
|
||||
directories:
|
||||
# directory under which all generated sources should reside
|
||||
@@ -8,25 +16,6 @@ directories:
|
||||
api_base: etc/api
|
||||
# all mako source files
|
||||
mako_src: src/mako
|
||||
api:
|
||||
base_path: "etc/api"
|
||||
terms:
|
||||
# how to actually do something with the API
|
||||
action: doit
|
||||
# when a resource is supposed to be uploaded
|
||||
upload_action: upload
|
||||
properties:
|
||||
# additional fields specified by the user
|
||||
params: '_additional_params'
|
||||
# custom scopes for authentication
|
||||
scopes: '_scopes'
|
||||
templates:
|
||||
# all output directories are relative to the one set for the respective API
|
||||
- source: README.md
|
||||
- source: LICENSE.md
|
||||
- source: Cargo.toml
|
||||
- source: lib.rs
|
||||
output_dir: src
|
||||
cargo:
|
||||
build_version: "0.1.1"
|
||||
repo_base_url: https://github.com/Byron/google-apis-rs
|
||||
@@ -34,7 +23,7 @@ cargo:
|
||||
authors:
|
||||
# don't forget to possibly add them to copyright authors
|
||||
- Sebastian Thiel <byronimo@gmail>
|
||||
keywords: [google, protocol, web, api]
|
||||
keywords: [google]
|
||||
# All APIs should live in the same repository
|
||||
repository_url: https://github.com/Byron/google-apis-rs
|
||||
urls:
|
||||
|
||||
33
etc/api/type-api.yaml
Normal file
33
etc/api/type-api.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
api:
|
||||
base_path: "etc/api"
|
||||
terms:
|
||||
# how to actually do something with the API
|
||||
action: doit
|
||||
# when a resource is supposed to be uploaded
|
||||
upload_action: upload
|
||||
properties:
|
||||
# additional fields specified by the user
|
||||
params: '_additional_params'
|
||||
# custom scopes for authentication
|
||||
scopes: '_scopes'
|
||||
make:
|
||||
id: api
|
||||
target_name: APIs
|
||||
target_suffix: ''
|
||||
aggregated_target_suffix: -api
|
||||
depends_on_suffix:
|
||||
global_targets: Yes
|
||||
templates:
|
||||
# all output directories are relative to the one set for the respective API
|
||||
- source: README.md
|
||||
- source: ../LICENSE.md
|
||||
- source: ../Cargo.toml
|
||||
- source: lib.rs
|
||||
output_dir: src
|
||||
cargo:
|
||||
build_version: "0.1.1"
|
||||
keywords: [protocol, web, api]
|
||||
dependencies:
|
||||
- url = "*"
|
||||
- serde = "*"
|
||||
- serde_macros = "*"
|
||||
14
etc/api/type-cli.yaml
Normal file
14
etc/api/type-cli.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
make:
|
||||
id: cli
|
||||
target_name: CLIs
|
||||
target_suffix: -cli
|
||||
aggregated_target_suffix: -cli
|
||||
depends_on_suffix: ''
|
||||
templates:
|
||||
- source: ../LICENSE.md
|
||||
- source: ../Cargo.toml
|
||||
- source: main.rs
|
||||
output_dir: src
|
||||
cargo:
|
||||
build_version: "0.0.1"
|
||||
keywords: [cli]
|
||||
@@ -330,7 +330,10 @@ def merge(a, b, path=None):
|
||||
merge(a[key], b[key], path + [str(key)])
|
||||
else:
|
||||
# overwrite leafs unconditionally !
|
||||
a[key] = b[key]
|
||||
if isinstance(a[key], list) and isinstance(b[key], list):
|
||||
a[key] = a[key] + b[key]
|
||||
else:
|
||||
a[key] = b[key]
|
||||
else:
|
||||
a[key] = b[key]
|
||||
return a
|
||||
|
||||
@@ -16,7 +16,7 @@ keywords = ["drive", "google", "protocol", "web", "api"]
|
||||
[dependencies]
|
||||
hyper = "*"
|
||||
mime = "*"
|
||||
yup-oauth2 = "*"
|
||||
url = "*"
|
||||
serde = "*"
|
||||
serde_macros = "*"
|
||||
yup-oauth2 = "*"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!---
|
||||
DO NOT EDIT !
|
||||
This file was generated automatically from 'src/mako/README.md.mako'
|
||||
This file was generated automatically from 'src/mako/api/README.md.mako'
|
||||
DO NOT EDIT !
|
||||
-->
|
||||
The `google-drive2` library allows access to all features of the *Google drive* service.
|
||||
@@ -69,6 +69,8 @@ The API is structured into the following primary items:
|
||||
|
||||
* **[Hub](http://byron.github.io/google-apis-rs/google-drive2/struct.Drive.html)**
|
||||
* a central object to maintain state and allow accessing all *Activities*
|
||||
* creates [*Method Builders*](http://byron.github.io/google-apis-rs/google-drive2/trait.MethodsBuilder.html) which in turn
|
||||
allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google-drive2/trait.CallBuilder.html)
|
||||
* **[Resources](http://byron.github.io/google-apis-rs/google-drive2/trait.Resource.html)**
|
||||
* primary types that you can apply *Activities* to
|
||||
* a collection of properties and *Parts*
|
||||
@@ -78,6 +80,8 @@ The API is structured into the following primary items:
|
||||
* **[Activities](http://byron.github.io/google-apis-rs/google-drive2/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
|
||||
@@ -124,7 +128,7 @@ extern crate hyper;
|
||||
extern crate "yup-oauth2" as oauth2;
|
||||
extern crate "google-drive2" as drive2;
|
||||
use drive2::File;
|
||||
use drive2::Result;
|
||||
use drive2::{Result, Error};
|
||||
use std::default::Default;
|
||||
use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||||
use drive2::Drive;
|
||||
@@ -165,15 +169,17 @@ let result = hub.files().patch(&req, "fileId")
|
||||
.doit();
|
||||
|
||||
match result {
|
||||
Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
Result::MissingToken => println!("OAuth2: Missing Token"),
|
||||
Result::Cancelled => println!("Operation cancelled by user"),
|
||||
Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
Result::Success(_) => println!("Success (value doesn't print)"),
|
||||
Err(e) => match e {
|
||||
Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
Error::MissingToken => println!("OAuth2: Missing Token"),
|
||||
Error::Cancelled => println!("Operation canceled by user"),
|
||||
Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
},
|
||||
Ok(_) => println!("Success (value doesn't print)"),
|
||||
}
|
||||
|
||||
```
|
||||
@@ -186,7 +192,7 @@ the doit() methods, or handed as possibly intermediate results to either the
|
||||
When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
||||
makes the system potentially resilient to all kinds of errors.
|
||||
|
||||
## Uploads and Downlods
|
||||
## Uploads and Downloads
|
||||
If a method supports downloads, the response body, which is part of the [Result](http://byron.github.io/google-apis-rs/google-drive2/enum.Result.html), should be
|
||||
read by you to obtain the media.
|
||||
If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google-drive2/trait.ResponseResult.html), it will return that by default.
|
||||
@@ -209,8 +215,9 @@ The [delegate trait](http://byron.github.io/google-apis-rs/google-drive2/trait.D
|
||||
## Optional Parts in Server-Requests
|
||||
|
||||
All structures provided by this library are made to be [enocodable](http://byron.github.io/google-apis-rs/google-drive2/trait.RequestValue.html) and
|
||||
[decodable](http://byron.github.io/google-apis-rs/google-drive2/trait.ResponseResult.html) via json. Optionals are used to indicate that partial requests are responses are valid.
|
||||
Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google-drive2/trait.Part.html) which are identifyable by name, which will be sent to
|
||||
[decodable](http://byron.github.io/google-apis-rs/google-drive2/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses
|
||||
are valid.
|
||||
Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google-drive2/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
|
||||
|
||||
@@ -24,7 +24,7 @@ use serde;
|
||||
pub trait Hub: MarkerTrait {}
|
||||
|
||||
/// Identifies types for building methods of a particular resource type
|
||||
pub trait ResourceMethodsBuilder: MarkerTrait {}
|
||||
pub trait MethodsBuilder: MarkerTrait {}
|
||||
|
||||
/// Identifies types which represent builders for a particular resource method
|
||||
pub trait CallBuilder: MarkerTrait {}
|
||||
@@ -105,12 +105,15 @@ pub trait Delegate {
|
||||
/// information if he is interesting in knowing more context when further calls to it
|
||||
/// are made.
|
||||
/// The matching `finished()` call will always be made, no matter whether or not the API
|
||||
/// request was sucessfull. That way, the delgate may easily maintain a clean state
|
||||
/// request was successful. That way, the delegate may easily maintain a clean state
|
||||
/// between various API calls.
|
||||
fn begin(&mut self, MethodInfo) {}
|
||||
|
||||
/// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), usually if there are network problems.
|
||||
///
|
||||
/// If you choose to retry after a duration, the duration should be chosen using the
|
||||
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
|
||||
///
|
||||
/// Return retry information.
|
||||
fn http_error(&mut self, &hyper::HttpError) -> Retry {
|
||||
Retry::Abort
|
||||
@@ -133,7 +136,7 @@ pub trait Delegate {
|
||||
/// Called during resumable uploads to provide a URL for the impending upload.
|
||||
/// It was saved after a previous call to `store_upload_url(...)`, and if not None,
|
||||
/// will be used instead of asking the server for a new upload URL.
|
||||
/// This is useful in case a previous resumable upload was aborted/cancelled, but should now
|
||||
/// This is useful in case a previous resumable upload was aborted/canceled, but should now
|
||||
/// be resumed.
|
||||
/// The returned URL will be used exactly once - if it fails again and the delegate allows
|
||||
/// to retry, we will ask the server for a new upload URL.
|
||||
@@ -154,8 +157,8 @@ pub trait Delegate {
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `json_encoded_value` - The json-encoded value which failed to decode.
|
||||
/// `json_decode_error` - The decoder error
|
||||
/// * `json_encoded_value` - The json-encoded value which failed to decode.
|
||||
/// * `json_decode_error` - The decoder error
|
||||
fn response_json_decode_error(&mut self, json_encoded_value: &str, json_decode_error: &serde::json::Error) {
|
||||
let _ = json_encoded_value;
|
||||
let _ = json_decode_error;
|
||||
@@ -166,6 +169,9 @@ pub trait Delegate {
|
||||
/// depends on the used API method.
|
||||
/// The delegate should check the status, header and decoded json error to decide
|
||||
/// whether to retry or not. In the latter case, the underlying call will fail.
|
||||
///
|
||||
/// If you choose to retry after a duration, the duration should be chosen using the
|
||||
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
|
||||
fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry {
|
||||
Retry::Abort
|
||||
}
|
||||
@@ -197,8 +203,8 @@ pub trait Delegate {
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `is_success` - a true value indicates the operation was successful. If false, you should
|
||||
/// discard all values stored during `store_upload_url`.
|
||||
/// * `is_success` - a true value indicates the operation was successful. If false, you should
|
||||
/// discard all values stored during `store_upload_url`.
|
||||
fn finished(&mut self, is_success: bool) {
|
||||
let _ = is_success;
|
||||
}
|
||||
@@ -212,8 +218,8 @@ pub struct DefaultDelegate;
|
||||
impl Delegate for DefaultDelegate {}
|
||||
|
||||
|
||||
/// A universal result type used as return for all action method results.
|
||||
pub enum Result<T = ()> {
|
||||
|
||||
pub enum Error {
|
||||
/// The http connection failed
|
||||
HttpError(hyper::HttpError),
|
||||
|
||||
@@ -240,11 +246,11 @@ pub enum Result<T = ()> {
|
||||
|
||||
/// Indicates an HTTP repsonse with a non-success status code
|
||||
Failure(hyper::client::Response),
|
||||
|
||||
/// It worked !
|
||||
Success(T),
|
||||
}
|
||||
|
||||
/// A universal result type used as return for all calls.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Contains information about an API request.
|
||||
pub struct MethodInfo {
|
||||
pub id: &'static str,
|
||||
@@ -499,7 +505,7 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
where NC: hyper::net::NetworkConnector,
|
||||
A: oauth2::GetToken {
|
||||
|
||||
fn query_transfer_status(&mut self) -> (Option<u64>, hyper::HttpResult<hyper::client::Response>) {
|
||||
fn query_transfer_status(&mut self) -> std::result::Result<u64, hyper::HttpResult<hyper::client::Response>> {
|
||||
loop {
|
||||
match self.client.post(self.url)
|
||||
.header(UserAgent(self.user_agent.to_string()))
|
||||
@@ -516,17 +522,17 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return (None, Ok(r))
|
||||
return Err(Ok(r))
|
||||
}
|
||||
};
|
||||
return (Some(h.0.last), Ok(r))
|
||||
return Ok(h.0.last)
|
||||
}
|
||||
Err(err) => {
|
||||
if let Retry::After(d) = self.delegate.http_error(&err) {
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return (None, Err(err))
|
||||
return Err(Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,8 +545,8 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
let mut start = match self.start_at {
|
||||
Some(s) => s,
|
||||
None => match self.query_transfer_status() {
|
||||
(Some(s), _) => s,
|
||||
(_, result) => return Some(result)
|
||||
Ok(s) => s,
|
||||
Err(result) => return Some(result)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
0
gen/groupsmigration1-cli/.timestamp
Normal file
0
gen/groupsmigration1-cli/.timestamp
Normal file
22
gen/groupsmigration1-cli/Cargo.toml
Normal file
22
gen/groupsmigration1-cli/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
# DO NOT EDIT !
|
||||
# This file was generated automatically from 'src/mako/Cargo.toml.mako'
|
||||
# DO NOT EDIT !
|
||||
[package]
|
||||
|
||||
name = "google-groupsmigration1-cli"
|
||||
version = "0.0.1+20140416"
|
||||
authors = ["Sebastian Thiel <byronimo@gmail>"]
|
||||
description = "A complete library to interact with Groups Migration (protocol v1)"
|
||||
repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/groupsmigration1"
|
||||
homepage = "https://developers.google.com/google-apps/groups-migration/"
|
||||
documentation = "http://byron.github.io/google-apis-rs/google-groupsmigration1-cli"
|
||||
license = "MIT"
|
||||
keywords = ["groupsmigration", "google", "cli"]
|
||||
|
||||
[dependencies]
|
||||
hyper = "*"
|
||||
mime = "*"
|
||||
yup-oauth2 = "*"
|
||||
|
||||
[dependencies.google-groupsmigration1]
|
||||
path = "../groupsmigration1"
|
||||
30
gen/groupsmigration1-cli/LICENSE.md
Normal file
30
gen/groupsmigration1-cli/LICENSE.md
Normal file
@@ -0,0 +1,30 @@
|
||||
<!---
|
||||
DO NOT EDIT !
|
||||
This file was generated automatically from 'src/mako/LICENSE.md.mako'
|
||||
DO NOT EDIT !
|
||||
-->
|
||||
The MIT License (MIT)
|
||||
=====================
|
||||
|
||||
Copyright © `2015` `Sebastian Thiel`
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the “Software”), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
2
gen/groupsmigration1-cli/src/cmn.rs
Normal file
2
gen/groupsmigration1-cli/src/cmn.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
// COPY OF 'src/rust/cli/cmn.rs'
|
||||
// DO NOT EDIT
|
||||
3
gen/groupsmigration1-cli/src/main.rs
Normal file
3
gen/groupsmigration1-cli/src/main.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, groupsmigration:v1 !");
|
||||
}
|
||||
@@ -16,7 +16,7 @@ keywords = ["groupsmigration", "google", "protocol", "web", "api"]
|
||||
[dependencies]
|
||||
hyper = "*"
|
||||
mime = "*"
|
||||
yup-oauth2 = "*"
|
||||
url = "*"
|
||||
serde = "*"
|
||||
serde_macros = "*"
|
||||
yup-oauth2 = "*"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!---
|
||||
DO NOT EDIT !
|
||||
This file was generated automatically from 'src/mako/README.md.mako'
|
||||
This file was generated automatically from 'src/mako/api/README.md.mako'
|
||||
DO NOT EDIT !
|
||||
-->
|
||||
The `google-groupsmigration1` library allows access to all features of the *Google Groups Migration* service.
|
||||
@@ -29,6 +29,8 @@ The API is structured into the following primary items:
|
||||
|
||||
* **[Hub](http://byron.github.io/google-apis-rs/google-groupsmigration1/struct.GroupsMigration.html)**
|
||||
* a central object to maintain state and allow accessing all *Activities*
|
||||
* creates [*Method Builders*](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.MethodsBuilder.html) which in turn
|
||||
allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.CallBuilder.html)
|
||||
* **[Resources](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.Resource.html)**
|
||||
* primary types that you can apply *Activities* to
|
||||
* a collection of properties and *Parts*
|
||||
@@ -38,6 +40,8 @@ The API is structured into the following primary items:
|
||||
* **[Activities](http://byron.github.io/google-apis-rs/google-groupsmigration1/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
|
||||
@@ -72,7 +76,7 @@ google-groupsmigration1 = "*"
|
||||
extern crate hyper;
|
||||
extern crate "yup-oauth2" as oauth2;
|
||||
extern crate "google-groupsmigration1" as groupsmigration1;
|
||||
use groupsmigration1::Result;
|
||||
use groupsmigration1::{Result, Error};
|
||||
use std::fs;
|
||||
use std::default::Default;
|
||||
use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||||
@@ -97,15 +101,17 @@ let result = hub.archive().insert("groupId")
|
||||
.upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap());
|
||||
|
||||
match result {
|
||||
Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
Result::MissingToken => println!("OAuth2: Missing Token"),
|
||||
Result::Cancelled => println!("Operation cancelled by user"),
|
||||
Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
Result::Success(_) => println!("Success (value doesn't print)"),
|
||||
Err(e) => match e {
|
||||
Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
Error::MissingToken => println!("OAuth2: Missing Token"),
|
||||
Error::Cancelled => println!("Operation canceled by user"),
|
||||
Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
},
|
||||
Ok(_) => println!("Success (value doesn't print)"),
|
||||
}
|
||||
|
||||
```
|
||||
@@ -118,7 +124,7 @@ the doit() methods, or handed as possibly intermediate results to either the
|
||||
When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
||||
makes the system potentially resilient to all kinds of errors.
|
||||
|
||||
## Uploads and Downlods
|
||||
## Uploads and Downloads
|
||||
If a method supports downloads, the response body, which is part of the [Result](http://byron.github.io/google-apis-rs/google-groupsmigration1/enum.Result.html), should be
|
||||
read by you to obtain the media.
|
||||
If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.ResponseResult.html), it will return that by default.
|
||||
@@ -141,8 +147,9 @@ The [delegate trait](http://byron.github.io/google-apis-rs/google-groupsmigratio
|
||||
## Optional Parts in Server-Requests
|
||||
|
||||
All structures provided by this library are made to be [enocodable](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.RequestValue.html) and
|
||||
[decodable](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.ResponseResult.html) via json. Optionals are used to indicate that partial requests are responses are valid.
|
||||
Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.Part.html) which are identifyable by name, which will be sent to
|
||||
[decodable](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses
|
||||
are valid.
|
||||
Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google-groupsmigration1/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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// COPY OF 'src/rust/cmn.rs'
|
||||
// COPY OF 'src/rust/api/cmn.rs'
|
||||
// DO NOT EDIT
|
||||
use std::marker::MarkerTrait;
|
||||
use std::io::{self, Read, Seek, Cursor, Write, SeekFrom};
|
||||
@@ -24,7 +24,7 @@ use serde;
|
||||
pub trait Hub: MarkerTrait {}
|
||||
|
||||
/// Identifies types for building methods of a particular resource type
|
||||
pub trait ResourceMethodsBuilder: MarkerTrait {}
|
||||
pub trait MethodsBuilder: MarkerTrait {}
|
||||
|
||||
/// Identifies types which represent builders for a particular resource method
|
||||
pub trait CallBuilder: MarkerTrait {}
|
||||
@@ -105,12 +105,15 @@ pub trait Delegate {
|
||||
/// information if he is interesting in knowing more context when further calls to it
|
||||
/// are made.
|
||||
/// The matching `finished()` call will always be made, no matter whether or not the API
|
||||
/// request was sucessfull. That way, the delgate may easily maintain a clean state
|
||||
/// request was successful. That way, the delegate may easily maintain a clean state
|
||||
/// between various API calls.
|
||||
fn begin(&mut self, MethodInfo) {}
|
||||
|
||||
/// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), usually if there are network problems.
|
||||
///
|
||||
/// If you choose to retry after a duration, the duration should be chosen using the
|
||||
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
|
||||
///
|
||||
/// Return retry information.
|
||||
fn http_error(&mut self, &hyper::HttpError) -> Retry {
|
||||
Retry::Abort
|
||||
@@ -133,7 +136,7 @@ pub trait Delegate {
|
||||
/// Called during resumable uploads to provide a URL for the impending upload.
|
||||
/// It was saved after a previous call to `store_upload_url(...)`, and if not None,
|
||||
/// will be used instead of asking the server for a new upload URL.
|
||||
/// This is useful in case a previous resumable upload was aborted/cancelled, but should now
|
||||
/// This is useful in case a previous resumable upload was aborted/canceled, but should now
|
||||
/// be resumed.
|
||||
/// The returned URL will be used exactly once - if it fails again and the delegate allows
|
||||
/// to retry, we will ask the server for a new upload URL.
|
||||
@@ -154,8 +157,8 @@ pub trait Delegate {
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `json_encoded_value` - The json-encoded value which failed to decode.
|
||||
/// `json_decode_error` - The decoder error
|
||||
/// * `json_encoded_value` - The json-encoded value which failed to decode.
|
||||
/// * `json_decode_error` - The decoder error
|
||||
fn response_json_decode_error(&mut self, json_encoded_value: &str, json_decode_error: &serde::json::Error) {
|
||||
let _ = json_encoded_value;
|
||||
let _ = json_decode_error;
|
||||
@@ -166,6 +169,9 @@ pub trait Delegate {
|
||||
/// depends on the used API method.
|
||||
/// The delegate should check the status, header and decoded json error to decide
|
||||
/// whether to retry or not. In the latter case, the underlying call will fail.
|
||||
///
|
||||
/// If you choose to retry after a duration, the duration should be chosen using the
|
||||
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
|
||||
fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry {
|
||||
Retry::Abort
|
||||
}
|
||||
@@ -197,8 +203,8 @@ pub trait Delegate {
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `is_success` - a true value indicates the operation was successful. If false, you should
|
||||
/// discard all values stored during `store_upload_url`.
|
||||
/// * `is_success` - a true value indicates the operation was successful. If false, you should
|
||||
/// discard all values stored during `store_upload_url`.
|
||||
fn finished(&mut self, is_success: bool) {
|
||||
let _ = is_success;
|
||||
}
|
||||
@@ -212,8 +218,8 @@ pub struct DefaultDelegate;
|
||||
impl Delegate for DefaultDelegate {}
|
||||
|
||||
|
||||
/// A universal result type used as return for all action method results.
|
||||
pub enum Result<T = ()> {
|
||||
|
||||
pub enum Error {
|
||||
/// The http connection failed
|
||||
HttpError(hyper::HttpError),
|
||||
|
||||
@@ -240,11 +246,11 @@ pub enum Result<T = ()> {
|
||||
|
||||
/// Indicates an HTTP repsonse with a non-success status code
|
||||
Failure(hyper::client::Response),
|
||||
|
||||
/// It worked !
|
||||
Success(T),
|
||||
}
|
||||
|
||||
/// A universal result type used as return for all calls.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Contains information about an API request.
|
||||
pub struct MethodInfo {
|
||||
pub id: &'static str,
|
||||
@@ -499,7 +505,7 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
where NC: hyper::net::NetworkConnector,
|
||||
A: oauth2::GetToken {
|
||||
|
||||
fn query_transfer_status(&mut self) -> (Option<u64>, hyper::HttpResult<hyper::client::Response>) {
|
||||
fn query_transfer_status(&mut self) -> std::result::Result<u64, hyper::HttpResult<hyper::client::Response>> {
|
||||
loop {
|
||||
match self.client.post(self.url)
|
||||
.header(UserAgent(self.user_agent.to_string()))
|
||||
@@ -516,17 +522,17 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return (None, Ok(r))
|
||||
return Err(Ok(r))
|
||||
}
|
||||
};
|
||||
return (Some(h.0.last), Ok(r))
|
||||
return Ok(h.0.last)
|
||||
}
|
||||
Err(err) => {
|
||||
if let Retry::After(d) = self.delegate.http_error(&err) {
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return (None, Err(err))
|
||||
return Err(Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,8 +545,8 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
let mut start = match self.start_at {
|
||||
Some(s) => s,
|
||||
None => match self.query_transfer_status() {
|
||||
(Some(s), _) => s,
|
||||
(_, result) => return Some(result)
|
||||
Ok(s) => s,
|
||||
Err(result) => return Some(result)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// DO NOT EDIT !
|
||||
// This file was generated automatically from 'src/mako/lib.rs.mako'
|
||||
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
||||
// DO NOT EDIT !
|
||||
|
||||
//! This documentation was generated from *Groups Migration* crate version *0.1.1+20140416*, where *20140416* is the exact revision of the *groupsmigration:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.1*.
|
||||
@@ -29,6 +29,8 @@
|
||||
//!
|
||||
//! * **[Hub](struct.GroupsMigration.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*
|
||||
@@ -38,6 +40,8 @@
|
||||
//! * **[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
|
||||
@@ -72,7 +76,7 @@
|
||||
//! extern crate hyper;
|
||||
//! extern crate "yup-oauth2" as oauth2;
|
||||
//! extern crate "google-groupsmigration1" as groupsmigration1;
|
||||
//! use groupsmigration1::Result;
|
||||
//! use groupsmigration1::{Result, Error};
|
||||
//! use std::fs;
|
||||
//! # #[test] fn egal() {
|
||||
//! use std::default::Default;
|
||||
@@ -98,15 +102,17 @@
|
||||
//! .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap());
|
||||
//!
|
||||
//! match result {
|
||||
//! Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
//! Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
//! Result::MissingToken => println!("OAuth2: Missing Token"),
|
||||
//! Result::Cancelled => println!("Operation cancelled by user"),
|
||||
//! Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
//! Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
//! Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
//! Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
//! Result::Success(_) => println!("Success (value doesn't print)"),
|
||||
//! Err(e) => match e {
|
||||
//! Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
//! Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
//! Error::MissingToken => println!("OAuth2: Missing Token"),
|
||||
//! Error::Cancelled => println!("Operation canceled by user"),
|
||||
//! Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
//! Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
//! Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
//! Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
//! },
|
||||
//! Ok(_) => println!("Success (value doesn't print)"),
|
||||
//! }
|
||||
//! # }
|
||||
//! ```
|
||||
@@ -119,7 +125,7 @@
|
||||
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
||||
//! makes the system potentially resilient to all kinds of errors.
|
||||
//!
|
||||
//! ## Uploads and Downlods
|
||||
//! ## 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.
|
||||
@@ -142,8 +148,9 @@
|
||||
//! ## Optional Parts in Server-Requests
|
||||
//!
|
||||
//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and
|
||||
//! [decodable](trait.ResponseResult.html) via json. Optionals are used to indicate that partial requests are responses are valid.
|
||||
//! Most optionals are are considered [Parts](trait.Part.html) which are identifyable by name, which will be sent to
|
||||
//! [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
|
||||
@@ -192,7 +199,7 @@ use std::io;
|
||||
use std::fs;
|
||||
use std::thread::sleep;
|
||||
|
||||
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, ResourceMethodsBuilder, Resource, JsonServerError};
|
||||
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError};
|
||||
|
||||
|
||||
// ##############
|
||||
@@ -238,7 +245,7 @@ impl Default for Scope {
|
||||
/// extern crate hyper;
|
||||
/// extern crate "yup-oauth2" as oauth2;
|
||||
/// extern crate "google-groupsmigration1" as groupsmigration1;
|
||||
/// use groupsmigration1::Result;
|
||||
/// use groupsmigration1::{Result, Error};
|
||||
/// use std::fs;
|
||||
/// # #[test] fn egal() {
|
||||
/// use std::default::Default;
|
||||
@@ -264,15 +271,17 @@ impl Default for Scope {
|
||||
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap());
|
||||
///
|
||||
/// match result {
|
||||
/// Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
/// Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
/// Result::MissingToken => println!("OAuth2: Missing Token"),
|
||||
/// Result::Cancelled => println!("Operation cancelled by user"),
|
||||
/// Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
/// Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
/// Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
/// Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
/// Result::Success(_) => println!("Success (value doesn't print)"),
|
||||
/// Err(e) => match e {
|
||||
/// Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
/// Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
/// Error::MissingToken => println!("OAuth2: Missing Token"),
|
||||
/// Error::Cancelled => println!("Operation canceled by user"),
|
||||
/// Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
/// Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
/// Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
/// Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
/// },
|
||||
/// Ok(_) => println!("Success (value doesn't print)"),
|
||||
/// }
|
||||
/// # }
|
||||
/// ```
|
||||
@@ -328,9 +337,9 @@ impl<'a, C, NC, A> GroupsMigration<C, NC, A>
|
||||
///
|
||||
#[derive(Default, Clone, Debug, Deserialize)]
|
||||
pub struct Groups {
|
||||
/// The kind of insert resource this is.
|
||||
/// The kind of insert resource this is.
|
||||
pub kind: String,
|
||||
/// The status of the insert request.
|
||||
/// The status of the insert request.
|
||||
#[serde(alias="responseCode")]
|
||||
pub response_code: String,
|
||||
}
|
||||
@@ -377,13 +386,17 @@ pub struct ArchiveMethods<'a, C, NC, A>
|
||||
hub: &'a GroupsMigration<C, NC, A>,
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> ResourceMethodsBuilder for ArchiveMethods<'a, C, NC, A> {}
|
||||
impl<'a, C, NC, A> MethodsBuilder for ArchiveMethods<'a, C, NC, A> {}
|
||||
|
||||
impl<'a, C, NC, A> ArchiveMethods<'a, C, NC, A> {
|
||||
|
||||
/// Create a builder to help you perform the following task:
|
||||
///
|
||||
/// Inserts a new mail into the archive of the Google group.
|
||||
/// Inserts a new mail into the archive of the Google group.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `groupId` - The group ID
|
||||
pub fn insert(&self, group_id: &str) -> ArchiveInsertCall<'a, C, NC, A> {
|
||||
ArchiveInsertCall {
|
||||
hub: self.hub,
|
||||
@@ -406,7 +419,7 @@ impl<'a, C, NC, A> ArchiveMethods<'a, C, NC, A> {
|
||||
/// Inserts a new mail into the archive of the Google group.
|
||||
///
|
||||
/// A builder for the *insert* method supported by a *archive* resource.
|
||||
/// It is not used directly, but through a `ArchiveMethods`.
|
||||
/// It is not used directly, but through a `ArchiveMethods` instance.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
@@ -466,7 +479,7 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network
|
||||
for &field in ["alt", "groupId"].iter() {
|
||||
if self._additional_params.contains_key(field) {
|
||||
dlg.finished(false);
|
||||
return Result::FieldClash(field);
|
||||
return Err(Error::FieldClash(field));
|
||||
}
|
||||
}
|
||||
for (name, value) in self._additional_params.iter() {
|
||||
@@ -529,7 +542,7 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network
|
||||
}
|
||||
if token.is_none() {
|
||||
dlg.finished(false);
|
||||
return Result::MissingToken
|
||||
return Err(Error::MissingToken)
|
||||
}
|
||||
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
||||
access_token: token.unwrap().access_token });
|
||||
@@ -555,7 +568,7 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network
|
||||
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
||||
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||||
if size > 16777216 {
|
||||
return Result::UploadSizeLimitExceeded(size, 16777216)
|
||||
return Err(Error::UploadSizeLimitExceeded(size, 16777216))
|
||||
}
|
||||
req = req.header(ContentType(reader_mime_type.clone()))
|
||||
.header(ContentLength(size))
|
||||
@@ -568,7 +581,6 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network
|
||||
|
||||
dlg.pre_request();
|
||||
req.send()
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -579,7 +591,7 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network
|
||||
continue;
|
||||
}
|
||||
dlg.finished(false);
|
||||
return Result::HttpError(err)
|
||||
return Err(Error::HttpError(err))
|
||||
}
|
||||
Ok(mut res) => {
|
||||
if !res.status.is_success() {
|
||||
@@ -590,13 +602,13 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network
|
||||
continue;
|
||||
}
|
||||
dlg.finished(false);
|
||||
return Result::Failure(res)
|
||||
return Err(Error::Failure(res))
|
||||
}
|
||||
if protocol == "resumable" {
|
||||
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
||||
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||||
if size > 16777216 {
|
||||
return Result::UploadSizeLimitExceeded(size, 16777216)
|
||||
return Err(Error::UploadSizeLimitExceeded(size, 16777216))
|
||||
}
|
||||
let mut client = &mut *self.hub.client.borrow_mut();
|
||||
let upload_result = {
|
||||
@@ -621,17 +633,17 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network
|
||||
match upload_result {
|
||||
None => {
|
||||
dlg.finished(false);
|
||||
return Result::Cancelled
|
||||
return Err(Error::Cancelled)
|
||||
}
|
||||
Some(Err(err)) => {
|
||||
dlg.finished(false);
|
||||
return Result::HttpError(err)
|
||||
return Err(Error::HttpError(err))
|
||||
}
|
||||
Some(Ok(upload_result)) => {
|
||||
res = upload_result;
|
||||
if !res.status.is_success() {
|
||||
dlg.finished(false);
|
||||
return Result::Failure(res)
|
||||
return Err(Error::Failure(res))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -643,13 +655,13 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network
|
||||
Ok(decoded) => (res, decoded),
|
||||
Err(err) => {
|
||||
dlg.response_json_decode_error(&json_response, &err);
|
||||
return Result::JsonDecodeError(err);
|
||||
return Err(Error::JsonDecodeError(err));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
dlg.finished(true);
|
||||
return Result::Success(result_value)
|
||||
return Ok(result_value)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -665,11 +677,14 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network
|
||||
where RS: ReadSeek {
|
||||
self.doit(stream, mime_type, "simple")
|
||||
}
|
||||
/// Upload media in a resumeable fashion.
|
||||
/// Upload media in a resumable fashion.
|
||||
/// Even if the upload fails or is interrupted, it can be resumed for a
|
||||
/// certain amount of time as the server maintains state temporarily.
|
||||
///
|
||||
/// TODO: Write more about how delegation works in this particular case.
|
||||
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
|
||||
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
|
||||
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
|
||||
/// `cancel_chunk_upload(...)`.
|
||||
///
|
||||
/// * *max size*: 16MB
|
||||
/// * *multipart*: yes
|
||||
@@ -684,7 +699,7 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network
|
||||
/// Even though the property as already been set when instantiating this call,
|
||||
/// we provide this method for API completeness.
|
||||
///
|
||||
/// The group ID
|
||||
/// The group ID
|
||||
pub fn group_id(mut self, new_value: &str) -> ArchiveInsertCall<'a, C, NC, A> {
|
||||
self._group_id = new_value.to_string();
|
||||
self
|
||||
|
||||
0
gen/youtube3-cli/.timestamp
Normal file
0
gen/youtube3-cli/.timestamp
Normal file
22
gen/youtube3-cli/Cargo.toml
Normal file
22
gen/youtube3-cli/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
# DO NOT EDIT !
|
||||
# This file was generated automatically from 'src/mako/Cargo.toml.mako'
|
||||
# DO NOT EDIT !
|
||||
[package]
|
||||
|
||||
name = "google-youtube3-cli"
|
||||
version = "0.0.1+20150309"
|
||||
authors = ["Sebastian Thiel <byronimo@gmail>"]
|
||||
description = "A complete library to interact with YouTube (protocol v3)"
|
||||
repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/youtube3"
|
||||
homepage = "https://developers.google.com/youtube/v3"
|
||||
documentation = "http://byron.github.io/google-apis-rs/google-youtube3-cli"
|
||||
license = "MIT"
|
||||
keywords = ["youtube", "google", "cli"]
|
||||
|
||||
[dependencies]
|
||||
hyper = "*"
|
||||
mime = "*"
|
||||
yup-oauth2 = "*"
|
||||
|
||||
[dependencies.google-youtube3]
|
||||
path = "../youtube3"
|
||||
30
gen/youtube3-cli/LICENSE.md
Normal file
30
gen/youtube3-cli/LICENSE.md
Normal file
@@ -0,0 +1,30 @@
|
||||
<!---
|
||||
DO NOT EDIT !
|
||||
This file was generated automatically from 'src/mako/LICENSE.md.mako'
|
||||
DO NOT EDIT !
|
||||
-->
|
||||
The MIT License (MIT)
|
||||
=====================
|
||||
|
||||
Copyright © `2015` `Sebastian Thiel`
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the “Software”), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
2
gen/youtube3-cli/src/cmn.rs
Normal file
2
gen/youtube3-cli/src/cmn.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
// COPY OF 'src/rust/cli/cmn.rs'
|
||||
// DO NOT EDIT
|
||||
3
gen/youtube3-cli/src/main.rs
Normal file
3
gen/youtube3-cli/src/main.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, youtube:v3 !");
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<!---
|
||||
DO NOT EDIT !
|
||||
This file was generated automatically from 'src/mako/README.md.mako'
|
||||
This file was generated automatically from 'src/mako/api/README.md.mako'
|
||||
DO NOT EDIT !
|
||||
-->
|
||||
The `google-youtube3` library allows access to all features of the *Google YouTube* service.
|
||||
@@ -68,6 +68,8 @@ The API is structured into the following primary items:
|
||||
|
||||
* **[Hub](http://byron.github.io/google-apis-rs/google-youtube3/struct.YouTube.html)**
|
||||
* a central object to maintain state and allow accessing all *Activities*
|
||||
* creates [*Method Builders*](http://byron.github.io/google-apis-rs/google-youtube3/trait.MethodsBuilder.html) which in turn
|
||||
allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google-youtube3/trait.CallBuilder.html)
|
||||
* **[Resources](http://byron.github.io/google-apis-rs/google-youtube3/trait.Resource.html)**
|
||||
* primary types that you can apply *Activities* to
|
||||
* a collection of properties and *Parts*
|
||||
@@ -77,6 +79,8 @@ The API is structured into the following primary items:
|
||||
* **[Activities](http://byron.github.io/google-apis-rs/google-youtube3/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
|
||||
@@ -117,7 +121,7 @@ google-youtube3 = "*"
|
||||
extern crate hyper;
|
||||
extern crate "yup-oauth2" as oauth2;
|
||||
extern crate "google-youtube3" as youtube3;
|
||||
use youtube3::Result;
|
||||
use youtube3::{Result, Error};
|
||||
use std::default::Default;
|
||||
use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||||
use youtube3::YouTube;
|
||||
@@ -148,15 +152,17 @@ let result = hub.live_broadcasts().list("part")
|
||||
.doit();
|
||||
|
||||
match result {
|
||||
Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
Result::MissingToken => println!("OAuth2: Missing Token"),
|
||||
Result::Cancelled => println!("Operation cancelled by user"),
|
||||
Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
Result::Success(_) => println!("Success (value doesn't print)"),
|
||||
Err(e) => match e {
|
||||
Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
||||
Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
||||
Error::MissingToken => println!("OAuth2: Missing Token"),
|
||||
Error::Cancelled => println!("Operation canceled by user"),
|
||||
Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
||||
Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
||||
Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
||||
Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
||||
},
|
||||
Ok(_) => println!("Success (value doesn't print)"),
|
||||
}
|
||||
|
||||
```
|
||||
@@ -169,7 +175,7 @@ the doit() methods, or handed as possibly intermediate results to either the
|
||||
When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
||||
makes the system potentially resilient to all kinds of errors.
|
||||
|
||||
## Uploads and Downlods
|
||||
## Uploads and Downloads
|
||||
If a method supports downloads, the response body, which is part of the [Result](http://byron.github.io/google-apis-rs/google-youtube3/enum.Result.html), should be
|
||||
read by you to obtain the media.
|
||||
If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google-youtube3/trait.ResponseResult.html), it will return that by default.
|
||||
@@ -192,8 +198,9 @@ The [delegate trait](http://byron.github.io/google-apis-rs/google-youtube3/trait
|
||||
## Optional Parts in Server-Requests
|
||||
|
||||
All structures provided by this library are made to be [enocodable](http://byron.github.io/google-apis-rs/google-youtube3/trait.RequestValue.html) and
|
||||
[decodable](http://byron.github.io/google-apis-rs/google-youtube3/trait.ResponseResult.html) via json. Optionals are used to indicate that partial requests are responses are valid.
|
||||
Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google-youtube3/trait.Part.html) which are identifyable by name, which will be sent to
|
||||
[decodable](http://byron.github.io/google-apis-rs/google-youtube3/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses
|
||||
are valid.
|
||||
Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google-youtube3/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
|
||||
|
||||
@@ -16,7 +16,7 @@ keywords = ["youtube", "google", "protocol", "web", "api"]
|
||||
[dependencies]
|
||||
hyper = "*"
|
||||
mime = "*"
|
||||
yup-oauth2 = "*"
|
||||
url = "*"
|
||||
serde = "*"
|
||||
serde_macros = "*"
|
||||
yup-oauth2 = "*"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// COPY OF 'src/rust/cmn.rs'
|
||||
// COPY OF 'src/rust/api/cmn.rs'
|
||||
// DO NOT EDIT
|
||||
use std::marker::MarkerTrait;
|
||||
use std::io::{self, Read, Seek, Cursor, Write, SeekFrom};
|
||||
@@ -24,7 +24,7 @@ use serde;
|
||||
pub trait Hub: MarkerTrait {}
|
||||
|
||||
/// Identifies types for building methods of a particular resource type
|
||||
pub trait ResourceMethodsBuilder: MarkerTrait {}
|
||||
pub trait MethodsBuilder: MarkerTrait {}
|
||||
|
||||
/// Identifies types which represent builders for a particular resource method
|
||||
pub trait CallBuilder: MarkerTrait {}
|
||||
@@ -105,12 +105,15 @@ pub trait Delegate {
|
||||
/// information if he is interesting in knowing more context when further calls to it
|
||||
/// are made.
|
||||
/// The matching `finished()` call will always be made, no matter whether or not the API
|
||||
/// request was sucessfull. That way, the delgate may easily maintain a clean state
|
||||
/// request was successful. That way, the delegate may easily maintain a clean state
|
||||
/// between various API calls.
|
||||
fn begin(&mut self, MethodInfo) {}
|
||||
|
||||
/// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), usually if there are network problems.
|
||||
///
|
||||
/// If you choose to retry after a duration, the duration should be chosen using the
|
||||
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
|
||||
///
|
||||
/// Return retry information.
|
||||
fn http_error(&mut self, &hyper::HttpError) -> Retry {
|
||||
Retry::Abort
|
||||
@@ -133,7 +136,7 @@ pub trait Delegate {
|
||||
/// Called during resumable uploads to provide a URL for the impending upload.
|
||||
/// It was saved after a previous call to `store_upload_url(...)`, and if not None,
|
||||
/// will be used instead of asking the server for a new upload URL.
|
||||
/// This is useful in case a previous resumable upload was aborted/cancelled, but should now
|
||||
/// This is useful in case a previous resumable upload was aborted/canceled, but should now
|
||||
/// be resumed.
|
||||
/// The returned URL will be used exactly once - if it fails again and the delegate allows
|
||||
/// to retry, we will ask the server for a new upload URL.
|
||||
@@ -154,8 +157,8 @@ pub trait Delegate {
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `json_encoded_value` - The json-encoded value which failed to decode.
|
||||
/// `json_decode_error` - The decoder error
|
||||
/// * `json_encoded_value` - The json-encoded value which failed to decode.
|
||||
/// * `json_decode_error` - The decoder error
|
||||
fn response_json_decode_error(&mut self, json_encoded_value: &str, json_decode_error: &serde::json::Error) {
|
||||
let _ = json_encoded_value;
|
||||
let _ = json_decode_error;
|
||||
@@ -166,6 +169,9 @@ pub trait Delegate {
|
||||
/// depends on the used API method.
|
||||
/// The delegate should check the status, header and decoded json error to decide
|
||||
/// whether to retry or not. In the latter case, the underlying call will fail.
|
||||
///
|
||||
/// If you choose to retry after a duration, the duration should be chosen using the
|
||||
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
|
||||
fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry {
|
||||
Retry::Abort
|
||||
}
|
||||
@@ -197,8 +203,8 @@ pub trait Delegate {
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `is_success` - a true value indicates the operation was successful. If false, you should
|
||||
/// discard all values stored during `store_upload_url`.
|
||||
/// * `is_success` - a true value indicates the operation was successful. If false, you should
|
||||
/// discard all values stored during `store_upload_url`.
|
||||
fn finished(&mut self, is_success: bool) {
|
||||
let _ = is_success;
|
||||
}
|
||||
@@ -212,8 +218,8 @@ pub struct DefaultDelegate;
|
||||
impl Delegate for DefaultDelegate {}
|
||||
|
||||
|
||||
/// A universal result type used as return for all action method results.
|
||||
pub enum Result<T = ()> {
|
||||
|
||||
pub enum Error {
|
||||
/// The http connection failed
|
||||
HttpError(hyper::HttpError),
|
||||
|
||||
@@ -240,11 +246,11 @@ pub enum Result<T = ()> {
|
||||
|
||||
/// Indicates an HTTP repsonse with a non-success status code
|
||||
Failure(hyper::client::Response),
|
||||
|
||||
/// It worked !
|
||||
Success(T),
|
||||
}
|
||||
|
||||
/// A universal result type used as return for all calls.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Contains information about an API request.
|
||||
pub struct MethodInfo {
|
||||
pub id: &'static str,
|
||||
@@ -499,7 +505,7 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
where NC: hyper::net::NetworkConnector,
|
||||
A: oauth2::GetToken {
|
||||
|
||||
fn query_transfer_status(&mut self) -> (Option<u64>, hyper::HttpResult<hyper::client::Response>) {
|
||||
fn query_transfer_status(&mut self) -> std::result::Result<u64, hyper::HttpResult<hyper::client::Response>> {
|
||||
loop {
|
||||
match self.client.post(self.url)
|
||||
.header(UserAgent(self.user_agent.to_string()))
|
||||
@@ -516,17 +522,17 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return (None, Ok(r))
|
||||
return Err(Ok(r))
|
||||
}
|
||||
};
|
||||
return (Some(h.0.last), Ok(r))
|
||||
return Ok(h.0.last)
|
||||
}
|
||||
Err(err) => {
|
||||
if let Retry::After(d) = self.delegate.http_error(&err) {
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return (None, Err(err))
|
||||
return Err(Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,8 +545,8 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
let mut start = match self.start_at {
|
||||
Some(s) => s,
|
||||
None => match self.query_transfer_status() {
|
||||
(Some(s), _) => s,
|
||||
(_, result) => return Some(result)
|
||||
Ok(s) => s,
|
||||
Err(result) => return Some(result)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
<%! from util import (estr, hash_comment) %>\
|
||||
<%! from util import (estr, hash_comment, library_to_crate_name) %>\
|
||||
<%namespace name="util" file="lib/util.mako"/>\
|
||||
<%block filter="hash_comment">\
|
||||
<%util:gen_info source="${self.uri}" />\
|
||||
@@ -10,7 +10,9 @@ version = "${util.crate_version()}"
|
||||
authors = [${",\n ".join('"%s"' % a for a in cargo.authors)}]
|
||||
description = "A complete library to interact with ${util.canonical_name()} (protocol ${version})"
|
||||
repository = "${util.github_source_root_url()}"
|
||||
% if documentationLink is not UNDEFINED:
|
||||
homepage = "${documentationLink}"
|
||||
% endif
|
||||
documentation = "${cargo.doc_base_url}/${util.crate_name()}"
|
||||
license = "${copyright.license_abbrev}"
|
||||
keywords = ["${name}", ${", ".join(estr(cargo.keywords))}]
|
||||
@@ -18,7 +20,13 @@ keywords = ["${name}", ${", ".join(estr(cargo.keywords))}]
|
||||
[dependencies]
|
||||
hyper = "*"
|
||||
mime = "*"
|
||||
url = "*"
|
||||
serde = "*"
|
||||
serde_macros = "*"
|
||||
yup-oauth2 = "*"
|
||||
% for dep in cargo.get('dependencies', list()):
|
||||
${dep}
|
||||
% endfor
|
||||
% if make.depends_on_suffix is not None:
|
||||
|
||||
<% api_name = util.library_name() %>\
|
||||
[dependencies.${library_to_crate_name(api_name, suffix=make.depends_on_suffix)}]
|
||||
path = "../${api_name}"
|
||||
% endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
c = new_context(schemas, resources, context.get('methods'))
|
||||
%>\
|
||||
<%namespace name="lib" file="lib/lib.mako"/>\
|
||||
<%namespace name="util" file="lib/util.mako"/>\
|
||||
<%namespace name="util" file="../lib/util.mako"/>\
|
||||
<%block filter="markdown_comment">\
|
||||
<%util:gen_info source="${self.uri}" />\
|
||||
</%block>
|
||||
@@ -1,5 +1,5 @@
|
||||
<%namespace name="lib" file="lib/lib.mako"/>\
|
||||
<%namespace name="util" file="lib/util.mako"/>\
|
||||
<%namespace name="util" file="../lib/util.mako"/>\
|
||||
<%namespace name="rbuild" file="lib/rbuild.mako"/>\
|
||||
<%namespace name="mbuild" file="lib/mbuild.mako"/>\
|
||||
<%namespace name="schema" file="lib/schema.mako"/>\
|
||||
@@ -11,7 +11,7 @@
|
||||
def pretty_name(name):
|
||||
return ' '.join(split_camelcase_s(name).split('.'))
|
||||
%>\
|
||||
<%namespace name="util" file="util.mako"/>\
|
||||
<%namespace name="util" file="../../lib/util.mako"/>\
|
||||
<%namespace name="mbuild" file="mbuild.mako"/>\
|
||||
|
||||
## If rust-doc is True, examples will be made to work for rust doc tests. Otherwise they are set
|
||||
@@ -36,7 +36,7 @@
|
||||
fn_name = 'add_' + fn_name
|
||||
return fn_name
|
||||
%>\
|
||||
<%namespace name="util" file="util.mako"/>\
|
||||
<%namespace name="util" file="../../lib/util.mako"/>\
|
||||
<%namespace name="lib" file="lib.mako"/>\
|
||||
|
||||
## Creates a method builder type
|
||||
@@ -8,7 +8,7 @@
|
||||
struct_type_bounds_s, METHODS_RESOURCE, SPACES_PER_TAB, prefix_all_but_first_with,
|
||||
METHODS_BUILDER_MARKER_TRAIT, remove_empty_lines)
|
||||
%>\
|
||||
<%namespace name="util" file="util.mako"/>\
|
||||
<%namespace name="util" file="../../lib/util.mako"/>\
|
||||
<%namespace name="lib" file="lib.mako"/>\
|
||||
|
||||
## Creates a Resource builder type
|
||||
3
src/mako/cli/main.rs.mako
Normal file
3
src/mako/cli/main.rs.mako
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, ${id} !");
|
||||
}
|
||||
@@ -17,6 +17,10 @@
|
||||
discovery_url = 'https://www.googleapis.com/discovery/v1/'
|
||||
apis = json.loads(urllib2.urlopen(discovery_url + "apis").read())
|
||||
json_api_targets = []
|
||||
|
||||
suffix = make.target_suffix
|
||||
agsuffix = make.aggregated_target_suffix
|
||||
global_targets = make.get('global_targets', False)
|
||||
%>\
|
||||
% for an, versions in api.list.iteritems():
|
||||
% if an in api.get('blacklist', list()):
|
||||
@@ -29,55 +33,59 @@
|
||||
import json
|
||||
|
||||
api_name = util.library_name(an, version)
|
||||
crate_name = util.library_to_crate_name(api_name)
|
||||
gen_root = directories.output + '/' + api_name
|
||||
api_target = api_name + suffix
|
||||
depends_on_target = ''
|
||||
if make.depends_on_suffix is not None:
|
||||
depends_on_target = api_name + make.depends_on_suffix
|
||||
crate_name = util.library_to_crate_name(api_name, suffix)
|
||||
gen_root = directories.output + '/' + api_target
|
||||
gen_root_stamp = gen_root + '/.timestamp'
|
||||
api_common = gen_root + '/src/cmn.rs'
|
||||
api_clean = api_name + '-clean'
|
||||
api_cargo = api_name + '-cargo'
|
||||
api_doc = api_name + '-doc'
|
||||
api_clean = api_target + '-clean'
|
||||
api_cargo = api_target + '-cargo'
|
||||
api_doc = api_target + '-doc'
|
||||
|
||||
api_doc_root = to_doc_root(gen_root, crate_name)
|
||||
api_doc_index = api_doc_root + '/index.html'
|
||||
|
||||
# source, destination of individual output files
|
||||
sds = [(directories.mako_src + '/' + i.source + '.mako', gen_root + '/' + i.get('output_dir', '') + '/' + i.source)
|
||||
for i in api.templates]
|
||||
sds = [(directories.mako_src + '/' + make.id + '/' + i.source + '.mako', gen_root + '/' + i.get('output_dir', '') + '/' + i.source.strip('../'))
|
||||
for i in make.templates]
|
||||
api_json = directories.api_base + '/' + an + '/' + version + '/' + an + '-api.json'
|
||||
api_meta_dir = os.path.dirname(api_json)
|
||||
api_crate_publish_file = api_meta_dir + '/crates/' + util.crate_version(cargo.build_version,
|
||||
api_crate_publish_file = api_meta_dir + '/crates/' + util.crate_version(cargo.build_version + make.aggregated_target_suffix,
|
||||
json.load(open(api_json, 'r'))['revision'])
|
||||
api_json_overrides = api_meta_dir + '/' + an + '-api_overrides.json'
|
||||
api_json_inputs = api_json + ' $(API_SHARED_INFO)'
|
||||
api_json_inputs = api_json + ' $(API_SHARED_INFO) $(API_DIR)/type-' + make.id + '.yaml'
|
||||
if os.path.isfile(api_json_overrides):
|
||||
api_json_inputs += ' ' + api_json_overrides
|
||||
api_info.append((api_name, api_clean, api_cargo, api_doc, api_crate_publish_file, gen_root))
|
||||
api_info.append((api_target, api_clean, api_cargo, api_doc, api_crate_publish_file, gen_root))
|
||||
|
||||
space_join = lambda i: ' '.join(a[i] for a in api_info)
|
||||
%>\
|
||||
${api_common}: $(RUST_SRC)/cmn.rs $(lastword $(MAKEFILE_LIST)) ${gen_root_stamp}
|
||||
${api_common}: $(RUST_SRC)/${make.id}/cmn.rs $(lastword $(MAKEFILE_LIST)) ${gen_root_stamp}
|
||||
@ echo "// COPY OF '$<'" > $@
|
||||
@ echo "// DO NOT EDIT" >> $@
|
||||
@cat $< >> $@
|
||||
|
||||
${gen_root_stamp}: ${' '.join(i[0] for i in sds)} ${api_json_inputs} $(MAKO_STANDARD_DEPENDENCIES)
|
||||
@echo Generating ${api_name}
|
||||
@$(MAKO) --template-dir '.' -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} --data-files ${api_json_inputs}
|
||||
${gen_root_stamp}: ${' '.join(i[0] for i in sds)} ${api_json_inputs} $(MAKO_STANDARD_DEPENDENCIES) ${depends_on_target}
|
||||
@echo Generating ${api_target}
|
||||
@$(MAKO) -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} --data-files ${api_json_inputs}
|
||||
@touch $@
|
||||
|
||||
${api_name}: ${api_common}
|
||||
${api_target}: ${api_common}
|
||||
|
||||
${api_crate_publish_file}:
|
||||
cd ${gen_root} && cargo publish
|
||||
@mkdir -p ${os.path.dirname(api_crate_publish_file)}
|
||||
touch $@
|
||||
|
||||
${api_cargo}: ${api_name}
|
||||
${api_cargo}: ${api_target}
|
||||
cd ${gen_root} && cargo $(ARGS)
|
||||
|
||||
${api_doc_index}: ${api_name}
|
||||
${api_doc_index}: ${api_target}
|
||||
cd ${gen_root} && cargo doc
|
||||
@echo "Docs for ${api_name} at $@"
|
||||
@echo "Docs for ${api_target} at $@"
|
||||
|
||||
${api_doc}: ${api_doc_index}
|
||||
|
||||
@@ -90,28 +98,36 @@ ${api_clean}:
|
||||
% endfor
|
||||
% endfor
|
||||
|
||||
clean-apis: ${space_join(1)} docs-clean
|
||||
cargo: ${space_join(2)}
|
||||
publish: | apis ${space_join(4)}
|
||||
apis: ${space_join(0)}
|
||||
clean${agsuffix}: ${space_join(1)} docs-clean${agsuffix}
|
||||
cargo${agsuffix}: ${space_join(2)}
|
||||
publish${agsuffix}: | gen-all${agsuffix} ${space_join(4)}
|
||||
gen-all${agsuffix}: ${space_join(0)}
|
||||
|
||||
${doc_index}: ${' '.join(central_api_index(util.library_to_crate_name(a[0])) for a in api_info)} $(MAKO_STANDARD_DEPENDENCIES)
|
||||
% if global_targets:
|
||||
${doc_index}: docs${agsuffix} ## TODO: all type dependencies: docs-api, docs-cli
|
||||
$(MAKO) --var DOC_ROOT=${doc_root} -io $(MAKO_SRC)/index.html.mako=$@ --data-files $(API_SHARED_INFO) $(API_LIST)
|
||||
@echo Documentation index created at '$@'
|
||||
docs-all: ${doc_index}
|
||||
docs-all-clean:
|
||||
rm -Rf ${doc_root}
|
||||
|
||||
docs: ${doc_index}
|
||||
docs-clean:
|
||||
rm -Rf ${doc_root}
|
||||
|
||||
github-pages: | docs-clean docs
|
||||
github-pages: | docs-all-clean docs-all
|
||||
ghp-import -n ${doc_root}
|
||||
## Have to force-push - allows us to start docs fresh, clearing out unused history
|
||||
git push origin +gh-pages
|
||||
|
||||
.PHONY = $(.PHONY) update-json github-pages help-api clean-apis cargo publish apis docs docs-clean ${space_join(0)} ${space_join(1)} ${space_join(2)} ${space_join(3)}
|
||||
.PHONY += github-pages docs-all docs-all-clean
|
||||
% endif
|
||||
|
||||
help-api:
|
||||
$(info apis - make all APIs)
|
||||
docs${agsuffix}: ${' '.join(central_api_index(util.library_to_crate_name(a[0])) for a in api_info)} $(MAKO_STANDARD_DEPENDENCIES)
|
||||
|
||||
.PHONY = $(.PHONY) help${agsuffix} clean${agsuffix} cargo${agsuffix} publish${agsuffix} gen-all${agsuffix} ${space_join(0)} ${space_join(1)} ${space_join(2)} ${space_join(3)}
|
||||
|
||||
help${agsuffix}:
|
||||
$(info gen-all${agsuffix} - make all ${make.target_name})
|
||||
$(info clean-all${agsuffix} - delete all generated ${make.target_name})
|
||||
$(info cargo${agsuffix} - run cargo on all ${make.target_name}, use ARGS="args ..." to specify cargo arguments)
|
||||
$(info publish${agsuffix} - run cargo publish on all ${make.target_name} and remember successful ones with marker files)
|
||||
% for a in api_info:
|
||||
$(info ${a[0]} - build the ${a[0]} api)
|
||||
$(info ${a[1]} - clean all generated files of the ${a[0]} api)
|
||||
@@ -119,6 +135,9 @@ help-api:
|
||||
$(info ${a[3]} - run cargo doc on the ${a[0]}")
|
||||
% endfor
|
||||
|
||||
% if global_targets:
|
||||
.PHONY += update-json
|
||||
|
||||
% for info in apis['items']:
|
||||
<%
|
||||
import util
|
||||
@@ -135,4 +154,5 @@ ${fake_target}:
|
||||
% endfor
|
||||
|
||||
update-json: ${' '.join(json_api_targets)}
|
||||
$(API_VERSION_GEN) etc/api $(API_LIST) $(API_LIST)
|
||||
$(API_VERSION_GEN) $(API_DIR) $(API_LIST) $(API_LIST)
|
||||
% endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from util import (library_name, library_to_crate_name)
|
||||
|
||||
def api_index(name, version):
|
||||
index_file_path = library_to_crate_name(library_name(name, version)) + '/index.html'
|
||||
index_file_path = library_to_crate_name(library_name(name, version), make.target_suffix) + '/index.html'
|
||||
if os.path.isfile(DOC_ROOT + '/' + index_file_path):
|
||||
return index_file_path
|
||||
return None
|
||||
|
||||
@@ -24,7 +24,7 @@ ${util.library_name(name, version)}\
|
||||
</%def>
|
||||
|
||||
<%def name="crate_name()" buffered="True">\
|
||||
${util.library_to_crate_name(util.library_name(name, version))}\
|
||||
${util.library_to_crate_name(util.library_name(name, version), make.target_suffix)}\
|
||||
</%def>
|
||||
|
||||
<%def name="crate_version()" buffered="True">\
|
||||
|
||||
@@ -800,8 +800,8 @@ def library_name(name, version):
|
||||
return normalize_library_name(name) + version
|
||||
|
||||
# return crate name for given result of `library_name()`
|
||||
def library_to_crate_name(name):
|
||||
return 'google-' + name
|
||||
def library_to_crate_name(name, suffix=''):
|
||||
return 'google-' + name + suffix
|
||||
|
||||
# return version like 0.1.0+2014031421
|
||||
def crate_version(build_version, revision):
|
||||
|
||||
1
src/rust/api/mod.rs
Normal file
1
src/rust/api/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod cmn;
|
||||
0
src/rust/cli/cmn.rs
Normal file
0
src/rust/cli/cmn.rs
Normal file
1
src/rust/cli/mod.rs
Normal file
1
src/rust/cli/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod cmn;
|
||||
@@ -9,13 +9,14 @@ extern crate "yup-oauth2" as oauth2;
|
||||
extern crate serde;
|
||||
|
||||
// just pull it in the check if it compiles
|
||||
mod cmn;
|
||||
mod api;
|
||||
mod cli;
|
||||
|
||||
/// This module is for testing only, its code is used in mako templates
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
mod test_api {
|
||||
extern crate "yup-hyper-mock" as hyper_mock;
|
||||
use super::cmn::*;
|
||||
use super::api::cmn::*;
|
||||
use self::hyper_mock::*;
|
||||
use std::io::Read;
|
||||
use std::default::Default;
|
||||
|
||||
Reference in New Issue
Block a user