Skip to content

Commit 6a63a76

Browse files
committed
Update to use the latest version of discovery.
Reviewed in: http://codereview.appspot.com/4449066/
1 parent 652898b commit 6a63a76

File tree

7 files changed

+2752
-909
lines changed

7 files changed

+2752
-909
lines changed

apiclient/discovery.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343

4444
URITEMPLATE = re.compile('{[^}]*}')
4545
VARNAME = re.compile('[a-zA-Z0-9_-]+')
46-
DISCOVERY_URI = ('https://www.googleapis.com/discovery/v0.3/describe/'
47-
'{api}/{apiVersion}')
46+
DISCOVERY_URI = ('https://www.googleapis.com/discovery/v1/apis/'
47+
'{api}/{apiVersion}/rest')
4848
DEFAULT_METHOD_DOC = 'A description of how to use this function'
4949

5050
# Query parameters that work, but don't appear in discovery
@@ -164,7 +164,7 @@ def build_from_document(
164164
"""
165165

166166
service = simplejson.loads(service)
167-
base = urlparse.urljoin(base, service['restBasePath'])
167+
base = urlparse.urljoin(base, service['basePath'])
168168
if future:
169169
future = simplejson.loads(future)
170170
auth_discovery = future.get('auth', {})
@@ -232,16 +232,16 @@ def __init__(self):
232232
self._requestBuilder = requestBuilder
233233

234234
def createMethod(theclass, methodName, methodDesc, futureDesc):
235-
pathUrl = methodDesc['restPath']
235+
pathUrl = methodDesc['path']
236236
httpMethod = methodDesc['httpMethod']
237-
methodId = methodDesc['rpcMethod']
237+
methodId = methodDesc['id']
238238

239239
if 'parameters' not in methodDesc:
240240
methodDesc['parameters'] = {}
241241
for name in STACK_QUERY_PARAMETERS:
242242
methodDesc['parameters'][name] = {
243243
'type': 'string',
244-
'restParameterType': 'query'
244+
'location': 'query'
245245
}
246246

247247
if httpMethod in ['PUT', 'POST', 'PATCH']:
@@ -274,9 +274,9 @@ def createMethod(theclass, methodName, methodDesc, futureDesc):
274274
required_params.append(param)
275275
if desc.get('repeated', False):
276276
repeated_params.append(param)
277-
if desc.get('restParameterType') == 'query':
277+
if desc.get('location') == 'query':
278278
query_params.append(param)
279-
if desc.get('restParameterType') == 'path':
279+
if desc.get('location') == 'path':
280280
path_params[param] = param
281281
param_type[param] = desc.get('type', 'string')
282282

@@ -380,7 +380,7 @@ def method(self, **kwargs):
380380
setattr(theclass, methodName, method)
381381

382382
def createNextMethod(theclass, methodName, methodDesc, futureDesc):
383-
methodId = methodDesc['rpcMethod'] + '.next'
383+
methodId = methodDesc['id'] + '.next'
384384

385385
def methodNext(self, previous):
386386
"""

samples/api-python-client-doc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<body>
77
<h1> Google API Client for Python Documentation </h1>
88
{% for item in directory %}
9-
<p><a href="/{{ item.name }}/{{ item.version }}"><img src="{{ item.icons.x32 }}"/> {{ item.description }} </a></p>
9+
<p><a href="/{{ item.name }}/{{ item.version }}"><img src="{{ item.icons.x32 }}"/> {{ item.title }} </a></p>
1010
{% endfor %}
1111
</body>
1212
</html>

samples/api-python-client-doc/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ class MainHandler(webapp.RequestHandler):
3535

3636
def get(self):
3737
http = httplib2.Http(memcache)
38-
resp, content = http.request('https://www.googleapis.com/discovery/v0.3/directory?preferred=true')
38+
resp, content = http.request('https://www.googleapis.com/discovery/v1/apis?preferred=true')
3939
directory = simplejson.loads(content)['items']
40+
for item in directory:
41+
item['title'] = item.get('title', item.get('description', ''))
4042
path = os.path.join(os.path.dirname(__file__), 'index.html')
4143
self.response.out.write(
4244
template.render(

0 commit comments

Comments
 (0)