merge
This commit is contained in:
@@ -2,73 +2,73 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"latitude": {
|
"latitude": {
|
||||||
"v1": {
|
"v1": {
|
||||||
"baseUrl": "https://www.googleapis.com/",
|
"baseUrl": "https://www.googleapis.com/",
|
||||||
"auth": {
|
"auth": {
|
||||||
"request": {
|
"request": {
|
||||||
"url": "https://www.google.com/accounts/OAuthGetRequestToken",
|
"url": "https://www.google.com/accounts/OAuthGetRequestToken",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"xoauth_displayname": {
|
"xoauth_displayname": {
|
||||||
"parameterType": "query",
|
"parameterType": "query",
|
||||||
"required": False
|
"required": false
|
||||||
},
|
},
|
||||||
"domain": {
|
"domain": {
|
||||||
"parameterType": "query",
|
"parameterType": "query",
|
||||||
"required": True
|
"required": true
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"parameterType": "query",
|
"parameterType": "query",
|
||||||
"required": True
|
"required": true
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
"authorize": {
|
"authorize": {
|
||||||
"url": "https://www.google.com/latitude/apps/OAuthAuthorizeToken",
|
"url": "https://www.google.com/latitude/apps/OAuthAuthorizeToken",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"oauth_token": {
|
"oauth_token": {
|
||||||
"parameterType": "query",
|
"parameterType": "query",
|
||||||
"required": True
|
"required": true
|
||||||
},
|
},
|
||||||
"iconUrl": {
|
"iconUrl": {
|
||||||
"parameterType": "query",
|
"parameterType": "query",
|
||||||
"required": False
|
"required": false
|
||||||
},
|
},
|
||||||
"domain": {
|
"domain": {
|
||||||
"parameterType": "query",
|
"parameterType": "query",
|
||||||
"required": True
|
"required": true
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"parameterType": "query",
|
"parameterType": "query",
|
||||||
"required": True
|
"required": true
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
"access": {
|
"access": {
|
||||||
"url": "https://www.google.com/accounts/OAuthGetAccessToken",
|
"url": "https://www.google.com/accounts/OAuthGetAccessToken",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"domain": {
|
"domain": {
|
||||||
"parameterType": "query",
|
"parameterType": "query",
|
||||||
"required": True
|
"required": true
|
||||||
},
|
},
|
||||||
"scope": {
|
"scope": {
|
||||||
"parameterType": "query",
|
"parameterType": "query",
|
||||||
"required": True
|
"required": true
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"currentLocation": {
|
"currentLocation": {
|
||||||
"methods": {
|
"methods": {
|
||||||
"delete": {},
|
"delete": {},
|
||||||
"get": {},
|
"get": {},
|
||||||
"insert": {}
|
"insert": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"location": {
|
"location": {
|
||||||
"methods": {
|
"methods": {
|
||||||
"delete": {},
|
"delete": {},
|
||||||
"get": {},
|
"get": {},
|
||||||
"insert": {},
|
"insert": {},
|
||||||
"list": {}
|
"list": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,13 +108,15 @@ class JsonModel(object):
|
|||||||
raise HttpError(simplejson.loads(content)['error'])
|
raise HttpError(simplejson.loads(content)['error'])
|
||||||
|
|
||||||
|
|
||||||
def build(serviceName, version, http=httplib2.Http(),
|
def build(serviceName, version, http=None,
|
||||||
discoveryServiceUrl=DISCOVERY_URI, auth=None, model=JsonModel()):
|
discoveryServiceUrl=DISCOVERY_URI, auth=None, model=JsonModel()):
|
||||||
params = {
|
params = {
|
||||||
'api': serviceName,
|
'api': serviceName,
|
||||||
'apiVersion': version
|
'apiVersion': version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if http is None:
|
||||||
|
http = httplib2.Http()
|
||||||
requested_url = uritemplate.expand(discoveryServiceUrl, params)
|
requested_url = uritemplate.expand(discoveryServiceUrl, params)
|
||||||
logging.info('URL being requested: %s' % requested_url)
|
logging.info('URL being requested: %s' % requested_url)
|
||||||
resp, content = http.request(requested_url)
|
resp, content = http.request(requested_url)
|
||||||
|
|||||||
1
samples/helpdoc/apiclient
Symbolic link
1
samples/helpdoc/apiclient
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../apiclient/
|
||||||
12
samples/helpdoc/app.yaml
Normal file
12
samples/helpdoc/app.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
application: api-python-client-doc
|
||||||
|
version: 1
|
||||||
|
runtime: python
|
||||||
|
api_version: 1
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- url: /static
|
||||||
|
static_dir: static
|
||||||
|
|
||||||
|
- url: .*
|
||||||
|
script: main.py
|
||||||
|
|
||||||
1
samples/helpdoc/httplib2
Symbolic link
1
samples/helpdoc/httplib2
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../httplib2/
|
||||||
11
samples/helpdoc/index.yaml
Normal file
11
samples/helpdoc/index.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
indexes:
|
||||||
|
|
||||||
|
# AUTOGENERATED
|
||||||
|
|
||||||
|
# This index.yaml is automatically updated whenever the dev_appserver
|
||||||
|
# detects that a new type of query is run. If you want to manage the
|
||||||
|
# index.yaml file manually, remove the above marker line (the line
|
||||||
|
# saying "# AUTOGENERATED"). If you want to manage some indexes
|
||||||
|
# manually, move them above the marker line. The index.yaml file is
|
||||||
|
# automatically uploaded to the admin console when you next deploy
|
||||||
|
# your application using appcfg.py.
|
||||||
109
samples/helpdoc/main.py
Executable file
109
samples/helpdoc/main.py
Executable file
@@ -0,0 +1,109 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Copyright 2007 Google Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||||
|
|
||||||
|
|
||||||
|
import inspect
|
||||||
|
import pydoc
|
||||||
|
import re
|
||||||
|
|
||||||
|
from apiclient.discovery import build
|
||||||
|
|
||||||
|
from google.appengine.ext import webapp
|
||||||
|
from google.appengine.ext.webapp import util
|
||||||
|
|
||||||
|
# Replicate render_doc here from pydoc.py as it isn't available in Python 2.5
|
||||||
|
class _OldStyleClass: pass
|
||||||
|
|
||||||
|
def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
|
||||||
|
"""Render text documentation, given an object or a path to an object."""
|
||||||
|
object, name = pydoc.resolve(thing, forceload)
|
||||||
|
desc = pydoc.describe(object)
|
||||||
|
module = inspect.getmodule(object)
|
||||||
|
if name and '.' in name:
|
||||||
|
desc += ' in ' + name[:name.rfind('.')]
|
||||||
|
elif module and module is not object:
|
||||||
|
desc += ' in module ' + module.__name__
|
||||||
|
if type(object) is type(_OldStyleClass()):
|
||||||
|
# If the passed object is an instance of an old-style class,
|
||||||
|
# document its available methods instead of its value.
|
||||||
|
object = object.__class__
|
||||||
|
elif not (inspect.ismodule(object) or
|
||||||
|
inspect.isclass(object) or
|
||||||
|
inspect.isroutine(object) or
|
||||||
|
inspect.isgetsetdescriptor(object) or
|
||||||
|
inspect.ismemberdescriptor(object) or
|
||||||
|
isinstance(object, property)):
|
||||||
|
# If the passed object is a piece of data or an instance,
|
||||||
|
# document its available methods instead of its value.
|
||||||
|
object = type(object)
|
||||||
|
desc += ' object'
|
||||||
|
return title % desc + '\n\n' + pydoc.text.document(object, name)
|
||||||
|
|
||||||
|
|
||||||
|
class MainHandler(webapp.RequestHandler):
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
self.response.out.write("""
|
||||||
|
<h1>Google API Client for Python Documentation</h1>
|
||||||
|
<ul>
|
||||||
|
<li><a href='/buzz/v1'>buzz</a>
|
||||||
|
<li><a href='/moderator/v1'>moderator</a>
|
||||||
|
<li><a href='/latitude/v1'>latitude</a>
|
||||||
|
</ul>
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceHandler(webapp.RequestHandler):
|
||||||
|
|
||||||
|
def get(self, service_name, version):
|
||||||
|
service = build(service_name, version)
|
||||||
|
page = "<p><a href='/'>Home</a></p><pre>%s</pre>" % pydoc.plain(render_doc(service))
|
||||||
|
|
||||||
|
collections = []
|
||||||
|
for name in dir(service):
|
||||||
|
if not "_" in name and callable(getattr(service, name)):
|
||||||
|
collections.append(name)
|
||||||
|
|
||||||
|
for name in collections:
|
||||||
|
page = re.sub('(%s) =' % name, r'<a href="/%s/%s/%s">\1</a> =' % (service_name, version, name), page)
|
||||||
|
|
||||||
|
self.response.out.write(page)
|
||||||
|
|
||||||
|
|
||||||
|
class CollectionHandler(webapp.RequestHandler):
|
||||||
|
|
||||||
|
def get(self, service_name, version, collection):
|
||||||
|
service = build(service_name, version)
|
||||||
|
page = "<p><a href='/'>Home</a></p><pre>%s</pre>" % pydoc.plain(render_doc(getattr(service, collection)()))
|
||||||
|
self.response.out.write(page)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
application = webapp.WSGIApplication(
|
||||||
|
[
|
||||||
|
(r'/', MainHandler),
|
||||||
|
(r'/(\w*)/(\w*)', ServiceHandler),
|
||||||
|
(r'/(\w*)/(\w*)/(\w*)', CollectionHandler),
|
||||||
|
],
|
||||||
|
debug=True)
|
||||||
|
util.run_wsgi_app(application)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
1
samples/helpdoc/oauth2
Symbolic link
1
samples/helpdoc/oauth2
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../oauth2
|
||||||
1
samples/helpdoc/simplejson
Symbolic link
1
samples/helpdoc/simplejson
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../simplejson/
|
||||||
1
samples/helpdoc/uritemplate
Symbolic link
1
samples/helpdoc/uritemplate
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../uritemplate/
|
||||||
Reference in New Issue
Block a user