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
This commit is contained in:
Sebastian Thiel
2015-03-10 15:54:31 +01:00
parent ff5cbb3bf4
commit 92d8fa76d0
11 changed files with 32 additions and 14 deletions

View File

@@ -8,6 +8,8 @@ api:
adexchangeseller:
- v2.0
admin:
- directory_v1
- email_migration_v2
- reports_v1
adsense:
- v1.4

View File

@@ -0,0 +1,3 @@
{
"name": "groupsSettings"
}

View File

@@ -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

View File

@@ -0,0 +1,3 @@
{
"activity_root": "sql"
}

View File

@@ -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

View File

@@ -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)

View File

@@ -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:
// ###################

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -531,6 +531,8 @@ Context = collections.namedtuple('Context', ['sta_map', 'fqan_map', 'rta_map'])
# 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 }