Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support setting STORAGE_EMULATOR_HOST without /storage/{version} suffix #756

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions google/cloud/storage/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ class Connection(_http.JSONConnection):

def __init__(self, client, client_info=None, api_endpoint=None):
super(Connection, self).__init__(client, client_info)
self.API_BASE_URL = api_endpoint or self.DEFAULT_API_ENDPOINT
self.API_BASE_URL = (
api_endpoint or self.DEFAULT_API_ENDPOINT + "/storage/{self.API_VERSION}"
)
# A template for the URL of a particular API call.
self.API_URL_TEMPLATE = (
"{api_base_url}/storage/{api_version}{path}"
if api_endpoint is None
else "{api_base_url}{path}"
)
self.API_BASE_MTLS_URL = self.DEFAULT_API_MTLS_ENDPOINT
self.ALLOW_AUTO_SWITCH_TO_MTLS_URL = api_endpoint is None
self._client_info.client_library_version = __version__
Expand All @@ -54,9 +62,6 @@ def __init__(self, client, client_info=None, api_endpoint=None):
API_VERSION = "v1"
"""The version of the API, used in building the API call's URL."""

API_URL_TEMPLATE = "{api_base_url}/storage/{api_version}{path}"
"""A template for the URL of a particular API call."""

def api_request(self, *args, **kwargs):
retry = kwargs.pop("retry", None)
call = functools.partial(super(Connection, self).api_request, *args, **kwargs)
Expand Down