mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2025-12-30 16:18:49 +01:00
fix(mako): deal with missing auth information
Now all APIs can be built successfully, which should help to prevent things from getting hardcoded in any way.
This commit is contained in:
@@ -9,24 +9,6 @@ directories:
|
||||
# all mako source files
|
||||
mako_src: src/mako
|
||||
api:
|
||||
blacklist:
|
||||
- groupsmigration # no oauth2
|
||||
- licensing # no oauth2
|
||||
- translate # no oauth2
|
||||
- pagespeedonline # no oauth2
|
||||
- gan # no oauth2
|
||||
- dataflow # no oauth2
|
||||
- civicinfo # no oauth2
|
||||
- webmasters # no oauth2
|
||||
- doubleclickbidmanager # no oauth2
|
||||
- freebase # no oauth2
|
||||
- spectrum # no oauth2
|
||||
- qpxexpress # no oauth2
|
||||
- discovery # no oauth2
|
||||
- identitytoolkit # no oauth2
|
||||
- audit # no oauth2
|
||||
- webfonts # no oauth2
|
||||
- customsearch # no oauth2
|
||||
base_path: "etc/api"
|
||||
terms:
|
||||
# how to actually do something with the API
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<%api_info=[]%>\
|
||||
% for an, versions in api.list.iteritems():
|
||||
% if an in api.blacklist:
|
||||
% if an in api.get('blacklist', list()):
|
||||
<% continue %>\
|
||||
% endif
|
||||
% for version in versions:
|
||||
|
||||
@@ -172,9 +172,13 @@ You can read the full text at the repository's [license file][repo-license].
|
||||
|
||||
|
||||
## Builds the scope-enum for the API
|
||||
## It's possible there is no scope enum if there is no auth information
|
||||
###############################################################################################
|
||||
###############################################################################################
|
||||
<%def name="scope_enum()">\
|
||||
% if not auth or not auth.oauth2:
|
||||
<% return '' %>\
|
||||
% endif
|
||||
/// Identifies the an OAuth2 authorization scope.
|
||||
/// A scope is needed when requesting an
|
||||
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
|
||||
|
||||
@@ -97,8 +97,10 @@ pub struct ${ThisType}
|
||||
% endfor
|
||||
## A generic map for additinal parameters. Sometimes you can set some that are documented online only
|
||||
${api.properties.params}: HashMap<String, String>,
|
||||
% if auth and auth.oauth2:
|
||||
## We need the scopes sorted, to not unnecessarily query new tokens
|
||||
${api.properties.scopes}: BTreeMap<String, ()>
|
||||
% endif
|
||||
}
|
||||
|
||||
impl${mb_tparams} MethodBuilder for ${ThisType} {}
|
||||
@@ -132,6 +134,7 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
|
||||
self
|
||||
}
|
||||
|
||||
% if auth and auth.oauth2:
|
||||
/// Identifies the authorization scope for the method you are building.
|
||||
///
|
||||
/// Use this method to actively specify which scope should be used, instead of relying on the
|
||||
@@ -148,6 +151,7 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
|
||||
self.${api.properties.scopes}.insert(scope.as_slice().to_string(), ());
|
||||
self
|
||||
}
|
||||
% endif
|
||||
}
|
||||
</%def>
|
||||
|
||||
|
||||
@@ -64,6 +64,9 @@ impl${rb_params} ${ThisType} {
|
||||
method_args = ', ' + ', '.join('%s: %s' % (mangle_ident(p.name), activity_input_type(p)) for p in required_props)
|
||||
|
||||
mb_tparams = mb_type_params_s(m)
|
||||
# we would could have information about data requirements for each property in it's dict.
|
||||
# for now, we just hardcode it, and treat the entries as way to easily change param names
|
||||
assert len(api.properties) == 2, "Hardcoded for now, thanks to scope requirements"
|
||||
%>\
|
||||
|
||||
% if 'description' in m:
|
||||
@@ -84,7 +87,10 @@ impl${rb_params} ${ThisType} {
|
||||
% for p in optional_props:
|
||||
${property(p.name)}: Default::default(),
|
||||
% endfor
|
||||
% for custom_name in api.properties.values():
|
||||
% for prop_key, custom_name in api.properties.iteritems():
|
||||
% if prop_key == 'scopes' and (not auth or not auth.oauth2):
|
||||
<% continue %>\
|
||||
% endif
|
||||
${custom_name}: Default::default(),
|
||||
% endfor
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user