Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
27 changes: 27 additions & 0 deletions .kokoro/continuous/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Download resources for system tests (service account key, etc.)
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-python"

# Use the trampoline script to run in docker.
build_file: "google-api-python-client/.kokoro/trampoline.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/google-api-python-client/.kokoro/build.sh"
}
File renamed without changes.
27 changes: 27 additions & 0 deletions .kokoro/presubmit/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Download resources for system tests (service account key, etc.)
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-python"

# Use the trampoline script to run in docker.
build_file: "google-api-python-client/.kokoro/trampoline.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/google-api-python-client/.kokoro/build.sh"
}
File renamed without changes.
19 changes: 18 additions & 1 deletion googleapiclient/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# Third-party imports
import httplib2
import uritemplate
import google.api_core.client_options

# Local imports
from googleapiclient import _auth
Expand Down Expand Up @@ -176,6 +177,7 @@ def build(
credentials=None,
cache_discovery=True,
cache=None,
client_options=None,
):
"""Construct a Resource for interacting with an API.

Expand All @@ -202,6 +204,8 @@ def build(
cache_discovery: Boolean, whether or not to cache the discovery doc.
cache: googleapiclient.discovery_cache.base.CacheBase, an optional
cache object for the discovery documents.
client_options: Dictionary or google.api_core.client_options, Client options to set user
options on the client. API endpoint should be set through client_options.

Returns:
A Resource object with methods for interacting with the service.
Expand All @@ -228,6 +232,7 @@ def build(
model=model,
requestBuilder=requestBuilder,
credentials=credentials,
client_options=client_options
)
except HttpError as e:
if e.resp.status == http_client.NOT_FOUND:
Expand Down Expand Up @@ -304,6 +309,7 @@ def build_from_document(
model=None,
requestBuilder=HttpRequest,
credentials=None,
client_options=None
):
"""Create a Resource for interacting with an API.

Expand All @@ -328,6 +334,8 @@ def build_from_document(
credentials: oauth2client.Credentials or
google.auth.credentials.Credentials, credentials to be used for
authentication.
client_options: Dictionary or google.api_core.client_options, Client options to set user
options on the client. API endpoint should be set through client_options.

Returns:
A Resource object with methods for interacting with the service.
Expand All @@ -350,7 +358,16 @@ def build_from_document(
)
raise InvalidJsonError()

base = urljoin(service["rootUrl"], service["servicePath"])
# If an API Endpoint is provided on client options, use that as the base URL
base = urljoin(service['rootUrl'], service["servicePath"])
if client_options:
if type(client_options) == dict:
client_options = google.api_core.client_options.from_dict(
client_options
)
if client_options.api_endpoint:
base = client_options.api_endpoint

schema = Schemas(service)

# If the http client is not specified, then we must construct an http client
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"httplib2>=0.9.2,<1dev",
"google-auth>=1.4.1",
"google-auth-httplib2>=0.0.3",
"google-api-core>=1.13.0,<2dev",
"six>=1.6.1,<2dev",
"uritemplate>=3.0.0,<4dev",
]
Expand Down
Loading