From 92d8fa76d0f419738e2efa7df3deebb974c1e0cf Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 10 Mar 2015 15:54:31 +0100 Subject: [PATCH] fix(apis): intermediate improvements ... ... it shows that the override I used previously won't work for `admin`. Therefore we have to keep the actual value, instead of degenrating it. Makes sense ... it's interesting how much one tends to hard-code things to work just for a few cases, unless you opt in to see the whole picture --- etc/api/api-list.yaml | 2 ++ .../v1/groupssettings-api_overrides.json | 3 +++ etc/api/shared.yaml | 11 ++++------- etc/api/sqladmin/v1beta4/sqladmin-api_overrides.json | 3 +++ etc/bin/mako-render | 6 +++--- src/mako/deps.mako | 4 ++++ src/mako/lib.rs.mako | 6 +++++- src/mako/lib/lib.mako | 5 ++++- src/mako/lib/mbuild.mako | 2 +- src/mako/lib/rbuild.mako | 2 +- src/mako/lib/util.py | 2 ++ 11 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 etc/api/groupssettings/v1/groupssettings-api_overrides.json create mode 100644 etc/api/sqladmin/v1beta4/sqladmin-api_overrides.json diff --git a/etc/api/api-list.yaml b/etc/api/api-list.yaml index 7166932a7ab..d4c091621df 100644 --- a/etc/api/api-list.yaml +++ b/etc/api/api-list.yaml @@ -8,6 +8,8 @@ api: adexchangeseller: - v2.0 admin: + - directory_v1 + - email_migration_v2 - reports_v1 adsense: - v1.4 diff --git a/etc/api/groupssettings/v1/groupssettings-api_overrides.json b/etc/api/groupssettings/v1/groupssettings-api_overrides.json new file mode 100644 index 00000000000..29329fe4bdd --- /dev/null +++ b/etc/api/groupssettings/v1/groupssettings-api_overrides.json @@ -0,0 +1,3 @@ +{ + "name": "groupsSettings" +} \ No newline at end of file diff --git a/etc/api/shared.yaml b/etc/api/shared.yaml index 9cc75f942a3..8635b04f762 100644 --- a/etc/api/shared.yaml +++ b/etc/api/shared.yaml @@ -10,20 +10,17 @@ directories: mako_src: src/mako api: blacklist: - - groupsmigration - - licensing - - groupssettings - - translate + - groupsmigration # no oauth2 + - licensing # no oauth2 + - translate # no oauth2 - pagespeedonline # no oauth2 - gan # no oauth2 - - sqladmin # ERROR - - dataflow # ERROR + - dataflow # no oauth2 - civicinfo # no oauth2 - webmasters # no oauth2 - doubleclickbidmanager # no oauth2 - freebase # ERROR - spectrum # no oauth2 - - analytics # ERROR - qpxexpress # no oauth2 - discovery # no oauth2 - identitytoolkit # no oauth2 diff --git a/etc/api/sqladmin/v1beta4/sqladmin-api_overrides.json b/etc/api/sqladmin/v1beta4/sqladmin-api_overrides.json new file mode 100644 index 00000000000..58143b21914 --- /dev/null +++ b/etc/api/sqladmin/v1beta4/sqladmin-api_overrides.json @@ -0,0 +1,3 @@ +{ + "activity_root": "sql" +} \ No newline at end of file diff --git a/etc/bin/mako-render b/etc/bin/mako-render index 422de6fc032..185dc5d7a5e 100644 --- a/etc/bin/mako-render +++ b/etc/bin/mako-render @@ -321,16 +321,16 @@ def cmdline(argv=None): # end for each input file # From http://stackoverflow.com/questions/7204805/dictionaries-of-dictionaries-merge +# But: We overwrite leafs unconditionally def merge(a, b, path=None): if path is None: path = [] for key in b: if key in a: if isinstance(a[key], dict) and isinstance(b[key], dict): merge(a[key], b[key], path + [str(key)]) - elif a[key] == b[key]: - pass # same leaf value else: - raise Exception('Conflict at %s' % '.'.join(path + [str(key)])) + # overwrite leafs unconditionally ! + a[key] = b[key] else: a[key] = b[key] return a diff --git a/src/mako/deps.mako b/src/mako/deps.mako index de2d05f4d22..d1adc3ce159 100644 --- a/src/mako/deps.mako +++ b/src/mako/deps.mako @@ -10,6 +10,7 @@ % for version in versions: <% import util + import os gen_root = directories.output + '/' + an + util.to_api_version(version) gen_root_stamp = gen_root + '/.timestamp' api_name = util.library_name(an, version) @@ -20,7 +21,10 @@ sds = [(directories.mako_src + '/' + i.source + '.mako', gen_root + '/' + i.get('output_dir', '') + '/' + i.source) for i in api.templates] api_json = directories.api_base + '/' + an + '/' + version + '/' + an + '-api.json' + api_json_overrides = os.path.dirname(api_json) + '/' + an + '-api_overrides.json' api_json_inputs = api_json + " $(API_SHARED_INFO)" + if os.path.isfile(api_json_overrides): + api_json_inputs += ' ' + api_json_overrides api_info.append((api_name, api_clean, api_cargo, gen_root)) space_join = lambda i: ' '.join(a[i] for a in api_info) diff --git a/src/mako/lib.rs.mako b/src/mako/lib.rs.mako index d6834e77f21..8379f43fad3 100644 --- a/src/mako/lib.rs.mako +++ b/src/mako/lib.rs.mako @@ -8,7 +8,9 @@ rust_module_doc_comment, rb_type, hub_type, mangle_ident, hub_type_params_s, hub_type_bounds, rb_type_params_s) - nested_schemas = list(iter_nested_types(schemas)) + nested_schemas = list() + if schemas: + nested_schemas = list(iter_nested_types(schemas)) c = new_context(resources) hub_type = hub_type(util.canonical_name()) ht_params = hub_type_params_s() @@ -104,12 +106,14 @@ impl<'a, C, NC, A> ${hub_type}${ht_params} } +% if schemas: // ############ // SCHEMAS ### // ########## % for s in schemas.values(): ${schema.new(s, c)} % endfor +% endif % if nested_schemas: // ################### diff --git a/src/mako/lib/lib.mako b/src/mako/lib/lib.mako index d5a7bae0858..f7d0342a2f6 100644 --- a/src/mako/lib/lib.mako +++ b/src/mako/lib/lib.mako @@ -11,7 +11,8 @@ <% # fr == fattest resource, the fatter, the more important, right ? fr = None - fr = sorted(schemas.values(), key=lambda s: (len(c.sta_map.get(s.id, [])), len(s.get('properties', []))), reverse=True)[0] + if schemas: + fr = sorted(schemas.values(), key=lambda s: (len(c.sta_map.get(s.id, [])), len(s.get('properties', []))), reverse=True)[0] %>\ # Features @@ -62,6 +63,7 @@ Generally speaking, you can invoke *Activities* like this: let r = hub.resource().activity(...).${api.terms.action}() ``` +% if fr: Or specifically ... ```ignore @@ -70,6 +72,7 @@ Or specifically ... let r = hub.${mangle_ident(resource)}().${mangle_ident(activity)}(...).${api.terms.action}() % endfor ``` +% endif The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be diff --git a/src/mako/lib/mbuild.mako b/src/mako/lib/mbuild.mako index b598b864450..fdff33545d2 100644 --- a/src/mako/lib/mbuild.mako +++ b/src/mako/lib/mbuild.mako @@ -32,7 +32,7 @@ <%def name="new(resource, method, c)">\ <% hub_type_name = hub_type(util.canonical_name()) - m = c.fqan_map[to_fqan(name, resource, method)] + m = c.fqan_map[to_fqan(activity_root or name, resource, method)] # an identifier for a property. We prefix them to prevent clashes with the setters mb_tparams = mb_type_params_s(m) ThisType = mb_type(resource, method) + mb_tparams diff --git a/src/mako/lib/rbuild.mako b/src/mako/lib/rbuild.mako index 638174c7fa9..29ae08d3807 100644 --- a/src/mako/lib/rbuild.mako +++ b/src/mako/lib/rbuild.mako @@ -51,7 +51,7 @@ impl${rb_params} ResourceMethodsBuilder for ${ThisType} {} impl${rb_params} ${ThisType} { % for a in c.rta_map[resource]: <% - m = c.fqan_map[to_fqan(name, resource, a)] + m = c.fqan_map[to_fqan(activity_root or name, resource, a)] RType = mb_type(resource, a) # skip part if we have a request resource. Only resources can have parts diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index be233c0cb83..a8fa5a5b0eb 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -531,6 +531,8 @@ def build_all_params(schemas, c, m, n, npn): # return a newly build context from the given data def new_context(resources): + if not resources: + return Context(dict(), dict(), dict()) # Returns (A, B) where # A: { SchemaTypeName -> { fqan -> ['request'|'response', ...]} # B: { fqan -> activity_method_data }