mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-01 17:14:19 +01:00
chore(code-update):added latest version of api+cli
APIs have additional files thanks to the build-script requirement. CLI has just seen minor changes though, making it usable with a stable compiler.
This commit is contained in:
16
gen/taskqueue1_beta2/src/build.rs
Normal file
16
gen/taskqueue1_beta2/src/build.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
extern crate syntex;
|
||||
extern crate serde_codegen;
|
||||
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
pub fn main() {
|
||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||
|
||||
let src = Path::new("src/lib.rs.in");
|
||||
let dst = Path::new(&out_dir).join("lib.rs");
|
||||
|
||||
let mut registry = syntex::Registry::new();
|
||||
serde_codegen::register(&mut registry);
|
||||
registry.expand("google-taskqueue1_beta2", &src, &dst).unwrap();
|
||||
}
|
||||
@@ -290,7 +290,7 @@ impl Display for Error {
|
||||
writeln!(f, "The media size {} exceeds the maximum allowed upload size of {}"
|
||||
, resource_size, max_size),
|
||||
Error::MissingAPIKey => {
|
||||
writeln!(f, "The application's API key was not found in the configuration").ok();
|
||||
(writeln!(f, "The application's API key was not found in the configuration")).ok();
|
||||
writeln!(f, "It is used as there are no Scopes defined for this method.")
|
||||
},
|
||||
Error::BadRequest(ref err) => {
|
||||
@@ -424,8 +424,8 @@ impl<'a> Read for MultiPartReader<'a> {
|
||||
(n, true, _) if n > 0 => {
|
||||
let (headers, reader) = self.raw_parts.remove(0);
|
||||
let mut c = Cursor::new(Vec::<u8>::new());
|
||||
write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING,
|
||||
headers, LINE_ENDING).unwrap();
|
||||
(write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING,
|
||||
headers, LINE_ENDING)).unwrap();
|
||||
c.seek(SeekFrom::Start(0)).unwrap();
|
||||
self.current_part = Some((c, reader));
|
||||
}
|
||||
@@ -471,18 +471,51 @@ impl<'a> Read for MultiPartReader<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
header!{
|
||||
#[doc="The `X-Upload-Content-Type` header."]
|
||||
(XUploadContentType, "X-Upload-Content-Type") => [Mime]
|
||||
// The following macro invocation needs to be expanded, as `include!`
|
||||
// doens't support external macros
|
||||
// header!{
|
||||
// #[doc="The `X-Upload-Content-Type` header."]
|
||||
// (XUploadContentType, "X-Upload-Content-Type") => [Mime]
|
||||
|
||||
xupload_content_type {
|
||||
test_header!(
|
||||
test1,
|
||||
vec![b"text/plain"],
|
||||
Some(HeaderField(
|
||||
vec![Mime(TopLevel::Text, SubLevel::Plain, Vec::new())]
|
||||
)));
|
||||
// xupload_content_type {
|
||||
// test_header!(
|
||||
// test1,
|
||||
// vec![b"text/plain"],
|
||||
// Some(HeaderField(
|
||||
// vec![Mime(TopLevel::Text, SubLevel::Plain, Vec::new())]
|
||||
// )));
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
/// The `X-Upload-Content-Type` header.
|
||||
///
|
||||
/// Generated via rustc --pretty expanded -Z unstable-options, and manually
|
||||
/// processed to be more readable.
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub struct XUploadContentType(pub Mime);
|
||||
|
||||
impl ::std::ops::Deref for XUploadContentType {
|
||||
type Target = Mime;
|
||||
fn deref<'a>(&'a self) -> &'a Mime { &self.0 }
|
||||
}
|
||||
impl ::std::ops::DerefMut for XUploadContentType {
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut Mime { &mut self.0 }
|
||||
}
|
||||
impl Header for XUploadContentType {
|
||||
fn header_name() -> &'static str { "X-Upload-Content-Type" }
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Self> {
|
||||
hyper::header::parsing::from_one_raw_str(raw).map(XUploadContentType)
|
||||
}
|
||||
}
|
||||
impl HeaderFormat for XUploadContentType {
|
||||
fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Display::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
impl Display for XUploadContentType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,7 +527,7 @@ pub struct Chunk {
|
||||
|
||||
impl fmt::Display for Chunk {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "{}-{}", self.first, self.last).ok();
|
||||
(write!(fmt, "{}-{}", self.first, self.last)).ok();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -536,7 +569,7 @@ impl Header for ContentRange {
|
||||
}
|
||||
|
||||
/// We are not parsable, as parsing is done by the `Range` header
|
||||
fn parse_header(_: &[Vec<u8>]) -> Option<ContentRange> {
|
||||
fn parse_header(_: &[Vec<u8>]) -> Option<Self> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -549,7 +582,7 @@ impl HeaderFormat for ContentRange {
|
||||
Some(ref c) => try!(c.fmt(fmt)),
|
||||
None => try!(fmt.write_str("*"))
|
||||
}
|
||||
write!(fmt, "/{}", self.total_length).ok();
|
||||
(write!(fmt, "/{}", self.total_length)).ok();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -562,8 +595,9 @@ impl Header for RangeResponseHeader {
|
||||
"Range"
|
||||
}
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<RangeResponseHeader> {
|
||||
if let [ref v] = raw {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Self> {
|
||||
if raw.len() > 0 {
|
||||
let v = &raw[0];
|
||||
if let Ok(s) = std::str::from_utf8(v) {
|
||||
const PREFIX: &'static str = "bytes ";
|
||||
if s.starts_with(PREFIX) {
|
||||
@@ -668,12 +702,14 @@ impl<'a, A> ResumableUploadHelper<'a, A>
|
||||
if self.delegate.cancel_chunk_upload(&range_header) {
|
||||
return None
|
||||
}
|
||||
match self.client.post(self.url)
|
||||
.header(range_header)
|
||||
.header(ContentType(self.media_type.clone()))
|
||||
.header(UserAgent(self.user_agent.to_string()))
|
||||
.body(&mut section_reader)
|
||||
.send() {
|
||||
// workaround https://github.com/rust-lang/rust/issues/22252
|
||||
let res = self.client.post(self.url)
|
||||
.header(range_header)
|
||||
.header(ContentType(self.media_type.clone()))
|
||||
.header(UserAgent(self.user_agent.to_string()))
|
||||
.body(&mut section_reader)
|
||||
.send();
|
||||
match res {
|
||||
Ok(mut res) => {
|
||||
if res.status == StatusCode::PermanentRedirect {
|
||||
continue
|
||||
@@ -700,4 +736,27 @@ impl<'a, A> ResumableUploadHelper<'a, A>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy of src/rust/cli/cmn.rs
|
||||
// TODO(ST): Allow sharing common code between program types
|
||||
pub fn remove_json_null_values(value: &mut serde::json::value::Value) {
|
||||
match *value {
|
||||
serde::json::value::Value::Object(ref mut map) => {
|
||||
let mut for_removal = Vec::new();
|
||||
|
||||
for (key, mut value) in map.iter_mut() {
|
||||
if value.is_null() {
|
||||
for_removal.push(key.clone());
|
||||
} else {
|
||||
remove_json_null_values(&mut value);
|
||||
}
|
||||
}
|
||||
|
||||
for key in &for_removal {
|
||||
map.remove(key);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2780
gen/taskqueue1_beta2/src/lib.rs.in
Normal file
2780
gen/taskqueue1_beta2/src/lib.rs.in
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user