From 2691f64624a62d6b0c24f1edecf773684ebb602d Mon Sep 17 00:00:00 2001 From: jaybeeo Date: Wed, 13 Aug 2014 11:47:37 -0700 Subject: [PATCH 1/5] Update sample_tools.py Enhance discovery.py's init() function to support using a local discovery document. This is useful when the discovery document is not accessible via URL (e.g. for non-public APIs). --- googleapiclient/sample_tools.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/googleapiclient/sample_tools.py b/googleapiclient/sample_tools.py index d002eb34737..a311453ec8f 100644 --- a/googleapiclient/sample_tools.py +++ b/googleapiclient/sample_tools.py @@ -31,7 +31,7 @@ from oauth2client import tools -def init(argv, name, version, doc, filename, scope=None, parents=[]): +def init(argv, name, version, doc, filename, scope=None, parents=[], discovery_filename=None): """A common initialization routine for samples. Many of the sample applications do the same initialization, which has now @@ -49,6 +49,7 @@ def init(argv, name, version, doc, filename, scope=None, parents=[]): file: string, filename of the application. Usually set to __file__. parents: list of argparse.ArgumentParser, additional command-line flags. scope: string, The OAuth scope used. + discovery_filename: string, name of local discovery file (JSON). Use when discovery doc not available via URL. Returns: A tuple of (service, flags), where service is the service object and flags @@ -88,6 +89,16 @@ def init(argv, name, version, doc, filename, scope=None, parents=[]): credentials = tools.run_flow(flow, storage, flags) http = credentials.authorize(http = httplib2.Http()) - # Construct a service object via the discovery service. - service = discovery.build(name, version, http=http) + if discovery_filename is None: + # Construct a service object via the discovery service. + service = discovery.build(name, version, http=http) + else # Construct a service from the local documents + # Construct a service object using a local discovery document file. + f = open(discovery_filename) + discovery_doc = f.read() + f.close() + service = discovery.build_from_document( + discovery_doc, + base='https://www.googleapis.com/', + http=http) return (service, flags) From 71a80eb60f897522306988139a50196abcb54418 Mon Sep 17 00:00:00 2001 From: jaybeeo Date: Wed, 13 Aug 2014 14:01:22 -0700 Subject: [PATCH 2/5] Update sample_tools.py --- googleapiclient/sample_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googleapiclient/sample_tools.py b/googleapiclient/sample_tools.py index a311453ec8f..20b4d32ebe4 100644 --- a/googleapiclient/sample_tools.py +++ b/googleapiclient/sample_tools.py @@ -92,7 +92,7 @@ def init(argv, name, version, doc, filename, scope=None, parents=[], discovery_f if discovery_filename is None: # Construct a service object via the discovery service. service = discovery.build(name, version, http=http) - else # Construct a service from the local documents + else: # Construct a service object using a local discovery document file. f = open(discovery_filename) discovery_doc = f.read() From db78b520c5e10f46fcbc2dfe6cc77d1a6a2112c5 Mon Sep 17 00:00:00 2001 From: jaybeeo Date: Wed, 13 Aug 2014 18:45:27 -0700 Subject: [PATCH 3/5] Updated docs --- docs/epy/class-tree.html | 2 +- docs/epy/googleapiclient-module.html | 2 +- docs/epy/googleapiclient-pysrc.html | 4 +- docs/epy/googleapiclient.channel-module.html | 2 +- docs/epy/googleapiclient.channel-pysrc.html | 2 +- ...googleapiclient.channel.Channel-class.html | 11 +- ...eapiclient.channel.Notification-class.html | 9 +- .../epy/googleapiclient.discovery-module.html | 17 +- docs/epy/googleapiclient.discovery-pysrc.html | 1928 +++++++++-------- ...gleapiclient.discovery.Resource-class.html | 11 +- ...covery.ResourceMethodParameters-class.html | 10 +- docs/epy/googleapiclient.errors-module.html | 2 +- docs/epy/googleapiclient.errors-pysrc.html | 4 +- ...ogleapiclient.errors.BatchError-class.html | 26 +- .../googleapiclient.errors.Error-class.html | 24 +- ...oogleapiclient.errors.HttpError-class.html | 25 +- ...nt.errors.InvalidChunkSizeError-class.html | 25 +- ...iclient.errors.InvalidJsonError-class.html | 25 +- ...errors.InvalidNotificationError-class.html | 25 +- ...ent.errors.MediaUploadSizeError-class.html | 25 +- ...ent.errors.ResumableUploadError-class.html | 26 +- ...rrors.UnacceptableMimeTypeError-class.html | 25 +- ...ient.errors.UnexpectedBodyError-class.html | 25 +- ...nt.errors.UnexpectedMethodError-class.html | 25 +- ....errors.UnknownApiNameOrVersion-class.html | 25 +- ...piclient.errors.UnknownFileType-class.html | 25 +- ...piclient.errors.UnknownLinkType-class.html | 25 +- docs/epy/googleapiclient.http-module.html | 2 +- docs/epy/googleapiclient.http-pysrc.html | 749 +++---- ...apiclient.http.BatchHttpRequest-class.html | 11 +- .../googleapiclient.http.HttpMock-class.html | 10 +- ...apiclient.http.HttpMockSequence-class.html | 10 +- ...oogleapiclient.http.HttpRequest-class.html | 14 +- ...eapiclient.http.HttpRequestMock-class.html | 10 +- ...ient.http.MediaDownloadProgress-class.html | 10 +- ...eapiclient.http.MediaFileUpload-class.html | 21 +- ...client.http.MediaInMemoryUpload-class.html | 20 +- ...client.http.MediaIoBaseDownload-class.html | 10 +- ...piclient.http.MediaIoBaseUpload-class.html | 19 +- ...oogleapiclient.http.MediaUpload-class.html | 17 +- ...client.http.MediaUploadProgress-class.html | 10 +- ...iclient.http.RequestMockBuilder-class.html | 10 +- ...ogleapiclient.http._StreamSlice-class.html | 10 +- .../epy/googleapiclient.mimeparse-module.html | 2 +- docs/epy/googleapiclient.mimeparse-pysrc.html | 2 +- docs/epy/googleapiclient.model-module.html | 2 +- docs/epy/googleapiclient.model-pysrc.html | 4 +- ...googleapiclient.model.BaseModel-class.html | 17 +- ...googleapiclient.model.JsonModel-class.html | 19 +- ...oogleapiclient.model.MediaModel-class.html | 20 +- .../googleapiclient.model.Model-class.html | 10 +- ...lient.model.ProtocolBufferModel-class.html | 19 +- .../googleapiclient.model.RawModel-class.html | 20 +- .../googleapiclient.sample_tools-module.html | 9 +- .../googleapiclient.sample_tools-pysrc.html | 201 +- docs/epy/googleapiclient.schema-module.html | 2 +- docs/epy/googleapiclient.schema-pysrc.html | 4 +- .../googleapiclient.schema.Schemas-class.html | 12 +- ...piclient.schema._SchemaToStruct-class.html | 15 +- docs/epy/help.html | 2 +- docs/epy/identifier-index.html | 2 +- docs/epy/module-tree.html | 2 +- 62 files changed, 1584 insertions(+), 2068 deletions(-) diff --git a/docs/epy/class-tree.html b/docs/epy/class-tree.html index ac7fd674bec..190d0e7143b 100644 --- a/docs/epy/class-tree.html +++ b/docs/epy/class-tree.html @@ -154,7 +154,7 @@

Class Hierarchy