diff --git a/etc/api/shared.yaml b/etc/api/shared.yaml index d669cf09237..76e7aaa0a6a 100644 --- a/etc/api/shared.yaml +++ b/etc/api/shared.yaml @@ -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 diff --git a/src/mako/deps.mako b/src/mako/deps.mako index d1adc3ce159..e5354727cff 100644 --- a/src/mako/deps.mako +++ b/src/mako/deps.mako @@ -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: diff --git a/src/mako/lib/lib.mako b/src/mako/lib/lib.mako index 57ce078280f..86be4305e75 100644 --- a/src/mako/lib/lib.mako +++ b/src/mako/lib/lib.mako @@ -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). diff --git a/src/mako/lib/mbuild.mako b/src/mako/lib/mbuild.mako index d90645273dc..41e5ed6ca80 100644 --- a/src/mako/lib/mbuild.mako +++ b/src/mako/lib/mbuild.mako @@ -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, + % if auth and auth.oauth2: ## We need the scopes sorted, to not unnecessarily query new tokens ${api.properties.scopes}: BTreeMap + % 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 } diff --git a/src/mako/lib/rbuild.mako b/src/mako/lib/rbuild.mako index 50ba56c5d62..419e4235e8b 100644 --- a/src/mako/lib/rbuild.mako +++ b/src/mako/lib/rbuild.mako @@ -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 }