Skip to content

Commit

Permalink
fix(apis): intermediate improvements ...
Browse files Browse the repository at this point in the history
... 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
  • Loading branch information
Byron committed Mar 10, 2015
1 parent ff5cbb3 commit 92d8fa7
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 14 deletions.
2 changes: 2 additions & 0 deletions etc/api/api-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ api:
adexchangeseller:
- v2.0
admin:
- directory_v1
- email_migration_v2
- reports_v1
adsense:
- v1.4
Expand Down
3 changes: 3 additions & 0 deletions etc/api/groupssettings/v1/groupssettings-api_overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "groupsSettings"
}
11 changes: 4 additions & 7 deletions etc/api/shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions etc/api/sqladmin/v1beta4/sqladmin-api_overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"activity_root": "sql"
}
6 changes: 3 additions & 3 deletions etc/bin/mako-render
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/mako/deps.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion src/mako/lib.rs.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
// ###################
Expand Down
5 changes: 4 additions & 1 deletion src/mako/lib/lib.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/mako/lib/mbuild.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/mako/lib/rbuild.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 92d8fa7

Please sign in to comment.