mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49: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
|
# all mako source files
|
||||||
mako_src: src/mako
|
mako_src: src/mako
|
||||||
api:
|
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"
|
base_path: "etc/api"
|
||||||
terms:
|
terms:
|
||||||
# how to actually do something with the API
|
# how to actually do something with the API
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<%api_info=[]%>\
|
<%api_info=[]%>\
|
||||||
% for an, versions in api.list.iteritems():
|
% for an, versions in api.list.iteritems():
|
||||||
% if an in api.blacklist:
|
% if an in api.get('blacklist', list()):
|
||||||
<% continue %>\
|
<% continue %>\
|
||||||
% endif
|
% endif
|
||||||
% for version in versions:
|
% 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
|
## 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()">\
|
<%def name="scope_enum()">\
|
||||||
|
% if not auth or not auth.oauth2:
|
||||||
|
<% return '' %>\
|
||||||
|
% endif
|
||||||
/// Identifies the an OAuth2 authorization scope.
|
/// Identifies the an OAuth2 authorization scope.
|
||||||
/// A scope is needed when requesting an
|
/// A scope is needed when requesting an
|
||||||
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
|
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
|
||||||
|
|||||||
@@ -97,8 +97,10 @@ pub struct ${ThisType}
|
|||||||
% endfor
|
% endfor
|
||||||
## A generic map for additinal parameters. Sometimes you can set some that are documented online only
|
## A generic map for additinal parameters. Sometimes you can set some that are documented online only
|
||||||
${api.properties.params}: HashMap<String, String>,
|
${api.properties.params}: HashMap<String, String>,
|
||||||
|
% if auth and auth.oauth2:
|
||||||
## We need the scopes sorted, to not unnecessarily query new tokens
|
## We need the scopes sorted, to not unnecessarily query new tokens
|
||||||
${api.properties.scopes}: BTreeMap<String, ()>
|
${api.properties.scopes}: BTreeMap<String, ()>
|
||||||
|
% endif
|
||||||
}
|
}
|
||||||
|
|
||||||
impl${mb_tparams} MethodBuilder for ${ThisType} {}
|
impl${mb_tparams} MethodBuilder for ${ThisType} {}
|
||||||
@@ -132,6 +134,7 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
% if auth and auth.oauth2:
|
||||||
/// Identifies the authorization scope for the method you are building.
|
/// 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
|
/// 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.${api.properties.scopes}.insert(scope.as_slice().to_string(), ());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
% endif
|
||||||
}
|
}
|
||||||
</%def>
|
</%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)
|
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)
|
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:
|
% if 'description' in m:
|
||||||
@@ -84,7 +87,10 @@ impl${rb_params} ${ThisType} {
|
|||||||
% for p in optional_props:
|
% for p in optional_props:
|
||||||
${property(p.name)}: Default::default(),
|
${property(p.name)}: Default::default(),
|
||||||
% endfor
|
% 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(),
|
${custom_name}: Default::default(),
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user