mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
fix(mako): fix name clashes
Scopes could be invalid, previosly, and the hub type could clash with other types provided as Schema. Also, we used reserved identifiers
This commit is contained in:
@@ -133,7 +133,7 @@ use std::marker::PhantomData;
|
|||||||
use std::borrow::BorrowMut;
|
use std::borrow::BorrowMut;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::io::{Read, Seek};
|
use std::io;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
@@ -5264,7 +5264,7 @@ impl<'a, C, NC, A> ChannelBannerInsertMethodBuilder<'a, C, NC, A> where NC: hype
|
|||||||
|
|
||||||
|
|
||||||
/// Perform the operation you have build so far.
|
/// Perform the operation you have build so far.
|
||||||
fn doit<R, RS>(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> Result<ChannelBannerResource> where R: Read, RS: ReadSeek {
|
fn doit<R, RS>(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> Result<ChannelBannerResource> where R: io::Read, RS: ReadSeek {
|
||||||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||||||
if self._on_behalf_of_content_owner.is_some() {
|
if self._on_behalf_of_content_owner.is_some() {
|
||||||
params.push(("onBehalfOfContentOwner", self._on_behalf_of_content_owner.unwrap().to_string()));
|
params.push(("onBehalfOfContentOwner", self._on_behalf_of_content_owner.unwrap().to_string()));
|
||||||
@@ -5304,7 +5304,7 @@ impl<'a, C, NC, A> ChannelBannerInsertMethodBuilder<'a, C, NC, A> where NC: hype
|
|||||||
/// * *multipart*: yes
|
/// * *multipart*: yes
|
||||||
/// * *valid mime types*: 'application/octet-stream', 'image/jpeg' and 'image/png'
|
/// * *valid mime types*: 'application/octet-stream', 'image/jpeg' and 'image/png'
|
||||||
pub fn upload<R>(mut self, stream: R, size: u64, mime_type: mime::Mime) -> Result<ChannelBannerResource>
|
pub fn upload<R>(mut self, stream: R, size: u64, mime_type: mime::Mime) -> Result<ChannelBannerResource>
|
||||||
where R: Read {
|
where R: io::Read {
|
||||||
self.doit(Some((stream, size, mime_type)), None::<(fs::File, u64, mime::Mime)>, )
|
self.doit(Some((stream, size, mime_type)), None::<(fs::File, u64, mime::Mime)>, )
|
||||||
}
|
}
|
||||||
/// Upload media in a resumeable fashion.
|
/// Upload media in a resumeable fashion.
|
||||||
@@ -7271,7 +7271,7 @@ impl<'a, C, NC, A> ThumbnailSetMethodBuilder<'a, C, NC, A> where NC: hyper::net:
|
|||||||
|
|
||||||
|
|
||||||
/// Perform the operation you have build so far.
|
/// Perform the operation you have build so far.
|
||||||
fn doit<R, RS>(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> Result<ThumbnailSetResponse> where R: Read, RS: ReadSeek {
|
fn doit<R, RS>(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> Result<ThumbnailSetResponse> where R: io::Read, RS: ReadSeek {
|
||||||
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
||||||
params.push(("videoId", self._video_id.to_string()));
|
params.push(("videoId", self._video_id.to_string()));
|
||||||
if self._on_behalf_of_content_owner.is_some() {
|
if self._on_behalf_of_content_owner.is_some() {
|
||||||
@@ -7312,7 +7312,7 @@ impl<'a, C, NC, A> ThumbnailSetMethodBuilder<'a, C, NC, A> where NC: hyper::net:
|
|||||||
/// * *multipart*: yes
|
/// * *multipart*: yes
|
||||||
/// * *valid mime types*: 'application/octet-stream', 'image/jpeg' and 'image/png'
|
/// * *valid mime types*: 'application/octet-stream', 'image/jpeg' and 'image/png'
|
||||||
pub fn upload<R>(mut self, stream: R, size: u64, mime_type: mime::Mime) -> Result<ThumbnailSetResponse>
|
pub fn upload<R>(mut self, stream: R, size: u64, mime_type: mime::Mime) -> Result<ThumbnailSetResponse>
|
||||||
where R: Read {
|
where R: io::Read {
|
||||||
self.doit(Some((stream, size, mime_type)), None::<(fs::File, u64, mime::Mime)>, )
|
self.doit(Some((stream, size, mime_type)), None::<(fs::File, u64, mime::Mime)>, )
|
||||||
}
|
}
|
||||||
/// Upload media in a resumeable fashion.
|
/// Upload media in a resumeable fashion.
|
||||||
@@ -8540,7 +8540,7 @@ impl<'a, C, NC, A> VideoInsertMethodBuilder<'a, C, NC, A> where NC: hyper::net::
|
|||||||
|
|
||||||
|
|
||||||
/// Perform the operation you have build so far.
|
/// Perform the operation you have build so far.
|
||||||
fn doit<R, RS>(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> Result<Video> where R: Read, RS: ReadSeek {
|
fn doit<R, RS>(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> Result<Video> where R: io::Read, RS: ReadSeek {
|
||||||
let mut params: Vec<(&str, String)> = Vec::with_capacity(8 + self._additional_params.len());
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(8 + self._additional_params.len());
|
||||||
if self._part.len() == 0 {
|
if self._part.len() == 0 {
|
||||||
self._part = self._request.to_parts();
|
self._part = self._request.to_parts();
|
||||||
@@ -8596,7 +8596,7 @@ impl<'a, C, NC, A> VideoInsertMethodBuilder<'a, C, NC, A> where NC: hyper::net::
|
|||||||
/// * *multipart*: yes
|
/// * *multipart*: yes
|
||||||
/// * *valid mime types*: 'application/octet-stream' and 'video/*'
|
/// * *valid mime types*: 'application/octet-stream' and 'video/*'
|
||||||
pub fn upload<R>(mut self, stream: R, size: u64, mime_type: mime::Mime) -> Result<Video>
|
pub fn upload<R>(mut self, stream: R, size: u64, mime_type: mime::Mime) -> Result<Video>
|
||||||
where R: Read {
|
where R: io::Read {
|
||||||
self.doit(Some((stream, size, mime_type)), None::<(fs::File, u64, mime::Mime)>, )
|
self.doit(Some((stream, size, mime_type)), None::<(fs::File, u64, mime::Mime)>, )
|
||||||
}
|
}
|
||||||
/// Upload media in a resumeable fashion.
|
/// Upload media in a resumeable fashion.
|
||||||
@@ -12292,7 +12292,7 @@ impl<'a, C, NC, A> WatermarkSetMethodBuilder<'a, C, NC, A> where NC: hyper::net:
|
|||||||
|
|
||||||
|
|
||||||
/// Perform the operation you have build so far.
|
/// Perform the operation you have build so far.
|
||||||
fn doit<R, RS>(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> Result<()> where R: Read, RS: ReadSeek {
|
fn doit<R, RS>(mut self, stream: Option<(R, u64, mime::Mime)>, resumeable_stream: Option<(RS, u64, mime::Mime)>) -> Result<()> where R: io::Read, RS: ReadSeek {
|
||||||
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
||||||
params.push(("channelId", self._channel_id.to_string()));
|
params.push(("channelId", self._channel_id.to_string()));
|
||||||
if self._on_behalf_of_content_owner.is_some() {
|
if self._on_behalf_of_content_owner.is_some() {
|
||||||
@@ -12333,7 +12333,7 @@ impl<'a, C, NC, A> WatermarkSetMethodBuilder<'a, C, NC, A> where NC: hyper::net:
|
|||||||
/// * *multipart*: yes
|
/// * *multipart*: yes
|
||||||
/// * *valid mime types*: 'application/octet-stream', 'image/jpeg' and 'image/png'
|
/// * *valid mime types*: 'application/octet-stream', 'image/jpeg' and 'image/png'
|
||||||
pub fn upload<R>(mut self, stream: R, size: u64, mime_type: mime::Mime) -> Result<()>
|
pub fn upload<R>(mut self, stream: R, size: u64, mime_type: mime::Mime) -> Result<()>
|
||||||
where R: Read {
|
where R: io::Read {
|
||||||
self.doit(Some((stream, size, mime_type)), None::<(fs::File, u64, mime::Mime)>, )
|
self.doit(Some((stream, size, mime_type)), None::<(fs::File, u64, mime::Mime)>, )
|
||||||
}
|
}
|
||||||
/// Upload media in a resumeable fashion.
|
/// Upload media in a resumeable fashion.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
if schemas:
|
if schemas:
|
||||||
nested_schemas = list(iter_nested_types(schemas))
|
nested_schemas = list(iter_nested_types(schemas))
|
||||||
c = new_context(resources)
|
c = new_context(resources)
|
||||||
hub_type = hub_type(util.canonical_name())
|
hub_type = hub_type(schemas, util.canonical_name())
|
||||||
ht_params = hub_type_params_s()
|
ht_params = hub_type_params_s()
|
||||||
%>\
|
%>\
|
||||||
<%block filter="rust_comment">\
|
<%block filter="rust_comment">\
|
||||||
@@ -37,7 +37,7 @@ use std::marker::PhantomData;
|
|||||||
use std::borrow::BorrowMut;
|
use std::borrow::BorrowMut;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::io::{Read, Seek};
|
use std::io;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
###############################################################################################
|
###############################################################################################
|
||||||
<%def name="new(resource, method, c)">\
|
<%def name="new(resource, method, c)">\
|
||||||
<%
|
<%
|
||||||
hub_type_name = hub_type(util.canonical_name())
|
hub_type_name = hub_type(schemas,util.canonical_name())
|
||||||
m = c.fqan_map[to_fqan(c.rtc_map[resource], resource, method)]
|
m = c.fqan_map[to_fqan(c.rtc_map[resource], resource, method)]
|
||||||
# an identifier for a property. We prefix them to prevent clashes with the setters
|
# an identifier for a property. We prefix them to prevent clashes with the setters
|
||||||
mb_tparams = mb_type_params_s(m)
|
mb_tparams = mb_type_params_s(m)
|
||||||
@@ -212,7 +212,7 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
|
|||||||
###############################################################################################
|
###############################################################################################
|
||||||
<%def name="usage(resource, method, m, params, request_value, parts)">\
|
<%def name="usage(resource, method, m, params, request_value, parts)">\
|
||||||
<%
|
<%
|
||||||
hub_type_name = hub_type(util.canonical_name())
|
hub_type_name = hub_type(schemas, util.canonical_name())
|
||||||
required_props, optional_props, part_prop = organize_params(params, request_value)
|
required_props, optional_props, part_prop = organize_params(params, request_value)
|
||||||
is_string_value = lambda v: v.endswith('"')
|
is_string_value = lambda v: v.endswith('"')
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
###############################################################################################
|
###############################################################################################
|
||||||
<%def name="new(resource, c)">\
|
<%def name="new(resource, c)">\
|
||||||
<%
|
<%
|
||||||
hub_type_name = hub_type(util.canonical_name())
|
hub_type_name = hub_type(schemas, util.canonical_name())
|
||||||
rb_params = rb_type_params_s(resource, c)
|
rb_params = rb_type_params_s(resource, c)
|
||||||
ThisType = rb_type(resource) + rb_params
|
ThisType = rb_type(resource) + rb_params
|
||||||
%>\
|
%>\
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ PROTOCOL_TYPE_INFO = {
|
|||||||
'description': """Upload media all at once.
|
'description': """Upload media all at once.
|
||||||
If the upload fails for whichever reason, all progress is lost.""",
|
If the upload fails for whichever reason, all progress is lost.""",
|
||||||
'default': 'fs::File',
|
'default': 'fs::File',
|
||||||
'where': 'Read',
|
'where': 'io::Read',
|
||||||
'suffix': '',
|
'suffix': '',
|
||||||
'example_value': 'fs::File::open("file.ext").unwrap(), 148, "application/octet-stream".parse().unwrap()'
|
'example_value': 'fs::File::open("file.ext").unwrap(), 148, "application/octet-stream".parse().unwrap()'
|
||||||
},
|
},
|
||||||
@@ -238,6 +238,7 @@ def extract_parts(desc):
|
|||||||
# Return transformed string that could make a good type name
|
# Return transformed string that could make a good type name
|
||||||
def canonical_type_name(s):
|
def canonical_type_name(s):
|
||||||
# can't use s.capitalize() as it will lower-case the remainder of the string
|
# can't use s.capitalize() as it will lower-case the remainder of the string
|
||||||
|
s = s.replace(' ', '')
|
||||||
return s[:1].upper() + s[1:]
|
return s[:1].upper() + s[1:]
|
||||||
|
|
||||||
def nested_type_name(sn, pn):
|
def nested_type_name(sn, pn):
|
||||||
@@ -246,7 +247,7 @@ def nested_type_name(sn, pn):
|
|||||||
# Make properties which are reserved keywords usable
|
# Make properties which are reserved keywords usable
|
||||||
def mangle_ident(n):
|
def mangle_ident(n):
|
||||||
n = '_'.join(singular(w) for w in camel_to_under(n).split('.'))
|
n = '_'.join(singular(w) for w in camel_to_under(n).split('.'))
|
||||||
if n == 'type':
|
if n in ('type', 'where', 'override', 'move'):
|
||||||
return n + '_'
|
return n + '_'
|
||||||
return n
|
return n
|
||||||
|
|
||||||
@@ -635,8 +636,11 @@ def mb_additional_type_params(m):
|
|||||||
def mb_type(r, m):
|
def mb_type(r, m):
|
||||||
return "%s%sMethodBuilder" % (singular(canonical_type_name(r)), dot_sep_to_canonical_type_name(m))
|
return "%s%sMethodBuilder" % (singular(canonical_type_name(r)), dot_sep_to_canonical_type_name(m))
|
||||||
|
|
||||||
def hub_type(canonicalName):
|
def hub_type(schemas, canonicalName):
|
||||||
return canonical_type_name(canonicalName)
|
name = canonical_type_name(canonicalName)
|
||||||
|
if schemas and name in schemas:
|
||||||
|
name += 'Hub'
|
||||||
|
return name
|
||||||
|
|
||||||
# return e + d[n] + e + ' ' or ''
|
# return e + d[n] + e + ' ' or ''
|
||||||
def get_word(d, n, e = ''):
|
def get_word(d, n, e = ''):
|
||||||
@@ -661,16 +665,22 @@ def dot_sep_to_canonical_type_name(n):
|
|||||||
def scope_url_to_variant(name, url, fully_qualified=True):
|
def scope_url_to_variant(name, url, fully_qualified=True):
|
||||||
FULL = 'Full'
|
FULL = 'Full'
|
||||||
fqvn = lambda n: fully_qualified and 'Scope::%s' % n or n
|
fqvn = lambda n: fully_qualified and 'Scope::%s' % n or n
|
||||||
|
repl = lambda n: n.replace('-', '.').replace('_', '.')
|
||||||
|
|
||||||
|
if url.endswith('/'):
|
||||||
|
url = name[:-1]
|
||||||
base = os.path.basename(url)
|
base = os.path.basename(url)
|
||||||
|
|
||||||
|
assert base, name
|
||||||
# special case, which works for now ... https://mail.gmail.com
|
# special case, which works for now ... https://mail.gmail.com
|
||||||
|
# NO can do ! Must play safe here ...
|
||||||
if not base.startswith(name):
|
if not base.startswith(name):
|
||||||
return fqvn(FULL)
|
return fqvn(dot_sep_to_canonical_type_name(repl(base)))
|
||||||
base = base[len(name):]
|
base = base[len(name):]
|
||||||
base = base.strip('-').strip('.')
|
base = base.strip('-').strip('.')
|
||||||
if len(base) == 0:
|
if len(base) == 0:
|
||||||
return fqvn(FULL)
|
return fqvn(FULL)
|
||||||
base = base.replace('-', '.')
|
return fqvn(dot_sep_to_canonical_type_name(repl(base)))
|
||||||
return fqvn(dot_sep_to_canonical_type_name(base))
|
|
||||||
|
|
||||||
|
|
||||||
# given a rust type-name (no optional, as from to_rust_type), you will get a suitable random default value
|
# given a rust type-name (no optional, as from to_rust_type), you will get a suitable random default value
|
||||||
|
|||||||
Reference in New Issue
Block a user