Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Specify HTTP client when building service #1275

Merged
merged 1 commit into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private SampleView createSampleView(SampleTransformerContext context) {
discoveryBuildParams.add(String.format("'%s'", config.apiVersion()));
switch (config.authType()) {
case NONE:
discoveryBuildParams.add("http=httplib2.Http(timeout=60)");
break;
case API_KEY:
discoveryBuildParams.add("developerKey=" + credentialsVarName);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/com/google/api/codegen/py/sample.snip
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
from pprint import pprint
@end

@if class.auth.type == "NONE"
import httplib2
@end
from googleapiclient import discovery
@if class.auth.type == "APPLICATION_DEFAULT_CREDENTIALS"
from oauth2client.client import GoogleCredentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ BEFORE RUNNING:
"""
from pprint import pprint

import httplib2
from googleapiclient import discovery

service = discovery.build('foo', 'v1', discoveryServiceUrl='localhost:8080/$discovery/foo?version=v1')
service = discovery.build('foo', 'v1', http=httplib2.Http(timeout=60), discoveryServiceUrl='localhost:8080/$discovery/foo?version=v1')

request = service.baz().get()
response = request.execute()
Expand Down